Added common recipe for building CMake projects. And added Catch2 recipe.
This commit is contained in:
parent
1988bcc99b
commit
d1c48fbd8a
@ -206,6 +206,13 @@ env['UNITY_CACHE_DIR'] = Dir(f'{env["CACHE_DIR"]}/unity')
|
||||
env['BUILD_TYPE'] = build_type
|
||||
env.Append(LIBPATH = [env['LIB_DIR']]) # to allow submodules to link to each other without hassle
|
||||
|
||||
# make sure these are all defined in case someone wants to use/copy them
|
||||
env.Append(CCFLAGS = [])
|
||||
env.Append(CXXFLAGS = [])
|
||||
env.Append(CPPPATH = [])
|
||||
env.Append(CPPDEFINES = [])
|
||||
env.Append(LINKFLAGS = [])
|
||||
|
||||
# create the cache dir
|
||||
os.makedirs(env['CACHE_DIR'], exist_ok=True)
|
||||
cache_gitignore = f'{env["CACHE_DIR"]}/.gitignore'
|
||||
|
33
recipes/CMakeProject/recipe.py
Normal file
33
recipes/CMakeProject/recipe.py
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
from SCons.Script import *
|
||||
|
||||
_BUILT_STAMPFILE = '.spp_built'
|
||||
|
||||
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}')
|
||||
install_dir = os.path.join(project_root, f'install_{config}')
|
||||
is_built = os.path.exists(os.path.join(project_root, _BUILT_STAMPFILE))
|
||||
if not is_built or env['UPDATE_REPOSITORIES']:
|
||||
print(f'Building {project_root}, config {config}')
|
||||
os.makedirs(build_dir, exist_ok=True)
|
||||
build_type = {
|
||||
'debug': 'Debug',
|
||||
'release_debug': 'RelWithDebInfo',
|
||||
'release': 'Release',
|
||||
'profile': 'RelWithDebInfo'
|
||||
}.get(env['BUILD_TYPE'], 'RelWithDebInfo')
|
||||
subprocess.run(('cmake', '-G', 'Ninja', '-B', build_dir, f'-DCMAKE_BUILD_TYPE={build_type}', f'-DCMAKE_INSTALL_PREFIX={install_dir}', *generate_args, project_root), 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)
|
||||
pathlib.Path(project_root, _BUILT_STAMPFILE).touch()
|
||||
|
||||
return {
|
||||
'LIBPATH': [os.path.join(install_dir, 'lib')],
|
||||
'CPPPATH': [os.path.join(install_dir, 'include')]
|
||||
}
|
||||
|
21
recipes/Catch2/recipe.py
Normal file
21
recipes/Catch2/recipe.py
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
from SCons.Script import *
|
||||
|
||||
def cook(env: Environment, git_ref: str = 'master', own_main: bool = False) -> dict:
|
||||
repo = env.Cook('GitBranch', repo_name = 'catch2', remote_url = 'https://github.com/catchorg/Catch2.git', git_ref = git_ref)
|
||||
checkout_root = repo['checkout_root']
|
||||
build_result = env.Cook('CMakeProject', project_root=checkout_root)
|
||||
|
||||
lib_name = {
|
||||
'debug': 'Catch2d'
|
||||
}.get(env['BUILD_TYPE'], 'Catch2')
|
||||
libs = [lib_name]
|
||||
if not own_main:
|
||||
libs.append({
|
||||
'debug': 'Catch2Maind'
|
||||
}.get(env['BUILD_TYPE'], 'Catch2Main'))
|
||||
return {
|
||||
'LIBPATH': build_result['LIBPATH'],
|
||||
'CPPPATH': build_result['CPPPATH'],
|
||||
'LIBS': libs
|
||||
}
|
@ -7,34 +7,13 @@ 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']
|
||||
|
||||
config = env['BUILD_TYPE']
|
||||
build_dir = os.path.join(checkout_root, f'build_{config}')
|
||||
install_dir = os.path.join(checkout_root, f'install_{config}')
|
||||
lib_fname = {
|
||||
'debug': 'libSDL2d.a'
|
||||
}.get(env['BUILD_TYPE'], 'libSDL2.a') # TODO: who cares about windows?
|
||||
is_built = os.path.exists(os.path.join(build_dir, lib_fname)) # TODO!
|
||||
if not is_built:
|
||||
print(f'Building SDL, config {config}')
|
||||
os.makedirs(build_dir, exist_ok=True)
|
||||
build_type = {
|
||||
'debug': 'Debug',
|
||||
'release_debug': 'RelWithDebInfo',
|
||||
'release': 'Release',
|
||||
'profile': 'RelWithDebInfo'
|
||||
}.get(env['BUILD_TYPE'], 'RelWithDebInfo')
|
||||
subprocess.run(('cmake', '-G', 'Ninja', '-B', build_dir, f'-DCMAKE_BUILD_TYPE={build_type}', '-DSDL_STATIC=ON', '-DSDL_SHARED=OFF', f'-DCMAKE_INSTALL_PREFIX={install_dir}', checkout_root), stdout=sys.stdout, stderr=sys.stderr, check=True)
|
||||
subprocess.run(('cmake', '--build', build_dir), stdout=sys.stdout, stderr=sys.stderr, check=True)
|
||||
subprocess.run(('cmake', '--install', build_dir), stdout=sys.stdout, stderr=sys.stderr, check=True)
|
||||
|
||||
|
||||
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')
|
||||
return {
|
||||
'LIBPATH': [os.path.join(install_dir, 'lib')],
|
||||
'CPPPATH': [os.path.join(install_dir, 'include')],
|
||||
'LIBS': [lib_name, 'm']
|
||||
'LIBPATH': build_result['LIBPATH'],
|
||||
'CPPPATH': build_result['CPPPATH'],
|
||||
'LIBS': [lib_name]
|
||||
}
|
||||
|
||||
|
@ -1,35 +0,0 @@
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from SCons.Script import *
|
||||
|
||||
def cook(env: Environment, git_ref: str = "master") -> dict:
|
||||
repo = env.Cook('GitBranch', repo_name = 'criterion', remote_url = 'https://github.com/Snaipe/Criterion.git', git_ref = git_ref)
|
||||
checkout_root = repo['checkout_root']
|
||||
|
||||
config = env['BUILD_TYPE']
|
||||
build_dir = os.path.join(checkout_root, f'build_{config}')
|
||||
install_dir = os.path.join(checkout_root, f'install_{config}')
|
||||
lib_fname = 'libcriterion.a' # TODO: who cares about windows?
|
||||
is_built = os.path.exists(os.path.join(install_dir, 'lib', lib_fname)) # TODO!
|
||||
if not is_built:
|
||||
print(f'Building Criterion, config {config}')
|
||||
os.makedirs(build_dir, exist_ok=True)
|
||||
build_type = {
|
||||
'debug': 'debug',
|
||||
'release_debug': 'debugoptimized',
|
||||
'release': 'release',
|
||||
'profile': 'debugoptimized'
|
||||
}.get(env['BUILD_TYPE'], 'debugoptimized')
|
||||
subprocess.run(['meson', 'setup', '--prefix', install_dir, '--buildtype', build_type, build_dir, checkout_root], stdout=sys.stdout, stderr=sys.stderr, check=True)
|
||||
subprocess.run(['meson', 'install', '-C', build_dir], stdout=sys.stdout, stderr=sys.stderr, check=True)
|
||||
|
||||
|
||||
lib_name = 'criterion'
|
||||
return {
|
||||
'LIBPATH': [os.path.join(install_dir, 'lib')],
|
||||
'CPPPATH': [os.path.join(install_dir, 'include')],
|
||||
'LIBS': [lib_name]
|
||||
}
|
||||
|
@ -1,40 +1,16 @@
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from SCons.Script import *
|
||||
|
||||
def cook(env: Environment, git_ref: str = "master") -> dict:
|
||||
def cook(env: Environment, git_ref: str = 'master') -> dict:
|
||||
repo = env.Cook('GitBranch', repo_name = 'fmt', remote_url = 'https://github.com/fmtlib/fmt.git', git_ref = git_ref)
|
||||
checkout_root = repo['checkout_root']
|
||||
|
||||
config = env['BUILD_TYPE']
|
||||
build_dir = os.path.join(checkout_root, f'build_{config}')
|
||||
install_dir = os.path.join(checkout_root, f'install_{config}')
|
||||
lib_fname = {
|
||||
'debug': 'libfmtd.a'
|
||||
}.get(env['BUILD_TYPE'], 'libfmt.a') # TODO: who cares about windows?
|
||||
is_built = os.path.exists(os.path.join(build_dir, lib_fname)) # TODO!
|
||||
if not is_built:
|
||||
print(f'Building LibFMT, config {config}')
|
||||
os.makedirs(build_dir, exist_ok=True)
|
||||
build_type = {
|
||||
'debug': 'Debug',
|
||||
'release_debug': 'RelWithDebInfo',
|
||||
'release': 'Release',
|
||||
'profile': 'RelWithDebInfo'
|
||||
}.get(env['BUILD_TYPE'], 'RelWithDebInfo')
|
||||
subprocess.run(('cmake', '-G', 'Ninja', '-B', build_dir, f'-DCMAKE_BUILD_TYPE={build_type}', '-DFMT_TEST=OFF', f'-DCMAKE_INSTALL_PREFIX={install_dir}', checkout_root), stdout=sys.stdout, stderr=sys.stderr, check=True)
|
||||
subprocess.run(('cmake', '--build', build_dir), stdout=sys.stdout, stderr=sys.stderr, check=True)
|
||||
subprocess.run(('cmake', '--install', build_dir), stdout=sys.stdout, stderr=sys.stderr, check=True)
|
||||
|
||||
build_result = env.Cook('CMakeProject', project_root=checkout_root, generate_args = ['-DFMT_TEST=OFF'])
|
||||
|
||||
lib_name = {
|
||||
'debug': 'fmtd'
|
||||
}.get(env['BUILD_TYPE'], 'fmt')
|
||||
return {
|
||||
'LIBPATH': [os.path.join(install_dir, 'lib')],
|
||||
'CPPPATH': [os.path.join(install_dir, 'include')],
|
||||
'LIBS': [lib_name, 'm']
|
||||
'LIBPATH': build_result['LIBPATH'],
|
||||
'CPPPATH': build_result['CPPPATH'],
|
||||
'LIBS': [lib_name]
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user