build (client cpp): Configure cmake build w/ presets

This commit is contained in:
John Colvin committed 2022-07-01 13:18:05 -05:00
1 parent 8122e22c1b
commit 8301fdccf4
1 file changed
+12 -20
+12 -20
View File
@@ -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()]