Added experimental recipe for libmagic.
This commit is contained in:
parent
54b4bb8232
commit
d2bc446cb9
79
recipes/libmagic/recipe.py
Normal file
79
recipes/libmagic/recipe.py
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
from SCons.Script import *
|
||||||
|
|
||||||
|
_DEPENDENCIES = {
|
||||||
|
'zlib': {}
|
||||||
|
}
|
||||||
|
|
||||||
|
def _git_cook(env: Environment, repo: dict) -> dict:
|
||||||
|
checkout_root = repo['checkout_root']
|
||||||
|
|
||||||
|
magic_source_files = [
|
||||||
|
os.path.join(checkout_root, 'src/buffer.c'),
|
||||||
|
os.path.join(checkout_root, 'src/magic.c'),
|
||||||
|
os.path.join(checkout_root, 'src/apprentice.c'),
|
||||||
|
os.path.join(checkout_root, 'src/softmagic.c'),
|
||||||
|
os.path.join(checkout_root, 'src/ascmagic.c'),
|
||||||
|
os.path.join(checkout_root, 'src/encoding.c'),
|
||||||
|
os.path.join(checkout_root, 'src/compress.c'),
|
||||||
|
os.path.join(checkout_root, 'src/is_csv.c'),
|
||||||
|
os.path.join(checkout_root, 'src/is_json.c'),
|
||||||
|
os.path.join(checkout_root, 'src/is_simh.c'),
|
||||||
|
os.path.join(checkout_root, 'src/is_tar.c'),
|
||||||
|
os.path.join(checkout_root, 'src/readelf.c'),
|
||||||
|
os.path.join(checkout_root, 'src/print.c'),
|
||||||
|
os.path.join(checkout_root, 'src/fsmagic.c'),
|
||||||
|
os.path.join(checkout_root, 'src/funcs.c'),
|
||||||
|
os.path.join(checkout_root, 'src/apptype.c'),
|
||||||
|
os.path.join(checkout_root, 'src/der.c'),
|
||||||
|
os.path.join(checkout_root, 'src/cdf.c'),
|
||||||
|
os.path.join(checkout_root, 'src/cdf_time.c'),
|
||||||
|
os.path.join(checkout_root, 'src/readcdf.c'),
|
||||||
|
os.path.join(checkout_root, 'src/fmtcheck.c')
|
||||||
|
]
|
||||||
|
|
||||||
|
version_dict = {'X.YY': '5.46'}
|
||||||
|
env.Substfile(os.path.join(checkout_root, 'src/magic.h.in'), SUBST_DICT=version_dict)
|
||||||
|
|
||||||
|
additional_ccflags = []
|
||||||
|
if env['COMPILER_FAMILY'] == 'gcc':
|
||||||
|
additional_ccflags.extend(['-Wno-unused-parameter', '-Wno-unused-const-variable'])
|
||||||
|
|
||||||
|
lib_magic = env.StaticLibrary(
|
||||||
|
CPPDEFINES = list(env['CPPDEFINES']) + ['HAVE_BYTESWAP_H', 'HAVE_BZLIB_H', 'HAVE_ERR_H',
|
||||||
|
'HAVE_FREELOCALE', 'HAVE_GETOPT_H', 'HAVE_INTTYPES_H', 'HAVE_LIBSECCOMP',
|
||||||
|
'HAVE_LRZIP_H', 'HAVE_LZLIB_H', 'HAVE_LZMA_H', 'HAVE_MBRTOWC',
|
||||||
|
'HAVE_MEMMEM', 'HAVE_MMAP', 'HAVE_NEWLOCALE',
|
||||||
|
'HAVE_POSIX_SPAWNP', 'HAVE_SPAWN_H', 'HAVE_STDINT_H', 'HAVE_STRNDUP',
|
||||||
|
'HAVE_STRTOF', 'HAVE_STRUCT_OPTION', 'HAVE_STRUCT_STAT_ST_RDEV',
|
||||||
|
'HAVE_STRUCT_TM_TM_GMTOFF', 'HAVE_STRUCT_TM_TM_ZONE',
|
||||||
|
'HAVE_SYS_IOCTL_H', 'HAVE_SYS_MMAN_H', 'HAVE_SYS_SYSMACROS_H',
|
||||||
|
'HAVE_SYS_TIME_H', 'HAVE_SYS_UTIME_H', 'HAVE_SYS_WAIT_H',
|
||||||
|
'HAVE_UNISTD_H', 'HAVE_USELOCALE', 'HAVE_UTIME', 'HAVE_UTIMES',
|
||||||
|
'HAVE_UTIME_H', 'HAVE_WCHAR_H', 'HAVE_WCTYPE_H', 'HAVE_WCWIDTH',
|
||||||
|
'HAVE_ZLIB_H', 'HAVE_ZSTD_H', 'VERSION=\\"5.46\\"'],
|
||||||
|
|
||||||
|
|
||||||
|
CCFLAGS = list(env['CCFLAGS']) + additional_ccflags,
|
||||||
|
target = env['LIB_DIR'] + '/magic',
|
||||||
|
source = magic_source_files,
|
||||||
|
dependencies = _DEPENDENCIES
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
'CPPPATH': [os.path.join(checkout_root, 'src')],
|
||||||
|
'LIBS': [lib_magic]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
env.GitRecipe(
|
||||||
|
globals = globals(),
|
||||||
|
repo_name = 'libmagic',
|
||||||
|
repo_url = 'https://github.com/file/file.git',
|
||||||
|
tag_pattern = re.compile(r'^FILE([0-9]+)_([0-9]+)$'),
|
||||||
|
tag_fn = lambda version: f'FILE{version[0]}_{version[1]}',
|
||||||
|
cook_fn = _git_cook,
|
||||||
|
dependencies = _DEPENDENCIES
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user