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 {
|
||||
|
||||
@@ -1,17 +1,27 @@
|
||||
|
||||
import os
|
||||
import platform
|
||||
from SCons.Script import *
|
||||
|
||||
def cook(env: Environment, git_ref: str = "main") -> dict:
|
||||
repo = env.Cook('GitBranch', repo_name = 'SDL', remote_url = 'https://github.com/libsdl-org/SDL.git', git_ref = git_ref)
|
||||
checkout_root = repo['checkout_root']
|
||||
build_result = env.Cook('CMakeProject', project_root=checkout_root, generate_args = ['-DSDL_STATIC=ON', '-DSDL_SHARED=OFF'])
|
||||
lib_name = {
|
||||
'debug': 'SDL2d'
|
||||
}.get(env['BUILD_TYPE'], 'SDL2')
|
||||
libs = []
|
||||
if platform.system() == 'Windows':
|
||||
if env['BUILD_TYPE'] == 'debug':
|
||||
libs.append('SDL2-staticd')
|
||||
else:
|
||||
libs.append('SDL2-static')
|
||||
libs.extend(('kernel32', 'user32', 'gdi32', 'winmm', 'imm32', 'ole32', 'oleaut32', 'version', 'uuid', 'advapi32', 'setupapi', 'shell32', 'dinput8'))
|
||||
else:
|
||||
if env['BUILD_TYPE'] == 'debug':
|
||||
libs.append('SDL2d')
|
||||
else:
|
||||
libs.append('SDL2')
|
||||
return {
|
||||
'LIBPATH': build_result['LIBPATH'],
|
||||
'CPPPATH': [os.path.join(build_result['install_dir'], 'include/SDL2')], # SDL is really weird about include paths ...
|
||||
'LIBS': [lib_name]
|
||||
'LIBS': libs
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import os
|
||||
import pathlib
|
||||
import platform
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
_SCRIPT_STAMPFILE = '.spp_script_run'
|
||||
@@ -21,7 +20,13 @@ def cook(env: Environment, remote: str = 'github', git_ref: str = '') -> dict:
|
||||
# TODO: windows?
|
||||
did_run_script = os.path.exists(os.path.join(repo['checkout_root'], _SCRIPT_STAMPFILE))
|
||||
if not did_run_script or env['UPDATE_REPOSITORIES']:
|
||||
subprocess.run(('/usr/bin/env', 'python3', 'update_glslang_sources.py'), cwd=checkout_root, stdout=sys.stdout, stderr=sys.stderr, check=True)
|
||||
python_exe = os.path.realpath(sys.executable)
|
||||
script_file = os.path.join(repo['checkout_root'], 'update_glslang_sources.py')
|
||||
prev_cwd = os.getcwd()
|
||||
os.chdir(repo['checkout_root'])
|
||||
if env.Execute(f'"{python_exe}" {script_file}'):
|
||||
env.Exit(1)
|
||||
os.chdir(prev_cwd)
|
||||
pathlib.Path(repo['checkout_root'], _SCRIPT_STAMPFILE).touch()
|
||||
|
||||
# generate the build_info.h
|
||||
@@ -44,7 +49,7 @@ def cook(env: Environment, remote: str = 'github', git_ref: str = '') -> dict:
|
||||
+ env.RGlob(os.path.join(repo['checkout_root'], 'glslang/OGLCompilersDLL/'), '*.cpp') \
|
||||
+ env.RGlob(os.path.join(repo['checkout_root'], 'glslang/ResourceLimits/'), '*.cpp') \
|
||||
+ env.RGlob(os.path.join(repo['checkout_root'], 'SPIRV/'), '*.cpp') \
|
||||
+ env.RGlob(os.path.join(repo['checkout_root'], f'glslang/OSDependent/{platform_source_dir}/'), '*.cpp')
|
||||
+ [os.path.join(repo['checkout_root'], f'glslang/OSDependent/{platform_source_dir}/ossource.cpp')]
|
||||
|
||||
# disable a few warnings when compiling with clang
|
||||
additional_cxx_flags = {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
from SCons.Script import *
|
||||
|
||||
def cook(env: Environment, git_ref = 'master') -> dict:
|
||||
if env['COMPILER_FAMILY'] not in ('gcc', 'clang'):
|
||||
env.Error('libbacktrace requires gcc or clang.')
|
||||
repo = env.Cook('GitBranch', repo_name = 'libbacktrace', remote_url = 'https://github.com/ianlancetaylor/libbacktrace.git', git_ref = git_ref)
|
||||
checkout_root = repo['checkout_root']
|
||||
build_result = env.Cook('AutotoolsProject', checkout_root)
|
||||
|
||||
Reference in New Issue
Block a user