Skip to content

Commit

Permalink
use build_windows/vcpkg_installed as cache
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-christophe81 committed Jul 23, 2024
1 parent 9d86fbb commit f7fdf70
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 70 deletions.
17 changes: 9 additions & 8 deletions .github/scripts/windows-agent-compile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Set-PSDebug -Trace 2

Write-Host "Work in" $pwd.ToString()

[System.Environment]::SetEnvironmentVariable("VCPKG_BINARY_SOURCES", "clear;files," + $pwd.ToString() + "\vcpkg\vcpkg-binary-cache,readwrite")
[System.Environment]::SetEnvironmentVariable("VCPKG_ROOT",$pwd.ToString()+"\vcpkg")
[System.Environment]::SetEnvironmentVariable("PATH",$pwd.ToString()+"\vcpkg:" + $env:PATH)
[System.Environment]::SetEnvironmentVariable("AWS_EC2_METADATA_DISABLED","true")
Expand All @@ -30,23 +29,25 @@ $file_name = "windows-agent-binary-cache-" + $vcpkg_hash.Hash
$file_name_extension = "${file_name}.7z"

aws --quiet s3 cp s3://centreon-collect-robot-report/$file_name_extension $file_name_extension
if ( $? -ne 0 ) {
if ( $? -ne $true ) {
Write-Host "#######################################################################################################################"
Write-Host "binary cache unavailable for this version we will need to build it, it will take a long time"
Write-Host "compiled dependencies unavailable for this version we will need to build it, it will take a long time"
Write-Host "#######################################################################################################################"
Write-Host "Create cmake files before upload binary-cache"
cmake --preset=release
Write-Host "compile vcpkg dependencies"
vcpkg install --vcpkg-root $env:VCPKG_ROOT --x-install-root build_windows\vcpkg_installed --x-manifest-root . --overlay-triplets custom-triplets --triplet x64-windows

Write-Host "Compress binary archive"
7z a $file_name_extension vcpkg\vcpkg-binary-cache
7z a $file_name_extension build_windows\vcpkg_installed
Write-Host "Upload binary archive"
aws s3 cp $file_name_extension s3://centreon-collect-robot-report/$file_name_extension

Write-Host "create CMake files"
cmake -DCMAKE_BUILD_TYPE=Release -DWITH_TESTING=On -DWINDOWS=On -DBUILD_FROM_CACHE=On -GNinja -S. -Bbuild_windows
}
else {
7z x $file_name_extension

Write-Host "Create cmake files from binary-cache downloaded"
cmake --preset=release-ci-use-binary-cache
Write-Host "Create cmake files from binary-cache downloaded without use vcpkg"

}

Expand Down
35 changes: 19 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,29 @@ set(CMAKE_CXX_STANDARD 17)
string(TIMESTAMP CENTREON_CURRENT_YEAR "%Y")
add_definitions(-DCENTREON_CURRENT_YEAR="${CENTREON_CURRENT_YEAR}")

if(DEFINED ENV{VCPKG_ROOT})
set(VCPKG_ROOT "$ENV{VCPKG_ROOT}")
message(
STATUS "TOOLCHAIN set to ${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
set(CMAKE_TOOLCHAIN_FILE
"${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "Vcpkg toolchain file")
else()
message(
STATUS
"TOOLCHAIN set to ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake"
)
if (NOT BUILD_FROM_CACHE)
if(DEFINED ENV{VCPKG_ROOT})
set(VCPKG_ROOT "$ENV{VCPKG_ROOT}")
message(
STATUS "TOOLCHAIN set to ${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
set(CMAKE_TOOLCHAIN_FILE
"${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "Vcpkg toolchain file")
else()
message(
STATUS
"TOOLCHAIN set to ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake"
)
set(CMAKE_TOOLCHAIN_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "Vcpkg toolchain file")
endif()

set(CMAKE_TOOLCHAIN_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "Vcpkg toolchain file")
endif()

set(CMAKE_TOOLCHAIN_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "Vcpkg toolchain file")
endif()

project("Centreon Collect" C CXX)

Expand Down
4 changes: 4 additions & 0 deletions CMakeListsWindows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
# For more information : contact@centreon.com
#

if (BUILD_FROM_CACHE)
LIST(APPEND CMAKE_PREFIX_PATH "build_windows/vcpkg_installed/x64-windows")
endif()

find_package(fmt CONFIG REQUIRED)
find_package(spdlog CONFIG REQUIRED)
find_package(gRPC CONFIG REQUIRED)
Expand Down
13 changes: 0 additions & 13 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,6 @@
"VCPKG_OVERLAY_TRIPLETS": "custom-triplets",
"VCPKG_TARGET_TRIPLET": "x64-windows"
}
},
{
"name": "release-ci-use-binary-cache",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build_windows",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"WITH_TESTING": "On",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_OVERLAY_TRIPLETS": "custom-triplets",
"VCPKG_TARGET_TRIPLET": "x64-windows",
"VCPKG_INSTALL_OPTIONS": "--no-downloads"
}
}
]
}
18 changes: 9 additions & 9 deletions agent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ else()
add_executable(${CENTREON_AGENT} ${SRC_DIR}/main_win.cc)

