mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-11-10 01:09:28 +08:00
[build] cache Xmake toolchains and reuse mobile dependencies
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build the native controller in isolation from desktop and iOS caches."""
|
||||
import argparse
|
||||
import fcntl
|
||||
import os
|
||||
from pathlib import Path
|
||||
@@ -26,7 +27,7 @@ def find_xmake():
|
||||
return xmake
|
||||
|
||||
|
||||
def main():
|
||||
def main(configure_only=False):
|
||||
sdk = Path(os.environ.get('ANDROID_HOME') or os.environ.get('ANDROID_SDK_ROOT')
|
||||
or Path.home() / 'Library/Android/sdk')
|
||||
ndk = sdk / 'ndk/28.2.13676358'
|
||||
@@ -45,13 +46,20 @@ def main():
|
||||
# and updates. Only installed Android packages/build products are isolated.
|
||||
subprocess.run([xmake, 'f', '-P', str(work), '-y', '-p', 'android', '-a', 'arm64-v8a',
|
||||
'-m', 'release', '--ndk=' + str(ndk), '--ndk_sdkver=26',
|
||||
'--runtimes=c++_static', '--policies=package.precompiled:n',
|
||||
'--runtimes=c++_static',
|
||||
'--policies=package.precompiled:n,package.librarydeps.strict_compatibility',
|
||||
'-o', str(CACHE / 'build')], cwd=work, env=env, check=True)
|
||||
if configure_only:
|
||||
return
|
||||
subprocess.run([xmake, '-P', str(work), '-y', 'crossdesk_android'], cwd=work, env=env, check=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--configure-only', action='store_true',
|
||||
help='Install native dependencies before compiling application targets.')
|
||||
args = parser.parse_args()
|
||||
CACHE.mkdir(parents=True, exist_ok=True)
|
||||
with (CACHE / 'build.lock').open('w') as lock:
|
||||
fcntl.flock(lock, fcntl.LOCK_EX)
|
||||
main()
|
||||
main(configure_only=args.configure_only)
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
CONFIGURE_ONLY=false
|
||||
if [[ $# -eq 1 && "$1" == "--configure-only" ]]; then
|
||||
CONFIGURE_ONLY=true
|
||||
elif [[ $# -ne 0 ]]; then
|
||||
print -u2 "Usage: $0 [--configure-only]"
|
||||
exit 64
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="${0:A:h}"
|
||||
IOS_DIR="${SCRIPT_DIR:h}"
|
||||
REPO_DIR="${IOS_DIR:h:h}"
|
||||
@@ -169,7 +177,7 @@ configure_xmake() {
|
||||
print "Configuring iOS native project: ${project_dir}"
|
||||
run_xmake f -P "${project_dir}" "${clean_flags[@]}" "${XMAKE_LOG_FLAGS[@]}" -o "${build_dir}" \
|
||||
-p iphoneos -a arm64 --appledev="${APPLE_DEVICE}" -m "${MODE}" --target_minver=16.0 \
|
||||
--policies=package.precompiled:n -y "$@"
|
||||
--policies=package.precompiled:n,package.librarydeps.strict_compatibility -y "$@"
|
||||
mkdir -p "${build_dir}"
|
||||
print -r -- "${CONFIG_SIGNATURE}" > "${stamp}"
|
||||
}
|
||||
@@ -182,6 +190,24 @@ configure_xmake() {
|
||||
configure_xmake "${MINIRTC_DIR}" "${MINIRTC_BUILD_DIR}" \
|
||||
--as="${XMAKE_TOOLCHAIN_BIN}/clang" --USE_CUDA=false \
|
||||
--MINIRTC_ENABLE_AOM="${MINIRTC_ENABLE_AOM}"
|
||||
)
|
||||
|
||||
# Build the platform-independent wire archive from the root project's target.
|
||||
# The copied manifest only isolates Xmake's generated configuration; there is
|
||||
# no second project definition to maintain.
|
||||
(
|
||||
cd "${WIRE_WORK_DIR}"
|
||||
configure_xmake "${WIRE_WORK_DIR}" "${WIRE_BUILD_DIR}" \
|
||||
--CROSSDESK_BUILD_DESKTOP=false --CROSSDESK_BUILD_CLI=false
|
||||
)
|
||||
|
||||
# CI can persist the installed packages before compiling either archive.
|
||||
if [[ "${CONFIGURE_ONLY}" == true ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
(
|
||||
cd "${MINIRTC_DIR}"
|
||||
print "Building MiniRTC for ${SDK_NAME} (${MODE})"
|
||||
run_xmake b -P "${MINIRTC_DIR}" "${XMAKE_LOG_FLAGS[@]}" minirtc
|
||||
)
|
||||
@@ -191,13 +217,8 @@ if [[ ! -f "${MINIRTC_LIBRARY}" ]]; then
|
||||
exit 66
|
||||
fi
|
||||
|
||||
# Build the platform-independent wire archive from the root project's target.
|
||||
# The copied manifest only isolates Xmake's generated configuration; there is
|
||||
# no second project definition to maintain.
|
||||
(
|
||||
cd "${WIRE_WORK_DIR}"
|
||||
configure_xmake "${WIRE_WORK_DIR}" "${WIRE_BUILD_DIR}" \
|
||||
--CROSSDESK_BUILD_DESKTOP=false --CROSSDESK_BUILD_CLI=false
|
||||
print "Building CrossDesk wire for ${SDK_NAME} (${MODE})"
|
||||
run_xmake b -P "${WIRE_WORK_DIR}" "${XMAKE_LOG_FLAGS[@]}" crossdesk_wire
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user