aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mcompile.py
diff options
context:
space:
mode:
authorVili Väinölä <vilivainola@gmail.com>2020-09-13 09:03:35 +0300
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2020-10-02 09:09:43 +0000
commit32cf7a03d251e5a352e2cc2aa8ed4b95c6682bc0 (patch)
tree739cabf78b379169789118af74a6cd33e6d21813 /mesonbuild/mcompile.py
parent20663564bdde2a0ec4977b011259b09523555bcb (diff)
downloadmeson-32cf7a03d251e5a352e2cc2aa8ed4b95c6682bc0.zip
meson-32cf7a03d251e5a352e2cc2aa8ed4b95c6682bc0.tar.gz
meson-32cf7a03d251e5a352e2cc2aa8ed4b95c6682bc0.tar.bz2
Fix meson compile for 32-bit MSVC build
- Remove platform from env so that msbuild does not try to compile e.g. configuration debug|x86
Diffstat (limited to 'mesonbuild/mcompile.py')
-rw-r--r--mesonbuild/mcompile.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/mesonbuild/mcompile.py b/mesonbuild/mcompile.py
index 01b99bb..1e58207 100644
--- a/mesonbuild/mcompile.py
+++ b/mesonbuild/mcompile.py
@@ -137,7 +137,7 @@ def generate_target_names_ninja(target: ParsedTargetName, builddir: Path, intros
else:
return [str(Path(out_file).relative_to(builddir.resolve())) for out_file in intro_target['filename']]
-def get_parsed_args_ninja(options: 'argparse.Namespace', builddir: Path) -> T.List[str]:
+def get_parsed_args_ninja(options: 'argparse.Namespace', builddir: Path) -> T.Tuple[T.List[str], T.Optional[T.Dict[str, str]]]:
runner = detect_ninja()
if runner is None:
raise MesonException('Cannot find ninja.')
@@ -164,7 +164,7 @@ def get_parsed_args_ninja(options: 'argparse.Namespace', builddir: Path) -> T.Li
cmd += options.ninja_args
- return cmd
+ return cmd, None
def generate_target_name_vs(target: ParsedTargetName, builddir: Path, introspect_data: dict) -> str:
intro_target = get_target_from_intro_data(target, builddir, introspect_data)
@@ -179,7 +179,7 @@ def generate_target_name_vs(target: ParsedTargetName, builddir: Path, introspect
target_name = str(rel_path / target_name)
return target_name
-def get_parsed_args_vs(options: 'argparse.Namespace', builddir: Path) -> T.List[str]:
+def get_parsed_args_vs(options: 'argparse.Namespace', builddir: Path) -> T.Tuple[T.List[str], T.Optional[T.Dict[str, str]]]:
slns = list(builddir.glob('*.sln'))
assert len(slns) == 1, 'More than one solution in a project?'
sln = slns[0]
@@ -229,9 +229,13 @@ def get_parsed_args_vs(options: 'argparse.Namespace', builddir: Path) -> T.List[
cmd += options.vs_args
- return cmd
+ # Remove platform from env so that msbuild does not pick x86 platform when solution platform is Win32
+ env = os.environ.copy()
+ del env['PLATFORM']
-def get_parsed_args_xcode(options: 'argparse.Namespace', builddir: Path) -> T.List[str]:
+ return cmd, env
+
+def get_parsed_args_xcode(options: 'argparse.Namespace', builddir: Path) -> T.Tuple[T.List[str], T.Optional[T.Dict[str, str]]]:
runner = 'xcodebuild'
if not shutil.which(runner):
raise MesonException('Cannot find xcodebuild, did you install XCode?')
@@ -265,7 +269,7 @@ def get_parsed_args_xcode(options: 'argparse.Namespace', builddir: Path) -> T.Li
pass
cmd += options.xcode_args
- return cmd
+ return cmd, None
def add_arguments(parser: 'argparse.ArgumentParser') -> None:
"""Add compile specific arguments."""
@@ -330,23 +334,23 @@ def run(options: 'argparse.Namespace') -> int:
bdir = options.builddir # type: Path
validate_builddir(bdir.resolve())
- cmd = [] # type: T.List[str]
+ cmd = [] # type: T.List[str]
+ env = None # type: T.Optional[T.Dict[str, str]]
if options.targets and options.clean:
raise MesonException('`TARGET` and `--clean` can\'t be used simultaneously')
backend = get_backend_from_coredata(bdir)
if backend == 'ninja':
- cmd = get_parsed_args_ninja(options, bdir)
+ cmd, env = get_parsed_args_ninja(options, bdir)
elif backend.startswith('vs'):
- cmd = get_parsed_args_vs(options, bdir)
+ cmd, env = get_parsed_args_vs(options, bdir)
elif backend == 'xcode':
- mlog.warning('xcode backend is currently unmaintained, patches welcome')
- cmd = get_parsed_args_xcode(options, bdir)
+ cmd, env = get_parsed_args_xcode(options, bdir)
else:
raise MesonException(
'Backend `{}` is not yet supported by `compile`. Use generated project files directly instead.'.format(backend))
- p, *_ = mesonlib.Popen_safe(cmd, stdout=sys.stdout.buffer, stderr=sys.stderr.buffer)
+ p, *_ = mesonlib.Popen_safe(cmd, stdout=sys.stdout.buffer, stderr=sys.stderr.buffer, env=env)
return p.returncode