More recipes (libjpeg, libz, imagemagick).
This commit is contained in:
parent
abc72895e6
commit
bbfec6c98a
26
SConscript
26
SConscript
@ -65,6 +65,21 @@ def _make_interface(env: Environment, dependencies: list = []):
|
|||||||
'CPPDEFINES': kwargs.get('CPPDEFINES', [])
|
'CPPDEFINES': kwargs.get('CPPDEFINES', [])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _lib_filename(name: str, type: str = 'static') -> str:
|
||||||
|
# TODO: windows
|
||||||
|
ext = {
|
||||||
|
'static': 'a',
|
||||||
|
'shared': 'so'
|
||||||
|
}[type]
|
||||||
|
return f'lib{name}.{ext}'
|
||||||
|
|
||||||
|
def _find_lib(env: Environment, name: str, paths: 'list[str]', type : str = 'static'):
|
||||||
|
for path in paths:
|
||||||
|
lib_path = os.path.join(path, _lib_filename(name, type))
|
||||||
|
if os.path.exists(lib_path):
|
||||||
|
return lib_path
|
||||||
|
return None
|
||||||
|
|
||||||
def _error(env: Environment, message: str):
|
def _error(env: Environment, message: str):
|
||||||
print(message, file=sys.stderr)
|
print(message, file=sys.stderr)
|
||||||
env.Exit(1)
|
env.Exit(1)
|
||||||
@ -81,6 +96,12 @@ def _wrap_builder(builder, is_lib: bool = False):
|
|||||||
kwargs['LIBS'] = copy.copy(env['LIBS'])
|
kwargs['LIBS'] = copy.copy(env['LIBS'])
|
||||||
for dependency in dependencies:
|
for dependency in dependencies:
|
||||||
_inject_dependency(dependency, kwargs)
|
_inject_dependency(dependency, kwargs)
|
||||||
|
libs_copy = list(kwargs['LIBS'])
|
||||||
|
for lib in libs_copy:
|
||||||
|
if isinstance(lib, str) and os.path.isabs(lib):
|
||||||
|
kwargs['LIBS'].remove(lib)
|
||||||
|
kwargs['source'].append(lib)
|
||||||
|
|
||||||
result = builder(*args, **kwargs)
|
result = builder(*args, **kwargs)
|
||||||
if is_lib:
|
if is_lib:
|
||||||
# generate a new libconf
|
# generate a new libconf
|
||||||
@ -365,11 +386,11 @@ if env['COMPILER_FAMILY'] == 'gcc' or env['COMPILER_FAMILY'] == 'clang':
|
|||||||
|
|
||||||
elif build_type == 'release':
|
elif build_type == 'release':
|
||||||
env.Append(CCFLAGS = ['-Wno-unused-variable', '-Wno-unused-parameter', '-Wno-unused-but-set-variable', '-Wno-unused-local-typedef', '-Wno-unused-local-typedefs', '-O2'], CPPDEFINES = [f'{config["PREPROCESSOR_PREFIX"]}_RELEASE', 'NDEBUG'])
|
env.Append(CCFLAGS = ['-Wno-unused-variable', '-Wno-unused-parameter', '-Wno-unused-but-set-variable', '-Wno-unused-local-typedef', '-Wno-unused-local-typedefs', '-O2'], CPPDEFINES = [f'{config["PREPROCESSOR_PREFIX"]}_RELEASE', 'NDEBUG'])
|
||||||
|
|
||||||
if enable_asan:
|
if enable_asan:
|
||||||
env.Append(CCFLAGS = ['-fsanitize=address', '-fno-omit-frame-pointer'])
|
env.Append(CCFLAGS = ['-fsanitize=address', '-fno-omit-frame-pointer'])
|
||||||
env.Append(LINKFLAGS = ['-fsanitize=address'])
|
env.Append(LINKFLAGS = ['-fsanitize=address'])
|
||||||
|
|
||||||
elif env['COMPILER_FAMILY'] == 'cl':
|
elif env['COMPILER_FAMILY'] == 'cl':
|
||||||
# C4201: nonstandard extension used : nameless struct/union - I use it and want to continue using it
|
# C4201: nonstandard extension used : nameless struct/union - I use it and want to continue using it
|
||||||
# C4127: conditional expression is constant - some libs (CRC, format) don't compile with this enabled # TODO: fix?
|
# C4127: conditional expression is constant - some libs (CRC, format) don't compile with this enabled # TODO: fix?
|
||||||
@ -395,6 +416,7 @@ env.AddMethod(_cook, 'Cook')
|
|||||||
env.AddMethod(_parse_lib_conf, 'ParseLibConf')
|
env.AddMethod(_parse_lib_conf, 'ParseLibConf')
|
||||||
env.AddMethod(_rglob, 'RGlob')
|
env.AddMethod(_rglob, 'RGlob')
|
||||||
env.AddMethod(_make_interface, 'MakeInterface')
|
env.AddMethod(_make_interface, 'MakeInterface')
|
||||||
|
env.AddMethod(_find_lib, 'FindLib')
|
||||||
env.AddMethod(_error, 'Error')
|
env.AddMethod(_error, 'Error')
|
||||||
env.AddMethod(_wrap_builder(env.Library, is_lib = True), 'Library')
|
env.AddMethod(_wrap_builder(env.Library, is_lib = True), 'Library')
|
||||||
env.AddMethod(_wrap_builder(env.StaticLibrary, is_lib = True), 'StaticLibrary')
|
env.AddMethod(_wrap_builder(env.StaticLibrary, is_lib = True), 'StaticLibrary')
|
||||||
|
@ -33,9 +33,15 @@ def cook(env: Environment, project_root: str, generate_args: 'list[str]' = [], b
|
|||||||
run_cmd(['cmake', '--install', *install_args, cmd_quote(build_dir)])
|
run_cmd(['cmake', '--install', *install_args, cmd_quote(build_dir)])
|
||||||
pathlib.Path(install_dir, _BUILT_STAMPFILE).touch()
|
pathlib.Path(install_dir, _BUILT_STAMPFILE).touch()
|
||||||
|
|
||||||
|
libpath = []
|
||||||
|
for lib_folder in ('lib', 'lib64'):
|
||||||
|
full_path = os.path.join(install_dir, lib_folder)
|
||||||
|
if os.path.exists(full_path):
|
||||||
|
libpath.append(full_path)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'install_dir': install_dir,
|
'install_dir': install_dir,
|
||||||
'LIBPATH': [os.path.join(install_dir, 'lib')],
|
'LIBPATH': libpath,
|
||||||
'CPPPATH': [os.path.join(install_dir, 'include')]
|
'CPPPATH': [os.path.join(install_dir, 'include')]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
recipes/ImageMagick/recipe.py
Normal file
12
recipes/ImageMagick/recipe.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
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)
|
||||||
|
checkout_root = repo['checkout_root']
|
||||||
|
build_result = env.Cook('AutotoolsProject', checkout_root)
|
||||||
|
return {
|
||||||
|
'LIBPATH': build_result['LIBPATH'],
|
||||||
|
'CPPPATH': build_result['CPPPATH'],
|
||||||
|
'LIBS': ['backtrace']
|
||||||
|
}
|
11
recipes/libjpeg-turbo/recipe.py
Normal file
11
recipes/libjpeg-turbo/recipe.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
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)
|
||||||
|
checkout_root = repo['checkout_root']
|
||||||
|
build_result = env.Cook('CMakeProject', checkout_root)
|
||||||
|
return {
|
||||||
|
'CPPPATH': build_result['CPPPATH'],
|
||||||
|
'LIBS': [env.FindLib('jpeg', paths=build_result['LIBPATH'])],
|
||||||
|
}
|
@ -2,11 +2,12 @@
|
|||||||
from SCons.Script import *
|
from SCons.Script import *
|
||||||
|
|
||||||
def cook(env: Environment, git_ref = 'master') -> dict:
|
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.Cook('GitBranch', repo_name = 'libpng', remote_url = 'https://git.code.sf.net/p/libpng/code.git', git_ref = git_ref)
|
||||||
checkout_root = repo['checkout_root']
|
checkout_root = repo['checkout_root']
|
||||||
build_result = env.Cook('AutotoolsProject', checkout_root)
|
build_result = env.Cook('AutotoolsProject', checkout_root)
|
||||||
return {
|
return {
|
||||||
'LIBPATH': build_result['LIBPATH'],
|
|
||||||
'CPPPATH': build_result['CPPPATH'],
|
'CPPPATH': build_result['CPPPATH'],
|
||||||
'LIBS': ['png']
|
'LIBS': [env.FindLib('png16', paths=build_result['LIBPATH'])],
|
||||||
|
'DEPENDENCIES': [lib_z]
|
||||||
}
|
}
|
||||||
|
12
recipes/zlib/recipe.py
Normal file
12
recipes/zlib/recipe.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
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)
|
||||||
|
extracted_root = repo['checkout_root']
|
||||||
|
build_result = env.Cook('CMakeProject', project_root=extracted_root)
|
||||||
|
return {
|
||||||
|
'CPPPATH': [os.path.join(build_result['install_dir'], 'install')],
|
||||||
|
'LIBS': [env.FindLib('z', paths=build_result['LIBPATH'])]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user