Run the command without using shell=True.

It mainly allow to run command in directory containing space.
(Hello, `C:\Program Files\...`)
It would also allow to work on directory containning spaces
(`C:\Users\John Doe`) but xapian configure (at least) expressly doesn't
support it :/

- Run the command without shell=True
- The command must be a list instead of a string.
- All options must also be a list (or an iterable).
This commit is contained in:
Matthieu Gautier 2018-06-19 11:27:07 +02:00
parent e87835c61d
commit c99a9bd91f
36 changed files with 326 additions and 298 deletions

View File

@ -30,7 +30,7 @@ class PlatformNeutralEnv:
self.qmake_command = self._detect_qmake()
if not self.qmake_command:
print("WARNING: qmake command not found.", file=sys.stderr)
self.mesontest_command = "{} test".format(self.meson_command)
self.mesontest_command = [*self.meson_command, "test"]
def detect_platform(self):
_platform = platform.system()
@ -59,7 +59,7 @@ class PlatformNeutralEnv:
# Doesn't exist in PATH or isn't executable
continue
if retcode == 0:
return n
return [n]
def _detect_ninja(self):
@ -165,17 +165,14 @@ class BuildEnv:
@property
def configure_wrapper(self):
wrapper = getattr(self.platformInfo, "configure_wrapper", "")
if wrapper:
return "{} ".format(wrapper)
else:
return ""
try:
yield self.platformInfo.configure_wrapper
except AttributeError:
pass
@property
def make_wrapper(self):
wrapper = getattr(self.platformInfo, "make_wrapper", "")
if wrapper:
return "{} ".format(wrapper)
else:
return ""
try:
yield self.platformInfo.make_wrapper
except AttributeError:
pass

View File

@ -16,9 +16,9 @@ class Aria2(Dependency):
def _post_prepare_script(self, context):
context.try_skip(self.extract_path)
command = "autoreconf -i"
command = ["autoreconf", "-i"]
run_command(command, self.extract_path, context)
class Builder(MakeBuilder):
dependencies = ['zlib']
configure_option = "--disable-libaria2 --disable-websocket --without-sqlite3"
configure_options = ["--disable-libaria2", "--disable-websocket", "--without-sqlite3"]

View File

