diff --git a/addons/autotools_project.py b/addons/autotools_project.py index 11e12ba..287042d 100644 --- a/addons/autotools_project.py +++ b/addons/autotools_project.py @@ -9,7 +9,7 @@ _BUILT_STAMPFILE = '.spp_built' Import('env') -def _autotools_project(env: Environment, project_root: str, config_args: 'list[str]' = [], build_args : 'list[str]' = [], install_args : 'list[str]' = [], configure_script_path: str = 'configure') -> dict: +def _autotools_project(env: Environment, project_root: str, config_args: 'list[str]' = [], build_args : 'list[str]' = [], install_args : 'list[str]' = [], configure_script_path: str = 'configure', skip_steps = ()) -> 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}') @@ -32,9 +32,15 @@ def _autotools_project(env: Environment, project_root: str, config_args: 'list[s if not os.path.exists(config_script) and os.path.exists(f'{config_script}.ac'): subprocess.run(('autoreconf', '--install', '--force'), cwd=project_root) - subprocess.run((config_script, f'--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) + if 'configure' not in skip_steps: + subprocess.run((config_script, f'--prefix={install_dir}', *config_args), cwd=build_dir, env=env, stdout=sys.stdout, stderr=sys.stderr, check=True) + if 'build' not in skip_steps: + subprocess.run(('make', f'-j{jobs}', *build_args), cwd=build_dir, stdout=sys.stdout, stderr=sys.stderr, check=True) + if 'install' not in skip_steps: + subprocess.run(('make', 'install', *install_args), cwd=build_dir, stdout=sys.stdout, stderr=sys.stderr, check=True) + else: + # must still create the install dir for the stamp file + os.makedirs(install_dir, exist_ok=True) pathlib.Path(install_dir, _BUILT_STAMPFILE).touch() libpath = [] @@ -44,6 +50,7 @@ def _autotools_project(env: Environment, project_root: str, config_args: 'list[s libpath.append(full_path) return { + 'build_dir': build_dir, 'install_dir': install_dir, 'LIBPATH': libpath, 'CPPPATH': [os.path.join(install_dir, 'include')] diff --git a/recipes/sqlite/recipe.py b/recipes/sqlite/recipe.py index b06b6f2..51e14d5 100644 --- a/recipes/sqlite/recipe.py +++ b/recipes/sqlite/recipe.py @@ -1,4 +1,5 @@ +import glob import os import pathlib import re @@ -46,11 +47,29 @@ def _git_cook(env: Environment, repo: dict) -> dict: } else: checkout_root = repo['checkout_root'] - build_result = env.AutotoolsProject(checkout_root) + build_result = env.AutotoolsProject(checkout_root, skip_steps=('install',)) + + # the install script seems borked, do the install manually + include_dir = os.path.join(build_result['install_dir'], 'include') + lib_dir = os.path.join(build_result['install_dir'], 'lib') + os.makedirs(include_dir, exist_ok=True) + os.makedirs(lib_dir, exist_ok=True) + + for ext in ('*.a', '*.so'): + lib_files = glob.glob(os.path.join(build_result['build_dir'], ext)) + for lib_file in lib_files: + out_path = os.path.join(lib_dir, os.path.basename(lib_file)) + if not os.path.exists(out_path): + shutil.copy(lib_file, out_path) + for h_file in ('sqlite3.h',): + out_path = os.path.join(include_dir, h_file) + if not os.path.exists(out_path): + in_path = os.path.join(build_result['build_dir'], h_file) + shutil.copy(in_path, out_path) + return { - 'LIBPATH': build_result['LIBPATH'], 'CPPPATH': build_result['CPPPATH'], - 'LIBS': ['sqlite3'] + 'LIBS': [env.FindLib('sqlite3', paths=build_result['LIBPATH'])] } env.GitRecipe(