More recipes (libjpeg, libz, imagemagick).
This commit is contained in:
26
SConscript
26
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
|
||||
@@ -365,11 +386,11 @@ if env['COMPILER_FAMILY'] == 'gcc' or env['COMPILER_FAMILY'] == 'clang':
|
||||
|
||||
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'])
|
||||
|
||||
|
||||
if enable_asan:
|
||||
env.Append(CCFLAGS = ['-fsanitize=address', '-fno-omit-frame-pointer'])
|
||||
env.Append(LINKFLAGS = ['-fsanitize=address'])
|
||||
|
||||
|
||||
elif env['COMPILER_FAMILY'] == 'cl':
|
||||
# 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?
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user