From 266ee0cc4503aeb408247ad342bb3ab4f59ecb01 Mon Sep 17 00:00:00 2001 From: jean-christophe81 <98889244+jean-christophe81@users.noreply.github.com> Date: Wed, 6 Nov 2024 12:08:39 +0100 Subject: [PATCH] upgrade vcpkg (#1837) --- .github/scripts/agent_robot_test.ps1 | 8 +++---- .github/scripts/windows-agent-compile.ps1 | 28 +++++++++++++++-------- common/process/CMakeLists.txt | 4 ++++ 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/.github/scripts/agent_robot_test.ps1 b/.github/scripts/agent_robot_test.ps1 index 0e8937289bb..37345457f0a 100644 --- a/.github/scripts/agent_robot_test.ps1 +++ b/.github/scripts/agent_robot_test.ps1 @@ -60,7 +60,7 @@ $agent_log_path = $current_dir + "\reports\centagent.log" Set-ItemProperty -Path HKLM:\SOFTWARE\Centreon\CentreonMonitoringAgent -Name log_file -Value $agent_log_path #Start agent -Start-Process -FilePath build_windows\agent\Release\centagent.exe -RedirectStandardOutput reports\centagent_stdout.log -RedirectStandardError reports\centagent_stderr.log +$agent_process = Start-Process -PassThru -FilePath build_windows\agent\Release\centagent.exe -ArgumentList "--standalone" -RedirectStandardOutput reports\centagent_stdout.log -RedirectStandardError reports\centagent_stderr.log Write-Host ($agent_process | Format-Table | Out-String) @@ -73,7 +73,7 @@ Set-ItemProperty -Path HKLM:\SOFTWARE\Centreon\CentreonMonitoringAgent -Name en $agent_log_path = $current_dir + "\reports\encrypted_centagent.log" Set-ItemProperty -Path HKLM:\SOFTWARE\Centreon\CentreonMonitoringAgent -Name log_file -Value $agent_log_path -Start-Process -FilePath build_windows\agent\Release\centagent.exe -RedirectStandardOutput reports\encrypted_centagent_stdout.log -RedirectStandardError reports\encrypted_centagent_stderr.log +Start-Process -FilePath build_windows\agent\Release\centagent.exe -ArgumentList "--standalone" -RedirectStandardOutput reports\encrypted_centagent_stdout.log -RedirectStandardError reports\encrypted_centagent_stderr.log Start-Sleep -Seconds 1 @@ -86,7 +86,7 @@ Set-ItemProperty -Path HKLM:\SOFTWARE\Centreon\CentreonMonitoringAgent -Name re $agent_log_path = $current_dir + "\reports\reverse_centagent.log" Set-ItemProperty -Path HKLM:\SOFTWARE\Centreon\CentreonMonitoringAgent -Name log_file -Value $agent_log_path -Start-Process -FilePath build_windows\agent\Release\centagent.exe -RedirectStandardOutput reports\reversed_centagent_stdout.log -RedirectStandardError reports\reversed_centagent_stderr.log +Start-Process -FilePath build_windows\agent\Release\centagent.exe -ArgumentList "--standalone" -RedirectStandardOutput reports\reversed_centagent_stdout.log -RedirectStandardError reports\reversed_centagent_stderr.log Start-Sleep -Seconds 1 @@ -98,7 +98,7 @@ Set-ItemProperty -Path HKLM:\SOFTWARE\Centreon\CentreonMonitoringAgent -Name en $agent_log_path = $current_dir + "\reports\encrypted_reverse_centagent.log" Set-ItemProperty -Path HKLM:\SOFTWARE\Centreon\CentreonMonitoringAgent -Name log_file -Value $agent_log_path -Start-Process -FilePath build_windows\agent\Release\centagent.exe -RedirectStandardOutput reports\encrypted_reversed_centagent_stdout.log -RedirectStandardError reports\encrypted_reversed_centagent_stderr.log +Start-Process -FilePath build_windows\agent\Release\centagent.exe -ArgumentList "--standalone" -RedirectStandardOutput reports\encrypted_reversed_centagent_stdout.log -RedirectStandardError reports\encrypted_reversed_centagent_stderr.log wsl cd $wsl_path `&`& .github/scripts/wsl-collect-test-robot.sh broker-engine/cma.robot $my_host_name $my_ip $pwsh_path ${current_dir}.replace('\','/') diff --git a/.github/scripts/windows-agent-compile.ps1 b/.github/scripts/windows-agent-compile.ps1 index ed44fd015c5..b3246b59ed3 100644 --- a/.github/scripts/windows-agent-compile.ps1 +++ b/.github/scripts/windows-agent-compile.ps1 @@ -24,6 +24,14 @@ Write-Host $env:VCPKG_BINARY_SOURCES $current_dir = $pwd.ToString() +#install recent version of 7zip needed by some packages +Write-Host "install 7zip" + +#download 7zip +Invoke-WebRequest -Uri "https://www.7-zip.org/a/7z2408-x64.msi" -OutFile "7z2408-x64.msi" +#install 7zip +Start-Process 'msiexec.exe' -ArgumentList '/I "7z2408-x64.msi" /qn' -Wait + #get cache from s3 $files_to_hash = "vcpkg.json", "custom-triplets\x64-windows.cmake", "CMakeLists.txt", "CMakeListsWindows.txt" $files_content = Get-Content -Path $files_to_hash -Raw @@ -32,8 +40,9 @@ $writer = [System.IO.StreamWriter]::new($stringAsStream) $writer.write($files_content -join " ") $writer.Flush() $stringAsStream.Position = 0 +$vcpkg_release = "2024.10.21" $vcpkg_hash = Get-FileHash -InputStream $stringAsStream -Algorithm SHA256 | Select-Object Hash -$file_name = "windows-agent-vcpkg-dependencies-cache-" + $vcpkg_hash.Hash +$file_name = "windows-agent-vcpkg-dependencies-cache-" + $vcpkg_hash.Hash + "-" + $vcpkg_release $file_name_extension = "${file_name}.7z" #try to get compiled dependenciesfrom s3 @@ -46,7 +55,7 @@ if ( $? -ne $true ) { Write-Host "#######################################################################################################################" Write-Host "install vcpkg" - git clone --depth 1 -b 2024.07.12 https://github.com/microsoft/vcpkg.git + git clone --depth 1 -b $vcpkg_release https://github.com/microsoft/vcpkg.git cd vcpkg bootstrap-vcpkg.bat cd $current_dir @@ -57,23 +66,24 @@ if ( $? -ne $true ) { 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 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" + if ( $? -eq $true ) { + Write-Host "Compress binary archive" + 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 + } } else { 7z x $file_name_extension Write-Host "Create cmake files from binary-cache downloaded without use vcpkg" } - +Write-Host "create CMake files" cmake -DCMAKE_BUILD_TYPE=Release -DWITH_TESTING=On -DWINDOWS=On -DBUILD_FROM_CACHE=On -S. -DVCPKG_CRT_LINKAGE=dynamic -DBUILD_SHARED_LIBS=OFF -Bbuild_windows -Write-Host "------------- build agent and installer ---------------" +Write-Host "------------- build agent only ---------------" cmake --build build_windows --config Release diff --git a/common/process/CMakeLists.txt b/common/process/CMakeLists.txt index f79bbaaa657..22235468ac6 100644 --- a/common/process/CMakeLists.txt +++ b/common/process/CMakeLists.txt @@ -27,4 +27,8 @@ add_library( target_precompile_headers(centreon_process REUSE_FROM centreon_common) +if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + target_link_libraries(centreon_process INTERFACE Boost::process) +endif() + set_property(TARGET centreon_process PROPERTY POSITION_INDEPENDENT_CODE ON)