-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathKbuild_functions
More file actions
126 lines (99 loc) · 3.07 KB
/
Kbuild_functions
File metadata and controls
126 lines (99 loc) · 3.07 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Test Kbuild toolchain test functions and $(python,...) built-in
# --- $(python,...) tests ---
config TEST_PYTHON_SUCCESS
def_bool $(python,)
help
Empty code string = success = "y"
config TEST_PYTHON_ASSERT_PASS
def_bool $(python,assert not "")
help
Assertion that passes = "y"
config TEST_PYTHON_ASSERT_FAIL
def_bool $(python,assert False)
help
Assertion that fails = "n"
config TEST_PYTHON_ENV
def_bool $(python,assert os.environ.get('CC'))
help
Check env var via os module
config TEST_PYTHON_WHICH
def_bool $(python,assert shutil.which('python3') or shutil.which('python'))
help
Tool detection via shutil.which
config TEST_PYTHON_RUN
def_bool $(python,assert run(sys.executable, '-c', ''))
help
Shell-free subprocess via run()
config TEST_PYTHON_RUN_FAIL
def_bool $(python,assert not run(sys.executable, '-c', 'raise SystemExit(1)'))
help
Verify run() failure detection
config TEST_PYTHON_QUOTE_COMMA
def_bool $(python,assert "a,b" == "a,b")
help
Commas inside double quotes must not split arguments
config TEST_PYTHON_QUOTE_PAREN
def_bool $(python,assert "(" + ")" == "()")
help
Parentheses inside quotes must not affect nesting
config TEST_PYTHON_SINGLE_QUOTE
def_bool $(python,assert 'x,y' == 'x,y')
help
Single-quoted commas must not split arguments
config TEST_PYTHON_ESCAPED_QUOTE
def_bool $(python,assert "a\"b" == 'a"b')
help
Backslash-escaped quotes must not end quoted region
config TEST_PYTHON_TRIPLE_QUOTE
def_bool $(python,assert """a,b"c""" == 'a,b"c')
help
Triple-quoted string with comma and embedded quote
config TEST_PYTHON_TRIPLE_SINGLE
def_bool $(python,assert '''x,y'z''' == "x,y'z")
help
Triple single-quoted string with comma and embedded quote
GREETING = hello
config TEST_PYTHON_MACRO_BEFORE_ESCAPE
def_bool $(python,assert "$(GREETING)\n" == "hello\n")
help
Macro expansion must happen before backslash-escape processing
inside quoted regions so $(GREETING) is expanded, not skipped.
# --- Toolchain function tests (cc-option, ld-option, etc.) ---
config CC_HAS_WALL
def_bool $(cc-option,-Wall)
help
Test if compiler supports -Wall flag
config CC_HAS_WERROR
def_bool $(cc-option,-Werror)
help
Test if compiler supports -Werror flag
config CC_HAS_FSTACK_PROTECTOR
def_bool $(cc-option,-fstack-protector)
help
Test if compiler supports stack protector
config LD_HAS_VERSION
def_bool $(ld-option,--version)
help
Test if linker supports --version flag
config AS_HAS_NOP
def_bool $(as-instr,nop)
help
Test if assembler supports NOP instruction
config AS_HAS_MOVQ
def_bool $(as-instr,movq %rax$(comma) %rbx)
help
Test if assembler supports x86-64 MOVQ instruction
config AS_HAS_CUSTOM_FLAG
def_bool $(as-option,-march=native)
help
Test if assembler (via CC) supports custom flags
config CC_STACK_USAGE_FLAG
string
default "$(cc-option-bit,-fstack-usage)"
help
Returns -fstack-usage if supported, empty otherwise
# --- Failure cases ---
config TEST_INVALID_OPTION
def_bool $(cc-option,--this-option-does-not-exist-xyz)
help
Test cc-option with invalid flag (should return n)