From 5b0c35163a6a073ba961bdabfc7fd544c07da3d3 Mon Sep 17 00:00:00 2001 From: Bkacjios Date: Fri, 3 Jan 2025 13:16:00 -0500 Subject: [PATCH] Windows build? --- .github/workflows/cmake-multi-platform.yml | 107 ++++++++++++++++----- vcpkg-configuration.json | 5 + vcpkg.json | 25 +++++ 3 files changed, 113 insertions(+), 24 deletions(-) create mode 100644 vcpkg-configuration.json create mode 100644 vcpkg.json diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 2e20f59..59f6a4e 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -38,32 +38,42 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest] # You can also add windows-latest if you want to support Windows + os: [ubuntu-latest] #, windows-latest] build_type: [Release] - c_compiler: [gcc, clang] # Now we have gcc and clang in the same matrix include: + # For Linux, use gcc or clang as compilers - os: ubuntu-latest c_compiler: gcc cpp_compiler: g++ - - os: ubuntu-latest - c_compiler: clang - cpp_compiler: clang++ + # - os: ubuntu-latest + # c_compiler: clang + # cpp_compiler: clang++ + + # For Windows, use MSVC as the compiler + # - os: windows-latest + # c_compiler: msvc + # cpp_compiler: msvc steps: - uses: actions/checkout@v4 - name: Install Dependencies (Including gh) run: | - sudo apt-get update - sudo apt-get install -y \ - libssl-dev \ - libluajit-5.1-dev \ - protobuf-c-compiler \ - libprotobuf-c-dev \ - libopus-dev \ - libsndfile1-dev \ - libuv1-dev \ - gh # Install GitHub CLI + if [ "$RUNNER_OS" == "Linux" ]; then + sudo apt-get update + sudo apt-get install -y \ + libssl-dev \ + libluajit-5.1-dev \ + protobuf-c-compiler \ + libprotobuf-c-dev \ + libopus-dev \ + libsndfile1-dev \ + libuv1-dev \ + gh # Install GitHub CLI + elif [ "$RUNNER_OS" == "Windows" ]; then + echo "Windows dependencies installed via vcpkg" + fi + shell: bash - name: Set reusable strings id: strings @@ -71,16 +81,38 @@ jobs: run: | echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + - name: Install vcpkg for MSVC (Windows only) + if: matrix.os == 'windows-latest' + uses: lukka/run-vcpkg@v11 + with: + runVcpkgInstall: true + doNotUpdateVcpkg: true + vcpkgJsonGlob: "**/vcpkg.json" + env: + VCPKG_DEFAULT_TRIPLET: "x64-windows" # Set the default triplet for MSVC + - name: Configure CMake - run: > - cmake -B ${{ steps.strings.outputs.build-output-dir }} - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} - -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - -S ${{ github.workspace }} + run: | + if [ "$RUNNER_OS" == "Windows" ]; then + # CMake configuration for Windows (MSVC) + cmake -B ${{ steps.strings.outputs.build-output-dir }} \ + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -G "Visual Studio 16 2019" # Specify Visual Studio generator for MSVC + else + # CMake configuration for Linux + cmake -B ${{ steps.strings.outputs.build-output-dir }} \ + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -S ${{ github.workspace }} + fi + shell: bash - name: Build - run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + run: | + cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} - name: Test working-directory: ${{ steps.strings.outputs.build-output-dir }} @@ -106,10 +138,21 @@ jobs: echo "Zipped Clang .so files into $ZIP_FILE" working-directory: ${{ github.workspace }} + - name: Zip MSVC Files + if: matrix.c_compiler == 'msvc' + run: | + echo "Zipping MSVC files..." + MSVC_DLL_FILES=$(find ${{ steps.strings.outputs.build-output-dir }} -name '*.dll' -type f) + echo "Found MSVC .dll files: $MSVC_DLL_FILES" + ZIP_FILE="release-msvc.zip" + Compress-Archive -Path $MSVC_DLL_FILES -DestinationPath $ZIP_FILE # Zip all MSVC .dll files + echo "Zipped MSVC .dll files into $ZIP_FILE" + shell: powershell + - name: Upload GCC .so Zip to Release if: matrix.c_compiler == 'gcc' run: | - RELEASE_TAG="${{ needs.create_release.outputs.release_tag }}" # Ensure that the release tag is available here + RELEASE_TAG="${{ needs.create_release.outputs.release_tag }}" ZIP_FILE="release-gcc.zip" if [ -f "$ZIP_FILE" ]; then # Check if the zip file was created echo "Uploading $ZIP_FILE to release $RELEASE_TAG" @@ -124,7 +167,7 @@ jobs: - name: Upload Clang .so Zip to Release if: matrix.c_compiler == 'clang' run: | - RELEASE_TAG="${{ needs.create_release.outputs.release_tag }}" # Ensure that the release tag is available here + RELEASE_TAG="${{ needs.create_release.outputs.release_tag }}" ZIP_FILE="release-clang.zip" if [ -f "$ZIP_FILE" ]; then # Check if the zip file was created echo "Uploading $ZIP_FILE to release $RELEASE_TAG" @@ -135,3 +178,19 @@ jobs: fi env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload MSVC .dll Zip to Release + if: matrix.c_compiler == 'msvc' + run: | + echo "Uploading MSVC zip..." + RELEASE_TAG="${{ needs.create_release.outputs.release_tag }}" + ZIP_FILE="release-msvc.zip" + if [ -f "$ZIP_FILE" ]; then # Check if the zip file was created + echo "Uploading $ZIP_FILE to release $RELEASE_TAG" + gh release upload $RELEASE_TAG $ZIP_FILE --clobber + else + echo "Error: $ZIP_FILE not found." + exit 1 + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json new file mode 100644 index 0000000..01fa27c --- /dev/null +++ b/vcpkg-configuration.json @@ -0,0 +1,5 @@ +{ + "version-string": "2025.01", + "default-triplet": "x64-windows", + "vcpkg-commit-id": "latest" +} \ No newline at end of file diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000..8d09556 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,25 @@ +{ + "vcpkg-commit-id": "latest", + "dependencies": [ + { + "name": "libssl", + "version": "latest" + }, + { + "name": "protobuf-c", + "version": "latest" + }, + { + "name": "libopus", + "version": "latest" + }, + { + "name": "libsndfile", + "version": "latest" + }, + { + "name": "libuv", + "version": "latest" + } + ] +}