Moved all the recipes that weren't actually recipes to addons.

This commit is contained in:
Patrick 2024-08-04 13:11:10 +02:00
parent bbfec6c98a
commit 7d070c7e68
29 changed files with 63 additions and 43 deletions

View File

@ -433,8 +433,8 @@ env.AddMethod(_wrap_builder(env.UnitySharedLibrary, is_lib = True), 'UnityShared
if hasattr(env, 'Gch'):
env.AddMethod(_wrap_builder(env.Gch), 'Gch')
if hasattr(env, 'Jinja'):
env = SConscript('addons/jinja.py', exports = 'env')
for addon_file in env.Glob('addons/*.py'):
env = SConscript(addon_file, exports = 'env')
if dump_env:
print('==== Begin Environment Dump =====')

View File

@ -7,7 +7,9 @@ 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:
Import('env')
def _autotools_project(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}')
@ -37,3 +39,5 @@ def cook(env: Environment, project_root: str, config_args: 'list[str]' = [], bui
'CPPPATH': [os.path.join(install_dir, 'include')]
}
env.AddMethod(_autotools_project, 'AutotoolsProject')
Return('env')

View File

@ -5,11 +5,13 @@ from SCons.Script import *
_BUILT_STAMPFILE = '.spp_built'
Import('env')
def cmd_quote(s: str) -> str:
escaped = s.replace('\\', '\\\\')
return f'"{escaped}"'
def cook(env: Environment, project_root: str, generate_args: 'list[str]' = [], build_args : 'list[str]' = [], install_args : 'list[str]' = []) -> dict:
def _cmake_project(env: Environment, project_root: str, generate_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}')
@ -45,3 +47,5 @@ def cook(env: Environment, project_root: str, generate_args: 'list[str]' = [], b
'CPPPATH': [os.path.join(install_dir, 'include')]
}
env.AddMethod(_cmake_project, 'CMakeProject')
Return('env')

View File

@ -7,6 +7,8 @@ import zipfile
import urllib.request
from SCons.Script import *
Import('env')
class ArchiveType(Enum):
TAR_GZ = 0
ZIP = 1
@ -54,7 +56,7 @@ def _extract_file(path: pathlib.Path, output_dir: str, archive_type: ArchiveType
else:
raise Exception('invalid archive type')
def cook(env: Environment, repo_name: str, url: str, skip_folders: int = 0) -> dict:
def _download_and_extract(env: Environment, repo_name: str, url: str, skip_folders: int = 0) -> dict:
archive_type = _detect_archive_type(url)
ext = _archive_type_ext(archive_type)
path = pathlib.Path(env['DOWNLOAD_DIR'], f'{hashlib.shake_128(url.encode("utf-8")).hexdigest(6)}.{ext}')
@ -70,3 +72,5 @@ def cook(env: Environment, repo_name: str, url: str, skip_folders: int = 0) -> d
'extracted_root': str(output_dir)
}
env.AddMethod(_download_and_extract, 'DownloadAndExtract')
Return('env')

View File

@ -5,7 +5,9 @@ import hashlib
import os
from SCons.Script import *
def cook(env: Environment, repo_name: str, remote_url: str, git_ref: str = "main") -> dict:
Import('env')
def _gitbranch(env: Environment, repo_name: str, remote_url: str, git_ref: str = "main") -> dict:
repo_dir = os.path.join(env['CLONE_DIR'], 'git', repo_name, '_bare')
try:
repo = Repo(repo_dir)
@ -32,3 +34,6 @@ def cook(env: Environment, repo_name: str, remote_url: str, git_ref: str = "main
'checkout_root': worktree_dir
}
env.AddMethod(_gitbranch, 'GitBranch')
Return('env')

View File

@ -3,6 +3,9 @@ import pathlib
Import('env')
if not hasattr(env, 'Jinja'):
Return('env')
def _jinja_load_config(env, config_name):
searched_paths = []
for scons_path in env['JINJA_CONFIG_SEARCHPATH']:

View File

@ -2,9 +2,9 @@
from SCons.Script import *
def cook(env: Environment, git_ref: str = 'master', own_main: bool = False) -> dict:
repo = env.Cook('GitBranch', repo_name = 'catch2', remote_url = 'https://github.com/catchorg/Catch2.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'catch2', remote_url = 'https://github.com/catchorg/Catch2.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
build_result = env.Cook('CMakeProject', project_root=checkout_root)
build_result = env.CMakeProject(project_root=checkout_root)
lib_name = {
'debug': 'Catch2d'

View File

@ -2,9 +2,9 @@
from SCons.Script import *
def cook(env: Environment, git_ref = 'main') -> dict:
repo = env.Cook('GitBranch', repo_name = 'ImageMagick', remote_url = 'https://github.com/ImageMagick/ImageMagick.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'ImageMagick', remote_url = 'https://github.com/ImageMagick/ImageMagick.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
build_result = env.Cook('AutotoolsProject', checkout_root)
build_result = env.AutotoolsProject(checkout_root)
return {
'LIBPATH': build_result['LIBPATH'],
'CPPPATH': build_result['CPPPATH'],

View File

@ -4,9 +4,9 @@ import platform
from SCons.Script import *
def cook(env: Environment, git_ref: str = "main") -> dict:
repo = env.Cook('GitBranch', repo_name = 'SDL', remote_url = 'https://github.com/libsdl-org/SDL.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'SDL', remote_url = 'https://github.com/libsdl-org/SDL.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
build_result = env.Cook('CMakeProject', project_root=checkout_root, generate_args = ['-DSDL_STATIC=ON', '-DSDL_SHARED=OFF'])
build_result = env.CMakeProject(project_root=checkout_root, generate_args = ['-DSDL_STATIC=ON', '-DSDL_SHARED=OFF'])
libs = []
if platform.system() == 'Windows':
if env['BUILD_TYPE'] == 'debug':

View File

@ -4,9 +4,9 @@ from SCons.Script import *
def cook(env: Environment, remote: str = 'github', git_ref: str = 'main') -> dict:
if remote == 'mewin':
repo = env.Cook('GitBranch', repo_name = 'VulkanHeaders_mewin', remote_url = 'https://git.mewin.de/mewin/vulkan-headers.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'VulkanHeaders_mewin', remote_url = 'https://git.mewin.de/mewin/vulkan-headers.git', git_ref = git_ref)
else:
repo = env.Cook('GitBranch', repo_name = 'VulkanHeaders', remote_url = 'https://github.com/KhronosGroup/Vulkan-Headers.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'VulkanHeaders', remote_url = 'https://github.com/KhronosGroup/Vulkan-Headers.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
return {
'CPPPATH': [os.path.join(checkout_root, 'include')]

View File

@ -3,7 +3,7 @@ import os
from SCons.Script import *
def cook(env: Environment, git_ref: str = "master") -> dict:
repo = env.Cook('GitBranch', repo_name = 'argparse', remote_url = 'https://github.com/p-ranav/argparse.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'argparse', remote_url = 'https://github.com/p-ranav/argparse.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
return {
'CPPPATH': [os.path.join(checkout_root, 'include')]

View File

@ -5,7 +5,7 @@ from SCons.Script import *
def cook(env: Environment, version: str = "1.85.0") -> dict:
# TODO: build binaries?
url = f'https://archives.boost.io/release/{version}/source/boost_{version.replace(".", "_")}.tar.gz'
repo = env.Cook('DownloadAndExtract', f'boost_{version}', url = url, skip_folders = 1)
repo = env.DownloadAndExtract(f'boost_{version}', url = url, skip_folders = 1)
checkout_root = repo['extracted_root']
return {
'CPPPATH': [checkout_root]

View File

@ -2,7 +2,7 @@
from SCons.Script import *
def cook(env: Environment, git_ref: str = "master") -> dict:
repo = env.Cook('GitBranch', repo_name = 'cgltf', remote_url = 'https://github.com/jkuhlmann/cgltf.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'cgltf', remote_url = 'https://github.com/jkuhlmann/cgltf.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
return {
'CPPPATH': [checkout_root]

View File

@ -2,9 +2,9 @@
from SCons.Script import *
def cook(env: Environment, git_ref: str = 'master') -> dict:
repo = env.Cook('GitBranch', repo_name = 'fmt', remote_url = 'https://github.com/fmtlib/fmt.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'fmt', remote_url = 'https://github.com/fmtlib/fmt.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
build_result = env.Cook('CMakeProject', project_root=checkout_root, generate_args = ['-DFMT_TEST=OFF'])
build_result = env.CMakeProject(project_root=checkout_root, generate_args = ['-DFMT_TEST=OFF'])
lib_name = {
'debug': 'fmtd'

View File

@ -3,9 +3,9 @@ from SCons.Script import *
def cook(env: Environment, remote: str = 'github', git_ref: str = "master") -> dict:
if remote == 'mewin':
repo = env.Cook('GitBranch', repo_name = 'glm_mewin', remote_url = 'https://git.mewin.de/mewin/glm.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'glm_mewin', remote_url = 'https://git.mewin.de/mewin/glm.git', git_ref = git_ref)
else:
repo = env.Cook('GitBranch', repo_name = 'glm', remote_url = 'https://github.com/g-truc/glm.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'glm', remote_url = 'https://github.com/g-truc/glm.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
return {

View File

@ -12,9 +12,9 @@ _SCRIPT_STAMPFILE = '.spp_script_run'
def cook(env: Environment, remote: str = 'github', git_ref: str = '') -> dict:
if remote == 'mewin':
repo = env.Cook('GitBranch', repo_name = 'glslang_mewin', remote_url = 'https://git.mewin.de/mewin/glslang.git', git_ref = git_ref or 'master')
repo = env.GitBranch(repo_name = 'glslang_mewin', remote_url = 'https://git.mewin.de/mewin/glslang.git', git_ref = git_ref or 'master')
else:
repo = env.Cook('GitBranch', repo_name = 'glslang', remote_url = 'https://github.com/KhronosGroup/glslang.git', git_ref = git_ref or 'main')
repo = env.GitBranch(repo_name = 'glslang', remote_url = 'https://github.com/KhronosGroup/glslang.git', git_ref = git_ref or 'main')
checkout_root = repo['checkout_root']
# TODO: windows?

View File

@ -3,7 +3,7 @@ from SCons.Script import *
import os
def cook(env: Environment, backends: list = [], git_ref: str = '') -> dict:
repo = env.Cook('GitBranch', repo_name = 'imgui', remote_url = 'https://github.com/ocornut/imgui.git', git_ref = git_ref or 'master')
repo = env.GitBranch(repo_name = 'imgui', remote_url = 'https://github.com/ocornut/imgui.git', git_ref = git_ref or 'master')
imgui_source_files = [
os.path.join(repo['checkout_root'], 'imgui.cpp'),

View File

@ -3,6 +3,6 @@ import os
from SCons.Script import *
def cook(env: Environment, git_ref: str = "master") -> dict:
repo = env.Cook('GitBranch', repo_name = 'iwa', remote_url = 'https://git.mewin.de/mewin/iwa.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'iwa', remote_url = 'https://git.mewin.de/mewin/iwa.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
return SConscript(os.path.join(checkout_root, 'LibConf'), exports = ['env'])

View File

@ -4,9 +4,9 @@ from SCons.Script import *
def cook(env: Environment, git_ref = 'master') -> dict:
if env['COMPILER_FAMILY'] not in ('gcc', 'clang'):
env.Error('libbacktrace requires gcc or clang.')
repo = env.Cook('GitBranch', repo_name = 'libbacktrace', remote_url = 'https://github.com/ianlancetaylor/libbacktrace.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'libbacktrace', remote_url = 'https://github.com/ianlancetaylor/libbacktrace.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
build_result = env.Cook('AutotoolsProject', checkout_root)
build_result = env.AutotoolsProject(checkout_root)
return {
'LIBPATH': build_result['LIBPATH'],
'CPPPATH': build_result['CPPPATH'],

View File

@ -2,9 +2,9 @@
from SCons.Script import *
def cook(env: Environment, git_ref = 'main') -> dict:
repo = env.Cook('GitBranch', repo_name = 'libjpeg-turbo', remote_url = 'https://github.com/libjpeg-turbo/libjpeg-turbo.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'libjpeg-turbo', remote_url = 'https://github.com/libjpeg-turbo/libjpeg-turbo.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
build_result = env.Cook('CMakeProject', checkout_root)
build_result = env.CMakeProject(checkout_root)
return {
'CPPPATH': build_result['CPPPATH'],
'LIBS': [env.FindLib('jpeg', paths=build_result['LIBPATH'])],

View File

@ -3,9 +3,9 @@ from SCons.Script import *
def cook(env: Environment, git_ref = 'master') -> dict:
lib_z = env.Cook('zlib')
repo = env.Cook('GitBranch', repo_name = 'libpng', remote_url = 'https://git.code.sf.net/p/libpng/code.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'libpng', remote_url = 'https://git.code.sf.net/p/libpng/code.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
build_result = env.Cook('AutotoolsProject', checkout_root)
build_result = env.AutotoolsProject(checkout_root)
return {
'CPPPATH': build_result['CPPPATH'],
'LIBS': [env.FindLib('png16', paths=build_result['LIBPATH'])],

View File

@ -3,7 +3,7 @@ import os
from SCons.Script import *
def cook(env: Environment, git_ref: str = "master") -> dict:
repo = env.Cook('GitBranch', repo_name = 'magic_enum', remote_url = 'https://github.com/Neargye/magic_enum.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'magic_enum', remote_url = 'https://github.com/Neargye/magic_enum.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
return {
'CPPPATH': [os.path.join(checkout_root, 'include')]

View File

@ -4,9 +4,9 @@ from SCons.Script import *
import os
def cook(env: Environment, git_ref = 'master') -> dict:
repo = env.Cook('GitBranch', repo_name = 'mecab', remote_url = 'https://github.com/taku910/mecab.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'mecab', remote_url = 'https://github.com/taku910/mecab.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
build_result = env.Cook('AutotoolsProject', os.path.join(checkout_root, 'mecab'))
build_result = env.AutotoolsProject(os.path.join(checkout_root, 'mecab'))
return {
'LIBPATH': build_result['LIBPATH'],
'CPPPATH': build_result['CPPPATH'],

View File

@ -3,6 +3,6 @@ import os
from SCons.Script import *
def cook(env: Environment, git_ref: str = "master") -> dict:
repo = env.Cook('GitBranch', repo_name = 'mijin', remote_url = 'https://git.mewin.de/mewin/mijin2.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'mijin', remote_url = 'https://git.mewin.de/mewin/mijin2.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
return SConscript(os.path.join(checkout_root, 'LibConf'), exports = ['env'])

View File

@ -3,7 +3,7 @@ import os
from SCons.Script import *
def cook(env: Environment, git_ref: str = 'master') -> dict:
repo = env.Cook('GitBranch', repo_name = 'mikktspace', remote_url = 'https://github.com/mmikk/MikkTSpace.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'mikktspace', remote_url = 'https://github.com/mmikk/MikkTSpace.git', git_ref = git_ref)
lib_mikktspace = env.StaticLibrary(
CPPPATH = [repo['checkout_root']],
target = env['LIB_DIR'] + '/mikktspace',

View File

@ -2,9 +2,9 @@
from SCons.Script import *
def cook(env: Environment, git_ref: str = 'v1.x', use_external_libfmt = False) -> dict:
repo = env.Cook('GitBranch', repo_name = 'spdlog', remote_url = 'https://github.com/gabime/spdlog.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'spdlog', remote_url = 'https://github.com/gabime/spdlog.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
build_result = env.Cook('CMakeProject', project_root=checkout_root)
build_result = env.CMakeProject(project_root=checkout_root)
lib_name = {
'debug': 'spdlogd'

View File

@ -2,7 +2,7 @@
from SCons.Script import *
def cook(env: Environment, git_ref: str = "master") -> dict:
repo = env.Cook('GitBranch', repo_name = 'stb', remote_url = 'https://github.com/nothings/stb.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'stb', remote_url = 'https://github.com/nothings/stb.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
return {
'CPPPATH': [checkout_root]

View File

@ -1,9 +1,9 @@
from SCons.Script import *
def cook(env: Environment, git_ref: str = "master") -> dict:
repo = env.Cook('GitBranch', repo_name = 'yaml-cpp', remote_url = 'https://github.com/jbeder/yaml-cpp', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'yaml-cpp', remote_url = 'https://github.com/jbeder/yaml-cpp', git_ref = git_ref)
checkout_root = repo['checkout_root']
build_result = env.Cook('CMakeProject', project_root=checkout_root)
build_result = env.CMakeProject(project_root=checkout_root)
lib_name = {
'debug': 'yaml-cppd'
}.get(env['BUILD_TYPE'], 'yaml-cpp')

View File

@ -3,9 +3,9 @@ import os
from SCons.Script import *
def cook(env: Environment, git_ref: str = 'master') -> dict:
repo = env.Cook('GitBranch', repo_name = 'zlib', remote_url = 'https://github.com/madler/zlib.git', git_ref = git_ref)
repo = env.GitBranch(repo_name = 'zlib', remote_url = 'https://github.com/madler/zlib.git', git_ref = git_ref)
extracted_root = repo['checkout_root']
build_result = env.Cook('CMakeProject', project_root=extracted_root)
build_result = env.CMakeProject(project_root=extracted_root)
return {
'CPPPATH': [os.path.join(build_result['install_dir'], 'install')],
'LIBS': [env.FindLib('z', paths=build_result['LIBPATH'])]