Skip to content

Commit bdc1bd2

Browse files
committed
Add build script for Saigo SDK (host-mode deps)
Add external_deps/sdk-build.sh which can be used as an alternative to auto-downloading Saigo. Like external_deps/build.sh, it builds the dependency package and installs it to the expected location. It is a thin wrapper around the saigo-nacl-sdk CMake build; if you need more control it is better to use CMake directly.
1 parent 4ea77bf commit bdc1bd2

4 files changed

Lines changed: 88 additions & 1 deletion

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ build
4040
#ignore external deps
4141
external_deps/*
4242
!external_deps/build.sh
43+
!external_deps/sdk-build.sh
4344
!external_deps/cygtar.py
4445
!external_deps/*.patch
4546

‎CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ endif()
197197

198198
# Dependencies versions
199199
set(DEPS_VERSION 11) # This must match the number in external_deps/build.sh
200-
set(SAIGOSDK_VERSION 20260925)
200+
set(SAIGOSDK_VERSION 20260925) # This must match the number in external_deps/sdk-build.sh
201201

202202
option(USE_EXTERNAL_DEPS "Download or reuse dependencies from EXTERNAL_DEPS_DIR (mandatory for building and running NaCl .nexe binaries)." ON)
203203

‎cmake/DaemonDependenciesDownload.cmake‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ set(SAIGOSDK_BASENAME saigosdk-${DEPS_SYSTEM}-${DEPS_ARCH}_${SAIGOSDK_VERSION})
3030
set(SAIGOSDK_ROOT ${EXTERNAL_DEPS_DIR}/${SAIGOSDK_BASENAME})
3131
set(SAIGOSDK_ROOT "${SAIGOSDK_ROOT}" PARENT_SCOPE)
3232

33+
# As an alternative to downloading, external_deps/sdk-build.sh can be used, to build the host-mode
34+
# dependencies and install them in the expected path.
3335
function(download_saigosdk)
3436
if (NOT EXISTS ${SAIGOSDK_ROOT})
3537
set(DEPS_FILENAME "${SAIGOSDK_BASENAME}.tar.xz")

‎external_deps/sdk-build.sh‎

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env bash
2+
3+
# Exit on undefined variable and error.
4+
set -u -e -o pipefail
5+
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
7+
WORK_DIR="${PWD}"
8+
DOWNLOAD_DIR="${WORK_DIR}/download_cache"
9+
10+
# This should match the SAIGOSDK_VERSION in CMakeLists.txt.
11+
# This is mostly to ensure the path the files end up at if you build deps yourself
12+
# are the same as the ones when extracting from the downloaded packages.
13+
SAIGOSDK_VERSION=20260925
14+
# Can be a tag like v${SAIGOSDK_VERSION}, or a full commit hash
15+
SAIGOSDK_REF=cbd46205f43ed956382f6bcd88e51ccd9aeb12ee
16+
17+
REPO_BASENAME=saigo-nacl-sdk
18+
REPO_URL="https://github.com/DaemonEngine/${REPO_BASENAME}"
19+
ARCHIVE_PATH="${DOWNLOAD_DIR}/saigosdk-${SAIGOSDK_REF}.tar.gz"
20+
21+
usage() {
22+
echo "Usage: $0 <os>-<arch> (build | install | package | wipe)..."
23+
echo "<os>-<arch> should normally be your current native platform."
24+
echo "For a list of supported platforms see ${REPO_URL}/tree/master/tools/release/conf"
25+
echo "Actions:"
26+
echo " build - build all tools and libraries in the SDK"
27+
echo " install - install final build products to ${WORK_DIR}/saigosdk-<os>-<arch>_${SAIGOSDK_VERSION}/"
28+
echo " wipe - delete build products (except download cache) AND install directory"
29+
echo "If you want to build only a subset of packages, prefer using the"
30+
echo "${REPO_URL} CMake build directly."
31+
echo "Some global configuration options are available via environment"
32+
echo "variables; see ${REPO_URL}/tree/master/tools/release/build"
33+
}
34+
35+
download() {
36+
test -f "${ARCHIVE_PATH}" && return
37+
mkdir -p "${DOWNLOAD_DIR}"
38+
if grep -q -E '^[0-9a-f]{40}$' <<< "${SAIGOSDK_REF}"
39+
then
40+
DOWNLOAD_URL="https://github.com/DaemonEngine/saigo-nacl-sdk/archive/${SAIGOSDK_REF}.tar.gz"
41+
elif grep -q -E '^v[0-9]' <<< "${SAIGOSDK_REF}"
42+
then
43+
DOWNLOAD_URL="https://github.com/DaemonEngine/saigo-nacl-sdk/archive/refs/tags/${SAIGOSDK_REF}.tar.gz"
44+
fi
45+
curl --fail -L "${DOWNLOAD_URL}" -o "${ARCHIVE_PATH}"
46+
}
47+
48+
if [ "$#" -lt 2 ]
49+
then
50+
usage
51+
exit 1
52+
fi
53+
54+
PLATFORM="$1"
55+
shift
56+
57+
INSTALL_DIR="${WORK_DIR}/saigosdk-${PLATFORM}_${SAIGOSDK_VERSION}"
58+
BUILD_DIR="${WORK_DIR}/build-saigosdk_${SAIGOSDK_VERSION}"
59+
REPO_DIR="${BUILD_DIR}/${REPO_BASENAME}-${SAIGOSDK_REF}" # stupid wrapping directory in the tarball...
60+
61+
for target in "$@"
62+
do
63+
case "${target}" in
64+
build)
65+
download
66+
mkdir -p "${BUILD_DIR}"
67+
tar xzf "${ARCHIVE_PATH}" -C "${BUILD_DIR}"
68+
(
69+
cd "${REPO_DIR}"
70+
tools/release/build "${PLATFORM}"
71+
)
72+
;;
73+
install)
74+
cp -R "${REPO_DIR}/build/${PLATFORM}/install/." "${INSTALL_DIR}/"
75+
;;
76+
wipe)
77+
rm -rf "${BUILD_DIR}" "${INSTALL_DIR}"
78+
;;
79+
*)
80+
usage
81+
exit 1
82+
;;
83+
esac
84+
done

0 commit comments

Comments
 (0)