Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for building for iOS #1904

Merged
merged 3 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -321,13 +321,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