Skip to content

Commit

Permalink
Add support for building for iOS (#1904)
Browse files Browse the repository at this point in the history
* Add support for building for iOS

* Add iOS azure template

Co-authored-by: Thad House <[email protected]>
  • Loading branch information
thhous-msft and ThadHouse authored Aug 11, 2021
1 parent 289a595 commit 1b17a55
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
7 changes: 7 additions & 0 deletions .azure/azure-pipelines.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,13 @@ stages:
extraName: 'static'
extraBuildArgs: -Static -ExtraArtifactDir Static

- template: ./templates/build-config-user.yml
parameters:
image: macOS-10.15
platform: ios
arch: arm64
tls: openssl

- stage: merge_darwin
displayName: Merge Darwin (macOS)
dependsOn:
Expand Down
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,13 @@ if(QUIC_TLS STREQUAL "openssl")
list(APPEND QUIC_COMMON_DEFINES QUIC_DISABLE_DEFERRED_CERT_TESTS)
endif()

if (CMAKE_GENERATOR_PLATFORM STREQUAL "")
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} SYSTEM_PROCESSOR)
else()
string(TOLOWER ${CMAKE_GENERATOR_PLATFORM} SYSTEM_PROCESSOR)
endif()

if(WIN32)
if (CMAKE_GENERATOR_PLATFORM STREQUAL "")
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} SYSTEM_PROCESSOR)
else()
string(TOLOWER ${CMAKE_GENERATOR_PLATFORM} SYSTEM_PROCESSOR)
endif()

# Generate the MsQuicEtw header file.
file(MAKE_DIRECTORY ${QUIC_BUILD_DIR}/inc)

Expand Down
10 changes: 9 additions & 1 deletion scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ param (
[string]$Arch = "",

[Parameter(Mandatory = $false)]
[ValidateSet("uwp", "windows", "linux", "macos", "android")] # For future expansion
[ValidateSet("uwp", "windows", "linux", "macos", "android", "ios")] # For future expansion
[string]$Platform = "",

[Parameter(Mandatory = $false)]
Expand Down Expand Up @@ -219,6 +219,11 @@ if (!$IsWindows -And $Platform -eq "uwp") {
exit
}

if ($Platform -eq "ios" -and !$Static) {
$Static = $true
Write-Host "iOS can only be built as static"
}

# Root directory of the project.
$RootDir = Split-Path $PSScriptRoot -Parent

Expand Down Expand Up @@ -295,6 +300,9 @@ function CMake-Generate {
} else {
$Arguments += " $Generator"
}
if ($Platform -eq "ios") {
$Arguments += " -DCMAKE_SYSTEM_NAME=iOS"
}
if($Static) {
$Arguments += " -DQUIC_BUILD_SHARED=off"
}
Expand Down
11 changes: 10 additions & 1 deletion scripts/get-buildconfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ param (
[string]$Arch = "",

[Parameter(Mandatory = $false)]
[ValidateSet("uwp", "windows", "linux", "macos", "android", "")] # For future expansion
[ValidateSet("uwp", "windows", "linux", "macos", "android", "ios", "")] # For future expansion
[string]$Platform = "",

[Parameter(Mandatory = $false)]
Expand All @@ -53,6 +53,15 @@ if ($Platform -eq "android") {
}
}

if ($Platform -eq "ios") {
if (!$IsMacOS) {
Write-Error "Can only build ios on macOS"
}
if ($Arch -eq "") {
$Arch = "arm64"
}
}

if ("" -eq $Arch) {
if ($IsMacOS) {
$RunningArch = uname -m
Expand Down
6 changes: 6 additions & 0 deletions src/platform/selfsign_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#ifdef _WIN32
#pragma warning(pop)
#endif
#ifdef __APPLE__
#include <TargetConditionals.h>
#endif
#ifdef QUIC_CLOG
#include "selfsign_openssl.c.clog.h"
#endif
Expand Down Expand Up @@ -476,6 +479,9 @@ CxPlatFreeSelfSignedCert(
#ifdef _WIN32
DeleteFileA(Params->CertFilepath);
DeleteFileA(Params->PrivateKeyFilepath);
#elif TARGET_OS_IOS
UNREFERENCED_PARAMETER(CredConfig);
UNREFERENCED_PARAMETER(Params);
#else
char RmCmd[32] = {0};
strncpy(RmCmd, "rm -rf ", 7 + 1);
Expand Down

0 comments on commit 1b17a55

Please sign in to comment.