Added MSVC/Windows compatibility to a few recipes (and the main script).
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
from SCons.Script import *
|
||||
|
||||
_BUILT_STAMPFILE = '.spp_built'
|
||||
|
||||
def cmd_quote(s: str) -> str:
|
||||
return f'"{s.replace("\\", "\\\\")}"'
|
||||
|
||||
def cook(env: Environment, project_root: str, generate_args: 'list[str]' = [], build_args : 'list[str]' = [], install_args : 'list[str]' = []) -> dict:
|
||||
config = env['BUILD_TYPE']
|
||||
build_dir = os.path.join(project_root, f'build_{config}')
|
||||
@@ -21,11 +22,14 @@ def cook(env: Environment, project_root: str, generate_args: 'list[str]' = [], b
|
||||
'release': 'Release',
|
||||
'profile': 'RelWithDebInfo'
|
||||
}.get(env['BUILD_TYPE'], 'RelWithDebInfo')
|
||||
environ = os.environ.copy()
|
||||
environ['CXXFLAGS'] = ' '.join(f'-D{define}' for define in env['CPPDEFINES']) # TODO: who cares about windows?
|
||||
subprocess.run(('cmake', '-G', 'Ninja', '-B', build_dir, f'-DCMAKE_BUILD_TYPE={build_type}', f'-DCMAKE_INSTALL_PREFIX={install_dir}', '-DBUILD_TESTING=OFF', *generate_args, project_root), env=environ, stdout=sys.stdout, stderr=sys.stderr, check=True)
|
||||
subprocess.run(('cmake', '--build', *build_args, build_dir), stdout=sys.stdout, stderr=sys.stderr, check=True)
|
||||
subprocess.run(('cmake', '--install', *install_args, build_dir), stdout=sys.stdout, stderr=sys.stderr, check=True)
|
||||
def run_cmd(args):
|
||||
env.Execute(' '.join([str(s) for s in args]))
|
||||
# TODO: is this a problem?
|
||||
# environ = os.environ.copy()
|
||||
# environ['CXXFLAGS'] = ' '.join(f'-D{define}' for define in env['CPPDEFINES']) # TODO: who cares about windows?
|
||||
run_cmd(['cmake', '-G', 'Ninja', '-B', build_dir, f'-DCMAKE_BUILD_TYPE={build_type}', f'-DCMAKE_INSTALL_PREFIX={cmd_quote(install_dir)}', '-DBUILD_TESTING=OFF', *generate_args, project_root])
|
||||
run_cmd(['cmake', '--build', *build_args, cmd_quote(build_dir)])
|
||||
run_cmd(['cmake', '--install', *install_args, cmd_quote(build_dir)])
|
||||
pathlib.Path(install_dir, _BUILT_STAMPFILE).touch()
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user