Skip to content
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

Resolve Actions CI compilation problem on Windows #271

Merged
merged 14 commits into from
Mar 26, 2022
32 changes: 22 additions & 10 deletions .github/workflows/cmake_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@ jobs:
compiler_cache: ccache
compiler_cache_path: ~/.ccache

- name: macOS_Intel
os: macos-latest
arch: Intel # as reported by Apple menu > About This Mac
generator: Ninja
compiler_cache: ccache
compiler_cache_path: ~/Library/Caches/ccache
# Mac OS disabled because there is not maintainer for Mac.
# - name: macOS_Intel
# os: macos-latest
# arch: Intel # as reported by Apple menu > About This Mac
# generator: Ninja
# compiler_cache: ccache
# compiler_cache_path: ~/Library/Caches/ccache

- name: Windows_32bit
os: windows-latest
#same as below
#os: windows-latest
os: windows-2016
arch: x86 # as reported by Windows Settings > System > About
generator: Ninja
cc: cl
Expand All @@ -48,7 +51,16 @@ jobs:
compiler_cache_path: C:\Users\runneradmin\AppData\Local\Mozilla\sccache\cache

- name: Windows_64bit
os: windows-latest
#This wsas:
#os: windows-latest
#but at some point pressumably due to a Windows/MSVC update the Windows builds broke with this message:
#C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um\winnt.h(253): fatal error C1189: #error: Must define a target architecture.
#According to https://stackoverflow.com/questions/65402366/c5105-and-other-compiler-warnings-when-building-with-github-actions-winsdk-10
#this error happens because there are many Windows SDK versions installed that conflict with each other. This idea is supported by the fact that there were
#two different version numbers mentioned in the compilation logs, 10.0.10011.16384 and 10.0.22000.0, unless they're versions of different things.
#He solved by giving the -DCMAKE_SYSTEM_VERSION option to CMake but I couldn't solve it that way.
#So we switch to the Windows Server 2016 version of the Actions VM image.
os: windows-2016
arch: amd64 # as reported by Windows Settings > System > About
generator: Ninja
cc: cl
Expand All @@ -60,7 +72,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- uses: seanmiddleditch/gha-setup-ninja@master
- uses: seanmiddleditch/gha-setup-ninja@v3


- name: Dependencies
Expand All @@ -73,7 +85,7 @@ jobs:

- name: "Set up MSVC Developer Command Prompt"
if: startswith( matrix.config.os, 'windows' )
uses: seanmiddleditch/gha-setup-vsdevenv@v3
uses: seanmiddleditch/gha-setup-vsdevenv@master
with:
arch: ${{ matrix.config.arch }}

Expand Down
10 changes: 10 additions & 0 deletions scripts/ci/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env bash

echo "Begin build.sh"

echo "build.sh: checking bash version"

((${BASH_VERSION%%.*} >= 4)) || { echo >&2 "$0: Error: Please upgrade Bash."; exit 1; }

set -euxo pipefail
Expand All @@ -18,14 +22,20 @@ else # Linux & others

fi

echo "build.sh: building using $cpus cpus"

# Build Sneedacity
cmake --build build -j "${cpus}" --config "${SNEEDACITY_BUILD_TYPE}"

#Use this instead for debugging the build process:
#cmake --build build -j 1 --config "${SNEEDACITY_BUILD_TYPE}"

BIN_OUTPUT_DIR=build/bin/${SNEEDACITY_BUILD_TYPE}
SYMBOLS_OUTPUT_DIR=debug

mkdir ${SYMBOLS_OUTPUT_DIR}

echo "build.sh: removing debug symbols"
if [[ "${OSTYPE}" == msys* ]]; then # Windows
# copy PDBs to debug folder...
find ${BIN_OUTPUT_DIR} -name '*.pdb' | xargs -I % cp % ${SYMBOLS_OUTPUT_DIR}
Expand Down
11 changes: 11 additions & 0 deletions scripts/ci/configure.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/usr/bin/env bash

echo "Begin configure.sh"

echo "configure.sh: checking bash version"
((${BASH_VERSION%%.*} >= 4)) || { echo >&2 "$0: Error: Please upgrade Bash."; exit 1; }

set -euxo pipefail

echo "configure.sh: setting cmake_args"
cmake_args=(
-S .
-B build
Expand All @@ -13,6 +17,9 @@ cmake_args=(
-D CMAKE_INSTALL_PREFIX="${SNEEDACITY_INSTALL_PREFIX}"
)

echo "configure.sh: cmake_args: $cmake_args"
echo "configure.sh: SNEEDACITY_CMAKE_GENERATOR: ${SNEEDACITY_CMAKE_GENERATOR}"

if [[ "${SNEEDACITY_CMAKE_GENERATOR}" == "Visual Studio"* ]]; then
cmake_args+=(
# skip unneeded configurations
Expand Down Expand Up @@ -44,18 +51,22 @@ if [[ -n "${APPLE_CODESIGN_IDENTITY}" && "${OSTYPE}" == darwin* ]]; then
-D sneedacity_perform_notarization=yes
)
fi
echo "configure.sh: OSTYPE: ${OSTYPE}"
elif [[ -n "${WINDOWS_CERTIFICATE}" && "${OSTYPE}" == msys* ]]; then
# Windows certificate will be used from the environment
cmake_args+=(
-D sneedacity_perform_codesign=yes
)
fi

echo "configure.sh: GIT_BRANCH: "${GIT_BRANCH}

if [[ ${GIT_BRANCH} == release* ]]; then
cmake_args+=(
-D sneedacity_package_manual=yes
)
fi

# Configure Sneedacity
echo "configure.sh: running cmake with args: ${cmake_args[@]}"
cmake "${cmake_args[@]}"
15 changes: 14 additions & 1 deletion scripts/ci/environment.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env bash

echo "Begin environment.sh"

echo "environment.sh: Checking bash version"

if [[ "$0" == "${BASH_SOURCE}" ]]; then
echo >&2 "$0: Please source this script instead of running it."
exit 1
Expand All @@ -9,16 +13,25 @@ fi

function gh_export()
{
echo "environment.sh: Begin gh_export()"
[[ "${GITHUB_ENV-}" ]] || local -r GITHUB_ENV="/dev/null"
export -- "$@" && printf "%s\n" "$@" >> "${GITHUB_ENV}"
echo "environment.sh: returning from gh_export()"
}

repository_root="$(cd "$(dirname "${BASH_SOURCE}")/../.."; echo "${PWD}")"

echo "environment.sh: repository_root: "$repository_root


gh_export GIT_HASH="$(git show -s --format='%H')"
gh_export GIT_HASH_SHORT="$(git show -s --format='%h')"

gh_export SNEEDACITY_BUILD_TYPE="Release"
gh_export SNEEDACITY_BUILD_TYPE="Debug"
echo "environment.sh: SNEEDACITY_BUILD_TYPE: "$SNEEDACITY_BUILD_TYPE

gh_export SNEEDACITY_INSTALL_PREFIX="${repository_root}/build/install"
echo "environment.sh: SNEEDACITY_INSTALL_PREFIX: "$SNEEDACITY_INSTALL_PREFIX

gh_export GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "environment.sh: GIT_BRANCH: " $GIT_BRANCH