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}) |
| 18 | FILTER_ARG=-p "${FILTER_PATTERN}" |
| 19 | endif |
| 20 | |
Gyorgy Szing | ba1095c | 2020-11-24 00:33:11 +0100 | [diff] [blame] | 21 | all: |
Gyorgy Szing | b164e39 | 2021-09-04 01:51:57 +0200 | [diff] [blame] | 22 | ${MAKE} config |
Gyorgy Szing | f24a03a | 2023-03-21 03:00:40 +0100 | [diff] [blame] | 23 | bash run.sh ${FILTER_ARG} |
Gyorgy Szing | ba1095c | 2020-11-24 00:33:11 +0100 | [diff] [blame] | 24 | |
| 25 | config: ${OUTPUTS} |
| 26 | |
| 27 | list: |
Gyorgy Szing | b164e39 | 2021-09-04 01:51:57 +0200 | [diff] [blame] | 28 | ${MAKE} config |
Gyorgy Szing | f24a03a | 2023-03-21 03:00:40 +0100 | [diff] [blame] | 29 | bash run.sh ${FILTER_ARG} help |
Gyorgy Szing | ba1095c | 2020-11-24 00:33:11 +0100 | [diff] [blame] | 30 | |
| 31 | # run a command of the generated script |
| 32 | r-%: |
Gyorgy Szing | b164e39 | 2021-09-04 01:51:57 +0200 | [diff] [blame] | 33 | ${MAKE} config |
Gyorgy Szing | f24a03a | 2023-03-21 03:00:40 +0100 | [diff] [blame] | 34 | bash run.sh ${FILTER_ARG} "$*" |
Gyorgy Szing | ba1095c | 2020-11-24 00:33:11 +0100 | [diff] [blame] | 35 | |
| 36 | define help_msg |
| 37 | ************************************************************* |
Gyorgy Szing | f24a03a | 2023-03-21 03:00:40 +0100 | [diff] [blame] | 38 | Variables: |
| 39 | Variables can be passed as arguments (make <var>=<value>) |
| 40 | or be set in the environment (e.g. export <var>=<value>; |
| 41 | make ...). |
| 42 | |
| 43 | FILTER_PATTERN - grep regexp to limit test scope to tests |
| 44 | whose name matches. To see the selected tests |
| 45 | run: make FILTER_PATTERN=<pattern> list |
Gyorgy Szing | ba1095c | 2020-11-24 00:33:11 +0100 | [diff] [blame] | 46 | Available targets: |
| 47 | all - generate and run test script |
| 48 | config - run script generation only |
| 49 | clean - remove intermediate files |
| 50 | list - run config and list test cases |
| 51 | p-<variable> - print value of make variable (for debugging) |
| 52 | r-<test> - run a command of the generated script. Allow |
| 53 | executing a single test case. Use |
| 54 | make r-help |
| 55 | to get the list of tests. |
| 56 | ************************************************************* |
| 57 | endef |
| 58 | |
| 59 | export help_msg |
| 60 | help: |
| 61 | @echo "$$help_msg" |
| 62 | |
| 63 | # remove intermediate output |
| 64 | clean: |
| 65 | ifneq ($(wildcard ./run.sh),) |
| 66 | bash run.sh clean |
| 67 | endif |
| 68 | -rm -rf ${OUTPUTS} |
| 69 | |
| 70 | # Convert template to shell script |
| 71 | %.sh : %.sh.j2 test_data.yaml |
| 72 | yasha -v test_data.yaml $< |
| 73 | |
| 74 | # print variable value (i.e. make p-TEMPLATES) |
| 75 | p-%: |
| 76 | @echo $*=${$*} |