Added libbacktrace and recursive dependencies.

This commit is contained in:
Patrick 2023-11-11 12:42:21 +01:00
parent 0abc33d6f8
commit 3cac31bd81
3 changed files with 58 additions and 2 deletions

View File

@ -4,9 +4,11 @@ import os
def _cook(env: Environment, recipe_name: str, *args, **kwargs): def _cook(env: Environment, recipe_name: str, *args, **kwargs):
import importlib.util import importlib.util
source_file = None
for folder in env['RECIPES_FOLDERS']: for folder in env['RECIPES_FOLDERS']:
source_file = f'{folder.abspath}/{recipe_name}/recipe.py' try_source_file = f'{folder.abspath}/{recipe_name}/recipe.py'
if os.path.exists(source_file): if os.path.exists(try_source_file):
source_file = try_source_file
break break
if not source_file: if not source_file:
raise Exception(f'Could not find recipe {recipe_name}.') raise Exception(f'Could not find recipe {recipe_name}.')
@ -34,6 +36,9 @@ def _inject_dependency(dependency, kwargs: dict) -> None:
_inject_list(kwargs, dependency, 'CPPDEFINES') _inject_list(kwargs, dependency, 'CPPDEFINES')
_inject_list(kwargs, dependency, 'LIBPATH') _inject_list(kwargs, dependency, 'LIBPATH')
_inject_list(kwargs, dependency, 'LIBS') _inject_list(kwargs, dependency, 'LIBS')
if 'DEPENDENCIES' in dependency:
for inner_dependency in dependency['DEPENDENCIES']:
_inject_dependency(inner_dependency, kwargs)
def _rglob(env: Environment, root_path: str, pattern: str, **kwargs): def _rglob(env: Environment, root_path: str, pattern: str, **kwargs):
result_nodes = [] result_nodes = []

View File

@ -0,0 +1,39 @@
import os
import pathlib
import subprocess
import sys
from SCons.Script import *
_BUILT_STAMPFILE = '.spp_built'
def cook(env: Environment, project_root: str, config_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(install_dir, _BUILT_STAMPFILE))
if not is_built or env['UPDATE_REPOSITORIES']:
print(f'Building {project_root}, config {config}')
os.makedirs(build_dir, exist_ok=True)
opt_level = {
'debug': '-O0',
}.get(env['BUILD_TYPE'], '-O2')
debug_symbols = {
'release': ''
}.get(env['BUILD_TYPE'], '-g')
cflags = f'{opt_level} {debug_symbols}'
jobs = env.GetOption('num_jobs')
env = os.environ.copy()
env['CFLAGS'] = cflags
subprocess.run((os.path.join(project_root, 'configure'), '--prefix', install_dir, *config_args), cwd=build_dir, env=env, stdout=sys.stdout, stderr=sys.stderr, check=True)
subprocess.run(('make', f'-j{jobs}', *build_args), cwd=build_dir, stdout=sys.stdout, stderr=sys.stderr, check=True)
subprocess.run(('make', 'install', *install_args), cwd=build_dir, stdout=sys.stdout, stderr=sys.stderr, check=True)
pathlib.Path(install_dir, _BUILT_STAMPFILE).touch()
return {
'install_dir': install_dir,
'LIBPATH': [os.path.join(install_dir, 'lib')],
'CPPPATH': [os.path.join(install_dir, 'include')]
}

View File

@ -0,0 +1,12 @@
from SCons.Script import *
def cook(env: Environment) -> dict:
repo = env.Cook('GitBranch', repo_name = 'libbacktrace', remote_url = 'https://github.com/ianlancetaylor/libbacktrace.git', git_ref = 'master')
checkout_root = repo['checkout_root']
build_result = env.Cook('AutotoolsProject', checkout_root)
return {
'LIBPATH': build_result['LIBPATH'],
'CPPPATH': build_result['CPPPATH'],
'LIBS': ['backtrace']
}