forked from linux-kdevops/kdevops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.extra_vars
67 lines (54 loc) · 2.63 KB
/
Makefile.extra_vars
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
# SPDX-License-Identifier: copyleft-next-0.3.1
#
# This specifies how we generate the extra_vars.yaml file
EXTRA_VAR_INPUTS += most_extra_vars
EXTRA_VAR_INPUTS += most_extra_vars_separated
EXTRA_VAR_INPUTS += most_extra_vars_direct
# This ensures that for instance running 'make fstests-baseline-loop' will
# have the respective filesystem configuration file
# /var/lib/xfstests/configs/${HOST}.config get updated *with* a respective
# correct value in case you do dynamic updates to the .config.
# The extra_vars.yaml file will get the correct updated values, not the
# defaults from fstests/defaults/main.yml so long as the file
# workflows/fstests/Makefile also updates
EXTRA_VAR_INPUTS += $(KDEVOPS_PLAYBOOKS_DIR)/roles/*/defaults/main.yml
null :=
space := ${null} ${null}
${space} := ${space}
comma:= ,
define YAML_ENTRY
$(1)
endef
define YAML_ENTRY_SEP
$(subst +, ,$(1))
endef
# firstword only works with spaces, so we must introduce artificial spaces
# so we capture the first entry, we peg the '=' at the end after that and
# use that to substitute $first=% / $first:%
#
# We may be able to use YAML_ENTRY_DIRECT for all variables and then we
# phase out the others. This requires more inspection. But best would be
# for us to just add yaml output support directly upstream to kconfig.
define YAML_ENTRY_DIRECT
$(patsubst $(firstword $(subst =, ,$(1)))=%,$(firstword $(subst =, ,$(1))): "%",$(1))
endef
#$(patsubst $(firstword $(subst =, ,$(1)))=%,$(firstword $(subst =, ,$(1))):%,$(1))
#$(patsubst $(firstword $(subst =, ,$(1))=)%,$(firstword $(subst =, , $(1):)%,$(1)),$(1))
# We can transform most of .config things we need to using
# looping on ANSIBLE_EXTRA_ARGS and converting those with
# this target. If you need to do more complex fancy stuff
# extend the EXTRA_VAR_INPUTS variable in your workflow with
# your custom stuff.
most_extra_vars:
@echo --- > $(KDEVOPS_EXTRA_VARS)
@$(foreach exp,$(ANSIBLE_EXTRA_ARGS),echo $(call YAML_ENTRY,$(subst =,: ,$(exp)) >> $(KDEVOPS_EXTRA_VARS)))
# ANSIBLE_EXTRA_ARGS_SEPARATED is to be used for variables in .config
# which are separted by spaces. We use a trick and assume .config variables
# won't have the sign "+" so substitute spaces for "+" for looping over them and
# then substitute the "+" for the space when echoing the variable again.
most_extra_vars_separated:
@$(foreach exp,$(ANSIBLE_EXTRA_ARGS_SEPARATED),echo $(call YAML_ENTRY_SEP,$(subst =,: ,"$(exp)") >> $(KDEVOPS_EXTRA_VARS)))
# These are variable we want to express as-is, and which may also contain
# a '=' inside of it.
most_extra_vars_direct:
@$(foreach exp,$(ANSIBLE_EXTRA_ARGS_DIRECT),echo $(call YAML_ENTRY_DIRECT,$(exp) >> $(KDEVOPS_EXTRA_VARS)))