Skip to content

Commit 8f1c7e6

Browse files
jpakkaneeli-schwartz
authored andcommitted
env2mfile: add flag to use _FOR_BUILD envvars.
(cherry picked from commit 0efc339)
1 parent 78844d6 commit 8f1c7e6

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

mesonbuild/scripts/env2mfile.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
if T.TYPE_CHECKING:
1717
import argparse
1818

19-
def has_for_build() -> bool:
20-
for cenv in envconfig.ENV_VAR_COMPILER_MAP.values():
21-
if os.environ.get(cenv + '_FOR_BUILD'):
22-
return True
23-
return False
24-
2519
# Note: when adding arguments, please also add them to the completion
2620
# scripts in $MESONSRC/data/shell-completions/
2721
def add_arguments(parser: 'argparse.ArgumentParser') -> None:
@@ -35,6 +29,8 @@ def add_arguments(parser: 'argparse.ArgumentParser') -> None:
3529
help='Generate a cross compilation file.')
3630
parser.add_argument('--native', default=False, action='store_true',
3731
help='Generate a native compilation file.')
32+
parser.add_argument('--use-for-build', default=False, action='store_true',
33+
help='Use _FOR_BUILD envvars.')
3834
parser.add_argument('--system', default=None,
3935
help='Define system for cross compilation.')
4036
parser.add_argument('--subsystem', default=None,
@@ -421,12 +417,10 @@ def detect_missing_native_binaries(infos: MachineInfo) -> None:
421417
infos.binaries[toolname] = [exe]
422418

423419
def detect_native_env(options: T.Any) -> MachineInfo:
424-
use_for_build = has_for_build()
425-
if use_for_build:
426-
mlog.log('Using FOR_BUILD envvars for detection')
420+
if options.use_for_build:
421+
mlog.log('Using _FOR_BUILD envvars for detection (native file for use during cross compilation)')
427422
esuffix = '_FOR_BUILD'
428423
else:
429-
mlog.log('Using regular envvars for detection.')
430424
esuffix = ''
431425
infos = detect_compilers_from_envvars(esuffix)
432426
detect_missing_native_compilers(infos)
@@ -443,6 +437,8 @@ def run(options: T.Any) -> None:
443437
mlog.notice('This functionality is experimental and subject to change.')
444438
detect_cross = options.cross
445439
if detect_cross:
440+
if options.use_for_build:
441+
sys.exit('--use-for-build only makes sense for --native, not --cross')
446442
infos = detect_cross_env(options)
447443
write_system_info = True
448444
else:

0 commit comments

Comments
 (0)