From 3ba8369f22497ebf12de70b8881ffd883c6b1fb5 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 19 Jan 2020 14:04:59 +0000 Subject: [PATCH] Do major clean up of Windows CI workflow (#10581) - Move many of the post build operations in openrc2.proj to bash scripts, some of which can be shared with the macOS and Linux CIs. - Improve performance of NSIS stage by grabbing a pre-packaged portable zip from GitHub. This typically saves the CI a minute and is more reliable. --- .github/workflows/ci.yml | 75 +++++--------- openrct2.proj | 183 +++------------------------------- scripts/build | 26 +++++ scripts/build-installer | 47 +++++++++ scripts/build-portable | 58 +++++++++++ scripts/build-symbols | 25 +++++ scripts/create-portable-build | 29 ------ scripts/install-nsis | 34 +++++-- scripts/run-tests | 17 ++++ scripts/setenv | 70 +++++++++++++ scripts/vstool | 2 + scripts/vstool.cmd | 23 +++++ 12 files changed, 335 insertions(+), 254 deletions(-) create mode 100755 scripts/build create mode 100755 scripts/build-installer create mode 100755 scripts/build-portable create mode 100755 scripts/build-symbols delete mode 100644 scripts/create-portable-build mode change 100644 => 100755 scripts/install-nsis create mode 100755 scripts/run-tests create mode 100755 scripts/setenv create mode 100755 scripts/vstool create mode 100644 scripts/vstool.cmd diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 218f5c2bb0..ef33866446 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,7 @@ name: CI on: [push, pull_request] env: - BUILD_SERVER: GitHub + OPENRCT2_BUILD_SERVER: GitHub OPENRCT2_ORG_TOKEN: ${{ secrets.OPENRCT2_ORG_TOKEN }} OPENRCT2_VERSION: 0.2.4 jobs: @@ -24,52 +24,37 @@ jobs: env: CONFIGURATION: Release PLATFORM: ${{ matrix.platform }} - GIT_COMMIT_SHA1: ${{ github.sha }} steps: - uses: actions/checkout@v1 name: Checkout - - name: Install NSIS - shell: bash - run: scripts/install-nsis - - name: Prepare environment - shell: bash - run: dos2unix test/tests/testdata/keys/* - name: Build OpenRCT2 - shell: pwsh + shell: bash + run: . scripts/setenv && build + - name: Build artifacts + shell: bash run: | - $env:GIT_BRANCH = $env:GITHUB_REF -replace "refs/heads/(.*)", '$1' - $env:GIT_DESCRIBE = (git describe HEAD | sed -E "s/-g.+$//") - $env:BUILD_VERSION = $env:GIT_DESCRIBE | sed "s/v//" | sed "s/-/./" - Set-Content -Path 'resources\version.h' -Value "#define OPENRCT2_FILE_VERSION $($env:BUILD_VERSION -replace "\.", ",")" - Add-Content -Path 'resources\version.h' -Value "#define OPENRCT2_PRODUCT_VERSION `"$($env:BUILD_VERSION)-$($env:GIT_COMMIT_SHA1.Substring(0,10))`"" - Remove-Item -Force -Recurse "C:\Program Files (x86)\NSIS" - cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" && msbuild openrct2.proj' - - name: Run Tests - shell: cmd - run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" - msbuild openrct2.proj /t:test + . scripts/setenv -q + build-portable + build-symbols + build-installer -i - uses: actions/upload-artifact@master name: Upload artifacts (CI) with: name: "OpenRCT2-Windows-${{ matrix.platform }}" path: artifacts + - name: Run Tests + shell: bash + run: . scripts/setenv -q && run-tests - name: Upload artifacts (openrct2.org) shell: bash run: | - if [[ "$OPENRCT2_ORG_TOKEN" != "" ]]; then - if [[ $GITHUB_REF == refs/tags/* ]]; then - GITHUB_BRANCH= - else - GITHUB_BRANCH=${GITHUB_REF#refs/heads/} - if [[ ! "$GITHUB_BRANCH" =~ ^(develop|push/) ]]; then - exit 0 - fi - fi - - scripts/upload-build artifacts/openrct2-portable-*.zip "windows-portable-$PLATFORM" $OPENRCT2_VERSION $GIT_COMMIT_SHA1 $GITHUB_BRANCH - scripts/upload-build artifacts/openrct2-installer-*.exe "windows-installer-$PLATFORM" $OPENRCT2_VERSION $GIT_COMMIT_SHA1 $GITHUB_BRANCH - scripts/upload-build artifacts/openrct2-symbols-*.zip "windows-symbols-$PLATFORM" $OPENRCT2_VERSION $GIT_COMMIT_SHA1 $GITHUB_BRANCH + . scripts/setenv -q + if [[ "$OPENRCT2_PUSH" == "true" ]]; then + upload-build artifacts/openrct2-portable-*.zip "windows-portable-$PLATFORM" $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH + upload-build artifacts/openrct2-installer-*.exe "windows-installer-$PLATFORM" $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH + upload-build artifacts/openrct2-symbols-*.zip "windows-symbols-$PLATFORM" $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH + else + echo 'Not going to push build' fi osx: name: macOS @@ -79,6 +64,7 @@ jobs: name: Checkout - name: Build OpenRCT2 run: | + . scripts/setenv xcodebuild mkdir -p artifacts mv build/Release/OpenRCT2.app artifacts @@ -88,24 +74,15 @@ jobs: name: "OpenRCT2-macOS" path: artifacts - name: Upload artifacts (openrct2.org) - env: - GITHUB_SHA1: ${{ github.sha }} run: | - if [[ "$OPENRCT2_ORG_TOKEN" != "" ]]; then - if [[ $GITHUB_REF == refs/tags/* ]]; then - GITHUB_BRANCH= - else - GITHUB_BRANCH=${GITHUB_REF#refs/heads/} - if [[ ! "$GITHUB_BRANCH" =~ ^(develop|push/) ]]; then - exit 0 - fi - fi - - echo -e '\033[0;36mCompressing OpenRCT2.app...' + . scripts/setenv + if [[ "$OPENRCT2_PUSH" == "true" ]]; then + echo -e "\033[0;36mCompressing OpenRCT2.app...\033[0m" cd artifacts zip -rq openrct2-macos.zip OpenRCT2.app - - ../scripts/upload-build openrct2-macos.zip macos $OPENRCT2_VERSION $GITHUB_SHA1 $GITHUB_BRANCH + upload-build openrct2-macos.zip macos $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH + else + echo 'Not going to push build' fi build-appimage: name: Linux (x64, AppImage) diff --git a/openrct2.proj b/openrct2.proj index 9576de9283..0276404f4c 100644 --- a/openrct2.proj +++ b/openrct2.proj @@ -2,60 +2,36 @@ - + Debug - x64 - $(GIT_COMMIT_SHA1.Substring(0, 7)) - - 0.2.4 - -$(GIT_BRANCH)-$(GIT_COMMIT_SHA1_SHORT) - - 16 + x64 - /D "OPENRCT2_BUILD_SERVER=\"$(BUILD_SERVER)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS) - /D "OPENRCT2_BRANCH=\"$(GIT_BRANCH)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS) - /D "OPENRCT2_COMMIT_SHA1=\"$(GIT_COMMIT_SHA1)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS) - /D "OPENRCT2_COMMIT_SHA1_SHORT=\"$(GIT_COMMIT_SHA1_SHORT)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS) - /D "OPENRCT2_VERSION_TAG=\"$(GIT_DESCRIBE)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS) + /D "OPENRCT2_BUILD_SERVER=\"$(OPENRCT2_BUILD_SERVER)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS) + /D "OPENRCT2_BRANCH=\"$(OPENRCT2_BRANCH)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS) + /D "OPENRCT2_COMMIT_SHA1=\"$(OPENRCT2_SHA1)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS) + /D "OPENRCT2_COMMIT_SHA1_SHORT=\"$(OPENRCT2_SHA1_SHORT)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS) + /D "OPENRCT2_VERSION_TAG=\"$(OPENRCT2_DESCRIBE)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS) /D "USE_BREAKPAD" $(OPENRCT2_CL_ADDITIONALOPTIONS) $(MsBuildThisFileDirectory) - $(RootDir)distribution\ - $(RootDir)artifacts\ $(RootDir)bin\ - $(DistDir)windows\install.nsi - $(TargetDir)openrct2.exe - $(TargetDir)openrct2.com - $(TargetDir)openrct2.dll $(TargetDir)data\g2.dat - -$(Configuration)-$(Platform) - $(PublishPostfix)-$(GIT_COMMIT_SHA1_SHORT) - $(PublishPostfix.ToLower()) - $(ArtifactsDir)openrct2-portable$(PublishPostfix).zip - $(ArtifactsDir)openrct2-symbols$(PublishPostfix).zip - $(ArtifactsDir)openrct2-symbols$(PublishPostfix).zip - $(ArtifactsDir)openrct2-installer$(PublishPostfix).exe - - OpenRCT2-$(Version)$(VersionExtra)-windows-$(Platform.ToLower()) - $(SlnProperties);Platform=$(Platform) - $(SlnProperties);OPENRCT2_CL_ADDITIONALOPTIONS=$(OPENRCT2_CL_ADDITIONALOPTIONS) + $(SlnProperties);OPENRCT2_CL_ADDITIONALOPTIONS=$(OPENRCT2_CL_ADDITIONALOPTIONS) @@ -80,43 +56,6 @@ - - - - - - - - - - - - - - - - - - - - - - $(UploadFilename).zip - 1 - 6 - - - $(UploadFilename).exe - 2 - 7 - - - $(UploadFilename)-symbols.zip - 5 - 10 - - - $(SlnProperties);Configuration=$(Configuration) - - - - - - - @@ -156,9 +88,9 @@ - $(GIT_COMMIT_SHA1_SHORT) - $(BuildString) ($(GIT_BRANCH)) - $(BuildString) ($(GIT_DESCRIBE)) + $(OPENRCT2_SHA1_SHORT) + $(BuildString) ($(OPENRCT2_BRANCH)) + $(BuildString) ($(OPENRCT2_DESCRIBE)) @@ -183,18 +115,6 @@ - - - - - - - - - @@ -203,13 +123,6 @@ StandardOutputImportance="normal" /> - - - - - - - - - - - - - <_7z Output="$(PublishZip)" Inputs="@(PublishItems)" /> - - - - - - - <_7z Output="$(PublishSymbolsZip)" Inputs="@(SymbolItems)" /> - - - - - - $([System.IO.Path]::GetFilename($(PublishInstallerExe))) - - - - - - - - - - - - - - - https://openrct2.org/altapi/?command=push-build - %(UploadArtifacts.Filename)%(UploadArtifacts.Extension) - master - $(GIT_BRANCH) - - - - - - - diff --git a/scripts/build b/scripts/build new file mode 100755 index 0000000000..7c942feb6f --- /dev/null +++ b/scripts/build @@ -0,0 +1,26 @@ +#!/bin/bash +set -e + +# Ensure we are in root directory +basedir="$(readlink -f `dirname $0`/..)" +cd $basedir + +# Patch version.h +if [[ "$OPENRCT2_BUILD" != "" ]]; then + echo -e "\033[0;36mPatching version.h...\033[0m" + fileversion=$OPENRCT2_VERSION.$OPENRCT2_BUILD + productversion="$fileversion-${OPENRCT2_SHA1_SHORT}" + fileversion=${fileversion//./,} + echo "#define OPENRCT2_FILE_VERSION $fileversion" > "resources/version.h" + echo "#define OPENRCT2_PRODUCT_VERSION \"$productversion\"" >> "resources/version.h" + cat "resources/version.h" +fi + +# Build everything +echo -e "\033[0;36mBuilding OpenRCT2 for Windows $CONFIGURATION|$PLATFORM...\033[0m" +vstool msbuild openrct2.proj //t:build + +# Create openrct2.exe and openrct2.com with correct subsystem +cp bin/openrct2.exe bin/openrct2.com +vstool editbin //subsystem:console bin/openrct2.com +vstool editbin //subsystem:windows bin/openrct2.exe diff --git a/scripts/build-installer b/scripts/build-installer new file mode 100755 index 0000000000..49101bf4a5 --- /dev/null +++ b/scripts/build-installer @@ -0,0 +1,47 @@ +#!/bin/bash +set -e +if [[ "$#" -gt 2 || "$1" == "-h" ]]; then + echo 'Create a Windows installer for OpenRCT2' + echo '' + echo 'Usage: create-installer [-i] []' + echo '' + echo ' -i install portable NSIS' + exit 1 +fi + +installnsis= +output=$1 +if [[ "$1" == "-i" ]]; then + installnsis=true + output=$2 +fi + +basedir="$(readlink -f `dirname $0`/..)" +if [[ "$output" == "" ]]; then + mkdir -p "$basedir/artifacts" + output="$basedir/artifacts/openrct2-installer-$CONFIGURATION-$PLATFORM.exe" +fi + +outputdir=$(dirname $output) +if ! [ -d "$outputdir" ]; then + echo -e >&2 "\033[0;31m$outputdir does not exist\033[0m" + exit 1 +fi + +output=$(cygpath -w $(readlink -f $output)) + +# Check makensis is available +if [[ "$installnsis" == "true" ]]; then + $basedir/scripts/install-nsis -d /tmp/nsis + export PATH=/tmp/nsis/bin:$PATH +fi + +if ! [ -x "$(command -v makensis)" ]; then + echo -e >&2 "\033[0;31mmakensis not found\033[0m" + exit 1 +fi + +nsispath=$(cygpath -w $basedir/distribution/windows/install.nsi) +echo -e "\033[0;36mCreating installer for OpenRCT2 $OPENRCT2_VERSION-$OPENRCT2_VERSION_EXTRA ($PLATFORM)...\033[0m" +makensis "/DOUTFILE=$output" "//DAPPV_MAIN=$OPENRCT2_VERSION" "//DAPPV_EXTRA=${OPENRCT2_VERSION_EXTRA//\//\\}" "//DPLATFORM=$PLATFORM" "$nsispath" +printf '\033[0;32m%s\033[0m\n' "${output} created successfully" diff --git a/scripts/build-portable b/scripts/build-portable new file mode 100755 index 0000000000..b9a1068f5e --- /dev/null +++ b/scripts/build-portable @@ -0,0 +1,58 @@ +#!/bin/bash +set -e + +if [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]]; then + # Create a Windows symbols archive for OpenRCT2 + basedir="$(readlink -f `dirname $0`/..)" + cd $basedir/bin + + destination=../artifacts/openrct2-portable-$CONFIGURATION-$PLATFORM.zip + + # Check 7z is available + if ! [ -x "$(command -v 7z)" ]; then + echo -e >&2 "\033[0;7z not found\033[0m" + exit 1 + fi + + echo -e "\033[0;36mCreating portable zip for Windows OpenRCT2...\033[0m" + if [[ -f $destination ]]; then + rm $destination + fi + 7z a -r $destination \ + openrct2.exe openrct2.com openrct2.dll data \ + ../distribution/changelog.txt \ + ../distribution/contributors.md \ + ../distribution/licence.txt \ + ../distribution/readme.txt \ + + destination=$(cygpath -w $(readlink -f $destination)) + printf '\033[0;32m%s\033[0m\n' "${destination} created successfully" +else + if [[ "$#" -ne 2 ]]; then + echo 'Turn an OpenRCT2 cmake install into a portable tar.gz.' + echo '' + echo 'Usage: create-portable-build ' + exit 1 + fi + + output=$1 + install=$2 + + echo -e "\033[0;36mCreating $output..." + workdir=$output-temp + if [[ -d "$workdir" ]] + then + rm -rf $workdir + fi + + mkdir -p $workdir/OpenRCT2 + cp -r $install/bin/* $workdir/OpenRCT2 + cp -r $install/share/doc $workdir/OpenRCT2 + cp -r $install/share/openrct2 $workdir/OpenRCT2/data + pushd $workdir > /dev/null + tar -czf output.tar.gz OpenRCT2 + popd > /dev/null + mv $workdir/output.tar.gz $output + rm -rf $workdir + echo -e "\033[0;32m$output created successfully" +fi diff --git a/scripts/build-symbols b/scripts/build-symbols new file mode 100755 index 0000000000..620c0e5799 --- /dev/null +++ b/scripts/build-symbols @@ -0,0 +1,25 @@ +#!/bin/bash +set -e + +# Create a Windows symbols archive for OpenRCT2 +basedir="$(readlink -f `dirname $0`/..)" +cd $basedir/bin + +destination=../artifacts/openrct2-symbols-$CONFIGURATION-$PLATFORM.zip + +# Check 7z is available +if ! [ -x "$(command -v 7z)" ]; then + echo -e >&2 "\033[0;7z not found\033[0m" + exit 1 +fi + +echo -e "\033[0;36mCreating symbols archive for OpenRCT2...\033[0m" +if [[ -f $destination ]]; then + rm $destination +fi +7z a $destination \ + openrct2.exe openrct2.com openrct2.dll \ + openrct2-dll.pdb openrct2-win.pdb + +destination=$(cygpath -w $(readlink -f $destination)) +printf '\033[0;32m%s\033[0m\n' "${destination} created successfully" diff --git a/scripts/create-portable-build b/scripts/create-portable-build deleted file mode 100644 index 57c45530ec..0000000000 --- a/scripts/create-portable-build +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -set -e -if [[ "$#" -ne 2 ]]; then - echo 'Turn an OpenRCT2 cmake install into a portable tar.gz.' - echo '' - echo 'Usage: create-portable-build ' - exit 1 -fi - -output=$1 -install=$2 - -echo -e "\033[0;36mCreating $output..." -workdir=$output-temp -if [[ -d "$workdir" ]] -then - rm -rf $workdir -fi - -mkdir -p $workdir/OpenRCT2 -cp -r $install/bin/* $workdir/OpenRCT2 -cp -r $install/share/doc $workdir/OpenRCT2 -cp -r $install/share/openrct2 $workdir/OpenRCT2/data -pushd $workdir > /dev/null - tar -czf output.tar.gz OpenRCT2 -popd > /dev/null -mv $workdir/output.tar.gz $output -rm -rf $workdir -echo -e "\033[0;32m$output created successfully" diff --git a/scripts/install-nsis b/scripts/install-nsis old mode 100644 new mode 100755 index 2308030faa..43a1ec2029 --- a/scripts/install-nsis +++ b/scripts/install-nsis @@ -1,25 +1,43 @@ #!/bin/bash set -e +if [[ "$#" -ne 0 && "$#" -ne 2 ]]; then + echo 'Install a portable version of NSIS which can build the OpenRCT2 Windows installer.' + echo '' + echo 'Usage: install-nsis [-d ]' + echo '' + echo ' -d download prebuilt zip' + exit 1 +fi -nsisdir="C:/ProgramData/chocolatey/lib/nsis.portable" -if [[ -d $nsisdir ]] -then - echo -e "\033[0;36mNSIS already installed." +if [[ "$1" == "-d" ]]; then + echo -e "\033[0;36mDownloading prebuilt NSIS from GitHub...\033[0m" + curl -sLo nsis.zip "https://github.com/OpenRCT2/Dependencies/releases/download/v20/nsis.zip" + 7z -bd -y "-o$2" x nsis.zip + rm nsis.zip + echo -e "\033[0;32mNSIS downloaded, add "$2/bin" to PATH\033[0m" exit 0 fi -echo -e "\033[0;36mDownloading NSIS from chocolatey..." +# Download NSIS with chocolatey and then download extra plugins +nsisdir="C:/ProgramData/chocolatey/lib/nsis.portable" +if [[ -d $nsisdir ]] +then + echo -e "\033[0;36mNSIS already installed.\033[0m" + exit 0 +fi + +echo -e "\033[0;36mDownloading NSIS from chocolatey...\033[0m" cinst nsis.portable --version=3.01-beta1 -echo -e "\033[0;36mDownloading KillProcDLL for NSIS..." +echo -e "\033[0;36mDownloading KillProcDLL for NSIS...\033[0m" curl -sLo nsisxtra.zip "http://nsis.sourceforge.net/mediawiki/images/5/53/KillProcDll%26FindProcDll.zip" 7z x nsisxtra.zip cp FindProcDLL.dll "$nsisdir/tools/nsis-3.0b1/Plugins/x86-ansi" -echo -e "\033[0;36mDownloading UAC plugin for NSIS..." +echo -e "\033[0;36mDownloading UAC plugin for NSIS...\033[0m" curl -sLo uac.zip "http://nsis.sourceforge.net/mediawiki/images/8/8f/UAC.zip" 7z x uac.zip cp UAC.nsh "$nsisdir/tools/nsis-3.0b1/Include" cp -r Plugins "$nsisdir/tools/nsis-3.0b1" -echo -e "\033[0;32mNSIS installed!" +echo -e "\033[0;32mNSIS installed!\033[0m" diff --git a/scripts/run-tests b/scripts/run-tests new file mode 100755 index 0000000000..15daa8f8d2 --- /dev/null +++ b/scripts/run-tests @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +# Ensure we are in root directory +basedir="$(readlink -f `dirname $0`/..)" +cd $basedir/bin + +# Ensure test data uses LF +dos2unix testdata/keys/* + +# Scan objects first so that does not happen within a test +echo -e "\033[0;36mBuilding OpenRCT2 repository indexes...\033[0m" +./openrct2 scan-objects + +# Now run all the tests +echo -e "\033[0;36mRunning OpenRCT2 tests...\033[0m" +./tests --gtest_output=xml:../artifacts/test-results.xml diff --git a/scripts/setenv b/scripts/setenv new file mode 100755 index 0000000000..014d0ab624 --- /dev/null +++ b/scripts/setenv @@ -0,0 +1,70 @@ +#!/bin/bash + +# This sets up more environment variables using existing the environment +# It should be dot sourced into your environment +if [[ "$GITHUB_ACTIONS" != "true" ]]; then + export OPENRCT2_BUILD_SERVER=$(hostname) + export OPENRCT2_VERSION=0.2.4 + GITHUB_REF=$(git rev-parse --symbolic-full-name HEAD) + GITHUB_SHA=$(git rev-parse HEAD) +fi + +echo -e "\033[0;36mSetting up environment for OpenRCT2...\033[0m" + +# Get the build number (number of commits since last tag) +export OPENRCT2_DESCRIBE=$(git describe HEAD) +get_build_number() +{ + local pattern='.+-([0-9]+)-.+' + [[ $OPENRCT2_DESCRIBE =~ $pattern ]] + echo "${BASH_REMATCH[1]}" +} +export OPENRCT2_BUILD=$(get_build_number) + +# Get the name of the branch and decide whether we should push the build to openrct2.org +export OPENRCT2_TAG= +export OPENRCT2_PUSH= +if [[ $GITHUB_REF == refs/tags/* ]]; then + export OPENRCT2_BRANCH= + export OPENRCT2_TAG=true + export OPENRCT2_PUSH=true +else + export OPENRCT2_BRANCH=${GITHUB_REF#refs/heads/} + if [[ "$OPENRCT2_BRANCH" =~ ^(develop|push/) ]]; then + export OPENRCT2_PUSH=true + fi +fi +if [[ "$OPENRCT2_ORG_TOKEN" == "" ]]; then + export OPENRCT2_PUSH= +fi + +# Get the short SHA1 +export OPENRCT2_SHA1=$GITHUB_SHA +export OPENRCT2_SHA1_SHORT=${OPENRCT2_SHA1:0:7} +export OPENRCT2_VERSION_EXTRA= +if [[ "$OPENRCT2_TAG" != "true" ]]; then + export OPENRCT2_VERSION_EXTRA=$OPENRCT2_BRANCH-$OPENRCT2_SHA1_SHORT +fi + +# Add scripts directory to PATH +realpath() { + [[ $1 = /* ]] && echo "$1" || echo "$(pwd)/${1#./}" +} +scriptsdir="$(realpath `dirname ${BASH_SOURCE[0]}`)" +export PATH="$scriptsdir:$PATH" + +# Output all the variables +if [[ "$1" != "-q" ]]; then + echo "----------------------------------------------" + echo "OPENRCT2_BUILD_SERVER: $OPENRCT2_BUILD_SERVER" + echo "OPENRCT2_TAG: $OPENRCT2_TAG" + echo "OPENRCT2_BRANCH: $OPENRCT2_BRANCH" + echo "OPENRCT2_VERSION: $OPENRCT2_VERSION" + echo "OPENRCT2_VERSION_EXTRA: $OPENRCT2_VERSION_EXTRA" + echo "OPENRCT2_BUILD: $OPENRCT2_BUILD" + echo "OPENRCT2_DESCRIBE: $OPENRCT2_DESCRIBE" + echo "OPENRCT2_PUSH: $OPENRCT2_PUSH" + echo "OPENRCT2_SHA1: $OPENRCT2_SHA1" + echo "OPENRCT2_SHA1_SHORT: $OPENRCT2_SHA1_SHORT" + echo "----------------------------------------------" +fi diff --git a/scripts/vstool b/scripts/vstool new file mode 100755 index 0000000000..c7646ba07f --- /dev/null +++ b/scripts/vstool @@ -0,0 +1,2 @@ +#!/bin/bash +vstool.cmd $@ diff --git a/scripts/vstool.cmd b/scripts/vstool.cmd new file mode 100644 index 0000000000..b71a872510 --- /dev/null +++ b/scripts/vstool.cmd @@ -0,0 +1,23 @@ +@echo off + +rem Invokes a tool within a Visual Studio prompt +rem Uses %PLATFORM% to set architecture of prompt + +set "vspath=C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" +if exist "%vspath%" goto found +set "vspath=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community" +if exist "%vspath%" goto found + +:notfound +echo Visual Studio directory not found +exit /b 1 + +:found +if "%platform%"=="x64" ( + call "%vspath%\Common7\Tools\VsDevCmd.bat" -no_logo -arch=x64 +) else ( + call "%vspath%\Common7\Tools\VsDevCmd.bat" -no_logo +) + +%* +exit /b %errorlevel%