Skip to content

Commit 88a9e92

Browse files
committed
build-llvm.py: Add ability to override "true" arguments
Users (such as myself) may have wrappers around 'build-llvm.py' to set default arguments but allow additional arguments to be passed. Arguments that take a value can be overridden by subsequent instances of the arguments but boolean actions cannot. Python 3.9 introduced the BooleanOptionalAction action in the argparse package, which automatically defines '--foo' and '--no-foo', which would allow one to override '--assertions' with '--no-assertions' for that one invocation. For now, start with '--no-assertions', as the presence of the '--no-' value for the other boolean options is noisy and they are unlikely to defaulted to with the need to override. This change can be done to options as use cases appear. Signed-off-by: Nathan Chancellor <nathan@kernel.org>
1 parent 18c0282 commit 88a9e92

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

build-llvm.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
from tc_build.kernel import KernelBuilder, LinuxSourceManager, LLVMKernelBuilder
1414
from tc_build.tools import HostTools, StageTools
1515

16+
try:
17+
# pylint: disable-next=ungrouped-imports
18+
from argparse import BooleanOptionalAction
19+
# 'store_true' sets 'default' implicitly, do it explicitly to match
20+
BOOL_ARGS = {'action': BooleanOptionalAction, 'default': False}
21+
except ImportError:
22+
BOOL_ARGS = {'action': 'store_true'}
23+
1624
# This is a known good revision of LLVM for building the kernel
1725
GOOD_REVISION = 'd5802c30ae6cf296489daf12b36582e9e1d658bb'
1826

@@ -29,7 +37,7 @@
2937
issues when compiling but it will increase compile times by 15-20%%.
3038
3139
'''),
32-
action='store_true')
40+
**BOOL_ARGS)
3341
parser.add_argument('-b',
3442
'--build-folder',
3543
help=textwrap.dedent('''\

0 commit comments

Comments
 (0)