Skip to content

Commit

Permalink
Prepare for OneBranch Support (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
nibanks authored Mar 20, 2024
1 parent 4e49257 commit 570db01
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 10 deletions.
37 changes: 37 additions & 0 deletions .azure/post-build.ps1
Original file line number Diff line number Diff line change
@@ -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"
49 changes: 49 additions & 0 deletions .azure/pre-build.ps1
Original file line number Diff line number Diff line change
@@ -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 .."
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/onebranch.yml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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}$<IF:$<CONFIG:Debug>,chk,fre>)
set(REACH_OUTPUT_DIR ${REACH_BUILD_DIR}/bin/${REACH_ARCH}$<IF:$<CONFIG:Debug>,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$<$<CONFIG:Debug>:Debug>")
Expand Down
8 changes: 4 additions & 4 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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" }
Expand Down

0 comments on commit 570db01

Please sign in to comment.