@ -71,7 +71,7 @@ class Source:
context.try_skip(self.source_path)
for p in self.patches:
patch_file_path = pj(SCRIPT_DIR, 'patches', p)
patch_command = "patch -p1 -i {patch}".format(patch=patch_file_path)
patch_command = ["patch", "-p1", "-i", patch_file_path]
run_command(patch_command, self.source_path, context)
def command(self, name, function, *args):
@ -170,20 +170,19 @@ class GitClone(Source):
def _git_init(self, context):
if option('fast_clone') and self.force_full_clone == False:
command = "git clone --depth=1 --branch {} {} {}".format(
self.git_ref, self.git_remote, self.source_dir)
command = ["git", "clone" , "--depth=1", "--branch", self.git_ref, self.git_remote, self.source_dir]
run_command(command, neutralEnv('source_dir'), context)
else:
command = "git clone {} {}".format(self.git_remote, self.source_dir)
command = ["git", "clone", self.git_remote, self.source_dir]
run_command(command, neutralEnv('source_dir'), context)
command = "git checkout {}".format(self.git_ref)
command = ["git", "checkout", self.git_ref]
run_command(command, self.git_path, context)
def _git_update(self, context):
command = "git fetch origin {}".format(self.git_ref)
command = ["git", "fetch", "origin", self.git_ref]
run_command(command, self.git_path, context)
try:
command = "git merge --ff-only origin/{}".format(self.git_ref)
command = ["git", "merge", "--ff-only", f"origin/{self.git_ref}"]
run_command(command, self.git_path, context)
except subprocess.CalledProcessError:
raise WarningMessage("Cannot update, please check log for information")
@ -209,7 +208,10 @@ class SvnClone(Source):
def _svn_export(self, context):
if os.path.exists(self.svn_path):
raise SkipCommand()
command = "svn export {} {}".format(self.svn_remote, self.svn_dir)
command = [
"svn", "export",
self.svn_remote, self.svn_dir
]
run_command(command, neutralEnv('source_dir'), context)
def prepare(self):
@ -354,36 +356,37 @@ class TcCopyBuilder(Builder):
class MakeBuilder(Builder):
configure_option_template = "{dep_options} {static_option} {env_option} --prefix {install_dir} --libdir {libdir}"
configure_option = ""
dynamic_configure_option = "--enable-shared --disable-static"
static_configure_option = "--enable-static --disable-shared"
make_option = ""
install_option = ""
configure_options = []
dynamic_configure_options = ["--enable-shared", "--disable-static"]
static_configure_options = ["--enable-static", "--disable-shared"]
make_options = []
install_options = []
configure_script = "configure"
configure_env = {
'_format_CFLAGS' : '{env[CFLAGS]} -O3',
'_format_CXXFLAGS': '{env[CXXFLAGS]} -O3'
}
make_target = ""
make_targets = []
flatpak_buildsystem = None
@property
def make_install_target(self):
def make_install_targets(self):
if self.buildEnv.platformInfo.build in ('iOS', "wasm"):
return 'install'
return 'install-strip'
yield 'install'
else:
yield 'install-strip'
@property
def all_configure_option(self):
option = self.configure_option_template.format(
dep_options=self.configure_option,
static_option=self.static_configure_option if self.buildEnv.platformInfo.static else self.dynamic_configure_option,
env_option=self.buildEnv.platformInfo.configure_option if not self.target.force_native_build else "",
install_dir=self.buildEnv.install_dir,
libdir=pj(self.buildEnv.install_dir, self.buildEnv.libprefix)
)
return option
def all_configure_options(self):
yield from self.configure_options
if self.buildEnv.platformInfo.static:
yield from self.static_configure_options
else:
yield from self.dynamic_configure_options
if not self.target.force_native_build:
yield from self.buildEnv.platformInfo.configure_options
yield from ('--prefix', self.buildEnv.install_dir)
yield from ('--libdir', pj(self.buildEnv.install_dir, self.buildEnv.libprefix))
def set_configure_env(self, env):
dep_conf_env = self.configure_env
@ -399,41 +402,43 @@ class MakeBuilder(Builder):
def _configure(self, context):
context.try_skip(self.build_path)
command = "{configure_wrapper}{configure_script} {configure_option}"
command = command.format(
configure_wrapper=self.buildEnv.configure_wrapper,
configure_script=pj(self.source_path, self.configure_script),
configure_option=self.all_configure_option
)
command = [
*self.buildEnv.configure_wrapper,
pj(self.source_path, self.configure_script),
*self.all_configure_options
]
env = self.get_env(cross_comp_flags=True, cross_compilers=True, cross_path=True)
self.set_configure_env(env)
run_command(command, self.build_path, context, env=env)
def _compile(self, context):
context.try_skip(self.build_path)
command = "{make_wrapper}make -j4 {make_target} {make_option}".format(
make_wrapper=self.buildEnv.make_wrapper,
make_target=self.make_target,
make_option=self.make_option
)
command = [
*self.buildEnv.make_wrapper,
"make", "-j4",
*self.make_targets,
*self.make_options
]
env = self.get_env(cross_comp_flags=True, cross_compilers=True, cross_path=True)
run_command(command, self.build_path, context, env=env)
def _install(self, context):
context.try_skip(self.build_path)
command = "{make_wrapper}make {make_install_target} {make_option}".format(
make_wrapper=self.buildEnv.make_wrapper,
make_install_target=self.make_install_target,
make_option=self.make_option
)
command = [
*self.buildEnv.make_wrapper,
"make",
*self.make_install_targets,
*self.make_options
]
env = self.get_env(cross_comp_flags=True, cross_compilers=True, cross_path=True)
run_command(command, self.build_path, context, env=env)
def _make_dist(self, context):
context.try_skip(self.build_path)
command = "{make_wrapper}make dist".format(
make_wrapper=self.buildEnv.make_wrapper
)
command = [
*self.buildEnv.make_wrapper,
"make", "dist"
]
env = self.get_env(cross_comp_flags=True, cross_compilers=True, cross_path=True)
run_command(command, self.build_path, context, env=env)
@ -443,22 +448,18 @@ class CMakeBuilder(MakeBuilder):
def _configure(self, context):
context.try_skip(self.build_path)
cross_option = ""
cross_options = []
if not self.target.force_native_build and self.buildEnv.cmake_crossfile:
cross_option = "-DCMAKE_TOOLCHAIN_FILE={}".format(self.buildEnv.cmake_crossfile)
command = ("cmake {configure_option}"
" -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
" -DCMAKE_INSTALL_PREFIX={install_dir}"
" -DCMAKE_INSTALL_LIBDIR={libdir}"
" {source_path}"
" {cross_option}")
command = command.format(
configure_option=self.configure_option,
install_dir=self.buildEnv.install_dir,
libdir=self.buildEnv.libprefix,
source_path=self.source_path,
cross_option=cross_option
)
cross_options += [f"-DCMAKE_TOOLCHAIN_FILE={self.buildEnv.cmake_crossfile}"]
command = [
"cmake",
*self.configure_options,
"-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON",
f"-DCMAKE_INSTALL_PREFIX={self.buildEnv.install_dir}",
f"-DCMAKE_INSTALL_LIBDIR={self.buildEnv.libprefix}",
self.source_path,
*cross_options
]
env = self.get_env(cross_comp_flags=True, cross_compilers=False, cross_path=True)
self.set_configure_env(env)
run_command(command, self.build_path, context, env=env)
@ -469,49 +470,42 @@ class CMakeBuilder(MakeBuilder):
class QMakeBuilder(MakeBuilder):
qmake_target = ""
qmake_targets = []
flatpak_buildsystem = 'qmake'
@property
def env_option(self):
options = ""
def env_options(self):
if 'QMAKE_CC' in os.environ:
options += 'QMAKE_CC={} '.format(os.environ['QMAKE_CC'])
yield f"QMAKE_CC={os.environ['QMAKE_CC']}"
if 'QMAKE_CXX' in os.environ:
options += 'QMAKE_CXX={} '.format(os.environ['QMAKE_CXX'])
return options
yield f"QMAKE_CXX={os.environ['QMAKE_CXX']}"
def _configure(self, context):
context.try_skip(self.build_path)
cross_option = ""
command = ("{command} {configure_option}"
" {env_option}"
" {source_path}"
" {cross_option}")
command = command.format(
command = neutralEnv('qmake_command'),
configure_option=self.configure_option,
env_option=self.env_option,
source_path=self.source_path,
cross_option=cross_option
)
command = [
*neutralEnv('qmake_command'),
*self.configure_options,
*self.env_options,
self.source_path,
]
env = self.get_env(cross_comp_flags=True, cross_compilers=False, cross_path=True)
self.set_configure_env(env)
run_command(command, self.build_path, context, env=env)
def _make_dist(self, context):
command = "git archive -o {build_dir}/{name}.tar.gz --prefix={name}/ HEAD"
command = command.format(
build_dir = self.build_path,
name = self.target.full_name()
)
command = [
"git", "archive",
"-o", f"{self.build_path}/{self.target_full_name()}.tar.gz",
f"--prefix={self.target_full_name()}/",
"HEAD"
]
run_command(command, self.source_path, context)
class MesonBuilder(Builder):
configure_option = ""
test_option = ""
configure_options = []
test_options = []
flatpak_buildsystem = 'meson'
@property
@ -519,8 +513,9 @@ class MesonBuilder(Builder):
return 'release' if option('make_release') else 'debug'
@property
def strip_option(self):
return '--strip' if option('make_release') else ''
def strip_options(self):
if option('make_release'):
yield '--strip'
@property
def library_type(self):
@ -531,34 +526,26 @@ class MesonBuilder(Builder):
if os.path.exists(self.build_path):
shutil.rmtree(self.build_path)
os.makedirs(self.build_path)
configure_option = self.configure_option.format(buildEnv=self.buildEnv)
cross_option = ""
cross_options = []
if not self.target.force_native_build and self.buildEnv.meson_crossfile:
cross_option = "--cross-file {}".format(
self.buildEnv.meson_crossfile)
command = ("{command} . {build_path}"
" --buildtype={build_type} {strip_option}"
" --default-library={library_type}"
" {configure_option}"
" --prefix={buildEnv.install_dir}"
" --libdir={buildEnv.libprefix}"
" {cross_option}")
command = command.format(
command=neutralEnv('meson_command'),
build_type=self.build_type,
strip_option=self.strip_option,
library_type=self.library_type,
configure_option=configure_option,
build_path=self.build_path,
buildEnv=self.buildEnv,
cross_option=cross_option
)
cross_options += ["--cross-file", self.buildEnv.meson_crossfile]
command = [
*neutralEnv('meson_command'),
'.', self.build_path,
f'--buildtype={self.build_type}',
*self.strip_options,
f'--default-library={self.library_type}',
*self.configure_options,
f'--prefix={self.buildEnv.install_dir}',
f'--libdir={self.buildEnv.libprefix}',
*cross_options
]
env = self.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=True)
run_command(command, self.source_path, context, env=env)
def _compile(self, context):
context.try_skip(self.build_path)
command = "{} -v".format(neutralEnv('ninja_command'))
command = [*neutralEnv('ninja_command'), "-v"]
env = self.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=True)
run_command(command, self.build_path, context, env=env)
@ -569,17 +556,21 @@ class MesonBuilder(Builder):
and not self.buildEnv.platformInfo.static)
):
raise SkipCommand()
command = "{} --verbose {}".format(neutralEnv('mesontest_command'), self.test_option)
command = [
*neutralEnv('mesontest_command'),
'--verbose',
*self.test_options
]
env = self.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=True)
run_command(command, self.build_path, context, env=env)
def _install(self, context):
context.try_skip(self.build_path)
command = "{} -v install".format(neutralEnv('ninja_command'))
command = [*neutralEnv('ninja_command'), '-v', 'install']
env = self.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=True)
run_command(command, self.build_path, context, env=env)
def _make_dist(self, context):
command = "{} -v dist".format(neutralEnv('ninja_command'))
command = [*neutralEnv('ninja_command'), "-v", "dist"]
env = self.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=True)
run_command(command, self.build_path, context, env=env)

