From 417428e0d6cc64d98b06499547c946274dc6d327 Mon Sep 17 00:00:00 2001 From: Geoff Evans Date: Fri, 19 Feb 2021 13:19:18 -0800 Subject: [PATCH] Reconfigure build to github actions --- .appveyor.yml | 48 ------------------------- .github/workflows/build.yml | 65 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 63 ++++++++++++++++++++++++++++++++ Dependencies/openssl-build.bat | 37 ++++++++++--------- source_index_pdb.bat | 46 ++++++++++++++++++++++++ source_index_repo.bat | 33 +++++++++++++++++ 6 files changed, 228 insertions(+), 64 deletions(-) delete mode 100644 .appveyor.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml create mode 100644 source_index_pdb.bat create mode 100644 source_index_repo.bat diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 93329ee..0000000 --- a/.appveyor.yml +++ /dev/null @@ -1,48 +0,0 @@ -image: - - Visual Studio 2019 - -platform: - - x86 - - x64 - -configuration: - - Debug - - Release - -install: - - git submodule update --init - - if "%PLATFORM%" equ "x86" set BITS=32 - - if "%PLATFORM%" equ "x64" set BITS=64 - - if "%PLATFORM%" equ "x86" set ARCH=x86 - - if "%PLATFORM%" equ "x64" set ARCH=x86_64 - - if "%PLATFORM%" equ "x86" set PLAT=Win32 - - if "%PLATFORM%" equ "x64" set PLAT=x64 - - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars%BITS%.bat" - -build_script: - - cmd: cd Dependencies - - cmd: openssl-build - - cmd: cd .. - - cmd: premake --architecture=%ARCH% vs2019 - - cmd: msbuild Build\P4Win.sln /p:Configuration=%CONFIGURATION% /p:Platform=%PLAT% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /verbosity:minimal - - cmd: if "%CONFIGURATION%" equ "Release" if "%PLATFORM%" equ "x64" installer - -artifacts: - - path: Bin\$(configuration) - name: binaries - - path: Bin\$(configuration)\P4WinSetup.exe - name: installer - -version: '2008.1.1.{build}' - -deploy: - description: 'P4Win v$(appveyor_build_version)' - provider: GitHub - auth_token: - secure: wXIf6Ia9KbgkOdlA1aV7mkrA4OPZDOdxGd1cIV4+JjSXsLyDFqx/ElzCdDAjhYjA - artifact: installer - draft: true - on: - platform: x64 - configuration: Release - APPVEYOR_REPO_TAG: true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4fd423c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,65 @@ +name: Build + +on: + push: + branches: + - master + pull_request: {} + +jobs: + + build-debug: + name: Debug + runs-on: [windows-latest] + + steps: + - name: Checkout + uses: actions/checkout@v1 + with: + submodules: recursive + + - name: Build OpenSSL Debug + uses: ilammy/msvc-dev-cmd@v1 + run: | + cd ${{ github.workspace }}\Dependencies + cmd.exe /c call openssl-build.bat debug + + - name: Premake + run: | + cd ${{ github.workspace }} + cmd.exe /c call premake.bat + + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v1.0.2 + + - name: Build Debug + run: | + MSBuild.exe Build\P4Win.sln -p:Configuration=Debug + + build-release: + name: Release + runs-on: [windows-latest] + + steps: + - name: Checkout + uses: actions/checkout@v1 + with: + submodules: recursive + + - name: Build OpenSSL Release + uses: ilammy/msvc-dev-cmd@v1 + run: | + cd ${{ github.workspace }}\Dependencies + cmd.exe /c call openssl-build.bat release + + - name: Premake + run: | + cd ${{ github.workspace }} + cmd.exe /c call premake.bat + + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v1.0.2 + + - name: Build Release + run: | + MSBuild.exe Build\P4Win.sln -p:Configuration=Release diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..bc24deb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,63 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + release: + name: Release + runs-on: [windows-latest] + + steps: + - name: Checkout + uses: actions/checkout@v1 + with: + submodules: recursive + + - name: Build OpenSSL Release + uses: ilammy/msvc-dev-cmd@v1 + run: | + cd ${{ github.workspace }}\Dependencies + cmd.exe /c call openssl-build.bat release + + - name: Premake + run: | + cd ${{ github.workspace }} + cmd.exe /c call premake.bat + + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v1.0.2 + + - name: Build Release + run: | + MSBuild.exe Build\P4Win.sln -p:Configuration=Release + + - name: Source Index PDB + run: | + cmd.exe /c call source_index_pdb.bat Bin\Release\P4Win.pdb + + - name: Build Installer + run: | + cmd.exe /c call installer.bat + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + draft: false + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + + - name: Upload Release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: Bin/Release/P4WinSetup.exe + asset_name: P4WinSetup.exe + asset_content_type: application/vnd.microsoft.portable-executable \ No newline at end of file diff --git a/Dependencies/openssl-build.bat b/Dependencies/openssl-build.bat index 44b9c7f..ab45be6 100644 --- a/Dependencies/openssl-build.bat +++ b/Dependencies/openssl-build.bat @@ -18,6 +18,11 @@ if "%VSCMD_ARG_TGT_ARCH%" equ "x64" ( set SETUP=ms\do_ms.bat ) +if "%1" equ "" set BUILD_DEBUG=1 +if "%1" equ "" set BUILD_RELEASE=1 +if "%1" equ "debug" set BUILD_DEBUG=1 +if "%1" equ "release" set BUILD_RELEASE=1 + set RUNTIME=d pushd %~dp0openssl @@ -32,31 +37,31 @@ if "%RUNTIME%" equ "d" copy /y ms\nt.mak ms\nt.mak.orig :: Release :: -perl Configure %CONFIGURE% no-asm --prefix=%~dp0\%PLATFORM%-m%RUNTIME% -call %SETUP% +if defined BUILD_RELEASE perl Configure %CONFIGURE% no-asm --prefix=%~dp0\%PLATFORM%-m%RUNTIME% +if defined BUILD_RELEASE call %SETUP% -if "%RUNTIME%" equ "d" copy /y ms\nt.mak ms\nt.mak.unhacked -if "%RUNTIME%" equ "d" perl -p -e "s/\/MT/\/MD/g" ms\nt.mak.unhacked > ms\nt.mak +if defined BUILD_RELEASE if "%RUNTIME%" equ "d" copy /y ms\nt.mak ms\nt.mak.unhacked +if defined BUILD_RELEASE if "%RUNTIME%" equ "d" perl -p -e "s/\/MT/\/MD/g" ms\nt.mak.unhacked > ms\nt.mak -nmake -f ms\nt.mak -nmake -f ms\nt.mak install -copy /y tmp32\lib.pdb %~dp0\%PLATFORM%-m%RUNTIME%\lib\ -nmake -f ms\nt.mak clean +if defined BUILD_RELEASE nmake -f ms\nt.mak +if defined BUILD_RELEASE nmake -f ms\nt.mak install +if defined BUILD_RELEASE copy /y tmp32\lib.pdb %~dp0\%PLATFORM%-m%RUNTIME%\lib\ +if defined BUILD_RELEASE nmake -f ms\nt.mak clean :: :: Debug :: -perl Configure debug-%CONFIGURE% no-asm --prefix=%~dp0\%PLATFORM%-m%RUNTIME%d -call %SETUP% +if defined BUILD_DEBUG perl Configure debug-%CONFIGURE% no-asm --prefix=%~dp0\%PLATFORM%-m%RUNTIME%d +if defined BUILD_DEBUG call %SETUP% -if "%RUNTIME%" equ "d" copy /y ms\nt.mak ms\nt.mak.unhacked -if "%RUNTIME%" equ "d" perl -p -e "s/\/MT/\/MD/g" ms\nt.mak.unhacked > ms\nt.mak +if defined BUILD_DEBUG if "%RUNTIME%" equ "d" copy /y ms\nt.mak ms\nt.mak.unhacked +if defined BUILD_DEBUG if "%RUNTIME%" equ "d" perl -p -e "s/\/MT/\/MD/g" ms\nt.mak.unhacked > ms\nt.mak -nmake -f ms\nt.mak -nmake -f ms\nt.mak install -copy /y tmp32.dbg\lib.pdb %~dp0\%PLATFORM%-m%RUNTIME%d\lib\ -nmake -f ms\nt.mak clean +if defined BUILD_DEBUG nmake -f ms\nt.mak +if defined BUILD_DEBUG nmake -f ms\nt.mak install +if defined BUILD_DEBUG copy /y tmp32.dbg\lib.pdb %~dp0\%PLATFORM%-m%RUNTIME%d\lib\ +if defined BUILD_DEBUG nmake -f ms\nt.mak clean :: :: Restore diff --git a/source_index_pdb.bat b/source_index_pdb.bat new file mode 100644 index 0000000..fa72696 --- /dev/null +++ b/source_index_pdb.bat @@ -0,0 +1,46 @@ +@echo off + +setlocal +pushd %~dp0 + +:: +:: Generate the script section file for pdbstr.exe +:: + +echo: +echo Writing source_index.txt header... + +echo SRCSRV: ini ------------------------------------------------ > source_index.txt +echo VERSION=2 >> source_index.txt +echo VERCTRL=http >> source_index.txt +echo SRCSRV: variables ------------------------------------------ >> source_index.txt +echo HTTP_ALIAS=https://raw.githubusercontent.com >> source_index.txt +echo HTTP_EXTRACT_TARGET=%%HTTP_ALIAS%%%%var2%% >> source_index.txt +echo SRCSRVTRG=%%HTTP_EXTRACT_TARGET%% >> source_index.txt +echo SRCSRV: source files --------------------------------------- >> source_index.txt + +echo: +echo List Root +call source_index_repo.bat + +echo: +echo List Submodules +git submodule foreach --recursive cmd //c "%~dp0source_index_repo.bat" + +echo: +echo Writing footer... +echo SRCSRV: end ------------------------------------------------ >> source_index.txt + +:: +:: Update the pdb file with the script section +:: + +echo: +echo Adding srcsrv section to %1... +"%ProgramFiles(x86)%\Windows Kits\10\Debuggers\x64\srcsrv\pdbstr.exe" -w -p:%1 -s:srcsrv -i:source_index.txt + +popd +endlocal + +if %ERRORLEVEL% neq 0 exit /b 1 +exit /b 0 diff --git a/source_index_repo.bat b/source_index_repo.bat new file mode 100644 index 0000000..2f1f0de --- /dev/null +++ b/source_index_repo.bat @@ -0,0 +1,33 @@ +@echo off + +setlocal + +:: https://github.com/gorlak/PowerMateTray +for /f "delims=" %%f in ( 'git remote get-url origin' ) do set ORIGIN=%%f + +:: remove .git from the path if it's there (.git is the module url but not the source code url) +SET ORIGIN=%ORIGIN:.git=% + +:: 297d3d60af11c8749ab8515eec6ab188da3df317 +for /f "delims=" %%f in ( 'git rev-parse head' ) do set COMMIT=%%f + +:: /gorlak/PowerMateTray/297d3d60af11c8749ab8515eec6ab188da3df317/ +SET URL=%ORIGIN:https://github.com=%/%COMMIT% + +:: C:\Users\geoff\Projects\gorlak-PowerMateTray\.gitignore*.gitignore +for /f "delims=" %%f in ( 'git ls-files -- *.c *.C *.cc *.cp *.cpp *.cxx *.CPP *.h *.hh *.impl *.inl' ) do (call :PROCESS_FILE "%~dp0source_index.txt" "%%f") + +endlocal + +exit /b 0 + +:: +:: This is necessary to do some subsitutions that aren't possible with a for /f param +:: + +:PROCESS_FILE + set TXT=%1 + set FILE=%2 + set FILE_NOQUOTE=%FILE:"=% + echo %CD%\%FILE_NOQUOTE:/=\%*%URL%/%FILE_NOQUOTE% >> %TXT% + GOTO :eof \ No newline at end of file