build: Fix build_sparkd.py (broken since CMakePresets introduced)
Pass additional cmake opts through cli. Specifically, those that were moved from CMakeLists.txt to CMakePrests.json
This commit is contained in:
1 parent
99a778811a
commit
dcf80d7067
1 file changed
+51
-8
@@ -18,9 +18,9 @@ class CMakeCompilerPair:
|
||||
def to_opts(self):
|
||||
opts = {}
|
||||
if self.c:
|
||||
opts['C_COMPILER'] = self.c
|
||||
opts['CMAKE_C_COMPILER'] = self.c
|
||||
if self.cxx:
|
||||
opts['CXX_COMPILER'] = self.cxx
|
||||
opts['CMAKE_CXX_COMPILER'] = self.cxx
|
||||
return opts
|
||||
|
||||
def __str__(self):
|
||||
@@ -37,9 +37,9 @@ class CMakeConfigureCommand:
|
||||
self.add_opt('-B', build_dir)
|
||||
if generator is not None:
|
||||
self.add_opt('-G', generator)
|
||||
self.add_opt('BUILD_TYPE', build_type)
|
||||
self.add_opt('C_COMPILER', compiler.c)
|
||||
self.add_opt('CXX_COMPILER', compiler.cxx)
|
||||
self.add_opt('CMAKE_BUILD_TYPE', build_type)
|
||||
self.add_opt('CMAKE_C_COMPILER', compiler.c)
|
||||
self.add_opt('CMAKE_CXX_COMPILER', compiler.cxx)
|
||||
|
||||
def add_opt(self, name: str, value):
|
||||
if name is None:
|
||||
@@ -47,7 +47,7 @@ class CMakeConfigureCommand:
|
||||
if value is None:
|
||||
return self
|
||||
if not name.startswith('-'):
|
||||
name = f'-DCMAKE_{name}'
|
||||
name = f'-D{name}'
|
||||
self.cmd = f'{self.cmd} {name}={value}'
|
||||
else:
|
||||
self.cmd = f'{self.cmd} {name} {value}'
|
||||
@@ -180,6 +180,48 @@ def _get_cmake_build_type(build_type: str):
|
||||
return build_type
|
||||
|
||||
|
||||
def _get_cmake_opts(build_type, compiler):
|
||||
opts = {
|
||||
'WEB_TSCONFIG_NAME': f'{build_type}-{compiler}',
|
||||
}
|
||||
cxx_flags_common = [
|
||||
'-fPIC',
|
||||
'-Wall',
|
||||
'-pedantic',
|
||||
'-Wextra',
|
||||
'-Werror',
|
||||
'-Wno-missing-braces',
|
||||
'-Wno-ignored-qualifiers',
|
||||
'--std=c++17',
|
||||
'-fdiagnostics-color',
|
||||
]
|
||||
if compiler == 'gcc':
|
||||
cxx_flags_common.append('-Wno-stringop-overread')
|
||||
|
||||
if build_type == 'debug':
|
||||
cxx_flags_debug = cxx_flags_common + [
|
||||
'-DDEBUG',
|
||||
]
|
||||
opts['CMAKE_CXX_FLAGS_DEBUG'] = f'"{" ".join(cxx_flags_debug)}"'
|
||||
opts['CMAKE_EXPORT_COMPILE_COMMANDS'] = 'ON'
|
||||
else:
|
||||
cxx_flags_release = cxx_flags_common + [
|
||||
'-fno-omit-frame-pointer',
|
||||
'-DNDEBUG',
|
||||
'-O3',
|
||||
]
|
||||
if compiler == 'clang':
|
||||
cxx_flags_release.extend([
|
||||
'-Wno-uninitialized',
|
||||
])
|
||||
else:
|
||||
cxx_flags_release.extend([
|
||||
'-Wno-maybe-uninitialized',
|
||||
])
|
||||
opts['CMAKE_CXX_FLAGS_RELEASE'] = f'"{" ".join(cxx_flags_release)}"'
|
||||
return opts
|
||||
|
||||
|
||||
def _configure(
|
||||
src_dir, build_dir, build_type, compiler: CMakeCompilerPair) -> subprocess.CompletedProcess:
|
||||
'''Configures sparkd (server) build'''
|
||||
@@ -191,8 +233,9 @@ def _configure(
|
||||
generator='Ninja',
|
||||
build_type=cmake_build_type,
|
||||
compiler=compiler)
|
||||
if build_type.lower() == 'debug':
|
||||
cmd.add_opt('EXPORT_COMPILE_COMMANDS', True)
|
||||
opts = _get_cmake_opts(build_type, compiler.name)
|
||||
for name, value in opts.items():
|
||||
cmd.add_opt(name, value)
|
||||
|
||||
print(f'configure_cmd: {cmd}')
|
||||
with CWD(build_dir):
|
||||
|
||||
Reference in new issue
Block a user