36 lines
1.4 KiB
Python
36 lines
1.4 KiB
Python
|
|
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]
|
|
}
|
|
|