50 lines
1.7 KiB
Python
50 lines
1.7 KiB
Python
import os
|
|
|
|
from .base import (
|
|
Dependency,
|
|
ReleaseDownload,
|
|
MakeBuilder,
|
|
)
|
|
|
|
from kiwixbuild.utils import Remotefile, pj, Defaultdict, SkipCommand, run_command
|
|
from kiwixbuild._global import get_target_step
|
|
|
|
class LibMagic(Dependency):
|
|
name = "libmagic"
|
|
|
|
class Source(ReleaseDownload):
|
|
name = "libmagic"
|
|
source_dir = "libmagic"
|
|
archive_top_dir = 'file-5.44'
|
|
archive = Remotefile('file-5.44.tar.gz',
|
|
'3751c7fba8dbc831cb8d7cc8aff21035459b8ce5155ef8b0880a27d028475f3b')
|
|
|
|
class Builder(MakeBuilder):
|
|
@property
|
|
def configure_option(self):
|
|
return ("--disable-bzlib "
|
|
"--disable-xzlib "
|
|
"--disable-zstdlib "
|
|
"--disable-lzlib "
|
|
)
|
|
|
|
@classmethod
|
|
def get_dependencies(cls, platformInfo, allDeps):
|
|
if platformInfo.build != 'native':
|
|
return [('native_static', 'libmagic')]
|
|
return []
|
|
|
|
def _compile(self, context):
|
|
platformInfo = self.buildEnv.platformInfo
|
|
if platformInfo.build == 'native':
|
|
return super()._compile(context)
|
|
context.try_skip(self.build_path)
|
|
command = "make -j4 {make_target} {make_option}".format(
|
|
make_target=self.make_target,
|
|
make_option=self.make_option
|
|
)
|
|
env = self.buildEnv.get_env(cross_comp_flags=True, cross_compilers=True, cross_path=True)
|
|
libmagic_native_builder = get_target_step('libmagic', 'native_static')
|
|
env['PATH'] = ':'.join([pj(libmagic_native_builder.build_path, 'src'), env['PATH']])
|
|
run_command(command, self.build_path, context, env=env)
|