View File

@ -17,5 +17,5 @@ class docoptcpp(Dependency):
git_ref = "3dd23e3280f213bacefdf5fcb04857bf52e90917"
class Builder(CMakeBuilder):
make_install_target = 'install'
make_install_targets = ['install']

View File

@ -17,7 +17,7 @@ class Gumbo(Dependency):
def _post_prepare_script(self, context):
context.try_skip(self.extract_path)
command = "./autogen.sh"
command = ["./autogen.sh"]
run_command(command, self.extract_path, context)
Builder = MakeBuilder

View File

@ -53,7 +53,7 @@ class Icu(Dependency):
class Builder(MakeBuilder):
subsource_dir = "source"
make_install_target = "install"
make_install_targets = ["install"]
@classmethod
def get_dependencies(cls, platformInfo, allDeps):
@ -61,20 +61,23 @@ class Icu(Dependency):
return [(plt, 'icu4c')]
@property
def configure_option(self):
options = ("--disable-samples --disable-tests --disable-extras "
"--disable-dyload --enable-rpath "
"--disable-icuio --disable-layoutex")
def configure_options(self):
yield "--disable-samples"
yield "--disable-tests"
yield "--disable-extras"
yield "--disable-dyload"
yield "--enable-rpath"
yield "--disable-icuio"
yield "--disable-layoutex"
platformInfo = self.buildEnv.platformInfo
if platformInfo.build != 'native':
icu_native_builder = get_target_step(
'icu4c',
'native_static' if platformInfo.static else 'native_dyn')
options += " --with-cross-build={} --disable-tools".format(
icu_native_builder.build_path)
yield f"--with-cross-build={icu_native_builder.build_path}"
yield "--disable-tools"
if platformInfo.build in ('android', 'wasm'):
options += " --with-data-packaging=archive"
return options
yield "--with-data-packaging=archive"
def set_env(self, env):
env['ICU_DATA_FILTER_FILE'] = pj(os.path.dirname(os.path.realpath(__file__)), "icu4c_data_filter.json")

