Repository navigation
Conversation
When adding support for building the NaCl IRT in build.sh, we will need to know SAIGOSDK_VERSION in a 3rd file, so I decided it's time to store DEPS_VERSION and SAIGOSDK_VERSION constants in a single place. versions.sh can be sourced from shell scripts, or munged into an includable cmake script using cmake's configure_file.
|
This could also make it easier to keep testing package builds cleanly separated. Like you could have a temporary commit to use |
|
Good idea! But I think this can be made simpler, for example with that code in function(ReadConfigFile CONFIG_FILE)
file(STRINGS "${CONFIG_FILE}" config_lines)
# Make sure the list is empty, just in case.
unset(config_keys)
foreach(line IN LISTS config_lines)
# Skip empty lines and comments.
if (line MATCHES "^[ \t]*#" OR line MATCHES "^[ \t]*$")
continue()
endif()
if (line MATCHES "^([^=]+)=(.*)$")
set(key "${CMAKE_MATCH_1}")
set(value "${CMAKE_MATCH_2}")
# Remove surrounding quotes.
if (value MATCHES "^\"")
string(REGEX REPLACE "^\"(.*)\"$" "\\1" value "${value}")
elseif (value MATCHES "^'")
string(REGEX REPLACE "^\'(.*)\'$" "\\1" value "${value}")
endif()
set("${key}" "${value}")
list(APPEND config_keys "${key}")
endif()
endforeach()
# Expand variables.
foreach(key IN LISTS config_keys)
string(CONFIGURE "${${key}}" expanded_value)
set("${key}" "${expanded_value}" PARENT_SCOPE)
endforeach()
endfunction()
# Get DEPS_VERSION, SAIGOSDK_VERSION…
ReadConfigFile("${CMAKE_SOURCE_DIR}/external_deps/versions.conf")We can then do directly an easy to read and write # DEPS_VERSION and SAIGOSDK_VERSION are used to version packages which may be auto-downloaded
# by CMake. The numbers are also included in the install path if you use the scripts to build them
# yourself, so that they end up in the same path used by the download.
# Version for the target-specific library and runtime dependencies package.
# Can be auto-downloaded by CMake or built with build.sh.
DEPS_VERSION=11
# Version for the host mode Saigo NaCl SDK package.
# Can be auto-downloaded by CMake (when building NaCl) or built with sdk-build.sh.
SAIGOSDK_VERSION=20261030
# Only used by sdk-build.sh but it's closely coupled to SAIGOSDK_VERSION.
# Can be a tag like v${SAIGOSDK_VERSION}, or a full commit hash.
SAIGOSDK_REF="v${SAIGOSDK_VERSION}"And that would be sourced in bash scripts that way: source "${SCRIPT_DIR}/versions.conf"And that would not require to write a temporary file. |
|
I made a new, totally different version based on the CMake script mode (-P). The file is natively cmake and generates code for the shell to eval if run in script mode. As a general-purpose solution for sharing definitions, one would question making the shell script depend on |
|
Yes we can rely on CMake because those build scripts require CMake anyway. There is no need for a temporary eval "$(cmake -P "${SCRIPT_DIR}/versions.cmake" 2>&1)" |
|
You can even add a shebang! 😅️ $ head versions.cmake
#! /usr/bin/env -S cmake -P
# Daemon BSD Source Code
# Copyright (c) 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$ chmod +x versions.cmake
$ ./versions.cmake
DEPS_VERSION='11'
SAIGOSDK_VERSION='20261030'
SAIGOSDK_REF='v20261030'$ SCRIPT_DIR="$(pwd)"
$ eval "$("${SCRIPT_DIR}/versions.cmake" 2>&1)"
$ echo "${$SAIGOSDK_REF}"
v20261030 |
When adding support for building the NaCl IRT in build.sh, we will need to know SAIGOSDK_VERSION in a 3rd file, so I decided it's time to store DEPS_VERSION and SAIGOSDK_VERSION constants in a single place. versions.sh can be sourced from shell scripts, or munged into an includable cmake script using cmake's configure_file.