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.
pull/7490/head
Nirbheek Chauhan 4 years ago committed by Jussi Pakkanen
parent 9d017a9c15
commit 7fbdf38ce3
  1. 48
      mesonbuild/mcompile.py
  2. 2
      mesonbuild/msetup.py

@ -14,9 +14,11 @@
"""Entrypoint script for backend agnostic compile.""" """Entrypoint script for backend agnostic compile."""
import os
import json import json
import re import re
import sys import sys
import shutil
import typing as T import typing as T
from collections import defaultdict from collections import defaultdict
from pathlib import Path from pathlib import Path
@ -229,6 +231,42 @@ def get_parsed_args_vs(options: 'argparse.Namespace', builddir: Path) -> T.List[
return cmd 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: def add_arguments(parser: 'argparse.ArgumentParser') -> None:
"""Add compile specific arguments.""" """Add compile specific arguments."""
parser.add_argument( parser.add_argument(
@ -281,6 +319,12 @@ def add_arguments(parser: 'argparse.ArgumentParser') -> None:
default=[], default=[],
help='Arguments to pass to `msbuild` (applied only on `vs` backend).' 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: def run(options: 'argparse.Namespace') -> int:
bdir = options.builddir # type: Path bdir = options.builddir # type: Path
@ -296,8 +340,10 @@ def run(options: 'argparse.Namespace') -> int:
cmd = get_parsed_args_ninja(options, bdir) cmd = get_parsed_args_ninja(options, bdir)
elif backend.startswith('vs'): elif backend.startswith('vs'):
cmd = get_parsed_args_vs(options, bdir) 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: else:
# TODO: xcode?
raise MesonException( raise MesonException(
'Backend `{}` is not yet supported by `compile`. Use generated project files directly instead.'.format(backend)) 'Backend `{}` is not yet supported by `compile`. Use generated project files directly instead.'.format(backend))

@ -155,6 +155,8 @@ class MesonApp:
mlog.initialize(env.get_log_dir(), self.options.fatal_warnings) mlog.initialize(env.get_log_dir(), self.options.fatal_warnings)
if self.options.profile: if self.options.profile:
mlog.set_timestamp_start(time.monotonic()) mlog.set_timestamp_start(time.monotonic())
if env.coredata.builtins['backend'].value == 'xcode':
mlog.warning('xcode backend is currently unmaintained, patches welcome')
with mesonlib.BuildDirLock(self.build_dir): with mesonlib.BuildDirLock(self.build_dir):
self._generate(env) self._generate(env)

Loading…
Cancel
Save