From 8301fdccf4253b00ff558b23494dd645fe0af16a Mon Sep 17 00:00:00 2001 From: John Colvin Date: Wed, 29 Jun 2022 23:08:27 -0500 Subject: [PATCH] build (client cpp): Configure cmake build w/ presets --- tools/buildspark.py | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/tools/buildspark.py b/tools/buildspark.py index e967cf351..f59ffe943 100644 --- a/tools/buildspark.py +++ b/tools/buildspark.py @@ -1,10 +1,8 @@ import argparse import os import subprocess -import shutil from argparse_utils import add_toggle_opt, get_arg -from file_utils import create_dir from typing import Tuple @@ -19,15 +17,6 @@ class VisualStudioContext: def prompt_cmd(self): return f'{self.prompt_path} -arch=x64 -host_arch=x64' - def configure_libspark(self, build_dir): - with CWD(build_dir): - subprocess.call( - f'cmake.exe -G "Visual Studio {self.version} {self.year}" {SparkPaths.root()}' - ) - shutil.copy( - f'{SparkPaths.tools()}\\cpp.build.props', - 'Directory.Build.Props') - def msbuild_flag(self, flag): return f'{self._msbuild_arg_prefix}{flag}' @@ -243,6 +232,9 @@ def _get_arg_parser(): help= 'Whether or not to delete and overwrite an existing build directory') + parser.add_argument( + '--cmake-preset', help="The '--preset' argument passed to cmake") + parser.add_argument( '--verbosity', metavar='[q(uiet)|m(inimal)|n(ormal)|d(etailed)|diag(nostic)]', @@ -250,7 +242,12 @@ def _get_arg_parser(): type=str, help='The output verbosity level') - parser.set_defaults(restore=True, cpp=True, csharp=True, verbosity='minimal') + parser.set_defaults( + restore=True, + cpp=True, + csharp=True, + cmake_preset='spark', + verbosity='minimal') return parser @@ -274,15 +271,10 @@ if __name__ == "__main__": targets.append('all') verbosity = get_arg(args_dict, 'verbosity') + # configure cmake + subprocess.run(f'cmake --preset {args.cmake_preset}', shell=True) + vs_context = _deduce_visual_studio_context() - - try: - build_dir = os.path.realpath(build_dir) - create_dir(build_dir, clean) - vs_context.configure_libspark(build_dir) - except Exception as e: - _exit(1, e) - build_context = BuildContext(_workspace_root(), build_dir) csharp_targets, cpp_targets = build_context.parse_targets(targets) build_cmd_steps = [vs_context.prompt_cmd()]