diff options
| author | Jussi Pakkanen <jpakkane@gmail.com> | 2024-11-29 22:51:43 +0200 |
|---|---|---|
| committer | Jussi Pakkanen <jpakkane@gmail.com> | 2024-12-04 17:53:23 +0200 |
| commit | 0efc33940417ed3ca80addf702fb7549eef99b69 (patch) | |
| tree | 024c0d8ac73ff977e5fb4db73529c37424aacdbd | |
| parent | 9e4feed91ac0c43bf60103c26c1ceb004c7bac0a (diff) | |
| download | meson-0efc33940417ed3ca80addf702fb7549eef99b69.tar.gz | |
env2mfile: add flag to use _FOR_BUILD envvars.
| -rwxr-xr-x | mesonbuild/scripts/env2mfile.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/mesonbuild/scripts/env2mfile.py b/mesonbuild/scripts/env2mfile.py index 05bd1544e..16051a871 100755 --- a/mesonbuild/scripts/env2mfile.py +++ b/mesonbuild/scripts/env2mfile.py @@ -16,12 +16,6 @@ from ..compilers.detect import defaults as compiler_names if T.TYPE_CHECKING: import argparse -def has_for_build() -> bool: - for cenv in envconfig.ENV_VAR_COMPILER_MAP.values(): - if os.environ.get(cenv + '_FOR_BUILD'): - return True - return False - # Note: when adding arguments, please also add them to the completion # scripts in $MESONSRC/data/shell-completions/ def add_arguments(parser: 'argparse.ArgumentParser') -> None: @@ -35,6 +29,8 @@ def add_arguments(parser: 'argparse.ArgumentParser') -> None: help='Generate a cross compilation file.') parser.add_argument('--native', default=False, action='store_true', help='Generate a native compilation file.') + parser.add_argument('--use-for-build', default=False, action='store_true', + help='Use _FOR_BUILD envvars.') parser.add_argument('--system', default=None, help='Define system for cross compilation.') parser.add_argument('--subsystem', default=None, @@ -421,12 +417,10 @@ def detect_missing_native_binaries(infos: MachineInfo) -> None: infos.binaries[toolname] = [exe] def detect_native_env(options: T.Any) -> MachineInfo: - use_for_build = has_for_build() - if use_for_build: - mlog.log('Using FOR_BUILD envvars for detection') + if options.use_for_build: + mlog.log('Using _FOR_BUILD envvars for detection (native file for use during cross compilation)') esuffix = '_FOR_BUILD' else: - mlog.log('Using regular envvars for detection.') esuffix = '' infos = detect_compilers_from_envvars(esuffix) detect_missing_native_compilers(infos) @@ -443,6 +437,8 @@ def run(options: T.Any) -> None: mlog.notice('This functionality is experimental and subject to change.') detect_cross = options.cross if detect_cross: + if options.use_for_build: + sys.exit('--use-for-build only makes sense for --native, not --cross') infos = detect_cross_env(options) write_system_info = True else: |