target_link_libraries(
${CENTREON_AGENT} PRIVATE
centagent_lib
centreon_common
centreon_grpc
centreon_process
gRPC::gpr gRPC::grpc gRPC::grpc++ gRPC::grpc++_alts
absl::any absl::log absl::base absl::bits
Boost::program_options
fmt::fmt)
${CENTREON_AGENT} PRIVATE
centagent_lib
centreon_common
centreon_grpc
centreon_process
gRPC::gpr gRPC::grpc gRPC::grpc++ gRPC::grpc++_alts
absl::any absl::log absl::base absl::bits
Boost::program_options
fmt::fmt)
endif()


Expand Down
37 changes: 18 additions & 19 deletions agent/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,24 @@ set_target_properties(
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_BINARY_DIR}/tests)

if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
target_link_libraries(ut_agent PRIVATE
centagent_lib
centreon_common
centreon_process
GTest::gtest
GTest::gtest_main
GTest::gmock
GTest::gmock_main
-L${Boost_LIBRARY_DIR_RELEASE}
boost_program_options
stdc++fs
-L${PROTOBUF_LIB_DIR}
gRPC::gpr gRPC::grpc gRPC::grpc++ gRPC::grpc++_alts
fmt::fmt pthread
crypto ssl
)
target_link_libraries(ut_agent PRIVATE
centagent_lib
centreon_common
centreon_process
GTest::gtest
GTest::gtest_main
GTest::gmock
GTest::gmock_main
-L${Boost_LIBRARY_DIR_RELEASE}
boost_program_options
stdc++fs
-L${PROTOBUF_LIB_DIR}
gRPC::gpr gRPC::grpc gRPC::grpc++ gRPC::grpc++_alts
fmt::fmt pthread
crypto ssl
)
else()
target_link_libraries(ut_agent PRIVATE
target_link_libraries(ut_agent PRIVATE
centagent_lib
centreon_common
centreon_process
Expand All @@ -70,8 +70,7 @@ else()
GTest::gmock_main
Boost::program_options
gRPC::gpr gRPC::grpc gRPC::grpc++ gRPC::grpc++_alts
fmt::fmt
)
fmt::fmt)
endif()

add_dependencies(ut_agent centreon_common centagent_lib)
Expand Down
5 changes: 3 additions & 2 deletions common/grpc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ target_include_directories(centreon_grpc PRIVATE ${INC_DIR})

target_precompile_headers(centreon_grpc REUSE_FROM centreon_common)

set_target_properties(centreon_grpc PROPERTIES COMPILE_FLAGS "-fPIC")

if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set_target_properties(centreon_grpc PROPERTIES COMPILE_FLAGS "-fPIC")
endif()
5 changes: 2 additions & 3 deletions common/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
absl::bits
fmt::fmt pthread)

add_dependencies(ut_common centreon_common centreon_http)
add_dependencies(ut_common centreon_common centreon_http)

else()
target_link_libraries(
Expand All @@ -102,8 +102,7 @@ else()
absl::base
absl::bits
fmt::fmt)

add_dependencies(ut_common centreon_common)
add_dependencies(ut_common centreon_common)

endif()

Expand Down

0 comments on commit f7fdf70

Please sign in to comment.