Gyorgy Szing | f24a03a | 2023-03-21 03:00:40 +0100 | [diff] [blame] | 1 | # Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved. |
Gyorgy Szing | ba1095c | 2020-11-24 00:33:11 +0100 | [diff] [blame] | 2 | # |
| 3 | # SPDX-License-Identifier: BSD-3-Clause |
| 4 | # |
| 5 | |
| 6 | .SUFFIXES: |
| 7 | .SUFFIXES: .j2 |
| 8 | |
| 9 | # Disable parallel execution for this makefile. |
| 10 | .NOTPARALLEL: |
| 11 | |
| 12 | TEMPLATES:=$(wildcard *.j2) |
| 13 | OUTPUTS:=$(TEMPLATES:%.j2=%) |
| 14 | |
Gyorgy Szing | f24a03a | 2023-03-21 03:00:40 +0100 | [diff] [blame] | 15 | FILTER_PATTERN ?= |
| 16 | |
| 17 | ifneq (,${FILTER_PATTERN}) |
Gyorgy Szing | b73b5c2 | 2024-02-01 16:30:04 +0000 | [diff] [blame] | 18 | RUN_SH_ARGS += -p "${FILTER_PATTERN}" |
| 19 | endif |
| 20 | |
| 21 | ifneq (,${INSTALL_PREFIX}) |
| 22 | RUN_SH_ARGS += -i ${INSTALL_PREFIX} |
| 23 | endif |
| 24 | |
| 25 | ifneq (,${BUILD_PREFIX}) |
| 26 | RUN_SH_ARGS += -b ${BUILD_PREFIX} |
| 27 | endif |
| 28 | |
| 29 | ifneq (,${LOGDIR_ROOT}) |
| 30 | RUN_SH_ARGS += -l ${LOGDIR_ROOT} |
Gyorgy Szing | f24a03a | 2023-03-21 03:00:40 +0100 | [diff] [blame] | 31 | endif |
| 32 | |
Gyorgy Szing | ba1095c | 2020-11-24 00:33:11 +0100 | [diff] [blame] | 33 | all: |
Gyorgy Szing | b164e39 | 2021-09-04 01:51:57 +0200 | [diff] [blame] | 34 | ${MAKE} config |
Gyorgy Szing | b73b5c2 | 2024-02-01 16:30:04 +0000 | [diff] [blame] | 35 | bash run.sh ${RUN_SH_ARGS} |
Gyorgy Szing | ba1095c | 2020-11-24 00:33:11 +0100 | [diff] [blame] | 36 | |
| 37 | config: ${OUTPUTS} |
| 38 | |
| 39 | list: |
Gyorgy Szing | b164e39 | 2021-09-04 01:51:57 +0200 | [diff] [blame] | 40 | ${MAKE} config |
Gyorgy Szing | b73b5c2 | 2024-02-01 16:30:04 +0000 | [diff] [blame] | 41 | bash run.sh ${RUN_SH_ARGS} help |
Gyorgy Szing | ba1095c | 2020-11-24 00:33:11 +0100 | [diff] [blame] | 42 | |
| 43 | # run a command of the generated script |
| 44 | r-%: |
Gyorgy Szing | b164e39 | 2021-09-04 01:51:57 +0200 | [diff] [blame] | 45 | ${MAKE} config |
Gyorgy Szing | b73b5c2 | 2024-02-01 16:30:04 +0000 | [diff] [blame] | 46 | bash run.sh ${RUN_SH_ARGS} "$*" |
Gyorgy Szing | ba1095c | 2020-11-24 00:33:11 +0100 | [diff] [blame] | 47 | |
| 48 | define help_msg |
| 49 | ************************************************************* |
Gyorgy Szing | f24a03a | 2023-03-21 03:00:40 +0100 | [diff] [blame] | 50 | Variables: |
| 51 | Variables can be passed as arguments (make <var>=<value>) |
| 52 | or be set in the environment (e.g. export <var>=<value>; |
| 53 | make ...). |
| 54 | |
Gyorgy Szing | b73b5c2 | 2024-02-01 16:30:04 +0000 | [diff] [blame] | 55 | BUILD_PREFIX - Directory for build directories |
Gyorgy Szing | f24a03a | 2023-03-21 03:00:40 +0100 | [diff] [blame] | 56 | FILTER_PATTERN - grep regexp to limit test scope to tests |
| 57 | whose name matches. To see the selected tests |
| 58 | run: make FILTER_PATTERN=<pattern> list |
Gyorgy Szing | b73b5c2 | 2024-02-01 16:30:04 +0000 | [diff] [blame] | 59 | INSTALL_PREFIX - Directory to install projects |
| 60 | LOGDIR_ROOT - Directory to save build logs |
| 61 | |
Gyorgy Szing | ba1095c | 2020-11-24 00:33:11 +0100 | [diff] [blame] | 62 | Available targets: |
| 63 | all - generate and run test script |
| 64 | config - run script generation only |
| 65 | clean - remove intermediate files |
| 66 | list - run config and list test cases |
| 67 | p-<variable> - print value of make variable (for debugging) |
| 68 | r-<test> - run a command of the generated script. Allow |
| 69 | executing a single test case. Use |
| 70 | make r-help |
| 71 | to get the list of tests. |
| 72 | ************************************************************* |
| 73 | endef |
| 74 | |
| 75 | export help_msg |
| 76 | help: |
| 77 | @echo "$$help_msg" |
| 78 | |
| 79 | # remove intermediate output |
| 80 | clean: |
| 81 | ifneq ($(wildcard ./run.sh),) |
| 82 | bash run.sh clean |
| 83 | endif |
| 84 | -rm -rf ${OUTPUTS} |
| 85 | |
| 86 | # Convert template to shell script |
| 87 | %.sh : %.sh.j2 test_data.yaml |
| 88 | yasha -v test_data.yaml $< |
| 89 | |
| 90 | # print variable value (i.e. make p-TEMPLATES) |
| 91 | p-%: |
| 92 | @echo $*=${$*} |