View File

@ -40,11 +40,12 @@ class IOSFatLib(Dependency):
if f.endswith('.a') or f.endswith('.dylib'):
libs.append(f)
os.makedirs(pj(self.buildEnv.install_dir, 'lib'), exist_ok=True)
command_tmp = "lipo -create {input} -output {output}"
for l in libs:
command = command_tmp.format(
input=" ".join(pj(d, l) for d in lib_dirs),
output=pj(self.buildEnv.install_dir, 'lib', l))
command = [
'lipo',
'-create', *[pj(d, l) for d in lib_dirs],
'-output', pj(self.buildEnv.install_dir, 'lib', l)
]
run_command(command, self.buildEnv.install_dir, context)
def build(self):

View File

@ -13,7 +13,7 @@ class KiwixDesktop(Dependency):
class Builder(QMakeBuilder):
dependencies = ["qt", "qtwebengine", "libkiwix", "aria2"]
make_install_target = 'install'
make_install_targets = ['install']
configure_env = None
flatpack_build_options = {
@ -23,15 +23,12 @@ class KiwixDesktop(Dependency):
}
@property
def configure_option(self):
def configure_options(self):
if self.buildEnv.platformInfo.name == 'flatpak':
options = [
'QMAKE_INCDIR+=/app/include/QtWebEngine',
'QMAKE_INCDIR+=/app/include/QtWebEngineCore',
'QMAKE_INCDIR+=/app/include/QtWebEngineWidgets'
]
yield 'QMAKE_INCDIR+=/app/include/QtWebEngine'
yield 'QMAKE_INCDIR+=/app/include/QtWebEngineCore'
yield 'QMAKE_INCDIR+=/app/include/QtWebEngineWidgets'
else:
options = ["PREFIX={}".format(self.buildEnv.install_dir)]
yield f"PREFIX={self.buildEnv.install_dir}"
if self.buildEnv.platformInfo.static:
options.append('"CONFIG+=static"')
return " ".join(options)
yield 'CONFIG+=static'

View File

@ -15,7 +15,6 @@ class KiwixTools(Dependency):
dependencies = ["libkiwix"]
@property
def configure_option(self):
def configure_options(self):
if self.buildEnv.platformInfo.static:
return "-Dstatic-linkage=true"
return ""
yield "-Dstatic-linkage=true"

View File

@ -20,11 +20,11 @@ class LibCurl(Dependency):
class Builder(MakeBuilder):
dependencies = ['zlib']
configure_option = " ".join(
["--without-{}".format(p)
for p in ('libssh2', 'ssl', 'libmetalink', 'librtmp',
'nghttp2', 'libidn2', 'brotli')] +
["--disable-{}".format(p)
for p in ('ftp', 'file', 'ldap', 'ldaps', 'rtsp', 'dict',
'telnet', 'tftp', 'pop3', 'imap', 'smb', 'smtp',
'gopher', 'manual')])
configure_options = [
*[f"--without-{p}" for p in
('libssh2', 'ssl', 'libmetalink', 'librtmp', 'nghttp2', 'libidn2', 'brotli')
],
*[f"--disable-{p}" for p in
('ftp', 'file', 'ldap', 'ldaps', 'rtsp', 'dict', 'telnet',
'tftp', 'pop3', 'imap', 'smb', 'smtp', 'gopher', 'manual')]
]

