From 5159c801672d8d16fab410784a6d959fa03f69fe Mon Sep 17 00:00:00 2001 From: Patrick Wuttke Date: Tue, 11 Mar 2025 09:35:38 +0100 Subject: [PATCH] Added recipe for SQLite on Windows (still WIP). --- recipes/sqlite/recipe.py | 55 +++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/recipes/sqlite/recipe.py b/recipes/sqlite/recipe.py index 1358afb..b06b6f2 100644 --- a/recipes/sqlite/recipe.py +++ b/recipes/sqlite/recipe.py @@ -1,16 +1,57 @@ +import os +import pathlib import re +import shutil from SCons.Script import * +_BUILT_STAMPFILE = '.spp_built' + def _git_cook(env: Environment, repo: dict) -> dict: - checkout_root = repo['checkout_root'] - build_result = env.AutotoolsProject(checkout_root) - return { - 'LIBPATH': build_result['LIBPATH'], - 'CPPPATH': build_result['CPPPATH'], - 'LIBS': ['backtrace'] - } + if os.name == 'nt': + def run_cmd(args): + if env.Execute(' '.join([str(s) for s in args])): + Exit(1) + install_dir = os.path.join(repo['checkout_root'], 'install') + stamp_file = pathlib.Path(install_dir, _BUILT_STAMPFILE) + + include_path = os.path.join(install_dir, 'include') + bin_path = os.path.join(install_dir, 'bin') + lib_path = os.path.join(install_dir, 'lib') + if not stamp_file.exists(): + os.makedirs(include_path, exist_ok=True) + os.makedirs(bin_path, exist_ok=True) + os.makedirs(lib_path, exist_ok=True) + + old_cwd = os.getcwd() + os.chdir(repo['checkout_root']) + run_cmd(['nmake', '/f', 'Makefile.msc', 'sqlite3.dll']) + os.chdir(old_cwd) + + include_files = ['sqlite3.h'] + bin_files = ['sqlite3.dll'] + lib_files = ['sqlite3.def', 'sqlite3.lib'] + for file in include_files: + shutil.copy(os.path.join(repo['checkout_root'], file), include_path) + for file in bin_files: + shutil.copy(os.path.join(repo['checkout_root'], file), bin_path) + for file in lib_files: + shutil.copy(os.path.join(repo['checkout_root'], file), lib_path) + stamp_file.touch() + return { + 'CPPPATH': [include_path], + 'LIBPATH': [lib_path], + 'LIBS': ['sqlite3'] + } + else: + checkout_root = repo['checkout_root'] + build_result = env.AutotoolsProject(checkout_root) + return { + 'LIBPATH': build_result['LIBPATH'], + 'CPPPATH': build_result['CPPPATH'], + 'LIBS': ['sqlite3'] + } env.GitRecipe( globals = globals(),