Repository navigation
Auto-download Saigo SDK for any supported host platform #2010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # Daemon BSD Source Code | ||
| # Copyright (c) 2013-2026, Daemon Developers | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions are met: | ||
| # * Redistributions of source code must retain the above copyright | ||
| # notice, this list of conditions and the following disclaimer. | ||
| # * Redistributions in binary form must reproduce the above copyright | ||
| # notice, this list of conditions and the following disclaimer in the | ||
| # documentation and/or other materials provided with the distribution. | ||
| # * Neither the name of the Daemon developers nor the | ||
| # names of its contributors may be used to endorse or promote products | ||
| # derived from this software without specific prior written permission. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
| # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
| # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| # DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY | ||
| # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
| # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
| # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
| # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
|
||
| # TODO: Move other deps downloading code in here. | ||
|
|
||
| set(SAIGOSDK_BASENAME saigosdk-${DEPS_SYSTEM}-${DEPS_ARCH}_${SAIGOSDK_VERSION}) | ||
| set(SAIGOSDK_ROOT ${EXTERNAL_DEPS_DIR}/${SAIGOSDK_BASENAME}) | ||
| set(SAIGOSDK_ROOT "${SAIGOSDK_ROOT}" PARENT_SCOPE) | ||
|
|
||
| # As an alternative to downloading, external_deps/sdk-build.sh can be used, to build the host-mode | ||
| # dependencies and install them in the expected path. | ||
| function(download_saigosdk) | ||
| if (NOT EXISTS ${SAIGOSDK_ROOT}) | ||
| set(DEPS_FILENAME "${SAIGOSDK_BASENAME}.tar.xz") | ||
| set(REMOTE "https://github.com/DaemonEngine/saigo-nacl-sdk/releases/download/v${SAIGOSDK_VERSION}/${DEPS_FILENAME}") | ||
| message(STATUS "Downloading NaCl SDK from '${REMOTE}'") | ||
|
|
||
| file(DOWNLOAD "${REMOTE}" "${OBJ_DIR}/${DEPS_FILENAME}" | ||
| SHOW_PROGRESS | ||
| STATUS DOWNLOAD_RESULT | ||
| LOG DOWNLOAD_LOG | ||
| ) | ||
|
|
||
| list(GET DOWNLOAD_RESULT 0 DOWNLOAD_STATUS) | ||
| list(GET DOWNLOAD_RESULT 1 DOWNLOAD_STRING) | ||
|
|
||
| if (NOT DOWNLOAD_STATUS EQUAL 0) | ||
| message(FATAL_ERROR "Failed to download '${REMOTE}': This may be a network error, or your system may be an unsupported host platform. | ||
| Status code: ${DOWNLOAD_STATUS} | ||
| Error string: ${DOWNLOAD_STRING} | ||
| Download log: ${DOWNLOAD_LOG}" | ||
| ) | ||
| endif() | ||
|
|
||
| message(STATUS "SDK download completed successfully") | ||
|
|
||
| # Extract the downloaded archive | ||
| execute_process( | ||
| COMMAND ${CMAKE_COMMAND} -E tar xJf ${OBJ_DIR}/${DEPS_FILENAME} | ||
| WORKING_DIRECTORY ${EXTERNAL_DEPS_DIR} | ||
| RESULT_VARIABLE EXTRACT_RESULT | ||
| ) | ||
| if (NOT EXTRACT_RESULT EQUAL 0) | ||
| message(FATAL_ERROR "Could not extract ${DEPS_FILENAME}") | ||
| endif() | ||
| endif() | ||
| endfunction() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Exit on undefined variable and error. | ||
| set -u -e -o pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" | ||
| WORK_DIR="${PWD}" | ||
| DOWNLOAD_DIR="${WORK_DIR}/download_cache" | ||
|
|
||
| # This should match the SAIGOSDK_VERSION in CMakeLists.txt. | ||
| # This is mostly to ensure the path the files end up at if you build deps yourself | ||
| # are the same as the ones when extracting from the downloaded packages. | ||
| SAIGOSDK_VERSION=20261013 | ||
| # Can be a tag like v${SAIGOSDK_VERSION}, or a full commit hash | ||
| SAIGOSDK_REF="v${SAIGOSDK_VERSION}" | ||
|
|
||
| REPO_BASENAME=saigo-nacl-sdk | ||
| REPO_URL="https://github.com/DaemonEngine/${REPO_BASENAME}" | ||
| ARCHIVE_PATH="${DOWNLOAD_DIR}/saigosdk-${SAIGOSDK_REF}.tar.gz" | ||
|
|
||
| usage() { | ||
| echo "Usage: $0 <os>-<arch> (build | install | package | wipe)..." | ||
| echo "<os>-<arch> should normally be your current native platform." | ||
| echo "For a list of supported platforms see ${REPO_URL}/tree/master/tools/release/conf" | ||
| echo "Actions:" | ||
| echo " build - build all tools and libraries in the SDK" | ||
| echo " install - install final build products to ${WORK_DIR}/saigosdk-<os>-<arch>_${SAIGOSDK_VERSION}/" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Terminology: we tend to use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the user-facing help so I think OS is easier to understand for someone unfamiliar.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, ”system” as a short-hand for operating system is consistent with all our other writing when we don't fully write “operating system“, and someone knowing that “OS” means “operating system” would understand what “systems” means in such context (and if the people really doesn't know that “OS” is for “operating system”, then “system” is less obscure). The fact that it's common knowledge that “OS” is “operating system” actually tells we can use “system”.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "System" as a shorthand for operating system never occurred to me. Generally I think of a system as comprising both the hardware and software components. So OS and architecture are both parts of defining a target system. |
||
| echo " wipe - delete build products (except download cache) AND install directory" | ||
| echo "If you want to build only a subset of packages, prefer using the" | ||
| echo "${REPO_URL} CMake build directly." | ||
| echo "Some global configuration options are available via environment" | ||
| echo "variables; see ${REPO_URL}/tree/master/tools/release/build" | ||
| } | ||
|
|
||
| download() { | ||
| test -f "${ARCHIVE_PATH}" && return | ||
| mkdir -p "${DOWNLOAD_DIR}" | ||
| curl --fail -L "${DOWNLOAD_URL}" -o "${ARCHIVE_PATH}" | ||
| } | ||
|
|
||
| if [ "$#" -lt 2 ] | ||
| then | ||
| usage | ||
| exit 1 | ||
| fi | ||
|
|
||
| PLATFORM="$1" | ||
| shift | ||
|
|
||
| if grep -q -E '^[0-9a-f]{40}$' <<< "${SAIGOSDK_REF}" | ||
| then | ||
| DOWNLOAD_URL="https://github.com/DaemonEngine/saigo-nacl-sdk/archive/${SAIGOSDK_REF}.tar.gz" | ||
| TARBALL_OUTER_DIR="${REPO_BASENAME}-${SAIGOSDK_REF}" | ||
| elif grep -q -E '^v[0-9]' <<< "${SAIGOSDK_REF}" | ||
| then | ||
| # The 'v' from the tag name is mysteriously removed??? | ||
| TARBALL_OUTER_DIR="${REPO_BASENAME}-${SAIGOSDK_REF:1}" | ||
| DOWNLOAD_URL="https://github.com/DaemonEngine/saigo-nacl-sdk/archive/refs/tags/${SAIGOSDK_REF}.tar.gz" | ||
| fi | ||
|
|
||
| INSTALL_DIR="${WORK_DIR}/saigosdk-${PLATFORM}_${SAIGOSDK_VERSION}" | ||
| BUILD_DIR="${WORK_DIR}/build-saigosdk_${SAIGOSDK_VERSION}" | ||
| REPO_DIR="${BUILD_DIR}/${TARBALL_OUTER_DIR}" | ||
|
|
||
| for target in "$@" | ||
| do | ||
| case "${target}" in | ||
| build) | ||
| download | ||
| mkdir -p "${BUILD_DIR}" | ||
| tar xzf "${ARCHIVE_PATH}" -C "${BUILD_DIR}" | ||
| ( | ||
| cd "${REPO_DIR}" | ||
| tools/release/build "${PLATFORM}" | ||
| ) | ||
| ;; | ||
| install) | ||
| cp -R "${REPO_DIR}/build/${PLATFORM}/install/." "${INSTALL_DIR}/" | ||
| ;; | ||
| wipe) | ||
| rm -rf "${BUILD_DIR}" "${INSTALL_DIR}" | ||
| ;; | ||
| *) | ||
| usage | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bikeshedding from me, but it would be nice if brand new files can use tabs as indentation (same for CMake files).