View File

@ -17,7 +17,7 @@ class Libkiwix(Dependency):
class Builder(MesonBuilder):
dependencies = ["pugixml", "libzim", "zlib", "lzma", "libcurl", "libmicrohttpd", "icu4c", "mustache", "xapian-core"]
strip_option = ''
strip_options = []
@property
def build_type(self):
@ -26,15 +26,17 @@ class Libkiwix(Dependency):
return super().build_type
@property
def configure_option(self):
def configure_options(self):
platformInfo = self.buildEnv.platformInfo
if platformInfo.build == 'android':
return '-Dstatic-linkage=true -Dwerror=false'
yield '-Dstatic-linkage=true'
yield '-Dwerror=false'
if platformInfo.build == 'iOS':
yield '-Db_bitcode=true'
if platformInfo.name == 'flatpak':
return '--wrap-mode=nodownload'
yield '--wrap-mode=nodownload'
if platformInfo.mixed and option('target') == 'libkiwix':
return "-Dstatic-linkage=true"
return ''
yield "-Dstatic-linkage=true"
@property
def library_type(self):

View File

@ -21,12 +21,11 @@ class LibMagic(Dependency):
class Builder(MakeBuilder):
@property
def configure_option(self):
return ("--disable-bzlib "
"--disable-xzlib "
"--disable-zstdlib "
"--disable-lzlib "
)
def configure_options(self):
yield "--disable-bzlib"
yield "--disable-xzlib"
yield "--disable-zstdlib"
yield "--disable-lzlib"
@classmethod
def get_dependencies(cls, platformInfo, allDeps):
@ -39,10 +38,12 @@ class LibMagic(Dependency):
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
)
command = [
"make",
"-j4",
*self.make_targets,
*self.make_options
]
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']])

View File

@ -14,4 +14,4 @@ class MicroHttpd(Dependency):
'https://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-0.9.76.tar.gz')
class Builder(MakeBuilder):
configure_option = "--disable-https --without-libgcrypt --without-libcurl --disable-doc --disable-examples"
configure_options = ["--disable-https", "--without-libgcrypt", "--without-libcurl", "--disable-doc", "--disable-examples"]

View File

@ -13,8 +13,8 @@ class Libzim(Dependency):
git_dir = "libzim"
class Builder(MesonBuilder):
test_option = "-t 8"
strip_option = ''
test_options = ["-t", "8"]
strip_options = []
@property
def build_type(self):
@ -30,24 +30,22 @@ class Libzim(Dependency):
return deps
@property
def configure_option(self):
def configure_options(self):
platformInfo = self.buildEnv.platformInfo
config_options = []
if platformInfo.build == 'android':
config_options.append("-DUSE_BUFFER_HEADER=false")
config_options.append("-Dstatic-linkage=true")
yield "-DUSE_BUFFER_HEADER=false"
yield "-Dstatic-linkage=true"
if platformInfo.mixed and option('target') == 'libzim':
config_options.append("-Dstatic-linkage=true")
yield "-Dstatic-linkage=true"
if platformInfo.name == "flatpak":
config_options.append("--wrap-mode=nodownload")
config_options.append("-Dtest_data_dir=none")
yield "--wrap-mode=nodownload"
yield "-Dtest_data_dir=none"
if platformInfo.name == "wasm":
config_options.append("-Dexamples=false")
config_options.append("-DUSE_MMAP=false")
yield "-Dexamples=false"
yield "-DUSE_MMAP=false"
if platformInfo.name not in ("flatpak", "wasm"):
zim_testing_suite = get_target_step('zim-testing-suite', 'source')
config_options.append('-Dtest_data_dir={}'.format(zim_testing_suite.source_path))
return " ".join(config_options)
yield '-Dtest_data_dir={}'.format(zim_testing_suite.source_path)
@property
def library_type(self):

View File

@ -16,13 +16,13 @@ class lzma(Dependency):
class Builder(MakeBuilder):
@property
def configure_option(self):
return ("--disable-xz "
"--disable-xzdec "
"--disable-lzmadec "
"--disable-lzmainfo "
"--disable-lzma-links "
"--disable-scripts "
"--disable-doc "
def configure_options(self):
return ["--disable-xz",
"--disable-xzdec",
"--disable-lzmadec",
"--disable-lzmainfo",
"--disable-lzma-links",
"--disable-scripts",
"--disable-doc",
# "--disable-symbol-versions"
)
]

View File

@ -16,4 +16,4 @@ class Pugixml(Dependency):
class Builder(MesonBuilder):
build_type = 'release'
strip_option = ''
strip_options = []

