Skip to content

Commit

Permalink
[windows CI] get protobuf binaries from external source
Browse files Browse the repository at this point in the history
  • Loading branch information
em-eight committed Sep 24, 2023
1 parent 94fdac9 commit 48d48c4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
34 changes: 20 additions & 14 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,23 @@ 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")
set(protobuf_MODULE_COMPATIBLE ON)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
endif()
endif()

# Generate Protobuf files
set(PROTO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/proto")
Expand Down

0 comments on commit 48d48c4

Please sign in to comment.