diff --git a/aedi/target/base.py b/aedi/target/base.py index e1ba4b58..d41c4eb8 100644 --- a/aedi/target/base.py +++ b/aedi/target/base.py @@ -514,42 +514,69 @@ class SingleExeCTarget(MakeTarget): class MesonTarget(BuildTarget): def __init__(self, name=None): super().__init__(name) + self.configure_prefix = True def configure(self, state: BuildState): super().configure(state) - cross_file_path = Path() - - if not state.xcode: - cross_file_path = state.build_path / (state.architecture() + '.txt') - self._write_cross_file(cross_file_path, state) - args = [ - state.bin_path / 'meson', - f'--prefix={state.install_path}', + 'setup', '--buildtype=release', '--default-library=static', ] + if self.configure_prefix: + args.append(f'--prefix={state.install_path}') + if state.xcode: - args.append('--backend') - args.append('xcode') + args.append(f'--backend=xcode') else: + cross_file_path = state.build_path / (state.architecture() + '.txt') + self._write_cross_file(cross_file_path, state) args.append(f'--cross-file={cross_file_path}') + args.append(state.build_path) args.append(state.source) - subprocess.run(args, check=True, cwd=state.build_path, env=state.environment) + + # subprocess.run(args, check=True, cwd=state.build_path, env=state.environment) + self._run_meson(args, state) def build(self, state: BuildState): - args = ['ninja'] + if state.xcode: + args = ('open', f'{self.name}.xcodeproj') + subprocess.run(args, check=True, cwd=state.build_path, env=state.environment) + + # args = ['ninja'] + # + # if state.verbose: + # args.append('--verbose') + # + # subprocess.run(args, check=True, cwd=state.build_path, env=state.environment) + + args = [ + 'compile', + f'-C={state.build_path}', + ] if state.verbose: args.append('--verbose') - subprocess.run(args, check=True, cwd=state.build_path, env=state.environment) + self._run_meson(args, state) def post_build(self, state: BuildState): - self.install(state, tool='ninja') + if state.xcode: + return + + # self.install(state, tool='ninja') + args = [ + 'install', + f'-C={state.build_path}' + ] + + if not self.configure_prefix: + args.append(f'--destdir={state.install_path}') + + self._run_meson(args, state) @staticmethod def _write_cross_file(path: Path, state: BuildState): @@ -578,3 +605,10 @@ cpu_family = '{cpu_family}' cpu = '{cpu}' endian = 'little' ''') + + @staticmethod + def _run_meson(_args: typing.Sequence[typing.Union[str, Path]], state: BuildState): + args = [state.bin_path / 'meson'] + args.extend(_args) + + subprocess.run(args, check=True, cwd=state.build_path, env=state.environment)