View File

@ -21,12 +21,23 @@ class Qt(Dependency):
class Builder(MakeBuilder):
dependencies = ['icu4c', 'zlib']
configure_option_template = "{dep_options} {static_option} {env_option} -prefix {install_dir} -libdir {libdir}"
dynamic_configure_option = "-shared"
static_configure_option = "-static"
dynamic_configure_options = ["-shared"]
static_configure_options = ["-static"]
@property
def configure_option(self):
def all_configure_options(self):
yield from self.configure_options
if self.buildEnv.platformInfo.static:
yield from self.static_configure_options
else:
yield from self.dynamic_configure_options
if not self.target.force_native_build:
yield from self.buildEnv.platformInfo.configure_options
yield from ('-prefix', self.buildEnv.install_dir)
yield from ('-libdir', pj(self.buildEnv.install_dir, self.buildEnv.libprefix))
@property
def configure_options(self):
skip_modules = [
'qt3d',
'qtcanvas3d',
@ -56,9 +67,14 @@ class Qt(Dependency):
'qtwebsockets',
# 'qtwebview',
]
skip_modules = " ".join("-skip {}".format(m) for m in skip_modules)
options = "-recheck -opensource -confirm-license -ccache -make libs {}".format(skip_modules)
return options
yield '-recheck'
yield '-opensource'
yield '-confirm-license'
yield '-ccache'
yield from ('-make', 'libs')
for module in skip_modules:
yield from ('-skip', module)
class QtWebEngine(Dependency):
name = "qtwebengine"

View File

@ -47,13 +47,13 @@ class android_ndk(Dependency):
context.try_skip(self.build_path)
script = pj(self.source_path, 'build/tools/make_standalone_toolchain.py')
add_execution_right(script)
command = '{script} --arch={arch} --api={api} --install-dir={install_dir} --force'
command = command.format(
script=script,
arch=self.arch,
api=self.api,
install_dir=self.install_path
)
command = [
script,
f'--arch={self.arch}',
f'--api={self.api}',
f'--install-dir={self.install_path}',
'--force'
]
env = self.buildEnv.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=False)
run_command(command, self.build_path, context, env=env)

View File

@ -31,12 +31,12 @@ class emsdk(Dependency):
def _install(self, context):
context.try_skip(self.build_path)
command = "./emsdk install 3.1.24"
command = ["./emsdk", "install", "3.1.24"]
run_command(command, self.install_path, context)
def _activate(self, context):
context.try_skip(self.build_path)
command = "./emsdk activate 3.1.24"
command = ["./emsdk", "activate", "3.1.24"]
run_command(command, self.install_path, context)

View File

@ -13,21 +13,23 @@ class org_kde(Dependency):
class Builder(Builder):
def _setup_remote(self, context):
command = "flatpak --user remote-add --if-not-exists {remote_name} {remote_url}"
command = command.format(
remote_name = 'flathub',
remote_url = 'https://flathub.org/repo/flathub.flatpakrepo'
)
command = [
"flatpak",
"--user", "remote-add", "--if-not-exists",
"flathub",
"https://flathub.org/repo/flathub.flatpakrepo"
]
env = self.buildEnv.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=False)
run_command(command, self.buildEnv.build_dir, context, env=env)
def _install_sdk(self, context):
command = "flatpak --user install --noninteractive --verbose -y {remote_name} {name}.Sdk//{version} {name}.Platform//{version}"
command = command.format(
remote_name = 'flathub',
name = self.target.name,
version = self.target.version()
)
command = [
"flatpak",
"--user", "install", "--noninteractive", "--verbose", "-y",
"flathub",
f"{self.target.name}.Sdk//{self.target.version()}",
f"{self.target.name}.Platform//{self.target.version()}"
]
env = self.buildEnv.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=False)
run_command(command, self.buildEnv.build_dir, context, env=env)
@ -44,25 +46,25 @@ class io_qt_qtwebengine(Dependency):
class Builder(Builder):
def _setup_remote(self, context):
command = "flatpak --user remote-add --if-not-exists {remote_name} {remote_url}"
command = command.format(
remote_name = 'flathub',
remote_url = 'https://flathub.org/repo/flathub.flatpakrepo'
)
command = [
"flatpak",
"--user", "remote-add", "--if-not-exists",
"flathub",
"https://flathub.org/repo/flathub.flatpakrepo"
]
env = self.buildEnv.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=False)
run_command(command, self.buildEnv.build_dir, context, env=env)
def _install_sdk(self, context):
command = "flatpak --user install -y {remote_name} {name}.BaseApp//{version}"
command = command.format(
remote_name = 'flathub',
name = self.target.name,
version = self.target.version()
)
command = [
"flatpak",
"--user", "install", "-y",
"flathub",
f"{self.target.name}.BaseApp//{self.target.version()}"
]
env = self.buildEnv.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=False)
run_command(command, self.buildEnv.build_dir, context, env=env)
def build(self):
self.command('setup_remote', self._setup_remote)
self.command('install_sdk', self._install_sdk)

