[API change] Use just one option to specify the build target.
There is no more option for static or share build. This value is integrated in the build-target.
This commit is contained in:
parent
c31a29488a
commit
29bba313bc
10
.travis.yml
10
.travis.yml
|
@ -12,12 +12,12 @@ deploy:
|
|||
skip_cleanup: true
|
||||
script: travis/deploy.sh
|
||||
on:
|
||||
condition: ( "$STATIC_BUILD" = "true" ) && ( "$TRAVIS_EVENT_TYPE" = "cron" )
|
||||
condition: ( "$DEPLOY" = "true" ) && ( "$TRAVIS_EVENT_TYPE" = "cron" )
|
||||
env:
|
||||
- STATIC_BUILD=true BUILD_TARGET=native
|
||||
- STATIC_BUILD=true BUILD_TARGET=win32
|
||||
- STATIC_BUILD=false BUILD_TARGET=native
|
||||
- STATIC_BUILD=false BUILD_TARGET=win32
|
||||
- BUILD_OPTION="--target-platform=native_dyn"
|
||||
- BUILD_OPTION="--target-platform=native_static" ARCHIVE_TYPE="--tar" DEPLOY=true
|
||||
- BUILD_OPTION="--target-platform=win32_dyn"
|
||||
- BUILD_OPTION="--target-platform=win32_static" ARCHIVE_TYPE="--zip" DEPLOY=true
|
||||
notifications:
|
||||
irc:
|
||||
channels:
|
||||
|
|
|
@ -44,28 +44,28 @@ class zlib(Dependency):
|
|||
|
||||
@property
|
||||
def all_configure_option(self):
|
||||
return '--static' if self.buildEnv.build_static else '--shared'
|
||||
return '--static' if self.buildEnv.platform_info.static else '--shared'
|
||||
|
||||
@property
|
||||
def configure_option(self):
|
||||
options = "-DINSTALL_PKGCONFIG_DIR={}".format(pj(self.buildEnv.install_dir, self.buildEnv.libprefix, 'pkgconfig'))
|
||||
if self.buildEnv.build_static:
|
||||
if self.buildEnv.platform_info.static:
|
||||
options += " -DBUILD_SHARED_LIBS=false"
|
||||
else:
|
||||
options += " -DBUILD_SHARED_LIBS=true"
|
||||
return options
|
||||
|
||||
def _configure(self, context):
|
||||
if self.buildEnv.target_info.build == 'win32':
|
||||
if self.buildEnv.platform_info.build == 'win32':
|
||||
raise SkipCommand()
|
||||
return super()._configure(context)
|
||||
|
||||
@property
|
||||
def make_option(self):
|
||||
if self.buildEnv.target_info.build == 'win32':
|
||||
if self.buildEnv.platform_info.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.target_info.static else "1",
|
||||
static="0" if self.buildEnv.platform_info.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'),
|
||||
|
@ -121,7 +121,7 @@ class Xapian(Dependency):
|
|||
@property
|
||||
def dependencies(self):
|
||||
deps = ['zlib', 'lzma']
|
||||
if self.buildEnv.build_target == 'win32':
|
||||
if self.buildEnv.platform_info.build == 'win32':
|
||||
return deps
|
||||
return deps + ['UUID']
|
||||
|
||||
|
@ -241,7 +241,7 @@ class Kiwixlib(Dependency):
|
|||
|
||||
@property
|
||||
def dependencies(self):
|
||||
if self.buildEnv.build_target == 'win32':
|
||||
if self.buildEnv.platform_info.build == 'win32':
|
||||
return ["Xapian", "CTPP2", "Pugixml", "Icu_cross_compile", "Zimlib"]
|
||||
return ["Xapian", "CTPP2", "Pugixml", "Icu", "Zimlib"]
|
||||
|
||||
|
@ -265,6 +265,6 @@ class KiwixTools(Dependency):
|
|||
@property
|
||||
def configure_option(self):
|
||||
base_options = "-Dctpp2-install-prefix={buildEnv.install_dir}"
|
||||
if self.buildEnv.build_static:
|
||||
if self.buildEnv.platform_info.static:
|
||||
base_options += " -Dstatic-linkage=true"
|
||||
return base_options
|
||||
|
|
|
@ -196,7 +196,7 @@ class MakeBuilder(Builder):
|
|||
def all_configure_option(self):
|
||||
return "{} {} {}".format(
|
||||
self.configure_option,
|
||||
self.static_configure_option if self.buildEnv.build_static else self.dynamic_configure_option,
|
||||
self.static_configure_option if self.buildEnv.platform_info.static else self.dynamic_configure_option,
|
||||
self.buildEnv.configure_option if not self.target.force_native_build else "")
|
||||
|
||||
def _configure(self, context):
|
||||
|
@ -209,7 +209,7 @@ class MakeBuilder(Builder):
|
|||
libdir=pj(self.buildEnv.install_dir, self.buildEnv.libprefix)
|
||||
)
|
||||
env = Defaultdict(str, os.environ)
|
||||
if self.buildEnv.build_static:
|
||||
if self.buildEnv.platform_info.static:
|
||||
env['CFLAGS'] = env['CFLAGS'] + ' -fPIC'
|
||||
if self.configure_env:
|
||||
for k in self.configure_env:
|
||||
|
@ -254,7 +254,7 @@ class CMakeBuilder(MakeBuilder):
|
|||
cross_option="-DCMAKE_TOOLCHAIN_FILE={}".format(self.buildEnv.cmake_crossfile) if self.buildEnv.cmake_crossfile else ""
|
||||
)
|
||||
env = Defaultdict(str, os.environ)
|
||||
if self.buildEnv.build_static:
|
||||
if self.buildEnv.platform_info.static:
|
||||
env['CFLAGS'] = env['CFLAGS'] + ' -fPIC'
|
||||
if self.configure_env:
|
||||
for k in self.configure_env:
|
||||
|
@ -271,7 +271,7 @@ class MesonBuilder(Builder):
|
|||
|
||||
@property
|
||||
def library_type(self):
|
||||
return 'static' if self.buildEnv.build_static else 'shared'
|
||||
return 'static' if self.buildEnv.platform_info.static else 'shared'
|
||||
|
||||
def _configure(self, context):
|
||||
context.try_skip(self.build_path)
|
||||
|
|
|
@ -119,15 +119,26 @@ def which(name):
|
|||
return output[:-1].decode()
|
||||
|
||||
|
||||
class TargetInfo:
|
||||
def __init__(self, build, static):
|
||||
self.build = build
|
||||
self.static = static
|
||||
|
||||
def __str__(self):
|
||||
return "{}_{}".format(self.build, 'static' if self.static else 'dyn')
|
||||
|
||||
|
||||
class BuildEnv:
|
||||
build_targets = ['native', 'win32']
|
||||
target_platforms = {
|
||||
'native_dyn': TargetInfo('native', False),
|
||||
'native_static': TargetInfo('native', True),
|
||||
'win32_dyn': TargetInfo('win32', False),
|
||||
'win32_static': TargetInfo('win32', True)
|
||||
}
|
||||
|
||||
def __init__(self, options, targetsDict):
|
||||
self.source_dir = pj(options.working_dir, "SOURCE")
|
||||
build_dir = "BUILD_{target}_{libmod}".format(
|
||||
target=options.build_target,
|
||||
libmod='static' if options.build_static else 'dyn'
|
||||
)
|
||||
build_dir = "BUILD_{}".format(options.target_platform)
|
||||
self.build_dir = pj(options.working_dir, build_dir)
|
||||
self.archive_dir = pj(options.working_dir, "ARCHIVE")
|
||||
self.log_dir = pj(options.working_dir, 'LOGS')
|
||||
|
@ -145,7 +156,7 @@ class BuildEnv:
|
|||
self.meson_command = self._detect_meson()
|
||||
if not self.meson_command:
|
||||
sys.exit("ERROR: meson command not fount")
|
||||
self.setup_build(options.build_target)
|
||||
self.setup_build(options.target_platform)
|
||||
self.setup_toolchains()
|
||||
self.options = options
|
||||
self.libprefix = options.libprefix or self._detect_libdir()
|
||||
|
@ -169,20 +180,20 @@ class BuildEnv:
|
|||
if self.distname == 'ubuntu':
|
||||
self.distname = 'debian'
|
||||
|
||||
def setup_build(self, target):
|
||||
self.build_target = target
|
||||
if target == 'native':
|
||||
def setup_build(self, target_platform):
|
||||
self.platform_info = platform_info = self.target_platforms[target_platform]
|
||||
if platform_info.build == 'native':
|
||||
self.cross_env = {}
|
||||
else:
|
||||
cross_name = "{host}_{target}".format(
|
||||
host = self.distname,
|
||||
target = self.build_target)
|
||||
target = platform_info.build)
|
||||
try:
|
||||
self.cross_env = CROSS_ENV[cross_name]
|
||||
except KeyError:
|
||||
sys.exit("ERROR : We don't know how to set env to compile"
|
||||
" a {target} version on a {host} host.".format(
|
||||
target = self.build_target,
|
||||
target = platform_info.build,
|
||||
host = self.distname
|
||||
))
|
||||
|
||||
|
@ -192,7 +203,7 @@ class BuildEnv:
|
|||
for toolchain_name in toolchain_names]
|
||||
|
||||
def finalize_setup(self):
|
||||
getattr(self, 'setup_{}'.format(self.build_target))()
|
||||
getattr(self, 'setup_{}'.format(self.platform_info.build))()
|
||||
|
||||
def setup_native(self):
|
||||
self.cmake_crossfile = None
|
||||
|
@ -374,17 +385,15 @@ class BuildEnv:
|
|||
elif self.distname in ('debian', 'Ubuntu'):
|
||||
package_installer = 'sudo apt-get install {}'
|
||||
package_checker = 'LANG=C dpkg -s {} 2>&1 | grep Status | grep "ok installed" 1>/dev/null 2>&1'
|
||||
mapper_name = "{host}_{target}_{build_type}".format(
|
||||
mapper_name = "{host}_{target}".format(
|
||||
host=self.distname,
|
||||
target=self.build_target,
|
||||
build_type='static' if self.options.build_static else 'dyn')
|
||||
target=self.platform_info)
|
||||
try:
|
||||
package_name_mapper = PACKAGE_NAME_MAPPERS[mapper_name]
|
||||
except KeyError:
|
||||
print("SKIP : We don't know which packages we must install to compile"
|
||||
" a {target} {build_type} version on a {host} host.".format(
|
||||
target=self.build_target,
|
||||
build_type='static' if self.options.build_static else 'dyn',
|
||||
target=self.platform_info,
|
||||
host=self.distname))
|
||||
return
|
||||
|
||||
|
@ -546,8 +555,7 @@ def parse_args():
|
|||
parser.add_argument('targets', default='KiwixTools', nargs='?')
|
||||
parser.add_argument('--working-dir', default=".")
|
||||
parser.add_argument('--libprefix', default=None)
|
||||
parser.add_argument('--build-static', action="store_true")
|
||||
parser.add_argument('--build-target', default="native", choices=BuildEnv.build_targets)
|
||||
parser.add_argument('--target-platform', default="native_dyn", choices=BuildEnv.target_platforms)
|
||||
parser.add_argument('--verbose', '-v', action="store_true",
|
||||
help=("Print all logs on stdout instead of in specific"
|
||||
" log files per commands"))
|
||||
|
|
|
@ -2,9 +2,4 @@
|
|||
|
||||
set -e
|
||||
|
||||
OPTION=""
|
||||
if [ "${STATIC_BUILD}" = "true" ]; then
|
||||
OPTION="--build-static"
|
||||
fi
|
||||
|
||||
./kiwix-build.py --build-target=${BUILD_TARGET} ${OPTION}
|
||||
./kiwix-build.py $BUILD_OPTION
|
||||
|
|
|
@ -6,14 +6,8 @@ SSH_KEY=travis/travisci_builder_id_key
|
|||
|
||||
chmod 600 ${SSH_KEY}
|
||||
|
||||
|
||||
BASE_DIR="BUILD_${BUILD_TARGET}_static/INSTALL"
|
||||
if [ "${BUILD_TARGET}" = "win32" ]; then
|
||||
ARCHIVE_OPTION="--zip"
|
||||
else
|
||||
ARCHIVE_OPTION="--tar"
|
||||
fi
|
||||
./kiwix-deploy.py ${BASE_DIR} ${ARCHIVE_OPTION} \
|
||||
BASE_DIR="BUILD_*/INSTALL"
|
||||
./kiwix-deploy.py ${BASE_DIR} ${ARCHIVE_TYPE} \
|
||||
--deploy \
|
||||
--ssh_private_key=${SSH_KEY} \
|
||||
--server=nightlybot@download.kiwix.org \
|
||||
|
|
Loading…
Reference in New Issue