From 48d48c491d36815df2288925b51734bd7100db5f Mon Sep 17 00:00:00 2001 From: em-eight Date: Sun, 24 Sep 2023 18:59:55 +0300 Subject: [PATCH] [windows CI] get protobuf binaries from external source --- .github/workflows/windows.yml | 34 ++++++++++++++++++++-------------- CMakeLists.txt | 10 ++++++++++ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 115b0c4..b40bb93 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -14,32 +14,38 @@ jobs: - uses: actions/checkout@v3 - name: Install LLVM - run: choco install -y llvm - if: runner.os == 'Windows' + run: choco install -y llvm --version=16.0.6 + - name: Install Ninja + run: choco install -y ninja - - name: windows vcpkg shit - # https://vcpkg.io/en/getting-started.html + - name: Download protobuf run: | - git clone https://github.com/Microsoft/vcpkg.git - ./vcpkg/bootstrap-vcpkg.sh - vcpkg install protobuf protobuf:x64-windows - vcpkg owns protobuf - ls vcpkg/scripts/buildsystems/vcpkg.cmake + Invoke-WebRequest "https://github.com/protocolbuffers/protobuf/releases/download/v21.12/protoc-21.12-win64.zip" -OutFile protoc_x64-windows.zip + dir + mkdir protoc_x64-windows + 7z x protobuf_x64-windows.zip -oprotoc_x64-windows + dir + Invoke-WebRequest "https://www.dropbox.com/scl/fi/te9p80zrzcwgswrkw21en/protobuf_x64-windows.zip?rlkey=btmzjokhh256xxns348o3re7m&dl=1" -OutFile protobuf_x64-windows.zip + dir + 7z x protobuf_x64-windows.zip + dir + - name: CMake generate + shell: bash env: ARTIFACT_NAME: ppc2cpp-${{ runner.os }} run: | - echo $WINDOWS_FLAGS cmake --version - cmake -B build \ + cmake -B build -GNinja \ -DCMAKE_INSTALL_PREFIX=$ARTIFACT_NAME \ -DCMAKE_BUILD_TYPE=Release \ -DBUILD_TESTING=OFF \ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \ - -S . -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_GENERATOR_PLATFORM=x64 - shell: bash + -DEXTERNAL_LIBPROTOBUF_PATH=protobuf_x64-windows \ + -DEXTERNAL_PROTOC_PATH=protoc_x64-windows \ - name: Build - run: cmake --build build --target install -j + shell: bash + run: cmake --build build --target install --parallel - uses: actions/upload-artifact@v3 if: github.ref == 'refs/heads/main' && github.repository == 'em-eight/ppc2cpp' diff --git a/CMakeLists.txt b/CMakeLists.txt index d584446..eab13d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,15 @@ CPMAddPackage("gh:fmtlib/fmt#10.0.0") set(Protobuf_USE_STATIC_LIBS ON) +if(DEFINED EXTERNAL_LIBPROTOBUF_PATH AND DEFINED EXTERNAL_PROTOC_PATH) + # In case protobuf location is defined externally (Windows/CI hack) + find_package(Protobuf) # fails but defines protobuf_generate_cpp lmaoooo + link_directories(${EXTERNAL_LIBPROTOBUF_PATH}/lib) + set(Protobuf_LIBRARIES protobuf) + set(Protobuf_INCLUDE_DIRS "${EXTERNAL_LIBPROTOBUF_PATH}/include") + set(Protobuf_PROTOC_EXECUTABLE "${EXTERNAL_PROTOC_PATH}/bin/protoc.exe") + set(protobuf_MODULE_COMPATIBLE ON) +else() find_package(protobuf CONFIG) if(NOT protobuf_FOUND) # Legacy protobuf support message(STATUS "Trying legacy method of finding protobuf") @@ -41,6 +50,7 @@ if(NOT protobuf_FOUND) # Legacy protobuf support include(FindProtobuf) find_package(Protobuf REQUIRED) endif() +endif() # Generate Protobuf files set(PROTO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/proto")