View File

@ -17,9 +17,14 @@ class UUID(Dependency):
extract_dir = 'e2fsprogs-libs-1.43.4'
class Builder(MakeBuilder):
configure_option = ("--enable-libuuid --disable-debugfs --disable-imager --disable-resizer --disable-defrag --enable-fsck"
" --disable-uuidd")
configure_options = ["--enable-libuuid",
"--disable-debugfs",
"--disable-imager",
"--disable-resizer",
"--disable-defrag",
"--enable-fsck",
"--disable-uuidd"]
configure_env = {'_format_CFLAGS': "{env.CFLAGS} -O3 -fPIC"}
static_configure_option = dynamic_configure_option = ""
make_target = 'libs'
make_install_target = 'install-libs'
static_configure_options = dynamic_configure_options = []
make_targets = ['libs']
make_install_targets = ['install-libs']

View File

@ -16,7 +16,11 @@ class Xapian(Dependency):
'30d3518172084f310dab86d262b512718a7f9a13635aaa1a188e61dc26b2288c')
class Builder(MakeBuilder):
configure_option = "--disable-sse --disable-backend-chert --disable-backend-remote --disable-documentation"
configure_options = [
"--disable-sse",
"--disable-backend-chert",
"--disable-backend-remote",
"--disable-documentation"]
configure_env = {'_format_LDFLAGS': "{env.LDFLAGS} -L{buildEnv.install_dir}/{buildEnv.libprefix}",
'_format_CXXFLAGS': "{env.CXXFLAGS} -O3 -I{buildEnv.install_dir}/include"}

View File

@ -20,11 +20,9 @@ class ZimTools(Dependency):
return base_deps
@property
def configure_option(self):
base_option = ""
def configure_options(self):
# We don't build zimwriterfs on win32, and so we don't have magic
if self.buildEnv.platformInfo.build != 'win32':
base_option += " -Dmagic-install-prefix={buildEnv.install_dir}"
yield f"-Dmagic-install-prefix={self.buildEnv.install_dir}"
if self.buildEnv.platformInfo.static:
base_option += " -Dstatic-linkage=true"
return base_option
yield "-Dstatic-linkage=true"

View File

@ -18,10 +18,9 @@ class zlib(Dependency):
patches = ['zlib_std_libname.patch']
class Builder(MakeBuilder):
dynamic_configure_option = "--shared"
static_configure_option = "--static"
make_install_target = 'install'
configure_option_template = "{dep_options} {static_option} --prefix {install_dir} --libdir {libdir}"
dynamic_configure_options = ["--shared"]
static_configure_options = ["--static"]
make_install_targets = ['install']
def _pre_build_script(self, context):
context.try_skip(self.build_path)
@ -34,20 +33,27 @@ class zlib(Dependency):
return super()._configure(context)
@property
def make_option(self):
if self.buildEnv.platformInfo.build == 'win32':
return "--makefile win32/Makefile.gcc PREFIX={host}- SHARED_MODE={static} INCLUDE_PATH={include_path} LIBRARY_PATH={library_path} BINARY_PATH={binary_path}".format(
host='i686-w64-mingw32',
static="0" if self.buildEnv.platformInfo.static else "1",
include_path=pj(self.buildEnv.install_dir, 'include'),
library_path=pj(self.buildEnv.install_dir, self.buildEnv.libprefix),
binary_path=pj(self.buildEnv.install_dir, 'bin'),
)
return ""
def all_configure_options(self):
yield from self.configure_options
yield from self.static_configure_options if self.buildEnv.platformInfo.static else self.dynamic_configure_options
yield from ('--prefix', self.buildEnv.install_dir)
yield from ('--libdir', pj(self.buildEnv.install_dir, self.buildEnv.libprefix))
@property
def make_target(self):
def make_options(self):
if self.buildEnv.platformInfo.build != 'win32':
return
yield "--makefile"
yield "win32/Makefile.gcc"
yield "PREFIX=i686-w64-mingw32-",
yield "SHARED_MODE={}".format("0" if self.buildEnv.platformInfo.static else "1"),
yield "INCLUDE_PATH={}".format(pj(self.buildEnv.install_dir, 'include')),
yield "LIBRARY_PATH={}".format(pj(self.buildEnv.install_dir, self.buildEnv.libprefix)),
yield "BINARY_PATH={}".format(pj(self.buildEnv.install_dir, 'bin'))
@property
def make_targets(self):
if self.buildEnv.platformInfo.static:
return "static"
return ["static"]
else:
return "shared"
return ["shared"]

View File

@ -18,5 +18,5 @@ class zstd(Dependency):
class Builder(MesonBuilder):
subsource_dir = 'build/meson'
build_type = 'release'
strip_option = ''
configure_option = '-Dbin_programs=false -Dbin_contrib=false'
strip_options = []
configure_options = ['-Dbin_programs=false', '-Dbin_contrib=false']

