From 52fa87300b8421f57ae945a115b5974d2ca91a9c Mon Sep 17 00:00:00 2001 From: Ihor Dutchak Date: Sun, 8 May 2022 19:59:39 +0300 Subject: [PATCH] Windows build artifacts with Github Actions (#414) - a straight-forward build matrix for Appveyor; - MSBuild builds with Github Actions; - Visual Studio 2022 support for `.sln` (toolset v143); - gather Windows build artifacts with Github actions; --- .appveyor.yml | 38 +++++++------- .github/workflows/builds.yml | 97 +++++++++++++++++++++++------------- windows/hidapi.vcxproj | 4 ++ windows/hidtest.vcxproj | 4 ++ 4 files changed, 87 insertions(+), 56 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index b7e21c76..ebbce556 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -8,26 +8,22 @@ environment: arch: Win32 - BUILD_ENV: cygwin -install: - - cmd: if %BUILD_ENV%==cygwin ( - C:\cygwin64\setup-x86_64.exe --quiet-mode --no-shortcuts --upgrade-also --packages autoconf,automake ) +for: + - + matrix: + only: + - BUILD_ENV: msbuild -build_script: - - cmd: if %BUILD_ENV%==msbuild ( - msbuild .\windows\hidapi.sln /p:Configuration=Release /p:Platform=%arch% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" ) - - cmd: if %BUILD_ENV%==cygwin ( - C:\cygwin64\bin\bash -exlc "cd $APPVEYOR_BUILD_FOLDER; ./bootstrap; ./configure; make" ) + build_script: + - cmd: msbuild .\windows\hidapi.sln /p:Configuration=Release /p:Platform=%arch% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" -artifacts: - # Win32 artifacts - - path: .\windows\Release\hidapi.dll - - path: .\windows\Release\hidapi.lib - - path: .\windows\Release\hidapi.pdb - - path: .\windows\Release\hidtest.exe - - path: .\windows\Release\hidtest.pdb - # x64 artifacts - - path: .\windows\x64\Release\hidapi.dll - - path: .\windows\x64\Release\hidapi.lib - - path: .\windows\x64\Release\hidapi.pdb - - path: .\windows\x64\Release\hidtest.exe - - path: .\windows\x64\Release\hidtest.pdb + - + matrix: + only: + - BUILD_ENV: cygwin + + install: + - cmd: C:\cygwin64\setup-x86_64.exe --quiet-mode --no-shortcuts --upgrade-also --packages autoconf,automake + + build_script: + - cmd: C:\cygwin64\bin\bash -exlc "cd $APPVEYOR_BUILD_FOLDER; ./bootstrap; ./configure; make" diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 9e745ef3..c8bbc904 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -95,7 +95,7 @@ jobs: install/static/include/hidapi/hidapi_libusb.h" allow_failure: true - windows-cmake-msvc: + windows-cmake: runs-on: windows-latest @@ -103,64 +103,91 @@ jobs: - uses: actions/checkout@v2 with: path: hidapisrc - - name: Configure CMake + - name: Configure CMake MSVC shell: cmd run: | - RMDIR /Q /S build install - cmake -B build -S hidapisrc -DCMAKE_INSTALL_PREFIX=install -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=%MSVC_COMPILE_FLAGS%" - - name: Build CMake - working-directory: build + cmake -B build\msvc -S hidapisrc -DCMAKE_INSTALL_PREFIX=install\msvc -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=%MSVC_COMPILE_FLAGS%" + - name: Build CMake MSVC + working-directory: build/msvc run: cmake --build . --target install - - name: Check artifacts + - name: Check artifacts MSVC uses: andstor/file-existence-action@v1 with: - files: "install/lib/hidapi.lib, install/bin/hidapi.dll, install/include/hidapi/hidapi.h, install/include/hidapi/hidapi_winapi.h" + files: "install/msvc/lib/hidapi.lib, \ + install/msvc/bin/hidapi.dll, \ + install/msvc/include/hidapi/hidapi.h, \ + install/msvc/include/hidapi/hidapi_winapi.h" allow_failure: true - windows-cmake-nmake: - - runs-on: windows-latest - - steps: - - uses: actions/checkout@v2 - with: - path: hidapisrc - - name: Configure CMake + - name: Configure CMake NMake shell: cmd run: | - RMDIR /Q /S build install call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - cmake -G"NMake Makefiles" -B build -S hidapisrc -DCMAKE_INSTALL_PREFIX=install -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=%MSVC_COMPILE_FLAGS%" - - name: Build CMake - working-directory: build + cmake -G"NMake Makefiles" -B build\nmake -S hidapisrc -DCMAKE_INSTALL_PREFIX=install\nmake -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=%MSVC_COMPILE_FLAGS%" + - name: Build CMake NMake + working-directory: build\nmake shell: cmd run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" nmake install - - name: Check artifacts + - name: Check artifacts NMake + uses: andstor/file-existence-action@v1 + with: + files: "install/nmake/lib/hidapi.lib, \ + install/nmake/bin/hidapi.dll, \ + install/nmake/include/hidapi/hidapi.h, \ + install/nmake/include/hidapi/hidapi_winapi.h" + allow_failure: true + + - name: Configure CMake MinGW + shell: cmd + run: | + cmake -G"MinGW Makefiles" -B build\mingw -S hidapisrc -DCMAKE_INSTALL_PREFIX=install\mingw -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=%NIX_COMPILE_FLAGS%" + - name: Build CMake MinGW + working-directory: build\mingw + run: cmake --build . --target install + - name: Check artifacts MinGW uses: andstor/file-existence-action@v1 with: - files: "install/lib/hidapi.lib, install/bin/hidapi.dll, install/include/hidapi/hidapi.h, install/include/hidapi/hidapi_winapi.h" + files: "install/mingw/lib/libhidapi.dll.a, \ + install/mingw/bin/libhidapi.dll, \ + install/mingw/include/hidapi/hidapi.h, \ + install/mingw/include/hidapi/hidapi_winapi.h" allow_failure: true - windows-cmake-mingw: + windows-msbuild: runs-on: windows-latest steps: - uses: actions/checkout@v2 + - uses: microsoft/setup-msbuild@v1.1 + - name: MSBuild x86 + run: msbuild windows\hidapi.sln /p:Configuration=Release /p:Platform=Win32 + - name: Check artifacts x86 + uses: andstor/file-existence-action@v1 with: - path: hidapisrc - - name: Configure CMake - shell: cmd - run: | - RMDIR /Q /S build install - cmake -G"MinGW Makefiles" -B build -S hidapisrc -DCMAKE_INSTALL_PREFIX=install -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=%NIX_COMPILE_FLAGS%" - - name: Build CMake - working-directory: build - run: cmake --build . --target install - - name: Check artifacts + files: "windows/Release/hidapi.dll, windows/Release/hidapi.lib, windows/Release/hidapi.pdb" + allow_failure: true + - name: MSBuild x64 + run: msbuild windows\hidapi.sln /p:Configuration=Release /p:Platform=x64 + - name: Check artifacts x64 uses: andstor/file-existence-action@v1 with: - files: "install/lib/libhidapi.dll.a, install/bin/libhidapi.dll, install/include/hidapi/hidapi.h, install/include/hidapi/hidapi_winapi.h" + files: "windows/x64/Release/hidapi.dll, windows/x64/Release/hidapi.lib, windows/x64/Release/hidapi.pdb" allow_failure: true + - name: Gather artifacts + run: | + md artifacts + md artifacts\x86 + md artifacts\x64 + md artifacts\include + Copy-Item "windows\Release\hidapi.dll","windows\Release\hidapi.lib","windows\Release\hidapi.pdb" -Destination "artifacts\x86" + Copy-Item "windows\x64\Release\hidapi.dll","windows\x64\Release\hidapi.lib","windows\x64\Release\hidapi.pdb" -Destination "artifacts\x64" + Copy-Item "hidapi\hidapi.h","windows\hidapi_winapi.h" -Destination "artifacts\include" + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: hidapi-win + path: artifacts/ + retention-days: ${{ (github.event_name == 'pull_request' || github.ref_name != 'master') && 7 || 90 }} diff --git a/windows/hidapi.vcxproj b/windows/hidapi.vcxproj index b233f255..b14c5c1b 100644 --- a/windows/hidapi.vcxproj +++ b/windows/hidapi.vcxproj @@ -31,6 +31,7 @@ v140 v141 v142 + v143 Unicode true @@ -41,6 +42,7 @@ v140 v141 v142 + v143 Unicode true @@ -51,6 +53,7 @@ v140 v141 v142 + v143 Unicode @@ -60,6 +63,7 @@ v140 v141 v142 + v143 Unicode diff --git a/windows/hidtest.vcxproj b/windows/hidtest.vcxproj index d2c59f72..a468d8bc 100644 --- a/windows/hidtest.vcxproj +++ b/windows/hidtest.vcxproj @@ -30,6 +30,7 @@ v140 v141 v142 + v143 MultiByte true @@ -40,6 +41,7 @@ v140 v141 v142 + v143 MultiByte true @@ -50,6 +52,7 @@ v140 v141 v142 + v143 MultiByte @@ -59,6 +62,7 @@ v140 v141 v142 + v143 MultiByte