summaryrefslogtreecommitdiff
path: root/mesonbuild/mcompile.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2020-09-12 03:53:28 +0530
committerJussi Pakkanen <jpakkane@gmail.com>2020-09-13 20:44:30 +0300
commit7fbdf38ce3b02cc775ce22c3c303ad3529a758c2 (patch)
treef67a1afa31df71e50116fb2d13f6564ebffc2208 /mesonbuild/mcompile.py
parent9d017a9c159409951be7c2b9bda8f172420d2f69 (diff)
downloadmeson-7fbdf38ce3b02cc775ce22c3c303ad3529a758c2.tar.gz
mcompile: Add some basic XCode support
I wrote this to convert run_tests.get_backend_commands() over to the new meson wrappers, but that turned out to be harder than I expected, so just splitting this out for now.
Diffstat (limited to 'mesonbuild/mcompile.py')
-rw-r--r--mesonbuild/mcompile.py48
1 files changed, 47 insertions, 1 deletions
diff --git a/mesonbuild/mcompile.py b/mesonbuild/mcompile.py
index f91f05d61..01b99bbbc 100644
--- a/mesonbuild/mcompile.py
+++ b/mesonbuild/mcompile.py
@@ -14,9 +14,11 @@
"""Entrypoint script for backend agnostic compile."""
+import os
import json
import re
import sys
+import shutil
import typing as T
from collections import defaultdict
from pathlib import Path
@@ -229,6 +231,42 @@ def get_parsed_args_vs(options: 'argparse.Namespace', builddir: Path) -> T.List[
return cmd
+def get_parsed_args_xcode(options: 'argparse.Namespace', builddir: Path) -> T.List[str]:
+ runner = 'xcodebuild'
+ if not shutil.which(runner):
+ raise MesonException('Cannot find xcodebuild, did you install XCode?')
+
+ # No argument to switch directory
+ os.chdir(str(builddir))
+
+ cmd = [runner, '-parallelizeTargets']
+
+ if options.targets:
+ for t in options.targets:
+ cmd += ['-target', t]
+
+ if options.clean:
+ if options.targets:
+ cmd += ['clean']
+ else:
+ cmd += ['-alltargets', 'clean']
+ # Otherwise xcodebuild tries to delete the builddir and fails
+ cmd += ['-UseNewBuildSystem=FALSE']
+
+ if options.jobs > 0:
+ cmd.extend(['-jobs', str(options.jobs)])
+
+ if options.load_average > 0:
+ mlog.warning('xcodebuild does not have a load-average switch, ignoring')
+
+ if options.verbose:
+ # xcodebuild is already quite verbose, and -quiet doesn't print any
+ # status messages
+ pass
+
+ cmd += options.xcode_args
+ return cmd
+
def add_arguments(parser: 'argparse.ArgumentParser') -> None:
"""Add compile specific arguments."""
parser.add_argument(
@@ -281,6 +319,12 @@ def add_arguments(parser: 'argparse.ArgumentParser') -> None:
default=[],
help='Arguments to pass to `msbuild` (applied only on `vs` backend).'
)
+ parser.add_argument(
+ '--xcode-args',
+ type=array_arg,
+ default=[],
+ help='Arguments to pass to `xcodebuild` (applied only on `xcode` backend).'
+ )
def run(options: 'argparse.Namespace') -> int:
bdir = options.builddir # type: Path
@@ -296,8 +340,10 @@ def run(options: 'argparse.Namespace') -> int:
cmd = get_parsed_args_ninja(options, bdir)
elif backend.startswith('vs'):
cmd = 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)
else:
- # TODO: xcode?
raise MesonException(
'Backend `{}` is not yet supported by `compile`. Use generated project files directly instead.'.format(backend))