Atlas - Kpreprocess

Home / ext / kconfiglib / tests Lines: 1 | Size: 3594 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1# Simple assignments (with bad formatting, as an additional test) 2 3simple-recursive=foo 4simple-immediate:=bar 5# Should become recursive 6simple-recursive-2+=baz 7 8 whitespaced = foo 9 10 11# Simple += test. += should preserve the flavor of the variable (simple vs. 12# recursive). 13 14preserve-recursive = foo 15preserve-recursive += bar 16 17preserve-immediate := foo 18preserve-immediate += bar 19 20 21# Recursive substitution 22 23recursive = $(foo) $(bar) $($(b-char)a$(z-char)) 24recursive += $(indir) 25 26foo = abc 27bar = def 28baz = ghi 29 30b-char = b 31z-char = z 32 33indir = jkl $(indir-2) 34indir-2 = mno 35 36 37# Immediate substitution 38 39def = foo 40immediate := $(undef)$(def)$(undef)$(def) 41def = bar 42undef = bar 43 44 45# Function calls 46 47# Chained function call 48quote = "$(1)" "$(2)" 49rev-quote = $(quote,$(2),$(1)) 50surround-rev-quote = $(0) $(rev-quote,$(1),$(2)) $(0) 51surround-rev-quote-unused-arg = $(surround-rev-quote,$(1),$(2)) $(3) 52# No value is passed for $(3), so it expands to nothing 53fn-indir = surround-rev-quote 54messy-fn-res = $($(fn-indir)-unused-arg, a b (,) , c d ) 55 56# Special characters in function call 57comma = , 58right-paren = ) 59dollar = $ 60left-paren = ( 61fn = "$(1)" 62special-chars-fn-res = $(fn,$(comma)$(dollar)$(left-paren)foo$(right-paren)) 63 64 65# Variable expansions in various locations (verified by checking how the symbol 66# prints) 67 68qaz = QAZ 69echo = $(1) 70ignore-first = $(2) 71 72config PRINT_ME 73 string "$(ENV_1)" if ($(echo,FOO) && $(echo,BAR)) || !$(echo,BAZ) || !(($(qaz))) 74 default "$(echo,"foo")" if "foo $(echo,"bar") baz" = "$(undefined)" 75 76# Expansion within a symbol token, with deliberate sloppiness 77config PRINT_$(ignore-first, ,ME)_TOO 78 bool "foo" 79 default FOO$(ignore-first, ,BAR)BAZ$(qaz) if $(qaz)&&$(qaz)FOO&&x$(ignore-first, ,xx) 80 81 82# Recursive expansion (throws an exception) 83 84rec-1 = x $(rec-2) y 85rec-2 = x $(rec-3) y 86rec-3 = x $(rec-1) y 87 88# Functions are allowed to reference themselves, but an exception is thrown if 89# the function seems to be stuck (the recursion gets too deep) 90safe-fn-rec = $($(1)) 91safe-fn-rec-2 = $(safe-fn-rec,safe-fn-rec-3) 92safe-fn-rec-3 = foo 93safe-fn-rec-res = $(safe-fn-rec,safe-fn-rec-2) 94 95unsafe-fn-rec = $(unsafe-fn-rec,$(1)) 96 97 98# Expansion in the left-hand side of assignments 99 100dummy-arg-fn = bar 101lhs-indir-1 = lhs-indir-2 102lhs-indir-2 = -baz 103rhs = value 104# LHS expands to foo-bar-baz 105foo-$(dummy-arg-fn, ignored argument )$($(lhs-indir-1)) = $(rhs) 106# Expands to empty string, accepted 107 $(undefined) 108 109# Variable with a space in its name 110empty = 111space = $(empty) $(empty) 112foo$(space)bar = value 113space-var-res = $(foo bar) 114 115 116# Built-in functions 117 118# Expands to "baz qaz" 119shell-res = $(shell,false && echo foo bar || echo baz qaz) 120 121# Warns about output on stderr, expands to nothing 122shell-stderr-res := $(shell,echo message on stderr >&2) 123 124# Nested parens in macro call. Should give a single argument. Test it with 125# $(shell) to get a free argument number check. 126parens-res = pre-$(shell,echo '(a,$(b-char),(c,d),e)')-post 127 128# Expands to the current location 129location-res := $(filename):$(lineno) 130 131# Adds one warning, expands to nothing 132$(warning-if,,no warning) 133$(warning-if,n,no warning) 134warning-res := $(warning-if,y,a warning) 135 136# Does not cause an error, expands to nothing 137error-n-res := $(error-if,n,oops) 138 139# Causes an error when expanded 140error-y-res = $(error-if,y,oops) 141 142 143# Environment variables (for testing Kconfig.env_vars). ENV_1 is already 144# referenced above. 145env_ref_1 := xxx $(ENV_2) xxx 146env_ref_2 := $(shell,echo $(ENV_3)) 147env_ref_3 := 148env_ref_3 += $(ENV_4) 149$(warning-if,$(ENV_5),$(ENV_UNDEFINED)) 150source "$(ENV_6)" 151env_ref_4 = $(ENV_7) # Never evaluated 152
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.