65 lines
2.1 KiB
Python
65 lines
2.1 KiB
Python
|
|
import os
|
|
import pathlib
|
|
import re
|
|
import shutil
|
|
from SCons.Script import *
|
|
|
|
|
|
_BUILT_STAMPFILE = '.spp_built'
|
|
|
|
def _git_cook(env: Environment, repo: dict) -> dict:
|
|
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(),
|
|
repo_name = 'sqlite',
|
|
repo_url = 'https://github.com/sqlite/sqlite.git',
|
|
tag_pattern = re.compile(r'^version-([0-9]+)\.([0-9]+)\.([0-9]+)$'),
|
|
tag_fn = lambda version: f'version-{version[0]}.{version[1]}.{version[2]}',
|
|
cook_fn = _git_cook
|
|
)
|
|
|