Rename option `--target-platform` to `--config`
The target_platform option has always be wrongly named. This is not the platform we are targeted but how we compile. This was ok at beginning as specifying how we compile somehow define for what we compile but this is not a one to one mapping.
This commit is contained in:
parent
6dfb0da943
commit
c0ec9c44b8
43
README.md
43
README.md
|
@ -78,12 +78,12 @@ invalid choice: 'not-existing-target' (choose from 'alldependencies', 'android-n
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Target platform
|
#### Config
|
||||||
|
|
||||||
If no target platform is specified, the default will be `native_dyn`.
|
If no config is specified, the default will be `native_dyn`.
|
||||||
|
|
||||||
You can select another target platform using the option
|
You can select another config using the option
|
||||||
`--target-platform`. For now, there is ten different supported
|
`--config`. For now, there is ten different supported
|
||||||
platforms:
|
platforms:
|
||||||
|
|
||||||
- native_dyn
|
- native_dyn
|
||||||
|
@ -98,9 +98,12 @@ platforms:
|
||||||
- android_x86_64
|
- android_x86_64
|
||||||
- flatpak
|
- flatpak
|
||||||
|
|
||||||
So, if you want to compile `kiwix-tools` for win32 using static linkage:
|
All `native_*` config means using the native compiler without any cross-compilation option.
|
||||||
|
Other may simply use cross-compilation or may download a specific toolchain to use.
|
||||||
|
|
||||||
|
If you want to compile `kiwix-tools` for win32 using static linkage:
|
||||||
```bash
|
```bash
|
||||||
kiwix-build --target-platform win32_dyn
|
kiwix-build --config win32_dyn
|
||||||
```
|
```
|
||||||
|
|
||||||
Android
|
Android
|
||||||
|
@ -112,20 +115,20 @@ the `libkiwix` project.
|
||||||
When building `libkiwix`, you should directly use the
|
When building `libkiwix`, you should directly use the
|
||||||
target-platform `android_<arch>`:
|
target-platform `android_<arch>`:
|
||||||
```bash
|
```bash
|
||||||
kiwix-build libkiwix --target-platform android_arm
|
kiwix-build libkiwix --config android_arm
|
||||||
```
|
```
|
||||||
|
|
||||||
But, `libkiwix-app` is mainly multi arch.
|
You may directly use the special config `android` which will build different android architectures
|
||||||
To compile `libkiwix-app`, you must use the `android` platform:
|
|
||||||
```bash
|
```bash
|
||||||
kiwix-build --target-platform android libkiwix
|
kiwix-build --config android libkiwix
|
||||||
```
|
```
|
||||||
|
|
||||||
By default, when using platform `android`, `libkiwix` will be build for
|
By default, it will build for all android architecture,
|
||||||
all architectures. This can be changed by using the option `--android-arch`:
|
you can limit this with option `--android-arch`:
|
||||||
```bash
|
```bash
|
||||||
kiwix-build libkiwix --android-arch arm # aar with arm architecture
|
kiwix-build libkiwix --config android --android-arch arm # aar with arm architecture
|
||||||
kiwix-build libkiwix --android-arch arm --android-arch arm64 # aan with arm and arm64 architectures
|
kiwix-build libkiwix --config android --android-arch arm --android-arch arm64 # aan with arm and arm64 architectures
|
||||||
|
```
|
||||||
|
|
||||||
To build `kiwix-android` itself, you should see the documentation of `kiwix-android`.
|
To build `kiwix-android` itself, you should see the documentation of `kiwix-android`.
|
||||||
|
|
||||||
|
@ -139,13 +142,13 @@ To do so, you should directly use the target-platfrom `ios_multi`.
|
||||||
As for `android`, `kiwix-build` will build the library several times
|
As for `android`, `kiwix-build` will build the library several times
|
||||||
(once for each platform) and then create the fat library.
|
(once for each platform) and then create the fat library.
|
||||||
```bash
|
```bash
|
||||||
kiwix-build --target-platform iOS_multi libkiwix
|
kiwix-build --config iOS_multi libkiwix
|
||||||
```
|
```
|
||||||
|
|
||||||
You can specify the supported architectures with the option `--ios-arch`:
|
You can specify the supported architectures with the option `--ios-arch`:
|
||||||
```bash
|
```bash
|
||||||
kiwix-build --target-platform iOS_multi libkiwix # all architetures
|
kiwix-build --config iOS_multi libkiwix # all architetures
|
||||||
kiwix-build --target-platform iOS_multi --ios-arch arm --ios-arch arm64 # arm and arm64 arch only
|
kiwix-build --config iOS_multi --ios-arch arm --ios-arch arm64 # arm and arm64 arch only
|
||||||
```
|
```
|
||||||
|
|
||||||
Outputs
|
Outputs
|
||||||
|
@ -154,9 +157,9 @@ Outputs
|
||||||
Kiwix-build.py will create several directories:
|
Kiwix-build.py will create several directories:
|
||||||
- `ARCHIVES`: All the downloaded archives go there.
|
- `ARCHIVES`: All the downloaded archives go there.
|
||||||
- `SOURCES`: All the sources (extracted from archives and patched) go there.
|
- `SOURCES`: All the sources (extracted from archives and patched) go there.
|
||||||
- `BUILD_<target_platform>`: All the build files go there.
|
- `BUILD_<config>`: All the build files go there.
|
||||||
- `BUILD_<target_platform>/INSTALL`: The installed files go there.
|
- `BUILD_<config>/INSTALL`: The installed files go there.
|
||||||
- `BUILD_<target_platform>/LOGS`: The logs files of the build.
|
- `BUILD_<config>/LOGS`: The logs files of the build.
|
||||||
|
|
||||||
If you want to install all those directories elsewhere, you can pass the
|
If you want to install all those directories elsewhere, you can pass the
|
||||||
`--working-dir` option to `kiwix-build`:
|
`--working-dir` option to `kiwix-build`:
|
||||||
|
|
|
@ -4,7 +4,7 @@ import os, sys
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from .dependencies import Dependency
|
from .dependencies import Dependency
|
||||||
from .platforms import PlatformInfo
|
from .configs import ConfigInfo
|
||||||
from .builder import Builder
|
from .builder import Builder
|
||||||
from .flatpak_builder import FlatpakBuilder
|
from .flatpak_builder import FlatpakBuilder
|
||||||
from . import _global
|
from . import _global
|
||||||
|
@ -37,7 +37,9 @@ def parse_args():
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
parser.add_argument("--libprefix", default=None)
|
parser.add_argument("--libprefix", default=None)
|
||||||
parser.add_argument("--target-platform", choices=PlatformInfo.all_platforms)
|
parser.add_argument(
|
||||||
|
"--config", choices=ConfigInfo.all_configs, default="native_dyn"
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--verbose",
|
"--verbose",
|
||||||
"-v",
|
"-v",
|
||||||
|
@ -130,9 +132,6 @@ def parse_args():
|
||||||
if not options.ios_arch:
|
if not options.ios_arch:
|
||||||
options.ios_arch = ["arm64", "x86_64"]
|
options.ios_arch = ["arm64", "x86_64"]
|
||||||
|
|
||||||
if not options.target_platform:
|
|
||||||
options.target_platform = "native_dyn"
|
|
||||||
|
|
||||||
return options
|
return options
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,9 +139,9 @@ def main():
|
||||||
options = parse_args()
|
options = parse_args()
|
||||||
options.working_dir = os.path.abspath(options.working_dir)
|
options.working_dir = os.path.abspath(options.working_dir)
|
||||||
_global.set_options(options)
|
_global.set_options(options)
|
||||||
neutralEnv = buildenv.PlatformNeutralEnv()
|
neutralEnv = buildenv.NeutralEnv()
|
||||||
_global.set_neutralEnv(neutralEnv)
|
_global.set_neutralEnv(neutralEnv)
|
||||||
if options.target_platform == "flatpak":
|
if options.config == "flatpak":
|
||||||
builder = FlatpakBuilder()
|
builder = FlatpakBuilder()
|
||||||
else:
|
else:
|
||||||
builder = Builder()
|
builder = Builder()
|
||||||
|
|
|
@ -7,7 +7,7 @@ from .utils import pj, download_remote, escape_path
|
||||||
from ._global import neutralEnv, option
|
from ._global import neutralEnv, option
|
||||||
|
|
||||||
|
|
||||||
class PlatformNeutralEnv:
|
class NeutralEnv:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.working_dir = option("working_dir")
|
self.working_dir = option("working_dir")
|
||||||
self.source_dir = pj(self.working_dir, "SOURCE")
|
self.source_dir = pj(self.working_dir, "SOURCE")
|
||||||
|
@ -75,9 +75,9 @@ class PlatformNeutralEnv:
|
||||||
|
|
||||||
|
|
||||||
class BuildEnv:
|
class BuildEnv:
|
||||||
def __init__(self, platformInfo):
|
def __init__(self, configInfo):
|
||||||
build_dir = "BUILD_{}".format(platformInfo.name)
|
build_dir = "BUILD_{}".format(configInfo.name)
|
||||||
self.platformInfo = platformInfo
|
self.configInfo = configInfo
|
||||||
self.base_build_dir = pj(option("working_dir"), option("build_dir"))
|
self.base_build_dir = pj(option("working_dir"), option("build_dir"))
|
||||||
self.build_dir = pj(self.base_build_dir, build_dir)
|
self.build_dir = pj(self.base_build_dir, build_dir)
|
||||||
self.install_dir = pj(self.build_dir, "INSTALL")
|
self.install_dir = pj(self.build_dir, "INSTALL")
|
||||||
|
@ -102,8 +102,8 @@ class BuildEnv:
|
||||||
return os.path.isfile("/etc/debian_version")
|
return os.path.isfile("/etc/debian_version")
|
||||||
|
|
||||||
def _detect_libdir(self):
|
def _detect_libdir(self):
|
||||||
if self.platformInfo.libdir is not None:
|
if self.configInfo.libdir is not None:
|
||||||
return self.platformInfo.libdir
|
return self.configInfo.libdir
|
||||||
if self._is_debianlike():
|
if self._is_debianlike():
|
||||||
try:
|
try:
|
||||||
pc = subprocess.Popen(
|
pc = subprocess.Popen(
|
||||||
|
@ -122,7 +122,7 @@ class BuildEnv:
|
||||||
return "lib"
|
return "lib"
|
||||||
|
|
||||||
def get_env(self, *, cross_comp_flags, cross_compilers, cross_path):
|
def get_env(self, *, cross_comp_flags, cross_compilers, cross_path):
|
||||||
env = self.platformInfo.get_env()
|
env = self.configInfo.get_env()
|
||||||
pkgconfig_path = pj(self.install_dir, self.libprefix, "pkgconfig")
|
pkgconfig_path = pj(self.install_dir, self.libprefix, "pkgconfig")
|
||||||
env["PKG_CONFIG_PATH"] = ":".join([env["PKG_CONFIG_PATH"], pkgconfig_path])
|
env["PKG_CONFIG_PATH"] = ":".join([env["PKG_CONFIG_PATH"], pkgconfig_path])
|
||||||
|
|
||||||
|
@ -158,23 +158,23 @@ class BuildEnv:
|
||||||
)
|
)
|
||||||
|
|
||||||
if cross_comp_flags:
|
if cross_comp_flags:
|
||||||
self.platformInfo.set_comp_flags(env)
|
self.configInfo.set_comp_flags(env)
|
||||||
if cross_compilers:
|
if cross_compilers:
|
||||||
self.platformInfo.set_compiler(env)
|
self.configInfo.set_compiler(env)
|
||||||
if cross_path:
|
if cross_path:
|
||||||
env["PATH"] = ":".join(self.platformInfo.get_bin_dir() + [env["PATH"]])
|
env["PATH"] = ":".join(self.configInfo.get_bin_dir() + [env["PATH"]])
|
||||||
return env
|
return env
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def configure_wrapper(self):
|
def configure_wrapper(self):
|
||||||
try:
|
try:
|
||||||
yield self.platformInfo.configure_wrapper
|
yield self.configInfo.configure_wrapper
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def make_wrapper(self):
|
def make_wrapper(self):
|
||||||
try:
|
try:
|
||||||
yield self.platformInfo.make_wrapper
|
yield self.configInfo.make_wrapper
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -2,7 +2,7 @@ import sys
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from .buildenv import *
|
from .buildenv import *
|
||||||
|
|
||||||
from .platforms import PlatformInfo
|
from .configs import ConfigInfo
|
||||||
from .utils import remove_duplicates, StopBuild, colorize
|
from .utils import remove_duplicates, StopBuild, colorize
|
||||||
from .dependencies import Dependency
|
from .dependencies import Dependency
|
||||||
from .packages import PACKAGE_NAME_MAPPERS
|
from .packages import PACKAGE_NAME_MAPPERS
|
||||||
|
@ -19,19 +19,18 @@ from . import _global
|
||||||
class Builder:
|
class Builder:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._targets = {}
|
self._targets = {}
|
||||||
PlatformInfo.get_platform("neutral", self._targets)
|
ConfigInfo.get_config("neutral", self._targets)
|
||||||
|
|
||||||
target_platform = option("target_platform")
|
config_name = option("config")
|
||||||
platform = PlatformInfo.get_platform(target_platform, self._targets)
|
config = ConfigInfo.get_config(config_name, self._targets)
|
||||||
if neutralEnv("distname") not in platform.compatible_hosts:
|
if neutralEnv("distname") not in config.compatible_hosts:
|
||||||
print(
|
print(
|
||||||
(
|
(
|
||||||
colorize("ERROR")
|
colorize("ERROR") + ": The config {} cannot be build on host {}.\n"
|
||||||
+ ": The target platform {} cannot be build on host {}.\n"
|
"Select another config or change your host system."
|
||||||
"Select another target platform or change your host system."
|
).format(config.name, neutralEnv("distname"))
|
||||||
).format(platform.name, neutralEnv("distname"))
|
|
||||||
)
|
)
|
||||||
self.targetDefs = platform.add_targets(option("target"), self._targets)
|
self.targetDefs = config.add_targets(option("target"), self._targets)
|
||||||
|
|
||||||
def finalize_target_steps(self):
|
def finalize_target_steps(self):
|
||||||
steps = []
|
steps = []
|
||||||
|
@ -40,7 +39,7 @@ class Builder:
|
||||||
steps = list(remove_duplicates(steps))
|
steps = list(remove_duplicates(steps))
|
||||||
|
|
||||||
if option("build_nodeps"):
|
if option("build_nodeps"):
|
||||||
# add all platform steps
|
# add all config steps
|
||||||
for dep in steps:
|
for dep in steps:
|
||||||
stepClass = Dependency.all_deps[dep[1]]
|
stepClass = Dependency.all_deps[dep[1]]
|
||||||
if stepClass.dont_skip:
|
if stepClass.dont_skip:
|
||||||
|
@ -57,18 +56,18 @@ class Builder:
|
||||||
self.instanciate_steps()
|
self.instanciate_steps()
|
||||||
|
|
||||||
def order_steps(self, targetDef):
|
def order_steps(self, targetDef):
|
||||||
for pltName in PlatformInfo.all_running_platforms:
|
for cfgName in ConfigInfo.all_running_configs:
|
||||||
plt = PlatformInfo.all_platforms[pltName]
|
cfg = ConfigInfo.all_configs[cfgName]
|
||||||
for tlcName in plt.toolchain_names:
|
for tlcName in cfg.toolchain_names:
|
||||||
tlc = Dependency.all_deps[tlcName]
|
tlc = Dependency.all_deps[tlcName]
|
||||||
yield ("source", tlcName)
|
yield ("source", tlcName)
|
||||||
yield ("neutral" if tlc.neutral else pltName, tlcName)
|
yield ("neutral" if tlc.neutral else cfgName, tlcName)
|
||||||
_targets = dict(self._targets)
|
_targets = dict(self._targets)
|
||||||
yield from self.order_dependencies(targetDef, _targets)
|
yield from self.order_dependencies(targetDef, _targets)
|
||||||
|
|
||||||
def order_dependencies(self, targetDef, targets):
|
def order_dependencies(self, targetDef, targets):
|
||||||
targetPlatformName, targetName = targetDef
|
targetConfigName, targetName = targetDef
|
||||||
if targetPlatformName == "source":
|
if targetConfigName == "source":
|
||||||
# Do not try to order sources, they will be added as dep by the
|
# Do not try to order sources, they will be added as dep by the
|
||||||
# build step two lines later.
|
# build step two lines later.
|
||||||
return
|
return
|
||||||
|
@ -77,24 +76,24 @@ class Builder:
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return
|
return
|
||||||
|
|
||||||
targetPlatform = PlatformInfo.get_platform(targetPlatformName)
|
targetConfig = ConfigInfo.get_config(targetConfigName)
|
||||||
for dep in target.get_dependencies(targetPlatform, True):
|
for dep in target.get_dependencies(targetConfig, True):
|
||||||
depPlatform, depName = targetPlatform.get_fully_qualified_dep(dep)
|
depConfig, depName = targetConfig.get_fully_qualified_dep(dep)
|
||||||
if (depPlatform, depName) in targets:
|
if (depConfig, depName) in targets:
|
||||||
yield from self.order_dependencies((depPlatform, depName), targets)
|
yield from self.order_dependencies((depConfig, depName), targets)
|
||||||
yield ("source", targetName)
|
yield ("source", targetName)
|
||||||
yield targetDef
|
yield targetDef
|
||||||
|
|
||||||
def instanciate_steps(self):
|
def instanciate_steps(self):
|
||||||
for stepDef in list(target_steps()):
|
for stepDef in list(target_steps()):
|
||||||
stepPlatform, stepName = stepDef
|
stepConfig, stepName = stepDef
|
||||||
stepClass = Dependency.all_deps[stepName]
|
stepClass = Dependency.all_deps[stepName]
|
||||||
if stepPlatform == "source":
|
if stepConfig == "source":
|
||||||
source = get_target_step(stepDef)(stepClass)
|
source = get_target_step(stepDef)(stepClass)
|
||||||
add_target_step(stepDef, source)
|
add_target_step(stepDef, source)
|
||||||
else:
|
else:
|
||||||
source = get_target_step(stepName, "source")
|
source = get_target_step(stepName, "source")
|
||||||
env = PlatformInfo.get_platform(stepPlatform).buildEnv
|
env = ConfigInfo.get_config(stepConfig).buildEnv
|
||||||
builder = get_target_step(stepDef)(stepClass, source, env)
|
builder = get_target_step(stepDef)(stepClass, source, env)
|
||||||
add_target_step(stepDef, builder)
|
add_target_step(stepDef, builder)
|
||||||
|
|
||||||
|
@ -125,18 +124,18 @@ class Builder:
|
||||||
|
|
||||||
def _get_packages(self):
|
def _get_packages(self):
|
||||||
packages_list = []
|
packages_list = []
|
||||||
for platform in PlatformInfo.all_running_platforms.values():
|
for config in ConfigInfo.all_running_configs.values():
|
||||||
mapper_name = "{host}_{target}".format(
|
mapper_name = "{host}_{config}".format(
|
||||||
host=neutralEnv("distname"), target=platform
|
host=neutralEnv("distname"), config=config
|
||||||
)
|
)
|
||||||
package_name_mapper = PACKAGE_NAME_MAPPERS.get(mapper_name, {})
|
package_name_mapper = PACKAGE_NAME_MAPPERS.get(mapper_name, {})
|
||||||
packages_list += package_name_mapper.get("COMMON", [])
|
packages_list += package_name_mapper.get("COMMON", [])
|
||||||
|
|
||||||
to_drop = []
|
to_drop = []
|
||||||
for builderDef in self._targets:
|
for builderDef in self._targets:
|
||||||
platformName, builderName = builderDef
|
configName, builderName = builderDef
|
||||||
mapper_name = "{host}_{target}".format(
|
mapper_name = "{host}_{config}".format(
|
||||||
host=neutralEnv("distname"), target=platformName
|
host=neutralEnv("distname"), config=configName
|
||||||
)
|
)
|
||||||
package_name_mapper = PACKAGE_NAME_MAPPERS.get(mapper_name, {})
|
package_name_mapper = PACKAGE_NAME_MAPPERS.get(mapper_name, {})
|
||||||
packages = package_name_mapper.get(builderName)
|
packages = package_name_mapper.get(builderName)
|
||||||
|
@ -195,9 +194,9 @@ class Builder:
|
||||||
else:
|
else:
|
||||||
self.install_packages()
|
self.install_packages()
|
||||||
self.finalize_target_steps()
|
self.finalize_target_steps()
|
||||||
print("[SETUP PLATFORMS]")
|
print("[SETUP TOOLCHAINS]")
|
||||||
for platform in PlatformInfo.all_running_platforms.values():
|
for config in ConfigInfo.all_running_configs.values():
|
||||||
platform.finalize_setup()
|
config.finalize_setup()
|
||||||
print("[PREPARE]")
|
print("[PREPARE]")
|
||||||
self.prepare_sources()
|
self.prepare_sources()
|
||||||
print("[BUILD]")
|
print("[BUILD]")
|
||||||
|
@ -205,8 +204,8 @@ class Builder:
|
||||||
# No error, clean intermediate file at end of build if needed.
|
# No error, clean intermediate file at end of build if needed.
|
||||||
print("[CLEAN]")
|
print("[CLEAN]")
|
||||||
if option("clean_at_end"):
|
if option("clean_at_end"):
|
||||||
for platform in PlatformInfo.all_running_platforms.values():
|
for config in ConfigInfo.all_running_configs.values():
|
||||||
platform.clean_intermediate_directories()
|
config.clean_intermediate_directories()
|
||||||
else:
|
else:
|
||||||
print(colorize("SKIP"))
|
print(colorize("SKIP"))
|
||||||
except StopBuild as e:
|
except StopBuild as e:
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
from .base import PlatformInfo, MetaPlatformInfo
|
from .base import ConfigInfo, MetaConfigInfo
|
||||||
from kiwixbuild.utils import pj
|
from kiwixbuild.utils import pj
|
||||||
from kiwixbuild._global import get_target_step, option
|
from kiwixbuild._global import get_target_step, option
|
||||||
|
|
||||||
|
|
||||||
class AndroidPlatformInfo(PlatformInfo):
|
class AndroidConfigInfo(ConfigInfo):
|
||||||
build = "android"
|
build = "android"
|
||||||
static = True
|
static = True
|
||||||
toolchain_names = ["android-ndk"]
|
toolchain_names = ["android-ndk"]
|
||||||
|
@ -114,7 +114,7 @@ class AndroidPlatformInfo(PlatformInfo):
|
||||||
self.buildEnv.meson_crossfile = self._gen_crossfile("meson_cross_file.txt")
|
self.buildEnv.meson_crossfile = self._gen_crossfile("meson_cross_file.txt")
|
||||||
|
|
||||||
|
|
||||||
class AndroidArm(AndroidPlatformInfo):
|
class AndroidArm(AndroidConfigInfo):
|
||||||
name = "android_arm"
|
name = "android_arm"
|
||||||
arch = cpu = "arm"
|
arch = cpu = "arm"
|
||||||
arch_full = "arm-linux-androideabi"
|
arch_full = "arm-linux-androideabi"
|
||||||
|
@ -122,7 +122,7 @@ class AndroidArm(AndroidPlatformInfo):
|
||||||
march = "armv7-a"
|
march = "armv7-a"
|
||||||
|
|
||||||
|
|
||||||
class AndroidArm64(AndroidPlatformInfo):
|
class AndroidArm64(AndroidConfigInfo):
|
||||||
name = "android_arm64"
|
name = "android_arm64"
|
||||||
arch = "arm64"
|
arch = "arm64"
|
||||||
arch_full = "aarch64-linux-android"
|
arch_full = "aarch64-linux-android"
|
||||||
|
@ -130,25 +130,25 @@ class AndroidArm64(AndroidPlatformInfo):
|
||||||
abi = "arm64-v8a"
|
abi = "arm64-v8a"
|
||||||
|
|
||||||
|
|
||||||
class AndroidX86(AndroidPlatformInfo):
|
class AndroidX86(AndroidConfigInfo):
|
||||||
name = "android_x86"
|
name = "android_x86"
|
||||||
arch = abi = "x86"
|
arch = abi = "x86"
|
||||||
arch_full = "i686-linux-android"
|
arch_full = "i686-linux-android"
|
||||||
cpu = "i686"
|
cpu = "i686"
|
||||||
|
|
||||||
|
|
||||||
class AndroidX8664(AndroidPlatformInfo):
|
class AndroidX8664(AndroidConfigInfo):
|
||||||
name = "android_x86_64"
|
name = "android_x86_64"
|
||||||
arch = cpu = abi = "x86_64"
|
arch = cpu = abi = "x86_64"
|
||||||
arch_full = "x86_64-linux-android"
|
arch_full = "x86_64-linux-android"
|
||||||
|
|
||||||
|
|
||||||
class Android(MetaPlatformInfo):
|
class Android(MetaConfigInfo):
|
||||||
name = "android"
|
name = "android"
|
||||||
compatible_hosts = ["fedora", "debian"]
|
compatible_hosts = ["fedora", "debian"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def subPlatformNames(self):
|
def subConfigNames(self):
|
||||||
return ["android_{}".format(arch) for arch in option("android_arch")]
|
return ["android_{}".format(arch) for arch in option("android_arch")]
|
||||||
|
|
||||||
def add_targets(self, targetName, targets):
|
def add_targets(self, targetName, targets):
|
|
@ -1,11 +1,11 @@
|
||||||
from .base import PlatformInfo, MixedMixin
|
from .base import ConfigInfo, MixedMixin
|
||||||
|
|
||||||
from kiwixbuild.utils import pj
|
from kiwixbuild.utils import pj
|
||||||
from kiwixbuild._global import get_target_step
|
from kiwixbuild._global import get_target_step
|
||||||
|
|
||||||
|
|
||||||
# Base platform
|
# Base config for arm
|
||||||
class ArmPlatformInfo(PlatformInfo):
|
class ArmConfigInfo(ConfigInfo):
|
||||||
compatible_hosts = ["fedora", "debian"]
|
compatible_hosts = ["fedora", "debian"]
|
||||||
|
|
||||||
def get_cross_config(self):
|
def get_cross_config(self):
|
||||||
|
@ -113,7 +113,7 @@ class ArmPlatformInfo(PlatformInfo):
|
||||||
self.buildEnv.meson_crossfile = self._gen_crossfile("meson_cross_file.txt")
|
self.buildEnv.meson_crossfile = self._gen_crossfile("meson_cross_file.txt")
|
||||||
|
|
||||||
|
|
||||||
class Armv6(ArmPlatformInfo):
|
class Armv6(ArmConfigInfo):
|
||||||
build = "armv6"
|
build = "armv6"
|
||||||
arch_full = "armv6-rpi-linux-gnueabihf"
|
arch_full = "armv6-rpi-linux-gnueabihf"
|
||||||
toolchain_names = ["armv6"]
|
toolchain_names = ["armv6"]
|
||||||
|
@ -136,7 +136,7 @@ class Armv6Mixed(MixedMixin("armv6_static"), Armv6):
|
||||||
static = False
|
static = False
|
||||||
|
|
||||||
|
|
||||||
class Armv8(ArmPlatformInfo):
|
class Armv8(ArmConfigInfo):
|
||||||
build = "armv8"
|
build = "armv8"
|
||||||
arch_full = "armv8-rpi3-linux-gnueabihf"
|
arch_full = "armv8-rpi3-linux-gnueabihf"
|
||||||
toolchain_names = ["armv8"]
|
toolchain_names = ["armv8"]
|
||||||
|
@ -159,7 +159,7 @@ class Armv8Mixed(MixedMixin("armv8_static"), Armv8):
|
||||||
static = False
|
static = False
|
||||||
|
|
||||||
|
|
||||||
class Aarch64(ArmPlatformInfo):
|
class Aarch64(ArmConfigInfo):
|
||||||
build = "aarch64"
|
build = "aarch64"
|
||||||
arch_full = "aarch64-linux-gnu"
|
arch_full = "aarch64-linux-gnu"
|
||||||
toolchain_names = ["aarch64"]
|
toolchain_names = ["aarch64"]
|
|
@ -10,35 +10,35 @@ _SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||||
TEMPLATES_DIR = pj(os.path.dirname(_SCRIPT_DIR), "templates")
|
TEMPLATES_DIR = pj(os.path.dirname(_SCRIPT_DIR), "templates")
|
||||||
|
|
||||||
|
|
||||||
class _MetaPlatform(type):
|
class _MetaConfig(type):
|
||||||
def __new__(cls, name, bases, dct):
|
def __new__(cls, name, bases, dct):
|
||||||
_class = type.__new__(cls, name, bases, dct)
|
_class = type.__new__(cls, name, bases, dct)
|
||||||
if name not in ("PlatformInfo", "MetaPlatformInfo") and "name" in dct:
|
if name not in ("ConfigInfo", "MetaConfigInfo") and "name" in dct:
|
||||||
dep_name = dct["name"]
|
dep_name = dct["name"]
|
||||||
PlatformInfo.all_platforms[dep_name] = _class
|
ConfigInfo.all_configs[dep_name] = _class
|
||||||
return _class
|
return _class
|
||||||
|
|
||||||
|
|
||||||
class PlatformInfo(metaclass=_MetaPlatform):
|
class ConfigInfo(metaclass=_MetaConfig):
|
||||||
all_platforms = {}
|
all_configs = {}
|
||||||
all_running_platforms = {}
|
all_running_configs = {}
|
||||||
toolchain_names = []
|
toolchain_names = []
|
||||||
configure_options = []
|
configure_options = []
|
||||||
mixed = False
|
mixed = False
|
||||||
libdir = None
|
libdir = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_platform(cls, name, targets=None):
|
def get_config(cls, name, targets=None):
|
||||||
if name not in cls.all_running_platforms:
|
if name not in cls.all_running_configs:
|
||||||
if targets is None:
|
if targets is None:
|
||||||
print("Should not got there.")
|
print("Should not got there.")
|
||||||
print(cls.all_running_platforms)
|
print(cls.all_running_configs)
|
||||||
raise KeyError(name)
|
raise KeyError(name)
|
||||||
cls.all_running_platforms[name] = cls.all_platforms[name](targets)
|
cls.all_running_configs[name] = cls.all_configs[name](targets)
|
||||||
return cls.all_running_platforms[name]
|
return cls.all_running_configs[name]
|
||||||
|
|
||||||
def __init__(self, targets):
|
def __init__(self, targets):
|
||||||
self.all_running_platforms[self.name] = self
|
self.all_running_configs[self.name] = self
|
||||||
self.buildEnv = BuildEnv(self)
|
self.buildEnv = BuildEnv(self)
|
||||||
self.setup_toolchains(targets)
|
self.setup_toolchains(targets)
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ class PlatformInfo(metaclass=_MetaPlatform):
|
||||||
for tlc_name in self.toolchain_names:
|
for tlc_name in self.toolchain_names:
|
||||||
ToolchainClass = Dependency.all_deps[tlc_name]
|
ToolchainClass = Dependency.all_deps[tlc_name]
|
||||||
targets[("source", tlc_name)] = ToolchainClass.Source
|
targets[("source", tlc_name)] = ToolchainClass.Source
|
||||||
plt_name = "neutral" if ToolchainClass.neutral else self.name
|
cfg_name = "neutral" if ToolchainClass.neutral else self.name
|
||||||
targets[(plt_name, tlc_name)] = ToolchainClass.Builder
|
targets[(cfg_name, tlc_name)] = ToolchainClass.Builder
|
||||||
|
|
||||||
def add_targets(self, targetName, targets):
|
def add_targets(self, targetName, targets):
|
||||||
if (self.name, targetName) in targets:
|
if (self.name, targetName) in targets:
|
||||||
|
@ -60,11 +60,11 @@ class PlatformInfo(metaclass=_MetaPlatform):
|
||||||
targets[(self.name, targetName)] = targetClass.Builder
|
targets[(self.name, targetName)] = targetClass.Builder
|
||||||
for dep in targetClass.Builder.get_dependencies(self, False):
|
for dep in targetClass.Builder.get_dependencies(self, False):
|
||||||
if isinstance(dep, tuple):
|
if isinstance(dep, tuple):
|
||||||
depPlatformName, depName = dep
|
depConfigName, depName = dep
|
||||||
else:
|
else:
|
||||||
depPlatformName, depName = self.name, dep
|
depConfigName, depName = self.name, dep
|
||||||
depPlatform = self.get_platform(depPlatformName, targets)
|
depConfig = self.get_config(depConfigName, targets)
|
||||||
depPlatform.add_targets(depName, targets)
|
depConfig.add_targets(depName, targets)
|
||||||
return [(self.name, targetName)]
|
return [(self.name, targetName)]
|
||||||
|
|
||||||
def get_fully_qualified_dep(self, dep):
|
def get_fully_qualified_dep(self, dep):
|
||||||
|
@ -114,14 +114,14 @@ class PlatformInfo(metaclass=_MetaPlatform):
|
||||||
self.buildEnv.clean_intermediate_directories()
|
self.buildEnv.clean_intermediate_directories()
|
||||||
|
|
||||||
|
|
||||||
class MetaPlatformInfo(PlatformInfo):
|
class MetaConfigInfo(ConfigInfo):
|
||||||
subPlatformNames = []
|
subConfigNames = []
|
||||||
|
|
||||||
def add_targets(self, targetName, targets):
|
def add_targets(self, targetName, targets):
|
||||||
targetDefs = []
|
targetDefs = []
|
||||||
for platformName in self.subPlatformNames:
|
for configName in self.subConfigNames:
|
||||||
platform = self.get_platform(platformName, targets)
|
config = self.get_config(configName, targets)
|
||||||
targetDefs += platform.add_targets(targetName, targets)
|
targetDefs += config.add_targets(targetName, targets)
|
||||||
return targetDefs
|
return targetDefs
|
||||||
|
|
||||||
|
|
||||||
|
@ -135,8 +135,8 @@ def MixedMixin(static_name):
|
||||||
if option("target") == targetName:
|
if option("target") == targetName:
|
||||||
return super().add_targets(targetName, targets)
|
return super().add_targets(targetName, targets)
|
||||||
else:
|
else:
|
||||||
static_platform = self.get_platform(static_name, targets)
|
static_config = self.get_config(static_name, targets)
|
||||||
return static_platform.add_targets(targetName, targets)
|
return static_config.add_targets(targetName, targets)
|
||||||
|
|
||||||
def get_fully_qualified_dep(self, dep):
|
def get_fully_qualified_dep(self, dep):
|
||||||
if isinstance(dep, tuple):
|
if isinstance(dep, tuple):
|
||||||
|
@ -147,8 +147,8 @@ def MixedMixin(static_name):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def static_buildEnv(self):
|
def static_buildEnv(self):
|
||||||
static_platform = self.get_platform(static_name)
|
static_config = self.get_config(static_name)
|
||||||
return static_platform.buildEnv
|
return static_config.buildEnv
|
||||||
|
|
||||||
def get_include_dirs(self):
|
def get_include_dirs(self):
|
||||||
return [
|
return [
|
|
@ -1,8 +1,8 @@
|
||||||
from .base import PlatformInfo
|
from .base import ConfigInfo
|
||||||
from kiwixbuild._global import option, neutralEnv
|
from kiwixbuild._global import option, neutralEnv
|
||||||
|
|
||||||
|
|
||||||
class FlatpakPlatformInfo(PlatformInfo):
|
class FlatpakConfigInfo(ConfigInfo):
|
||||||
name = "flatpak"
|
name = "flatpak"
|
||||||
build = "flatpak"
|
build = "flatpak"
|
||||||
static = ""
|
static = ""
|
|
@ -1,10 +1,10 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from .base import PlatformInfo
|
from .base import ConfigInfo
|
||||||
from kiwixbuild.utils import which, pj
|
from kiwixbuild.utils import which, pj
|
||||||
|
|
||||||
|
|
||||||
class I586PlatformInfo(PlatformInfo):
|
class I586ConfigInfo(ConfigInfo):
|
||||||
build = "i586"
|
build = "i586"
|
||||||
arch_full = "i586-linux-gnu"
|
arch_full = "i586-linux-gnu"
|
||||||
compatible_hosts = ["fedora", "debian"]
|
compatible_hosts = ["fedora", "debian"]
|
||||||
|
@ -69,11 +69,11 @@ class I586PlatformInfo(PlatformInfo):
|
||||||
self.buildEnv.meson_crossfile = self._gen_crossfile("meson_cross_file.txt")
|
self.buildEnv.meson_crossfile = self._gen_crossfile("meson_cross_file.txt")
|
||||||
|
|
||||||
|
|
||||||
class I586Dyn(I586PlatformInfo):
|
class I586Dyn(I586ConfigInfo):
|
||||||
name = "i586_dyn"
|
name = "i586_dyn"
|
||||||
static = False
|
static = False
|
||||||
|
|
||||||
|
|
||||||
class I586Static(I586PlatformInfo):
|
class I586Static(I586ConfigInfo):
|
||||||
name = "i586_static"
|
name = "i586_static"
|
||||||
static = True
|
static = True
|
|
@ -2,14 +2,14 @@ import subprocess
|
||||||
|
|
||||||
from kiwixbuild._global import option
|
from kiwixbuild._global import option
|
||||||
from kiwixbuild.utils import pj, xrun_find
|
from kiwixbuild.utils import pj, xrun_find
|
||||||
from .base import PlatformInfo, MetaPlatformInfo, MixedMixin
|
from .base import ConfigInfo, MetaConfigInfo, MixedMixin
|
||||||
from kiwixbuild.dependencies.apple_xcframework import AppleXCFramework
|
from kiwixbuild.dependencies.apple_xcframework import AppleXCFramework
|
||||||
|
|
||||||
|
|
||||||
MIN_MACOS_VERSION = "12.0"
|
MIN_MACOS_VERSION = "12.0"
|
||||||
|
|
||||||
|
|
||||||
class ApplePlatformInfo(PlatformInfo):
|
class AppleConfigInfo(ConfigInfo):
|
||||||
build = "iOS"
|
build = "iOS"
|
||||||
static = True
|
static = True
|
||||||
compatible_hosts = ["Darwin"]
|
compatible_hosts = ["Darwin"]
|
||||||
|
@ -148,7 +148,7 @@ class ApplePlatformInfo(PlatformInfo):
|
||||||
yield f"--host={self.host}"
|
yield f"--host={self.host}"
|
||||||
|
|
||||||
|
|
||||||
class iOSArm64(ApplePlatformInfo):
|
class iOSArm64(AppleConfigInfo):
|
||||||
name = "iOS_arm64"
|
name = "iOS_arm64"
|
||||||
arch = cpu = "arm64"
|
arch = cpu = "arm64"
|
||||||
host = "arm-apple-darwin"
|
host = "arm-apple-darwin"
|
||||||
|
@ -157,7 +157,7 @@ class iOSArm64(ApplePlatformInfo):
|
||||||
min_iphoneos_version = "15.0"
|
min_iphoneos_version = "15.0"
|
||||||
|
|
||||||
|
|
||||||
class iOSx64Simulator(ApplePlatformInfo):
|
class iOSx64Simulator(AppleConfigInfo):
|
||||||
name = "iOSSimulator_x86_64"
|
name = "iOSSimulator_x86_64"
|
||||||
arch = cpu = "x86_64"
|
arch = cpu = "x86_64"
|
||||||
host = "x86_64-apple-darwin"
|
host = "x86_64-apple-darwin"
|
||||||
|
@ -166,7 +166,7 @@ class iOSx64Simulator(ApplePlatformInfo):
|
||||||
min_iphoneos_version = "15.0"
|
min_iphoneos_version = "15.0"
|
||||||
|
|
||||||
|
|
||||||
class iOSArm64Simulator(ApplePlatformInfo):
|
class iOSArm64Simulator(AppleConfigInfo):
|
||||||
name = "iOSSimulator_arm64"
|
name = "iOSSimulator_arm64"
|
||||||
arch = cpu = "arm64"
|
arch = cpu = "arm64"
|
||||||
host = "arm-apple-darwin"
|
host = "arm-apple-darwin"
|
||||||
|
@ -175,7 +175,7 @@ class iOSArm64Simulator(ApplePlatformInfo):
|
||||||
min_iphoneos_version = "15.0"
|
min_iphoneos_version = "15.0"
|
||||||
|
|
||||||
|
|
||||||
class macOSArm64(ApplePlatformInfo):
|
class macOSArm64(AppleConfigInfo):
|
||||||
name = "macOS_arm64_static"
|
name = "macOS_arm64_static"
|
||||||
arch = cpu = "arm64"
|
arch = cpu = "arm64"
|
||||||
host = "aarch64-apple-darwin"
|
host = "aarch64-apple-darwin"
|
||||||
|
@ -185,7 +185,7 @@ class macOSArm64(ApplePlatformInfo):
|
||||||
min_macos_version = MIN_MACOS_VERSION
|
min_macos_version = MIN_MACOS_VERSION
|
||||||
|
|
||||||
|
|
||||||
class macOSArm64Mixed(MixedMixin("macOS_arm64_static"), ApplePlatformInfo):
|
class macOSArm64Mixed(MixedMixin("macOS_arm64_static"), AppleConfigInfo):
|
||||||
name = "macOS_arm64_mixed"
|
name = "macOS_arm64_mixed"
|
||||||
arch = cpu = "arm64"
|
arch = cpu = "arm64"
|
||||||
host = "aarch64-apple-darwin"
|
host = "aarch64-apple-darwin"
|
||||||
|
@ -195,7 +195,7 @@ class macOSArm64Mixed(MixedMixin("macOS_arm64_static"), ApplePlatformInfo):
|
||||||
min_macos_version = MIN_MACOS_VERSION
|
min_macos_version = MIN_MACOS_VERSION
|
||||||
|
|
||||||
|
|
||||||
class macOSx64(ApplePlatformInfo):
|
class macOSx64(AppleConfigInfo):
|
||||||
name = "macOS_x86_64"
|
name = "macOS_x86_64"
|
||||||
arch = cpu = "x86_64"
|
arch = cpu = "x86_64"
|
||||||
host = "x86_64-apple-darwin"
|
host = "x86_64-apple-darwin"
|
||||||
|
@ -205,33 +205,33 @@ class macOSx64(ApplePlatformInfo):
|
||||||
min_macos_version = MIN_MACOS_VERSION
|
min_macos_version = MIN_MACOS_VERSION
|
||||||
|
|
||||||
|
|
||||||
class IOS(MetaPlatformInfo):
|
class IOS(MetaConfigInfo):
|
||||||
name = "iOS_multi"
|
name = "iOS_multi"
|
||||||
compatible_hosts = ["Darwin"]
|
compatible_hosts = ["Darwin"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def subPlatformNames(self):
|
def subConfigNames(self):
|
||||||
return ["iOS_{}".format(arch) for arch in option("ios_arch")]
|
return ["iOS_{}".format(arch) for arch in option("ios_arch")]
|
||||||
|
|
||||||
def add_targets(self, targetName, targets):
|
def add_targets(self, targetName, targets):
|
||||||
super().add_targets(targetName, targets)
|
super().add_targets(targetName, targets)
|
||||||
return PlatformInfo.add_targets(self, "_ios_fat_lib", targets)
|
return ConfigInfo.add_targets(self, "_ios_fat_lib", targets)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
class AppleStaticAll(MetaPlatformInfo):
|
class AppleStaticAll(MetaConfigInfo):
|
||||||
name = "apple_all_static"
|
name = "apple_all_static"
|
||||||
compatible_hosts = ["Darwin"]
|
compatible_hosts = ["Darwin"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def subPlatformNames(self):
|
def subConfigNames(self):
|
||||||
return AppleXCFramework.subPlatformNames
|
return AppleXCFramework.subConfigNames
|
||||||
|
|
||||||
def add_targets(self, targetName, targets):
|
def add_targets(self, targetName, targets):
|
||||||
super().add_targets(targetName, targets)
|
super().add_targets(targetName, targets)
|
||||||
return PlatformInfo.add_targets(self, "apple_xcframework", targets)
|
return ConfigInfo.add_targets(self, "apple_xcframework", targets)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
|
@ -1,10 +1,10 @@
|
||||||
from .base import PlatformInfo, MixedMixin
|
from .base import ConfigInfo, MixedMixin
|
||||||
|
|
||||||
from kiwixbuild.utils import pj
|
from kiwixbuild.utils import pj
|
||||||
from kiwixbuild._global import get_target_step
|
from kiwixbuild._global import get_target_step
|
||||||
|
|
||||||
|
|
||||||
class MuslPlatformInfo(PlatformInfo):
|
class MuslConfigInfo(ConfigInfo):
|
||||||
compatible_hosts = ["fedora", "debian"]
|
compatible_hosts = ["fedora", "debian"]
|
||||||
|
|
||||||
def get_cross_config(self):
|
def get_cross_config(self):
|
||||||
|
@ -113,7 +113,7 @@ class MuslPlatformInfo(PlatformInfo):
|
||||||
self.buildEnv.meson_crossfile = self._gen_crossfile("meson_cross_file.txt")
|
self.buildEnv.meson_crossfile = self._gen_crossfile("meson_cross_file.txt")
|
||||||
|
|
||||||
|
|
||||||
class Aarch64MuslPlatformInfo(MuslPlatformInfo):
|
class Aarch64MuslConfigInfo(MuslConfigInfo):
|
||||||
build = "aarch64_musl"
|
build = "aarch64_musl"
|
||||||
arch_full = "aarch64-linux-musl"
|
arch_full = "aarch64-linux-musl"
|
||||||
toolchain_names = ["aarch64_musl"]
|
toolchain_names = ["aarch64_musl"]
|
||||||
|
@ -123,22 +123,22 @@ class Aarch64MuslPlatformInfo(MuslPlatformInfo):
|
||||||
qemu = "qemu-arm"
|
qemu = "qemu-arm"
|
||||||
|
|
||||||
|
|
||||||
class Aarch64MuslDyn(Aarch64MuslPlatformInfo):
|
class Aarch64MuslDyn(Aarch64MuslConfigInfo):
|
||||||
name = "aarch64_musl_dyn"
|
name = "aarch64_musl_dyn"
|
||||||
static = False
|
static = False
|
||||||
|
|
||||||
|
|
||||||
class Aarch64MuslStatic(Aarch64MuslPlatformInfo):
|
class Aarch64MuslStatic(Aarch64MuslConfigInfo):
|
||||||
name = "aarch64_musl_static"
|
name = "aarch64_musl_static"
|
||||||
static = True
|
static = True
|
||||||
|
|
||||||
|
|
||||||
class Aarch64MuslMixed(MixedMixin("aarch64_musl_static"), Aarch64MuslPlatformInfo):
|
class Aarch64MuslMixed(MixedMixin("aarch64_musl_static"), Aarch64MuslConfigInfo):
|
||||||
name = "aarch64_musl_mixed"
|
name = "aarch64_musl_mixed"
|
||||||
static = False
|
static = False
|
||||||
|
|
||||||
|
|
||||||
class X86_64MuslPlatformInfo(MuslPlatformInfo):
|
class X86_64MuslConfigInfo(MuslConfigInfo):
|
||||||
build = "x86-64_musl"
|
build = "x86-64_musl"
|
||||||
arch_full = "x86_64-linux-musl"
|
arch_full = "x86_64-linux-musl"
|
||||||
toolchain_names = ["x86-64_musl"]
|
toolchain_names = ["x86-64_musl"]
|
||||||
|
@ -147,16 +147,16 @@ class X86_64MuslPlatformInfo(MuslPlatformInfo):
|
||||||
cpu = "x86_64"
|
cpu = "x86_64"
|
||||||
|
|
||||||
|
|
||||||
class X86_64MuslDyn(X86_64MuslPlatformInfo):
|
class X86_64MuslDyn(X86_64MuslConfigInfo):
|
||||||
name = "x86-64_musl_dyn"
|
name = "x86-64_musl_dyn"
|
||||||
static = False
|
static = False
|
||||||
|
|
||||||
|
|
||||||
class X86_64MuslStatic(X86_64MuslPlatformInfo):
|
class X86_64MuslStatic(X86_64MuslConfigInfo):
|
||||||
name = "x86-64_musl_static"
|
name = "x86-64_musl_static"
|
||||||
static = True
|
static = True
|
||||||
|
|
||||||
|
|
||||||
class x86_64MuslMixed(MixedMixin("x86-64_musl_static"), X86_64MuslPlatformInfo):
|
class x86_64MuslMixed(MixedMixin("x86-64_musl_static"), X86_64MuslConfigInfo):
|
||||||
name = "x86-64_musl_mixed"
|
name = "x86-64_musl_mixed"
|
||||||
static = False
|
static = False
|
|
@ -1,11 +1,11 @@
|
||||||
from .base import PlatformInfo, MixedMixin
|
from .base import ConfigInfo, MixedMixin
|
||||||
|
|
||||||
from kiwixbuild.utils import pj
|
from kiwixbuild.utils import pj
|
||||||
from kiwixbuild._global import option, neutralEnv
|
from kiwixbuild._global import option, neutralEnv
|
||||||
from kiwixbuild.platforms.ios import MIN_MACOS_VERSION
|
from kiwixbuild.configs.ios import MIN_MACOS_VERSION
|
||||||
|
|
||||||
|
|
||||||
class NativePlatformInfo(PlatformInfo):
|
class NativeConfigInfo(ConfigInfo):
|
||||||
build = "native"
|
build = "native"
|
||||||
|
|
||||||
def get_env(self):
|
def get_env(self):
|
||||||
|
@ -17,19 +17,19 @@ class NativePlatformInfo(PlatformInfo):
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
||||||
class NativeDyn(NativePlatformInfo):
|
class NativeDyn(NativeConfigInfo):
|
||||||
name = "native_dyn"
|
name = "native_dyn"
|
||||||
static = False
|
static = False
|
||||||
compatible_hosts = ["fedora", "debian", "Darwin"]
|
compatible_hosts = ["fedora", "debian", "Darwin"]
|
||||||
|
|
||||||
|
|
||||||
class NativeStatic(NativePlatformInfo):
|
class NativeStatic(NativeConfigInfo):
|
||||||
name = "native_static"
|
name = "native_static"
|
||||||
static = True
|
static = True
|
||||||
compatible_hosts = ["fedora", "debian"]
|
compatible_hosts = ["fedora", "debian"]
|
||||||
|
|
||||||
|
|
||||||
class NativeMixed(MixedMixin("native_static"), NativePlatformInfo):
|
class NativeMixed(MixedMixin("native_static"), NativeConfigInfo):
|
||||||
name = "native_mixed"
|
name = "native_mixed"
|
||||||
static = False
|
static = False
|
||||||
compatible_hosts = ["fedora", "debian", "Darwin"]
|
compatible_hosts = ["fedora", "debian", "Darwin"]
|
|
@ -1,7 +1,7 @@
|
||||||
from .base import PlatformInfo
|
from .base import ConfigInfo
|
||||||
|
|
||||||
|
|
||||||
class NeutralPlatformInfo(PlatformInfo):
|
class NeutralConfigInfo(ConfigInfo):
|
||||||
name = "neutral"
|
name = "neutral"
|
||||||
static = ""
|
static = ""
|
||||||
compatible_hosts = ["fedora", "debian", "Darwin"]
|
compatible_hosts = ["fedora", "debian", "Darwin"]
|
|
@ -1,10 +1,10 @@
|
||||||
from .base import PlatformInfo
|
from .base import ConfigInfo
|
||||||
|
|
||||||
from kiwixbuild.utils import pj
|
from kiwixbuild.utils import pj
|
||||||
from kiwixbuild._global import get_target_step
|
from kiwixbuild._global import get_target_step
|
||||||
|
|
||||||
|
|
||||||
class WasmPlatformInfo(PlatformInfo):
|
class WasmConfigInfo(ConfigInfo):
|
||||||
name = "wasm"
|
name = "wasm"
|
||||||
static = True
|
static = True
|
||||||
build = "wasm"
|
build = "wasm"
|
|
@ -1,11 +1,11 @@
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from .base import PlatformInfo
|
from .base import ConfigInfo
|
||||||
from kiwixbuild.utils import which, pj
|
from kiwixbuild.utils import which, pj
|
||||||
from kiwixbuild._global import neutralEnv
|
from kiwixbuild._global import neutralEnv
|
||||||
|
|
||||||
|
|
||||||
class Win32PlatformInfo(PlatformInfo):
|
class Win32ConfigInfo(ConfigInfo):
|
||||||
build = "win32"
|
build = "win32"
|
||||||
compatible_hosts = ["fedora", "debian"]
|
compatible_hosts = ["fedora", "debian"]
|
||||||
arch_full = "i686-w64-mingw32"
|
arch_full = "i686-w64-mingw32"
|
||||||
|
@ -89,11 +89,11 @@ class Win32PlatformInfo(PlatformInfo):
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
||||||
class Win32Dyn(Win32PlatformInfo):
|
class Win32Dyn(Win32ConfigInfo):
|
||||||
name = "win32_dyn"
|
name = "win32_dyn"
|
||||||
static = False
|
static = False
|
||||||
|
|
||||||
|
|
||||||
class Win32Static(Win32PlatformInfo):
|
class Win32Static(Win32ConfigInfo):
|
||||||
name = "win32_static"
|
name = "win32_static"
|
||||||
static = True
|
static = True
|
|
@ -1,11 +1,11 @@
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from .base import PlatformInfo
|
from .base import ConfigInfo
|
||||||
from kiwixbuild.utils import which, pj
|
from kiwixbuild.utils import which, pj
|
||||||
from kiwixbuild._global import neutralEnv
|
from kiwixbuild._global import neutralEnv
|
||||||
|
|
||||||
|
|
||||||
class Win64PlatformInfo(PlatformInfo):
|
class Win64ConfigInfo(ConfigInfo):
|
||||||
extra_libs = [
|
extra_libs = [
|
||||||
"-lmingw32",
|
"-lmingw32",
|
||||||
"-lwinmm",
|
"-lwinmm",
|
||||||
|
@ -93,11 +93,11 @@ class Win64PlatformInfo(PlatformInfo):
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
||||||
class Win64Dyn(Win64PlatformInfo):
|
class Win64Dyn(Win64ConfigInfo):
|
||||||
name = "win64_dyn"
|
name = "win64_dyn"
|
||||||
static = False
|
static = False
|
||||||
|
|
||||||
|
|
||||||
class Win64Static(Win64PlatformInfo):
|
class Win64Static(Win64ConfigInfo):
|
||||||
name = "win64_static"
|
name = "win64_static"
|
||||||
static = True
|
static = True
|
|
@ -12,8 +12,8 @@ class AllBaseDependencies(Dependency):
|
||||||
|
|
||||||
class Builder(NoopBuilder):
|
class Builder(NoopBuilder):
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_dependencies(cls, platformInfo, allDeps):
|
def get_dependencies(cls, configInfo, allDeps):
|
||||||
if platformInfo.build == "wasm" or environ.get("OS_NAME") == "bionic":
|
if configInfo.build == "wasm" or environ.get("OS_NAME") == "bionic":
|
||||||
return ["zlib", "lzma", "zstd", "icu4c", "xapian-core"]
|
return ["zlib", "lzma", "zstd", "icu4c", "xapian-core"]
|
||||||
|
|
||||||
base_deps = [
|
base_deps = [
|
||||||
|
@ -28,17 +28,14 @@ class AllBaseDependencies(Dependency):
|
||||||
"libmicrohttpd",
|
"libmicrohttpd",
|
||||||
"zim-testing-suite",
|
"zim-testing-suite",
|
||||||
]
|
]
|
||||||
# Add specific dependencies depending of the platform
|
# Add specific dependencies depending of the config
|
||||||
if platformInfo.build not in ("android", "iOS"):
|
if configInfo.build not in ("android", "iOS"):
|
||||||
# For zimtools
|
# For zimtools
|
||||||
base_deps += ["docoptcpp"]
|
base_deps += ["docoptcpp"]
|
||||||
if platformInfo.build != "win32":
|
if configInfo.build != "win32":
|
||||||
# zimwriterfs
|
# zimwriterfs
|
||||||
base_deps += ["libmagic", "gumbo"]
|
base_deps += ["libmagic", "gumbo"]
|
||||||
if (
|
if configInfo.build == "native" and neutralEnv("distname") != "Darwin":
|
||||||
platformInfo.build == "native"
|
|
||||||
and neutralEnv("distname") != "Darwin"
|
|
||||||
):
|
|
||||||
# We compile kiwix-desktop only on native and not on `Darwin`
|
# We compile kiwix-desktop only on native and not on `Darwin`
|
||||||
# So we need aria2 only there
|
# So we need aria2 only there
|
||||||
base_deps += ["aria2"]
|
base_deps += ["aria2"]
|
||||||
|
|
|
@ -2,14 +2,14 @@ import os
|
||||||
import shutil
|
import shutil
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from kiwixbuild.platforms import PlatformInfo
|
from kiwixbuild.configs import ConfigInfo
|
||||||
from kiwixbuild.utils import pj, run_command
|
from kiwixbuild.utils import pj, run_command
|
||||||
from .base import Dependency, NoopSource, Builder as BaseBuilder
|
from .base import Dependency, NoopSource, Builder as BaseBuilder
|
||||||
|
|
||||||
|
|
||||||
class AppleXCFramework(Dependency):
|
class AppleXCFramework(Dependency):
|
||||||
name = "apple_xcframework"
|
name = "apple_xcframework"
|
||||||
subPlatformNames = [
|
subConfigNames = [
|
||||||
"macOS_x86_64",
|
"macOS_x86_64",
|
||||||
"macOS_arm64_static",
|
"macOS_arm64_static",
|
||||||
"iOS_arm64",
|
"iOS_arm64",
|
||||||
|
@ -20,34 +20,32 @@ class AppleXCFramework(Dependency):
|
||||||
|
|
||||||
class Builder(BaseBuilder):
|
class Builder(BaseBuilder):
|
||||||
@property
|
@property
|
||||||
def all_subplatforms(self):
|
def all_subconfigs(self):
|
||||||
return self.buildEnv.platformInfo.subPlatformNames
|
return self.buildEnv.configInfo.subConfigNames
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def macos_subplatforms(self):
|
def macos_subconfigs(self):
|
||||||
return [
|
return [
|
||||||
target for target in self.all_subplatforms if target.startswith("macOS")
|
target for target in self.all_subconfigs if target.startswith("macOS")
|
||||||
]
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def iossimulator_subplatforms(self):
|
def iossimulator_subconfigs(self):
|
||||||
return [
|
return [
|
||||||
target
|
target
|
||||||
for target in self.all_subplatforms
|
for target in self.all_subconfigs
|
||||||
if target.startswith("iOSSimulator")
|
if target.startswith("iOSSimulator")
|
||||||
]
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ios_subplatforms(self):
|
def ios_subconfigs(self):
|
||||||
return [
|
return [
|
||||||
target for target in self.all_subplatforms if target.startswith("iOS_")
|
target for target in self.all_subconfigs if target.startswith("iOS_")
|
||||||
]
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_dependencies(cls, platfomInfo, alldeps):
|
def get_dependencies(cls, configInfo, alldeps):
|
||||||
return [
|
return [(target, "libkiwix") for target in AppleXCFramework.subConfigNames]
|
||||||
(target, "libkiwix") for target in AppleXCFramework.subPlatformNames
|
|
||||||
]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def final_path(self):
|
def final_path(self):
|
||||||
|
@ -62,11 +60,11 @@ class AppleXCFramework(Dependency):
|
||||||
def _merge_libs(self, context):
|
def _merge_libs(self, context):
|
||||||
"""create merged.a in all targets to bundle all static archives"""
|
"""create merged.a in all targets to bundle all static archives"""
|
||||||
xcf_libs = []
|
xcf_libs = []
|
||||||
for target in self.all_subplatforms:
|
for target in self.all_subconfigs:
|
||||||
static_ars = []
|
static_ars = []
|
||||||
|
|
||||||
plt = PlatformInfo.get_platform(target)
|
cfg = ConfigInfo.get_config(target)
|
||||||
lib_dir = pj(plt.buildEnv.install_dir, "lib")
|
lib_dir = pj(cfg.buildEnv.install_dir, "lib")
|
||||||
static_ars = [str(f) for f in Path(lib_dir).glob("*.a")]
|
static_ars = [str(f) for f in Path(lib_dir).glob("*.a")]
|
||||||
|
|
||||||
# create merged.a from all *.a in install_dir/lib
|
# create merged.a from all *.a in install_dir/lib
|
||||||
|
@ -74,17 +72,17 @@ class AppleXCFramework(Dependency):
|
||||||
run_command(command, lib_dir, context)
|
run_command(command, lib_dir, context)
|
||||||
|
|
||||||
# will be included in xcframework
|
# will be included in xcframework
|
||||||
if target in self.ios_subplatforms:
|
if target in self.ios_subconfigs:
|
||||||
xcf_libs.append(pj(lib_dir, "merged.a"))
|
xcf_libs.append(pj(lib_dir, "merged.a"))
|
||||||
|
|
||||||
return xcf_libs
|
return xcf_libs
|
||||||
|
|
||||||
def make_fat_with(self, platforms, folder_name, context):
|
def make_fat_with(self, configs, folder_name, context):
|
||||||
"""create fat merged.a in {folder_name} install/lib with {platforms} archs"""
|
"""create fat merged.a in {folder_name} install/lib with {configs}"""
|
||||||
libs = []
|
libs = []
|
||||||
for target in platforms:
|
for target in configs:
|
||||||
plt = PlatformInfo.get_platform(target)
|
cfg = ConfigInfo.get_config(target)
|
||||||
libs.append(pj(plt.buildEnv.install_dir, "lib", "merged.a"))
|
libs.append(pj(cfg.buildEnv.install_dir, "lib", "merged.a"))
|
||||||
|
|
||||||
fat_dir = pj(self.buildEnv.build_dir, folder_name)
|
fat_dir = pj(self.buildEnv.build_dir, folder_name)
|
||||||
os.makedirs(fat_dir, exist_ok=True)
|
os.makedirs(fat_dir, exist_ok=True)
|
||||||
|
@ -97,14 +95,14 @@ class AppleXCFramework(Dependency):
|
||||||
|
|
||||||
def _build_xcframework(self, xcf_libs, context):
|
def _build_xcframework(self, xcf_libs, context):
|
||||||
# create xcframework
|
# create xcframework
|
||||||
ref_plat = PlatformInfo.get_platform(self.macos_subplatforms[0])
|
ref_conf = ConfigInfo.get_config(self.macos_subconfigs[0])
|
||||||
command = ["xcodebuild", "-create-xcframework"]
|
command = ["xcodebuild", "-create-xcframework"]
|
||||||
for lib in xcf_libs:
|
for lib in xcf_libs:
|
||||||
command += [
|
command += [
|
||||||
"-library",
|
"-library",
|
||||||
lib,
|
lib,
|
||||||
"-headers",
|
"-headers",
|
||||||
pj(ref_plat.buildEnv.install_dir, "include"),
|
pj(ref_conf.buildEnv.install_dir, "include"),
|
||||||
]
|
]
|
||||||
command += ["-output", self.final_path]
|
command += ["-output", self.final_path]
|
||||||
run_command(command, self.buildEnv.build_dir, context)
|
run_command(command, self.buildEnv.build_dir, context)
|
||||||
|
@ -116,13 +114,13 @@ class AppleXCFramework(Dependency):
|
||||||
xcf_libs += self.command(
|
xcf_libs += self.command(
|
||||||
"make_macos_fat",
|
"make_macos_fat",
|
||||||
self.make_fat_with,
|
self.make_fat_with,
|
||||||
self.macos_subplatforms,
|
self.macos_subconfigs,
|
||||||
"macOS_fat",
|
"macOS_fat",
|
||||||
)
|
)
|
||||||
xcf_libs += self.command(
|
xcf_libs += self.command(
|
||||||
"make_simulator_fat",
|
"make_simulator_fat",
|
||||||
self.make_fat_with,
|
self.make_fat_with,
|
||||||
self.iossimulator_subplatforms,
|
self.iossimulator_subconfigs,
|
||||||
"iOS-simulator_fat",
|
"iOS-simulator_fat",
|
||||||
)
|
)
|
||||||
self.command("build_xcframework", self._build_xcframework, xcf_libs)
|
self.command("build_xcframework", self._build_xcframework, xcf_libs)
|
||||||
|
|
|
@ -237,7 +237,7 @@ class Builder:
|
||||||
self.buildEnv = buildEnv
|
self.buildEnv = buildEnv
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_dependencies(cls, platformInfo, allDeps):
|
def get_dependencies(cls, configInfo, allDeps):
|
||||||
return cls.dependencies
|
return cls.dependencies
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -323,9 +323,9 @@ class Builder:
|
||||||
cross_compilers=cross_compilers,
|
cross_compilers=cross_compilers,
|
||||||
cross_path=cross_path,
|
cross_path=cross_path,
|
||||||
)
|
)
|
||||||
for dep in self.get_dependencies(self.buildEnv.platformInfo, False):
|
for dep in self.get_dependencies(self.buildEnv.configInfo, False):
|
||||||
try:
|
try:
|
||||||
builder = get_target_step(dep, self.buildEnv.platformInfo.name)
|
builder = get_target_step(dep, self.buildEnv.configInfo.name)
|
||||||
builder.set_env(env)
|
builder.set_env(env)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# Some target may be missing (installed by a package, ...)
|
# Some target may be missing (installed by a package, ...)
|
||||||
|
@ -382,7 +382,7 @@ class MakeBuilder(Builder):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def make_install_targets(self):
|
def make_install_targets(self):
|
||||||
if self.buildEnv.platformInfo.build in ("iOS", "wasm"):
|
if self.buildEnv.configInfo.build in ("iOS", "wasm"):
|
||||||
yield "install"
|
yield "install"
|
||||||
else:
|
else:
|
||||||
yield "install-strip"
|
yield "install-strip"
|
||||||
|
@ -390,12 +390,12 @@ class MakeBuilder(Builder):
|
||||||
@property
|
@property
|
||||||
def all_configure_options(self):
|
def all_configure_options(self):
|
||||||
yield from self.configure_options
|
yield from self.configure_options
|
||||||
if self.buildEnv.platformInfo.static:
|
if self.buildEnv.configInfo.static:
|
||||||
yield from self.static_configure_options
|
yield from self.static_configure_options
|
||||||
else:
|
else:
|
||||||
yield from self.dynamic_configure_options
|
yield from self.dynamic_configure_options
|
||||||
if not self.target.force_native_build:
|
if not self.target.force_native_build:
|
||||||
yield from self.buildEnv.platformInfo.configure_options
|
yield from self.buildEnv.configInfo.configure_options
|
||||||
yield from ("--prefix", self.buildEnv.install_dir)
|
yield from ("--prefix", self.buildEnv.install_dir)
|
||||||
yield from ("--libdir", pj(self.buildEnv.install_dir, self.buildEnv.libprefix))
|
yield from ("--libdir", pj(self.buildEnv.install_dir, self.buildEnv.libprefix))
|
||||||
|
|
||||||
|
@ -532,7 +532,7 @@ class MesonBuilder(Builder):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def library_type(self):
|
def library_type(self):
|
||||||
return "static" if self.buildEnv.platformInfo.static else "shared"
|
return "static" if self.buildEnv.configInfo.static else "shared"
|
||||||
|
|
||||||
def _configure(self, context):
|
def _configure(self, context):
|
||||||
context.try_skip(self.build_path)
|
context.try_skip(self.build_path)
|
||||||
|
@ -569,9 +569,9 @@ class MesonBuilder(Builder):
|
||||||
|
|
||||||
def _test(self, context):
|
def _test(self, context):
|
||||||
context.try_skip(self.build_path)
|
context.try_skip(self.build_path)
|
||||||
if self.buildEnv.platformInfo.build == "android" or (
|
if self.buildEnv.configInfo.build == "android" or (
|
||||||
self.buildEnv.platformInfo.build != "native"
|
self.buildEnv.configInfo.build != "native"
|
||||||
and not self.buildEnv.platformInfo.static
|
and not self.buildEnv.configInfo.static
|
||||||
):
|
):
|
||||||
raise SkipCommand()
|
raise SkipCommand()
|
||||||
command = [*neutralEnv("mesontest_command"), "--verbose", *self.test_options]
|
command = [*neutralEnv("mesontest_command"), "--verbose", *self.test_options]
|
||||||
|
|
|
@ -58,8 +58,8 @@ class Icu(Dependency):
|
||||||
make_install_targets = ["install"]
|
make_install_targets = ["install"]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_dependencies(cls, platformInfo, allDeps):
|
def get_dependencies(cls, configInfo, allDeps):
|
||||||
plt = "native_static" if platformInfo.static else "native_dyn"
|
plt = "native_static" if configInfo.static else "native_dyn"
|
||||||
return [(plt, "icu4c")]
|
return [(plt, "icu4c")]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -71,14 +71,14 @@ class Icu(Dependency):
|
||||||
yield "--enable-rpath"
|
yield "--enable-rpath"
|
||||||
yield "--disable-icuio"
|
yield "--disable-icuio"
|
||||||
yield "--disable-layoutex"
|
yield "--disable-layoutex"
|
||||||
platformInfo = self.buildEnv.platformInfo
|
configInfo = self.buildEnv.configInfo
|
||||||
if platformInfo.build != "native":
|
if configInfo.build != "native":
|
||||||
icu_native_builder = get_target_step(
|
icu_native_builder = get_target_step(
|
||||||
"icu4c", "native_static" if platformInfo.static else "native_dyn"
|
"icu4c", "native_static" if configInfo.static else "native_dyn"
|
||||||
)
|
)
|
||||||
yield f"--with-cross-build={icu_native_builder.build_path}"
|
yield f"--with-cross-build={icu_native_builder.build_path}"
|
||||||
yield "--disable-tools"
|
yield "--disable-tools"
|
||||||
if platformInfo.build in ("android", "wasm"):
|
if configInfo.build in ("android", "wasm"):
|
||||||
yield "--with-data-packaging=archive"
|
yield "--with-data-packaging=archive"
|
||||||
|
|
||||||
def set_env(self, env):
|
def set_env(self, env):
|
||||||
|
@ -87,7 +87,7 @@ class Icu(Dependency):
|
||||||
)
|
)
|
||||||
|
|
||||||
def _post_configure_script(self, context):
|
def _post_configure_script(self, context):
|
||||||
if self.buildEnv.platformInfo.build != "wasm":
|
if self.buildEnv.configInfo.build != "wasm":
|
||||||
context.skip()
|
context.skip()
|
||||||
context.try_skip(self.build_path)
|
context.try_skip(self.build_path)
|
||||||
for line in fileinput.input(pj(self.build_path, "Makefile"), inplace=True):
|
for line in fileinput.input(pj(self.build_path, "Makefile"), inplace=True):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from kiwixbuild.platforms import PlatformInfo
|
from kiwixbuild.configs import ConfigInfo
|
||||||
from kiwixbuild.utils import pj, copy_tree, run_command
|
from kiwixbuild.utils import pj, copy_tree, run_command
|
||||||
from kiwixbuild._global import option
|
from kiwixbuild._global import option
|
||||||
from .base import Dependency, NoopSource, Builder as BaseBuilder
|
from .base import Dependency, NoopSource, Builder as BaseBuilder
|
||||||
|
@ -18,7 +18,7 @@ class IOSFatLib(Dependency):
|
||||||
return [("iOS_{}".format(arch), base_target) for arch in option("ios_arch")]
|
return [("iOS_{}".format(arch), base_target) for arch in option("ios_arch")]
|
||||||
|
|
||||||
def _copy_headers(self, context):
|
def _copy_headers(self, context):
|
||||||
plt = PlatformInfo.get_platform("iOS_{}".format(option("ios_arch")[0]))
|
plt = ConfigInfo.get_config("iOS_{}".format(option("ios_arch")[0]))
|
||||||
include_src = pj(plt.buildEnv.install_dir, "include")
|
include_src = pj(plt.buildEnv.install_dir, "include")
|
||||||
include_dst = pj(self.buildEnv.install_dir, "include")
|
include_dst = pj(self.buildEnv.install_dir, "include")
|
||||||
copy_tree(include_src, include_dst)
|
copy_tree(include_src, include_dst)
|
||||||
|
@ -26,7 +26,7 @@ class IOSFatLib(Dependency):
|
||||||
def _merge_libs(self, context):
|
def _merge_libs(self, context):
|
||||||
lib_dirs = []
|
lib_dirs = []
|
||||||
for arch in option("ios_arch"):
|
for arch in option("ios_arch"):
|
||||||
plt = PlatformInfo.get_platform("iOS_{}".format(arch))
|
plt = ConfigInfo.get_config("iOS_{}".format(arch))
|
||||||
lib_dirs.append(pj(plt.buildEnv.install_dir, "lib"))
|
lib_dirs.append(pj(plt.buildEnv.install_dir, "lib"))
|
||||||
libs = []
|
libs = []
|
||||||
for f in os.listdir(lib_dirs[0]):
|
for f in os.listdir(lib_dirs[0]):
|
||||||
|
|
|
@ -18,11 +18,11 @@ class KiwixDesktop(Dependency):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def configure_options(self):
|
def configure_options(self):
|
||||||
if self.buildEnv.platformInfo.name == "flatpak":
|
if self.buildEnv.configInfo.name == "flatpak":
|
||||||
yield "QMAKE_INCDIR+=/app/include/QtWebEngine"
|
yield "QMAKE_INCDIR+=/app/include/QtWebEngine"
|
||||||
yield "QMAKE_INCDIR+=/app/include/QtWebEngineCore"
|
yield "QMAKE_INCDIR+=/app/include/QtWebEngineCore"
|
||||||
yield "QMAKE_INCDIR+=/app/include/QtWebEngineWidgets"
|
yield "QMAKE_INCDIR+=/app/include/QtWebEngineWidgets"
|
||||||
else:
|
else:
|
||||||
yield f"PREFIX={self.buildEnv.install_dir}"
|
yield f"PREFIX={self.buildEnv.install_dir}"
|
||||||
if self.buildEnv.platformInfo.static:
|
if self.buildEnv.configInfo.static:
|
||||||
yield "CONFIG+=static"
|
yield "CONFIG+=static"
|
||||||
|
|
|
@ -14,5 +14,5 @@ class KiwixTools(Dependency):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def configure_options(self):
|
def configure_options(self):
|
||||||
if self.buildEnv.platformInfo.static:
|
if self.buildEnv.configInfo.static:
|
||||||
yield "-Dstatic-linkage=true"
|
yield "-Dstatic-linkage=true"
|
||||||
|
|
|
@ -29,25 +29,25 @@ class Libkiwix(Dependency):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def build_type(self):
|
def build_type(self):
|
||||||
if self.buildEnv.platformInfo.build == "android":
|
if self.buildEnv.configInfo.build == "android":
|
||||||
return "debug"
|
return "debug"
|
||||||
return super().build_type
|
return super().build_type
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def configure_options(self):
|
def configure_options(self):
|
||||||
platformInfo = self.buildEnv.platformInfo
|
configInfo = self.buildEnv.configInfo
|
||||||
if platformInfo.build == "android":
|
if configInfo.build == "android":
|
||||||
yield "-Dstatic-linkage=true"
|
yield "-Dstatic-linkage=true"
|
||||||
yield "-Dwerror=false"
|
yield "-Dwerror=false"
|
||||||
if platformInfo.build == "iOS":
|
if configInfo.build == "iOS":
|
||||||
yield "-Db_bitcode=true"
|
yield "-Db_bitcode=true"
|
||||||
if platformInfo.name == "flatpak":
|
if configInfo.name == "flatpak":
|
||||||
yield "--wrap-mode=nodownload"
|
yield "--wrap-mode=nodownload"
|
||||||
if platformInfo.mixed and option("target") == "libkiwix":
|
if configInfo.mixed and option("target") == "libkiwix":
|
||||||
yield "-Dstatic-linkage=true"
|
yield "-Dstatic-linkage=true"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def library_type(self):
|
def library_type(self):
|
||||||
if self.buildEnv.platformInfo.build == "android":
|
if self.buildEnv.configInfo.build == "android":
|
||||||
return "shared"
|
return "shared"
|
||||||
return super().library_type
|
return super().library_type
|
||||||
|
|
|
@ -31,14 +31,14 @@ class LibMagic(Dependency):
|
||||||
yield "--disable-lzlib"
|
yield "--disable-lzlib"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_dependencies(cls, platformInfo, allDeps):
|
def get_dependencies(cls, configInfo, allDeps):
|
||||||
if platformInfo.build != "native":
|
if configInfo.build != "native":
|
||||||
return [("native_static", "libmagic")]
|
return [("native_static", "libmagic")]
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def _compile(self, context):
|
def _compile(self, context):
|
||||||
platformInfo = self.buildEnv.platformInfo
|
configInfo = self.buildEnv.configInfo
|
||||||
if platformInfo.build == "native":
|
if configInfo.build == "native":
|
||||||
return super()._compile(context)
|
return super()._compile(context)
|
||||||
context.try_skip(self.build_path)
|
context.try_skip(self.build_path)
|
||||||
command = ["make", "-j4", *self.make_targets, *self.make_options]
|
command = ["make", "-j4", *self.make_targets, *self.make_options]
|
||||||
|
|
|
@ -16,37 +16,37 @@ class Libzim(Dependency):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def build_type(self):
|
def build_type(self):
|
||||||
if self.buildEnv.platformInfo.build == "android":
|
if self.buildEnv.configInfo.build == "android":
|
||||||
return "debug"
|
return "debug"
|
||||||
return super().build_type
|
return super().build_type
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_dependencies(cls, platformInfo, allDeps):
|
def get_dependencies(cls, configInfo, allDeps):
|
||||||
deps = ["lzma", "zstd", "xapian-core", "icu4c"]
|
deps = ["lzma", "zstd", "xapian-core", "icu4c"]
|
||||||
if platformInfo.name not in ("flatpak", "wasm"):
|
if configInfo.name not in ("flatpak", "wasm"):
|
||||||
deps.append("zim-testing-suite")
|
deps.append("zim-testing-suite")
|
||||||
return deps
|
return deps
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def configure_options(self):
|
def configure_options(self):
|
||||||
platformInfo = self.buildEnv.platformInfo
|
configInfo = self.buildEnv.configInfo
|
||||||
if platformInfo.build == "android":
|
if configInfo.build == "android":
|
||||||
yield "-DUSE_BUFFER_HEADER=false"
|
yield "-DUSE_BUFFER_HEADER=false"
|
||||||
yield "-Dstatic-linkage=true"
|
yield "-Dstatic-linkage=true"
|
||||||
if platformInfo.mixed and option("target") == "libzim":
|
if configInfo.mixed and option("target") == "libzim":
|
||||||
yield "-Dstatic-linkage=true"
|
yield "-Dstatic-linkage=true"
|
||||||
if platformInfo.name == "flatpak":
|
if configInfo.name == "flatpak":
|
||||||
yield "--wrap-mode=nodownload"
|
yield "--wrap-mode=nodownload"
|
||||||
yield "-Dtest_data_dir=none"
|
yield "-Dtest_data_dir=none"
|
||||||
if platformInfo.name == "wasm":
|
if configInfo.name == "wasm":
|
||||||
yield "-Dexamples=false"
|
yield "-Dexamples=false"
|
||||||
yield "-DUSE_MMAP=false"
|
yield "-DUSE_MMAP=false"
|
||||||
if platformInfo.name not in ("flatpak", "wasm"):
|
if configInfo.name not in ("flatpak", "wasm"):
|
||||||
zim_testing_suite = get_target_step("zim-testing-suite", "source")
|
zim_testing_suite = get_target_step("zim-testing-suite", "source")
|
||||||
yield "-Dtest_data_dir={}".format(zim_testing_suite.source_path)
|
yield "-Dtest_data_dir={}".format(zim_testing_suite.source_path)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def library_type(self):
|
def library_type(self):
|
||||||
if self.buildEnv.platformInfo.build == "android":
|
if self.buildEnv.configInfo.build == "android":
|
||||||
return "shared"
|
return "shared"
|
||||||
return super().library_type
|
return super().library_type
|
||||||
|
|
|
@ -25,12 +25,12 @@ class Qt(Dependency):
|
||||||
@property
|
@property
|
||||||
def all_configure_options(self):
|
def all_configure_options(self):
|
||||||
yield from self.configure_options
|
yield from self.configure_options
|
||||||
if self.buildEnv.platformInfo.static:
|
if self.buildEnv.configInfo.static:
|
||||||
yield from self.static_configure_options
|
yield from self.static_configure_options
|
||||||
else:
|
else:
|
||||||
yield from self.dynamic_configure_options
|
yield from self.dynamic_configure_options
|
||||||
if not self.target.force_native_build:
|
if not self.target.force_native_build:
|
||||||
yield from self.buildEnv.platformInfo.configure_options
|
yield from self.buildEnv.configInfo.configure_options
|
||||||
yield from ("-prefix", self.buildEnv.install_dir)
|
yield from ("-prefix", self.buildEnv.install_dir)
|
||||||
yield from (
|
yield from (
|
||||||
"-libdir",
|
"-libdir",
|
||||||
|
|
|
@ -34,18 +34,18 @@ class android_ndk(Dependency):
|
||||||
return self.target.api
|
return self.target.api
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def platform(self):
|
def config(self):
|
||||||
return "android-" + self.api
|
return "android-" + self.api
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def arch(self):
|
def arch(self):
|
||||||
return self.buildEnv.platformInfo.arch
|
return self.buildEnv.configInfo.arch
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def arch_full(self):
|
def arch_full(self):
|
||||||
return self.buildEnv.platformInfo.arch_full
|
return self.buildEnv.configInfo.arch_full
|
||||||
|
|
||||||
def _build_platform(self, context):
|
def _build_toolchain(self, context):
|
||||||
context.try_skip(self.build_path)
|
context.try_skip(self.build_path)
|
||||||
script = pj(self.source_path, "build/tools/make_standalone_toolchain.py")
|
script = pj(self.source_path, "build/tools/make_standalone_toolchain.py")
|
||||||
add_execution_right(script)
|
add_execution_right(script)
|
||||||
|
@ -85,5 +85,5 @@ class android_ndk(Dependency):
|
||||||
add_execution_right(file_path)
|
add_execution_right(file_path)
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
self.command("build_platform", self._build_platform)
|
self.command("build_toolchain", self._build_toolchain)
|
||||||
self.command("fix_permission_right", self._fix_permission_right)
|
self.command("fix_permission_right", self._fix_permission_right)
|
||||||
|
|
|
@ -26,10 +26,10 @@ class Xapian(Dependency):
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_dependencies(cls, platformInfo, allDeps):
|
def get_dependencies(cls, configInfo, allDeps):
|
||||||
deps = ["zlib", "lzma"]
|
deps = ["zlib", "lzma"]
|
||||||
if (
|
if (
|
||||||
platformInfo.build in ("win32", "wasm")
|
configInfo.build in ("win32", "wasm")
|
||||||
or neutralEnv("distname") == "Darwin"
|
or neutralEnv("distname") == "Darwin"
|
||||||
):
|
):
|
||||||
return deps
|
return deps
|
||||||
|
|
|
@ -11,16 +11,16 @@ class ZimTools(Dependency):
|
||||||
|
|
||||||
class Builder(MesonBuilder):
|
class Builder(MesonBuilder):
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_dependencies(cls, platformInfo, allDeps):
|
def get_dependencies(cls, configInfo, allDeps):
|
||||||
base_deps = ["libzim", "docoptcpp", "mustache"]
|
base_deps = ["libzim", "docoptcpp", "mustache"]
|
||||||
if platformInfo.build != "win32":
|
if configInfo.build != "win32":
|
||||||
base_deps += ["libmagic", "gumbo"]
|
base_deps += ["libmagic", "gumbo"]
|
||||||
return base_deps
|
return base_deps
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def configure_options(self):
|
def configure_options(self):
|
||||||
# We don't build zimwriterfs on win32, and so we don't have magic
|
# We don't build zimwriterfs on win32, and so we don't have magic
|
||||||
if self.buildEnv.platformInfo.build != "win32":
|
if self.buildEnv.configInfo.build != "win32":
|
||||||
yield f"-Dmagic-install-prefix={self.buildEnv.install_dir}"
|
yield f"-Dmagic-install-prefix={self.buildEnv.install_dir}"
|
||||||
if self.buildEnv.platformInfo.static:
|
if self.buildEnv.configInfo.static:
|
||||||
yield "-Dstatic-linkage=true"
|
yield "-Dstatic-linkage=true"
|
||||||
|
|
|
@ -25,14 +25,14 @@ class zlib(Dependency):
|
||||||
shutil.copytree(self.source_path, self.build_path)
|
shutil.copytree(self.source_path, self.build_path)
|
||||||
|
|
||||||
def _configure(self, context):
|
def _configure(self, context):
|
||||||
if self.buildEnv.platformInfo.build == "win32":
|
if self.buildEnv.configInfo.build == "win32":
|
||||||
raise SkipCommand()
|
raise SkipCommand()
|
||||||
return super()._configure(context)
|
return super()._configure(context)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def all_configure_options(self):
|
def all_configure_options(self):
|
||||||
yield from self.configure_options
|
yield from self.configure_options
|
||||||
yield from self.static_configure_options if self.buildEnv.platformInfo.static else self.dynamic_configure_options
|
yield from self.static_configure_options if self.buildEnv.configInfo.static else self.dynamic_configure_options
|
||||||
yield from ("--prefix", self.buildEnv.install_dir)
|
yield from ("--prefix", self.buildEnv.install_dir)
|
||||||
yield from (
|
yield from (
|
||||||
"--libdir",
|
"--libdir",
|
||||||
|
@ -41,13 +41,13 @@ class zlib(Dependency):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def make_options(self):
|
def make_options(self):
|
||||||
if self.buildEnv.platformInfo.build != "win32":
|
if self.buildEnv.configInfo.build != "win32":
|
||||||
return
|
return
|
||||||
yield "--makefile"
|
yield "--makefile"
|
||||||
yield "win32/Makefile.gcc"
|
yield "win32/Makefile.gcc"
|
||||||
yield "PREFIX=i686-w64-mingw32-",
|
yield "PREFIX=i686-w64-mingw32-",
|
||||||
yield "SHARED_MODE={}".format(
|
yield "SHARED_MODE={}".format(
|
||||||
"0" if self.buildEnv.platformInfo.static else "1"
|
"0" if self.buildEnv.configInfo.static else "1"
|
||||||
),
|
),
|
||||||
yield "INCLUDE_PATH={}".format(pj(self.buildEnv.install_dir, "include")),
|
yield "INCLUDE_PATH={}".format(pj(self.buildEnv.install_dir, "include")),
|
||||||
yield "LIBRARY_PATH={}".format(
|
yield "LIBRARY_PATH={}".format(
|
||||||
|
@ -57,7 +57,7 @@ class zlib(Dependency):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def make_targets(self):
|
def make_targets(self):
|
||||||
if self.buildEnv.platformInfo.static:
|
if self.buildEnv.configInfo.static:
|
||||||
return ["static"]
|
return ["static"]
|
||||||
else:
|
else:
|
||||||
return ["shared"]
|
return ["shared"]
|
||||||
|
|
|
@ -2,7 +2,7 @@ import sys
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from .buildenv import *
|
from .buildenv import *
|
||||||
|
|
||||||
from .platforms import PlatformInfo
|
from .configs import ConfigInfo
|
||||||
from .utils import remove_duplicates, run_command, StopBuild, Context
|
from .utils import remove_duplicates, run_command, StopBuild, Context
|
||||||
from .dependencies import Dependency
|
from .dependencies import Dependency
|
||||||
from .packages import PACKAGE_NAME_MAPPERS
|
from .packages import PACKAGE_NAME_MAPPERS
|
||||||
|
@ -77,16 +77,16 @@ GET_REF_URL_API_TEMPLATE = "https://api.github.com/repos{repo}/git/refs/tags/{re
|
||||||
class FlatpakBuilder:
|
class FlatpakBuilder:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._targets = {}
|
self._targets = {}
|
||||||
PlatformInfo.get_platform("neutral", self._targets)
|
ConfigInfo.get_config("neutral", self._targets)
|
||||||
self.platform = PlatformInfo.get_platform("flatpak", self._targets)
|
self.config = ConfigInfo.get_config("flatpak", self._targets)
|
||||||
if neutralEnv("distname") not in self.platform.compatible_hosts:
|
if neutralEnv("distname") not in self.config.compatible_hosts:
|
||||||
print(
|
print(
|
||||||
(
|
(
|
||||||
"ERROR: The target platform {} cannot be build on host {}.\n"
|
"ERROR: The config {} cannot be build on host {}.\n"
|
||||||
"Select another target platform or change your host system."
|
"Select another config or change your host system."
|
||||||
).format(self.platform.name, neutralEnv("distname"))
|
).format(self.config.name, neutralEnv("distname"))
|
||||||
)
|
)
|
||||||
self.targetDefs = self.platform.add_targets(option("target"), self._targets)
|
self.targetDefs = self.config.add_targets(option("target"), self._targets)
|
||||||
|
|
||||||
def finalize_target_steps(self):
|
def finalize_target_steps(self):
|
||||||
steps = []
|
steps = []
|
||||||
|
@ -94,14 +94,14 @@ class FlatpakBuilder:
|
||||||
steps += self.order_steps(targetDef)
|
steps += self.order_steps(targetDef)
|
||||||
steps = list(remove_duplicates(steps))
|
steps = list(remove_duplicates(steps))
|
||||||
|
|
||||||
for pltName in PlatformInfo.all_running_platforms:
|
for cfgName in ConfigInfo.all_running_configs:
|
||||||
plt = PlatformInfo.all_platforms[pltName]
|
cfg = ConfigInfo.all_configs[cfgName]
|
||||||
for tlcName in plt.toolchain_names:
|
for tlcName in cfg.toolchain_names:
|
||||||
tlc = Dependency.all_deps[tlcName]
|
tlc = Dependency.all_deps[tlcName]
|
||||||
src_plt_step = ("source", tlcName)
|
src_cfg_step = ("source", tlcName)
|
||||||
add_target_step(src_plt_step, self._targets[src_plt_step])
|
add_target_step(src_cfg_step, self._targets[src_cfg_step])
|
||||||
blt_plt_step = ("neutral" if tlc.neutral else pltName, tlcName)
|
blt_cfg_step = ("neutral" if tlc.neutral else cfgName, tlcName)
|
||||||
add_target_step(blt_plt_step, self._targets[blt_plt_step])
|
add_target_step(blt_cfg_step, self._targets[blt_cfg_step])
|
||||||
|
|
||||||
for dep in steps:
|
for dep in steps:
|
||||||
add_target_step(dep, self._targets[dep])
|
add_target_step(dep, self._targets[dep])
|
||||||
|
@ -112,8 +112,8 @@ class FlatpakBuilder:
|
||||||
yield from self.order_dependencies(targetDef, _targets)
|
yield from self.order_dependencies(targetDef, _targets)
|
||||||
|
|
||||||
def order_dependencies(self, targetDef, targets):
|
def order_dependencies(self, targetDef, targets):
|
||||||
targetPlatformName, targetName = targetDef
|
targetConfigName, targetName = targetDef
|
||||||
if targetPlatformName == "source":
|
if targetConfigName == "source":
|
||||||
# Do not try to order sources, they will be added as dep by the
|
# Do not try to order sources, they will be added as dep by the
|
||||||
# build step two lines later.
|
# build step two lines later.
|
||||||
return
|
return
|
||||||
|
@ -122,27 +122,27 @@ class FlatpakBuilder:
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return
|
return
|
||||||
|
|
||||||
targetPlatform = PlatformInfo.get_platform(targetPlatformName)
|
targetConfig = ConfigInfo.get_config(targetConfigName)
|
||||||
for dep in target.get_dependencies(targetPlatform, True):
|
for dep in target.get_dependencies(targetConfig, True):
|
||||||
if isinstance(dep, tuple):
|
if isinstance(dep, tuple):
|
||||||
depPlatform, depName = dep
|
depConfig, depName = dep
|
||||||
else:
|
else:
|
||||||
depPlatform, depName = targetPlatformName, dep
|
depConfig, depName = targetConfigName, dep
|
||||||
if (depPlatform, depName) in targets:
|
if (depConfig, depName) in targets:
|
||||||
yield from self.order_dependencies((depPlatform, depName), targets)
|
yield from self.order_dependencies((depConfig, depName), targets)
|
||||||
yield ("source", targetName)
|
yield ("source", targetName)
|
||||||
yield targetDef
|
yield targetDef
|
||||||
|
|
||||||
def instanciate_steps(self):
|
def instanciate_steps(self):
|
||||||
for stepDef in list(target_steps()):
|
for stepDef in list(target_steps()):
|
||||||
stepPlatform, stepName = stepDef
|
stepConfig, stepName = stepDef
|
||||||
stepClass = Dependency.all_deps[stepName]
|
stepClass = Dependency.all_deps[stepName]
|
||||||
if stepPlatform == "source":
|
if stepConfig == "source":
|
||||||
source = get_target_step(stepDef)(stepClass)
|
source = get_target_step(stepDef)(stepClass)
|
||||||
add_target_step(stepDef, source)
|
add_target_step(stepDef, source)
|
||||||
else:
|
else:
|
||||||
source = get_target_step(stepName, "source")
|
source = get_target_step(stepName, "source")
|
||||||
env = PlatformInfo.get_platform(stepPlatform).buildEnv
|
env = ConfigInfo.get_config(stepConfig).buildEnv
|
||||||
builder = get_target_step(stepDef)(stepClass, source, env)
|
builder = get_target_step(stepDef)(stepClass, source, env)
|
||||||
add_target_step(stepDef, builder)
|
add_target_step(stepDef, builder)
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ class FlatpakBuilder:
|
||||||
m["sources"] = temp
|
m["sources"] = temp
|
||||||
manifest["modules"] = modules
|
manifest["modules"] = modules
|
||||||
manifest_name = "{}.json".format(MANIFEST["app-id"])
|
manifest_name = "{}.json".format(MANIFEST["app-id"])
|
||||||
manifest_path = pj(self.platform.buildEnv.build_dir, manifest_name)
|
manifest_path = pj(self.config.buildEnv.build_dir, manifest_name)
|
||||||
with open(manifest_path, "w") as f:
|
with open(manifest_path, "w") as f:
|
||||||
f.write(json.dumps(manifest, indent=4))
|
f.write(json.dumps(manifest, indent=4))
|
||||||
|
|
||||||
|
@ -219,13 +219,13 @@ class FlatpakBuilder:
|
||||||
for p in source.patches:
|
for p in source.patches:
|
||||||
path = pj(SCRIPT_DIR, "patches", p)
|
path = pj(SCRIPT_DIR, "patches", p)
|
||||||
os.makedirs(
|
os.makedirs(
|
||||||
pj(self.platform.buildEnv.build_dir, "patches"), exist_ok=True
|
pj(self.config.buildEnv.build_dir, "patches"), exist_ok=True
|
||||||
)
|
)
|
||||||
dest = pj(self.platform.buildEnv.build_dir, "patches", p)
|
dest = pj(self.config.buildEnv.build_dir, "patches", p)
|
||||||
copyfile(path, dest)
|
copyfile(path, dest)
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
log = pj(self.platform.buildEnv.log_dir, "cmd_build_flatpak.log")
|
log = pj(self.config.buildEnv.log_dir, "cmd_build_flatpak.log")
|
||||||
context = Context("build", log, False)
|
context = Context("build", log, False)
|
||||||
command = [
|
command = [
|
||||||
"flatpak-builder",
|
"flatpak-builder",
|
||||||
|
@ -241,9 +241,9 @@ class FlatpakBuilder:
|
||||||
try:
|
try:
|
||||||
run_command(
|
run_command(
|
||||||
command,
|
command,
|
||||||
self.platform.buildEnv.build_dir,
|
self.config.buildEnv.build_dir,
|
||||||
context,
|
context,
|
||||||
env=self.platform.get_env(),
|
env=self.config.get_env(),
|
||||||
)
|
)
|
||||||
context._finalise()
|
context._finalise()
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
|
@ -252,16 +252,16 @@ class FlatpakBuilder:
|
||||||
raise StopBuild()
|
raise StopBuild()
|
||||||
|
|
||||||
def bundle(self):
|
def bundle(self):
|
||||||
log = pj(self.platform.buildEnv.log_dir, "cmd_bundle_flatpak.log")
|
log = pj(self.config.buildEnv.log_dir, "cmd_bundle_flatpak.log")
|
||||||
context = Context("bundle", log, False)
|
context = Context("bundle", log, False)
|
||||||
app_id = MANIFEST["app-id"]
|
app_id = MANIFEST["app-id"]
|
||||||
command = ["flatpak", "build-bundle", "repo", f"{app_id}.flatpak", app_id]
|
command = ["flatpak", "build-bundle", "repo", f"{app_id}.flatpak", app_id]
|
||||||
try:
|
try:
|
||||||
run_command(
|
run_command(
|
||||||
command,
|
command,
|
||||||
self.platform.buildEnv.build_dir,
|
self.config.buildEnv.build_dir,
|
||||||
context,
|
context,
|
||||||
env=self.platform.get_env(),
|
env=self.config.get_env(),
|
||||||
)
|
)
|
||||||
context._finalise()
|
context._finalise()
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
|
@ -274,7 +274,7 @@ class FlatpakBuilder:
|
||||||
|
|
||||||
to_drop = []
|
to_drop = []
|
||||||
for builderDef in self._targets:
|
for builderDef in self._targets:
|
||||||
platformName, builderName = builderDef
|
configName, builderName = builderDef
|
||||||
packages = package_name_mapper.get(builderName)
|
packages = package_name_mapper.get(builderName)
|
||||||
if packages:
|
if packages:
|
||||||
to_drop.append(builderDef)
|
to_drop.append(builderDef)
|
||||||
|
@ -288,16 +288,16 @@ class FlatpakBuilder:
|
||||||
# dependencies we already have in the sdk.
|
# dependencies we already have in the sdk.
|
||||||
self._get_packages()
|
self._get_packages()
|
||||||
self.finalize_target_steps()
|
self.finalize_target_steps()
|
||||||
print("[SETUP PLATFORMS]")
|
print("[SETUP TOOLCHAINS]")
|
||||||
for platform in PlatformInfo.all_running_platforms.values():
|
for config in ConfigInfo.all_running_configs.values():
|
||||||
platform.finalize_setup()
|
config.finalize_setup()
|
||||||
for pltName in PlatformInfo.all_running_platforms:
|
for cfgName in ConfigInfo.all_running_configs:
|
||||||
plt = PlatformInfo.all_platforms[pltName]
|
cfg = ConfigInfo.all_configs[cfgName]
|
||||||
for tlcName in plt.toolchain_names:
|
for tlcName in cfg.toolchain_names:
|
||||||
tlc = Dependency.all_deps[tlcName]
|
tlc = Dependency.all_deps[tlcName]
|
||||||
builderDef = (pltName, tlcName)
|
builderDef = (cfgName, tlcName)
|
||||||
builder = get_target_step(builderDef)
|
builder = get_target_step(builderDef)
|
||||||
print("build {} ({}):".format(builder.name, pltName[0]))
|
print("build {} ({}):".format(builder.name, cfgName[0]))
|
||||||
add_target_step(builderDef, builder)
|
add_target_step(builderDef, builder)
|
||||||
builder.build()
|
builder.build()
|
||||||
print("[GENERATE FLATPAK MANIFEST]")
|
print("[GENERATE FLATPAK MANIFEST]")
|
||||||
|
@ -310,8 +310,8 @@ class FlatpakBuilder:
|
||||||
# No error, clean intermediate file at end of build if needed.
|
# No error, clean intermediate file at end of build if needed.
|
||||||
print("[CLEAN]")
|
print("[CLEAN]")
|
||||||
if option("clean_at_end"):
|
if option("clean_at_end"):
|
||||||
for platform in PlatformInfo.all_running_platforms.values():
|
for config in ConfigInfo.all_running_configs.values():
|
||||||
platform.clean_intermediate_directories()
|
config.clean_intermediate_directories()
|
||||||
else:
|
else:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
except StopBuild:
|
except StopBuild:
|
||||||
|
|
Loading…
Reference in New Issue