Commit 4ec0187
committed
[AOMP] Taskification/control-flow inversion for scripts, part 1
This is an experimental patch to incrementally refactor the build scripts.
The approach taken is particularly relevant to scripts which build
multiple configurations of a component.
There are several ideas here. Firstly, build scripts can be introspected
so you can see what they are doing:
$ ./build_offload.sh list_configs
asan
perf
perf+asan
debug
debug+asan
$ AOMP_BUILD_SANITIZER=0 ./build_offload.sh list_configs
perf
debug
Build steps are split into different tasks, each of which is wrapped in a
"task_foo" function (which is passed the configuration name):
$ ./build_offload.sh list_tasks perf
clean
cmake
build
install
You can list all tasks list this:
$ ./build_offload.sh list
task_precheck
task_patch
task_clean asan
task_cmake asan
task_build asan
task_install asan
task_clean perf
task_cmake perf
task_build perf
task_install perf
task_clean perf+asan
task_cmake perf+asan
task_build perf+asan
task_install perf+asan
task_clean debug
task_cmake debug
task_build debug
task_install debug
task_postinstall debug
task_clean debug+asan
task_cmake debug+asan
task_build debug+asan
task_install debug+asan
task_unpatch
Or e.g. see what will happen for different env var settings:
$ AOMP_BUILD_DEBUG=0 ./build_offload.sh list
task_precheck
task_patch
task_clean asan
task_cmake asan
task_build asan
task_install asan
task_clean perf
task_cmake perf
task_build perf
task_install perf
task_clean perf+asan
task_cmake perf+asan
task_build perf+asan
task_install perf+asan
task_unpatch
You can still invoke the build scripts the same way as at present:
$ ./build_offload.sh
[...builds everything...]
$ ./build_offload.sh cmake
[...just runs cmake steps...]
$ ./build_offload.sh nocmake
[...just runs build steps...]
$ ./build_offload.sh install
[...just runs install steps...]
Only the build_offload.sh script has been done so far, but this
backward compatibility allows other scripts to be refactored in a similar
way incrementally.
The aim (not yet realised) is to then provide a new or alternate front-end
(to build_aomp.sh) using exactly the same build scripts, allowing
fine-grained control over which components to build/rebuild, and so on.
Internally, the refactoring already done on build_offload.sh demonstrates
very much deduplication, particularly around the setting of cmake
options. Further work will allow much of the "boilerplate" in each of
the build scripts to be replaced by a central implementation.
Environment variables used to control the build are now read via two
functions (get_config_var_string and get_config_var_bool). There are
several reasons for this indirection:
- It allows us to have a single location to check which environment
variables are being used to control the build.
- (For the alternate frontend) the options can be changed via
e.g. command-line options instead of environment variables.
- The _bool function emits the string 'true' or 'false'. This allows
the use of:
if $Result; then ... fi
instead of
if [ "$Result" -eq 1 ]; then ... fi
which is shorter/somewhat easier to read.
"Actions" (the emulated "nocmake", etc. options, and the new "list",
etc. options) are implemented as functions named "do_{foo}", invoked by
the new "command_dispatcher" function.
There are a few other actions, e.g.:
$ ./build_offload.sh show_build_dir perf
/home/julbrown/git/aomp21.0/build/home/julbrown/git/aomp21.0/offload_perf
These will be more useful once more scripts are "taskified".1 parent c846dc4 commit 4ec0187
2 files changed
+602
-435
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
236 | 396 | | |
237 | 397 | | |
238 | 398 | | |
| |||
0 commit comments