View File

@ -223,8 +223,12 @@ class FlatpakBuilder:
def build(self):
log = pj(self.platform.buildEnv.log_dir, 'cmd_build_flatpak.log')
context = Context('build', log, False)
command = "flatpak-builder --user --ccache --force-clean --keep-build-dirs --disable-rofiles-fuse --repo=repo builddir {id}.json"
command = command.format(id = MANIFEST['app-id'])
command = [
"flatpak-builder",
"--user", "--ccache", "--force-clean", "--keep-build-dirs",
"--disable-rofiles-fuse", "--repo=repo", "builddir",
f"{MANIFEST['app-id']}.json"
]
try:
run_command(command, self.platform.buildEnv.build_dir, context, env=self.platform.get_env())
context._finalise()
@ -236,8 +240,12 @@ class FlatpakBuilder:
def bundle(self):
log = pj(self.platform.buildEnv.log_dir, 'cmd_bundle_flatpak.log')
context = Context('bundle', log, False)
command = "flatpak build-bundle repo {id}.flatpak {id}"
command = command.format(id = MANIFEST['app-id'])
app_id = MANIFEST['app-id']
command = [
"flatpak", "build-bundle", "repo",
f"{app_id}.flatpak",
app_id
]
try:
run_command(command, self.platform.buildEnv.build_dir, context, env=self.platform.get_env())
context._finalise()

View File

@ -90,8 +90,8 @@ class AndroidPlatformInfo(PlatformInfo):
env[k] = v
@property
def configure_option(self):
return '--host={}'.format(self.arch_full)
def configure_options(self):
yield '--host={}'.format(self.arch_full)
def finalize_setup(self):
super().finalize_setup()

View File

@ -65,8 +65,8 @@ class ArmPlatformInfo(PlatformInfo):
return "exe_wrapper = 'qemu-arm'"
@property
def configure_option(self):
return '--host={}'.format(self.arch_full)
def configure_options(self):
yield '--host={}'.format(self.arch_full)
def get_bin_dir(self):
return [pj(self.root_path, 'bin')]

View File

@ -23,7 +23,7 @@ class PlatformInfo(metaclass=_MetaPlatform):
all_platforms = {}
all_running_platforms = {}
toolchain_names = []
configure_option = ""
configure_options = []
mixed = False
libdir = None

View File

@ -31,8 +31,8 @@ class I586PlatformInfo(PlatformInfo):
}
@property
def configure_option(self):
return '--host={}'.format(self.arch_full)
def configure_options(self):
yield f'--host={self.arch_full}'
@property
def binaries(self):

View File

@ -118,8 +118,8 @@ class ApplePlatformInfo(PlatformInfo):
}
@property
def configure_option(self):
return '--host={}'.format(self.host)
def configure_options(self):
yield f'--host={self.host}'
class iOSArm64(ApplePlatformInfo):

View File

@ -62,8 +62,8 @@ class MuslPlatformInfo(PlatformInfo):
return f"exe_wrapper = '{self.qemu}'"
@property
def configure_option(self):
return '--host={}'.format(self.arch_full)
def configure_options(self):
return [f'--host={self.arch_full}']
def get_bin_dir(self):
return [pj(self.root_path, 'bin')]

View File

@ -59,9 +59,9 @@ class WasmPlatformInfo(PlatformInfo):
return binaries
@property
def configure_option(self):
def configure_options(self):
#return ""
return '--host={}'.format(self.arch_full)
return [f'--host={self.arch_full}']
@property
def configure_wrapper(self):

View File

@ -63,8 +63,8 @@ class Win32PlatformInfo(PlatformInfo):
return "exe_wrapper = 'wine'"
@property
def configure_option(self):
return '--host={}'.format(self.arch_full)
def configure_options(self):
yield f'--host={self.arch_full}'
def set_compiler(self, env):
for k, v in self.binaries.items():

View File

@ -63,8 +63,8 @@ class Win64PlatformInfo(PlatformInfo):
return "exe_wrapper = 'wine'"
@property
def configure_option(self):
return '--host={}'.format(self.arch_full)
def configure_options(self):
return [f'--host={self.arch_full}']
def set_compiler(self, env):
for k, v in self.binaries.items():

View File

@ -294,7 +294,7 @@ def run_command(command, cwd, context, *, env=None, input=None):
kwargs = dict()
if input:
kwargs['stdin'] = subprocess.PIPE
process = subprocess.Popen(command, shell=True, cwd=cwd, env=env, stdout=log or sys.stdout, stderr=subprocess.STDOUT, **kwargs)
process = subprocess.Popen(command, cwd=cwd, env=env, stdout=log or sys.stdout, stderr=subprocess.STDOUT, **kwargs)
if input:
input = input.encode()
while True: