diff --git a/.azure/post-build.ps1 b/.azure/post-build.ps1 new file mode 100644 index 00000000..ddb41e4b --- /dev/null +++ b/.azure/post-build.ps1 @@ -0,0 +1,37 @@ +param ( + [Parameter(Mandatory = $false)] + [ValidateSet("x86", "x64", "arm", "arm64", "arm64ec")] + [string]$Arch = "x64", + + [Parameter(Mandatory = $false)] + [ValidateSet("Debug", "Release")] + [string]$Config = "Release" +) + +Set-StrictMode -Version 'Latest' +$PSDefaultParameterValues['*:ErrorAction'] = 'Stop' + +function Execute([String]$Name, [String]$Arguments) { + Write-Debug "$Name $Arguments" + $process = Start-Process $Name $Arguments -PassThru -NoNewWindow -WorkingDirectory "./build" + $handle = $process.Handle # Magic work around. Don't remove this line. + $process.WaitForExit(); + if ($process.ExitCode -ne 0) { + Write-Error "$Name exited with status code $($process.ExitCode)" + } +} + +if ($env:ONEBRANCH_ARCH) { + $Arch = $env:ONEBRANCH_ARCH +} +if ($env:ONEBRANCH_CONFIG) { + $Config = $env:ONEBRANCH_CONFIG +} + +$platform = "$($Arch)fre" +if ($Config -eq "Debug") { + $platform = "$($Arch)chk" +} + +Execute 'C:/Program Files (x86)/WiX Toolset v3.14/bin/candle.exe' "../src/installer.wxs -o bin/$platform/quicreach.wixobj" +Execute 'C:/Program Files (x86)/WiX Toolset v3.14/bin/light.exe' "-b bin/$($Arch)fre/Release -o bin/$platform/quicreach.msi bin/$($Arch)fre/quicreach.wixobj" diff --git a/.azure/pre-build.ps1 b/.azure/pre-build.ps1 new file mode 100644 index 00000000..df56d217 --- /dev/null +++ b/.azure/pre-build.ps1 @@ -0,0 +1,49 @@ +param ( + [Parameter(Mandatory = $false)] + [ValidateSet("x86", "x64", "arm", "arm64", "arm64ec")] + [string]$Arch = "x64", + + [Parameter(Mandatory = $false)] + [ValidateSet("Debug", "Release")] + [string]$Config = "Release", + + [Parameter(Mandatory = $false)] + [ValidateSet("schannel", "openssl")] + [string]$Tls = "schannel", + + [Parameter(Mandatory = $false)] + [ValidateSet("static", "shared")] + [string]$Link = "static" +) + +Set-StrictMode -Version 'Latest' +$PSDefaultParameterValues['*:ErrorAction'] = 'Stop' + +function Execute([String]$Name, [String]$Arguments) { + Write-Debug "$Name $Arguments" + $process = Start-Process $Name $Arguments -PassThru -NoNewWindow -WorkingDirectory "./build" + $handle = $process.Handle # Magic work around. Don't remove this line. + $process.WaitForExit(); + if ($process.ExitCode -ne 0) { + Write-Error "$Name exited with status code $($process.ExitCode)" + } +} + +if ($env:ONEBRANCH_ARCH) { + $Arch = $env:ONEBRANCH_ARCH +} +if ($env:ONEBRANCH_CONFIG) { + $Config = $env:ONEBRANCH_CONFIG +} + +if (!(Test-Path "./build")) { + New-Item -Path "./build" -ItemType Directory -Force | Out-Null +} + +$_Arch = $Arch +if ($_Arch -eq "x86") { $_Arch = "Win32" } + +$Shared = "off" +if ($Link -ne "static") { $Shared = "on" } + +Execute "cmake" "-G ""Visual Studio 17 2022"" -A $_Arch -DREACH_ARCH=$_Arch -DQUIC_TLS=$Tls -DQUIC_BUILD_SHARED=$Shared .." diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index acca8d2b..08034deb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,11 +51,11 @@ jobs: with: name: bin-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.tls }}-${{ matrix.link }} path: | - build/**/*.so - build/**/*.dll - build/**/quicreach - build/**/quicreach.exe - build/**/quicreach.msi + build/bin/**/*.so + build/bin/**/*.dll + build/bin/**/quicreach + build/bin/**/quicreach.exe + build/bin/**/quicreach.msi - name: Test (Linux) if: runner.os == 'Linux' run: /usr/local/lib/quicreach outlook-evergreen.office.com,www.cloudflare.com,www.google.com --req-all --stats diff --git a/.github/workflows/onebranch.yml b/.github/workflows/onebranch.yml new file mode 100644 index 00000000..dfeec9d4 --- /dev/null +++ b/.github/workflows/onebranch.yml @@ -0,0 +1,43 @@ +name: Build + +on: + push: + branches: main + pull_request: + branches: main + +permissions: read-all + +jobs: + build: + strategy: + fail-fast: false + matrix: + arch: [x64, arm64] + name: Build + runs-on: windows-latest + steps: + - name: Checkout repository + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + with: + submodules: 'recursive' + - name: Setup MSBuild + uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce + - name: Pre-Build + shell: pwsh + run: ./.azure/pre-build.ps1 -Arch ${{ matrix.arch }} + - name: Build + run: msbuild ./build/ALL_BUILD.vcxproj /p:Configuration=Release /p:Platform=${{ matrix.arch }} + - name: Post-Build + shell: pwsh + run: ./.azure/post-build.ps1 -Arch ${{ matrix.arch }} + - name: Upload + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 + with: + name: bin-windows-${{ matrix.arch }} + path: | + build/bin/**/*.so + build/bin/**/*.dll + build/bin/**/quicreach + build/bin/**/quicreach.exe + build/bin/**/quicreach.msi diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ce92015..c95ba5f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,8 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. -project(quicreach) cmake_minimum_required(VERSION 3.16) # 3.20 for non-shared libs +project(quicreach) # Use, i.e. don't skip the full RPATH for the build tree. set(CMAKE_SKIP_BUILD_RPATH FALSE) @@ -16,6 +16,20 @@ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") # outside the build tree to the install RPATH. set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +# Configure output paths. +set(REACH_ARCH ${CMAKE_SYSTEM_PROCESSOR} CACHE STRING "Output architecture") +set(REACH_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${REACH_BUILD_DIR}/obj/${REACH_ARCH}$,chk,fre>) +set(REACH_OUTPUT_DIR ${REACH_BUILD_DIR}/bin/${REACH_ARCH}$,chk,fre> CACHE STRING "Output directory for build artifacts") +message(STATUS "Build Output: ${REACH_OUTPUT_DIR}") + +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${REACH_OUTPUT_DIR}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${REACH_OUTPUT_DIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${REACH_OUTPUT_DIR}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${REACH_OUTPUT_DIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${REACH_OUTPUT_DIR}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${REACH_OUTPUT_DIR}) + if (WIN32) # Statically link the OS included part of the runtime. set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") diff --git a/build.ps1 b/build.ps1 index fa37eeb4..e60cfc24 100644 --- a/build.ps1 +++ b/build.ps1 @@ -53,12 +53,12 @@ if ($IsWindows) { $_Arch = $Arch if ($_Arch -eq "x86") { $_Arch = "Win32" } - Execute "cmake" "-G ""Visual Studio 17 2022"" -A $_Arch -DQUIC_TLS=$Tls -DQUIC_BUILD_SHARED=$Shared .." + Execute "cmake" "-G ""Visual Studio 17 2022"" -A $_Arch -DREACH_ARCH=$Arch -DQUIC_TLS=$Tls -DQUIC_BUILD_SHARED=$Shared .." Execute "cmake" "--build . --config $Config" if ($BuildInstaller) { - Execute 'C:/Program Files (x86)/WiX Toolset v3.14/bin/candle.exe' "../src/installer.wxs -o src/Release/quicreach.wixobj" - Execute 'C:/Program Files (x86)/WiX Toolset v3.14/bin/light.exe' "-b src/Release -o src/Release/quicreach.msi src/Release/quicreach.wixobj" + Execute 'C:/Program Files (x86)/WiX Toolset v3.14/bin/candle.exe' "../src/installer.wxs -o bin/$($Arch)fre/quicreach.wixobj" + Execute 'C:/Program Files (x86)/WiX Toolset v3.14/bin/light.exe' "-b bin/$($Arch)fre/Release -o bin/$($Arch)fre/quicreach.msi bin/$($Arch)fre/quicreach.wixobj" } if ($Install) { Execute "cmake" "--install . --config Release" } @@ -67,7 +67,7 @@ if ($IsWindows) { $BuildType = $Config if ($BuildType -eq "Release") { $BuildType = "RelWithDebInfo" } - Execute "cmake" "-G ""Unix Makefiles"" -DCMAKE_BUILD_TYPE=$BuildType -DQUIC_TLS=$Tls -DQUIC_BUILD_SHARED=$Shared .." + Execute "cmake" "-G ""Unix Makefiles"" -DCMAKE_BUILD_TYPE=$BuildType -DREACH_ARCH=$Arch -DQUIC_TLS=$Tls -DQUIC_BUILD_SHARED=$Shared .." Execute "cmake" "--build ." if ($Install) { Execute "sudo" "cmake --install . --config Release" }