More recipes (libjpeg, libz, imagemagick).
This commit is contained in:
parent
abc72895e6
commit
bbfec6c98a
22
SConscript
22
SConscript
@ -65,6 +65,21 @@ def _make_interface(env: Environment, dependencies: list = []):
|
||||
'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):
|
||||
print(message, file=sys.stderr)
|
||||
env.Exit(1)
|
||||
@ -81,6 +96,12 @@ def _wrap_builder(builder, is_lib: bool = False):
|
||||
kwargs['LIBS'] = copy.copy(env['LIBS'])
|
||||
for dependency in dependencies:
|
||||
_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)
|
||||
if is_lib:
|
||||
# generate a new libconf
|
||||
@ -395,6 +416,7 @@ env.AddMethod(_cook, 'Cook')
|
||||
env.AddMethod(_parse_lib_conf, 'ParseLibConf')
|
||||
env.AddMethod(_rglob, 'RGlob')
|
||||
env.AddMethod(_make_interface, 'MakeInterface')
|
||||
env.AddMethod(_find_lib, 'FindLib')
|
||||
env.AddMethod(_error, 'Error')
|
||||
env.AddMethod(_wrap_builder(env.Library, is_lib = True), 'Library')
|
||||
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)])
|
||||
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 {
|
||||
'install_dir': install_dir,
|
||||
'LIBPATH': [os.path.join(install_dir, 'lib')],
|
||||
'LIBPATH': libpath,
|
||||
'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 *
|
||||
|
||||
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)
|
||||
checkout_root = repo['checkout_root']
|
||||
build_result = env.Cook('AutotoolsProject', checkout_root)
|
||||
return {
|
||||
'LIBPATH': build_result['LIBPATH'],
|
||||
'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