diff --git a/.gitea/scripts/windows-native.sh b/.gitea/scripts/windows-native.sh index 7b2b3ea..46aa5e2 100644 --- a/.gitea/scripts/windows-native.sh +++ b/.gitea/scripts/windows-native.sh @@ -14,7 +14,13 @@ phase="${1:?phase (build or test)}" variant="${2:?variant}" build_type="${3:?build type}" -root="$(cd "$(dirname "$0")/../.." && pwd)" +# The script is piped through `bash -s`, so $0 is "bash": locate the checkout +# through GITHUB_WORKSPACE (set by the runner) instead of the script path. +if [ -n "${GITHUB_WORKSPACE:-}" ]; then + root="$(cygpath -u "${GITHUB_WORKSPACE}" 2>/dev/null || printf '%s' "${GITHUB_WORKSPACE}")" +else + root="$(pwd)" +fi cd "${root}" echo "workspace: $(pwd)" @@ -30,11 +36,20 @@ if ! command -v cmake >/dev/null 2>&1 || ! command -v ninja >/dev/null 2>&1; the fi fi +cxx_flags="" +linker_flags="" +if [ "${variant}" = "sanitizers" ]; then + cxx_flags="-fsanitize=address,undefined -fno-omit-frame-pointer" + linker_flags="-fsanitize=address,undefined" +fi + case "${phase}" in build) cmake -S . -B "${build}" -G Ninja \ -DCMAKE_BUILD_TYPE="${build_type}" \ -DCMAKE_CXX_COMPILER=g++ \ + -DCMAKE_CXX_FLAGS="${cxx_flags}" \ + -DCMAKE_EXE_LINKER_FLAGS="${linker_flags}" \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON cmake --build "${build}" --parallel 4 ;;