Skip to content

Commit ca7eaed

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 ca7eaed

4 files changed

Lines changed: 92 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: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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=20261013
14+
# Can be a tag like v${SAIGOSDK_VERSION}, or a full commit hash
15+
SAIGOSDK_REF="v${SAIGOSDK_VERSION}"
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+
curl --fail -L "${DOWNLOAD_URL}" -o "${ARCHIVE_PATH}"
39+
}
40+
41+
if [ "$#" -lt 2 ]
42+
then
43+
usage
44+
exit 1
45+
fi
46+
47+
PLATFORM="$1"
48+
shift
49+
50+
if grep -q -E '^[0-9a-f]{40}$' <<< "${SAIGOSDK_REF}"
51+
then
52+
DOWNLOAD_URL="https://github.com/DaemonEngine/saigo-nacl-sdk/archive/${SAIGOSDK_REF}.tar.gz"
53+
TARBALL_OUTER_DIR="${REPO_BASENAME}-${SAIGOSDK_REF}"
54+
elif grep -q -E '^v[0-9]' <<< "${SAIGOSDK_REF}"
55+
then
56+
# The 'v' from the tag name is mysteriously removed???
57+
TARBALL_OUTER_DIR="${REPO_BASENAME}-${SAIGOSDK_REF:1}"
58+
DOWNLOAD_URL="https://github.com/DaemonEngine/saigo-nacl-sdk/archive/refs/tags/${SAIGOSDK_REF}.tar.gz"
59+
fi
60+
61+
INSTALL_DIR="${WORK_DIR}/saigosdk-${PLATFORM}_${SAIGOSDK_VERSION}"
62+
BUILD_DIR="${WORK_DIR}/build-saigosdk_${SAIGOSDK_VERSION}"
63+
REPO_DIR="${BUILD_DIR}/${TARBALL_OUTER_DIR}"
64+
65+
for target in "$@"
66+
do
67+
case "${target}" in
68+
build)
69+
download
70+
mkdir -p "${BUILD_DIR}"
71+
tar xzf "${ARCHIVE_PATH}" -C "${BUILD_DIR}"
72+
(
73+
cd "${REPO_DIR}"
74+
tools/release/build "${PLATFORM}"
75+
)
76+
;;
77+
install)
78+
cp -R "${REPO_DIR}/build/${PLATFORM}/install/." "${INSTALL_DIR}/"
79+
;;
80+
wipe)
81+
rm -rf "${BUILD_DIR}" "${INSTALL_DIR}"
82+
;;
83+
*)
84+
usage
85+
exit 1
86+
;;
87+
esac
88+
done

0 commit comments

Comments
 (0)