-
Notifications
You must be signed in to change notification settings - Fork 5
/
Taskfile.yml
142 lines (132 loc) · 4.07 KB
/
Taskfile.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
version: "3"
includes:
docs: "docs/tasks.yml"
lint: "lint-tasks.yml"
utils: "tools/yscope-dev-utils/taskfiles/utils.yml"
vars:
# Paths
BUILD_DIR: "{{.ROOT_DIR}}/build"
CLP_FFI_PY_CMAKE_BUILD_DIR: "{{.BUILD_DIR}}/cmake_build"
CLP_FFI_PY_CMAKE_CACHE: "{{.CLP_FFI_PY_CMAKE_BUILD_DIR}}/CMakeCache.txt"
CLP_FFI_PY_COMPILE_COMMANDS_DB: "{{.CLP_FFI_PY_CMAKE_BUILD_DIR}}/compile_commands.json"
CLP_FFI_PY_CPP_SRC_DIR: "{{.ROOT_DIR}}/src/clp_ffi_py"
WHEEL_BUILD_DIR: "{{.BUILD_DIR}}/dist"
WHEEL_VENV_DIR: "{{.BUILD_DIR}}/wheel-venv"
tasks:
default:
deps: ["init", "wheel"]
clean:
cmds:
- "rm -rf '{{.BUILD_DIR}}'"
config-cmake-project:
internal: true
deps:
- "init"
- "submodules"
sources:
- "{{.TASKFILE}}"
- "CMakeLists.txt"
generates:
- "{{.CLP_FFI_PY_CMAKE_CACHE}}"
- "{{.CLP_FFI_PY_COMPILE_COMMANDS_DB}}"
cmd: "cmake -S '{{.ROOT_DIR}}' -B '{{.CLP_FFI_PY_CMAKE_BUILD_DIR}}'"
init:
internal: true
silent: true
run: "once"
cmds: ["mkdir -p '{{.BUILD_DIR}}'"]
wheel:
vars:
CHECKSUM_FILE: "{{.BUILD_DIR}}/{{.TASK}}.md5"
OUTPUT_DIR: "{{.WHEEL_BUILD_DIR}}"
deps:
- "submodules"
- "wheel-venv"
cmds:
- "rm -rf '{{.OUTPUT_DIR}}'"
- |-
. "{{.WHEEL_VENV_DIR}}/bin/activate"
export SKBUILD_BUILD_DIR="{{.WHEEL_BUILD_DIR}}"
python3 -m build --outdir "{{.OUTPUT_DIR}}"
# Checksum the generated files (this command must be last)
- |-
cd "{{.OUTPUT_DIR}}"
tar cf - {{.CHECKSUM_TAR_BASE_ARGS}} . | md5sum > "{{.CHECKSUM_FILE}}"
sources:
- "{{.BUILD_DIR}}/submodules.md5"
- "{{.BUILD_DIR}}/wheel-venv.md5"
- "{{.TASKFILE}}"
- "CMakeLists.txt"
- "clp_ffi_py/**/*"
- "pyproject.toml"
- "src/**/*"
status:
- "test -f '{{.CHECKSUM_FILE}}'"
- >-
diff
<(cd '{{.OUTPUT_DIR}}' && tar cf - {{.CHECKSUM_TAR_BASE_ARGS}} . | md5sum)
"{{.CHECKSUM_FILE}}"
build-venv:
internal: true
label: "{{.COMPONENT}}-{{.TASK}}"
requires:
vars:
- "COMPONENT"
- "OUTPUT_DIR"
- "REQUIREMENTS_FILE_PATH"
cmds:
- "rm -rf '{{.OUTPUT_DIR}}'"
- "python3 -m venv '{{.OUTPUT_DIR}}'"
- |-
. "{{.OUTPUT_DIR}}/bin/activate"
pip3 install -r "{{.REQUIREMENTS_FILE_PATH}}"
submodules:
internal: true
vars:
CHECKSUM_FILE: "{{.BUILD_DIR}}/{{.TASK}}.md5"
OUTPUT_DIR: "src/clp"
preconditions:
# Ensure there are no uncommitted changes to the submodules since the submodule update
# command might undo them. Specifically, the update command will undo any uncommitted changes
# to the commits that the submodules point to.
- sh: "git diff --quiet src/clp"
msg: "There are uncommitted changes to the submodules. Commit or stash them first."
cmds:
- "git submodule update --init --recursive"
# Checksum the generated files (this command must be last)
- |-
cd "{{.OUTPUT_DIR}}"
tar cf - {{.CHECKSUM_TAR_BASE_ARGS}} . | md5sum > "{{.CHECKSUM_FILE}}"
sources:
- "{{.TASKFILE}}"
- ".gitmodules"
status:
- "test -f '{{.CHECKSUM_FILE}}'"
- >-
diff
<(cd '{{.OUTPUT_DIR}}' && tar cf - {{.CHECKSUM_TAR_BASE_ARGS}} . | md5sum)
"{{.CHECKSUM_FILE}}"
wheel-venv:
internal: true
vars:
CHECKSUM_FILE: "{{.BUILD_DIR}}/{{.TASK}}.md5"
OUTPUT_DIR: "{{.WHEEL_VENV_DIR}}"
cmds:
- task: "build-venv"
vars:
COMPONENT: "wheel"
OUTPUT_DIR: "{{.OUTPUT_DIR}}"
REQUIREMENTS_FILE_PATH: "requirements-dev.txt"
# Checksum the generated files (this command must be last)
- |-
cd "{{.OUTPUT_DIR}}"
tar cf - {{.CHECKSUM_TAR_BASE_ARGS}} . | md5sum > "{{.CHECKSUM_FILE}}"
sources:
- "{{.TASKFILE}}"
- "requirements-dev.txt"
status:
- "test -f '{{.CHECKSUM_FILE}}'"
- >-
diff
<(cd '{{.OUTPUT_DIR}}' && tar cf - {{.CHECKSUM_TAR_BASE_ARGS}} . | md5sum)
"{{.CHECKSUM_FILE}}"