mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
iOS,macOS: Unify iOS,macOS build configs (#168517)
Merges: * //build/config/ios:compiler * //build/config/mac:compiler Into: * //build/config/apple:compiler Merges: * //flutter/shell/platform/darwin/ios:config_ios * //flutter/shell/platform/darwin/mac:config_macos Into: * //flutter/shell/platform/darwin/common:config Merges: * //flutter/shell/platform/darwin/ios:config_ios_test * //flutter/shell/platform/darwin/mac:config_macos_test Into: * //flutter/shell/platform/darwin/common:test_config This avoids the duplication between iOS and macOS build configs used for building Swift and Objective-C that depends on Swift, and avoids further duplication when we add Swift to //flutter/shell/platform/darwin/common in a followup patch. Issue: https://github.com/flutter/flutter/issues/167592 ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [X] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
parent
041bbeb882
commit
02d8c1aceb
76
engine/src/build/config/apple/BUILD.gn
Normal file
76
engine/src/build/config/apple/BUILD.gn
Normal file
@ -0,0 +1,76 @@
|
||||
# Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
assert(is_mac || is_ios)
|
||||
|
||||
import("//build/config/apple/apple_sdk.gni")
|
||||
|
||||
config("compiler") {
|
||||
# swiftc -sdk flag.
|
||||
if (is_ios) {
|
||||
_sdk_root = ios_sdk_path
|
||||
if (create_xcode_symlinks) {
|
||||
_sdk_root = rebase_path(ios_sdk_path, root_build_dir)
|
||||
}
|
||||
} else if (is_mac) {
|
||||
_sdk_root = mac_sdk_path
|
||||
if (create_xcode_symlinks) {
|
||||
_sdk_root = rebase_path(mac_sdk_path, root_build_dir)
|
||||
}
|
||||
} else {
|
||||
assert(false, "unsupported platform")
|
||||
}
|
||||
|
||||
# swiftc -target flag (target triplet).
|
||||
# CPU architecture.
|
||||
if (current_cpu == "x64") {
|
||||
_triplet_cpu = "x86_64"
|
||||
} else if (current_cpu == "arm64") {
|
||||
_triplet_cpu = "arm64"
|
||||
} else {
|
||||
# x86, arm, armv7, etc.
|
||||
assert(false, "unsupported cpu: $current_cpu")
|
||||
}
|
||||
# Environment.
|
||||
if (use_ios_simulator) {
|
||||
_triplet_environment = "-simulator"
|
||||
} else {
|
||||
_triplet_environment = ""
|
||||
}
|
||||
# OS.
|
||||
if (is_ios) {
|
||||
_triplet_os = "apple-ios"
|
||||
} else if (is_mac) {
|
||||
_triplet_os = "apple-macos"
|
||||
} else {
|
||||
assert(false, "unsupported Apple os")
|
||||
}
|
||||
_target_triplet = "$_triplet_cpu-$_triplet_os$mac_deployment_target$_triplet_environment"
|
||||
|
||||
# swiftc -swift-version flag.
|
||||
#
|
||||
# Swift 6 transition: As of April 2025, no public Flutter framework API is
|
||||
# authored in Swift. Swift 6 is ABI-compatible with Swift 5, but not
|
||||
# source-compatible. If any public API *is* written in Swift, it's possible
|
||||
# we may need to prepare concurrent Swift 5 and 6 builds during a transition
|
||||
# period.
|
||||
_swift_version = "5"
|
||||
|
||||
# TODO(cbracken): https://github.com/flutter/flutter/issues/167592
|
||||
# Look up xcode_version in apple_sdk.gni
|
||||
#
|
||||
# This is here so that all files get recompiled after an Xcode update.
|
||||
# (defines are passed via the command line, and build system rebuild things
|
||||
# when their commandline changes). Nothing should ever read this define.
|
||||
#defines = [ "CR_XCODE_VERSION=$xcode_version" ]
|
||||
|
||||
swiftflags = [
|
||||
"-sdk",
|
||||
_sdk_root,
|
||||
"-target",
|
||||
_target_triplet,
|
||||
"-swift-version",
|
||||
_swift_version
|
||||
]
|
||||
}
|
@ -72,10 +72,8 @@ config("compiler") {
|
||||
configs = []
|
||||
|
||||
# Platform-specific configs.
|
||||
if (is_ios) {
|
||||
configs += [ "//build/config/ios:compiler" ]
|
||||
} else if (is_mac) {
|
||||
configs += [ "//build/config/mac:compiler" ]
|
||||
if (is_ios || is_mac) {
|
||||
configs += [ "//build/config/apple:compiler" ]
|
||||
}
|
||||
|
||||
# In general, Windows is totally different, but all the other builds share
|
||||
|
@ -6,66 +6,6 @@ config("sdk") {
|
||||
cflags_cc = [ "-stdlib=libc++" ]
|
||||
}
|
||||
|
||||
config("compiler") {
|
||||
# swiftc -sdk flag.
|
||||
_sdk_root = ios_sdk_path
|
||||
if (create_xcode_symlinks) {
|
||||
_sdk_root = rebase_path(ios_sdk_path, root_build_dir)
|
||||
}
|
||||
|
||||
# swiftc -target flag (target triplet).
|
||||
# CPU architecture.
|
||||
if (current_cpu == "x64") {
|
||||
_triplet_cpu = "x86_64"
|
||||
} else if (current_cpu == "arm64") {
|
||||
_triplet_cpu = "arm64"
|
||||
} else {
|
||||
# x86, arm, armv7, etc.
|
||||
assert(false, "unsupported cpu: $current_cpu")
|
||||
}
|
||||
# Environment.
|
||||
if (use_ios_simulator) {
|
||||
_triplet_environment = "-simulator"
|
||||
} else {
|
||||
_triplet_environment = ""
|
||||
}
|
||||
# OS.
|
||||
if (is_ios) {
|
||||
_triplet_os = "apple-ios"
|
||||
} else if (is_mac) {
|
||||
_triplet_os = "apple-macos"
|
||||
} else {
|
||||
assert(false, "unsupported Apple os")
|
||||
}
|
||||
_target_triplet = "$_triplet_cpu-$_triplet_os$ios_deployment_target$_triplet_environment"
|
||||
|
||||
# swiftc -swift-version flag.
|
||||
#
|
||||
# Swift 6 transition: As of April 2025, no public Flutter framework API is
|
||||
# authored in Swift. Swift 6 is ABI-compatible with Swift 5, but not
|
||||
# source-compatible. If any public API *is* written in Swift, it's possible
|
||||
# we may need to prepare concurrent Swift 5 and 6 builds during a transition
|
||||
# period.
|
||||
_swift_version = "5"
|
||||
|
||||
# TODO(cbracken): https://github.com/flutter/flutter/issues/167592
|
||||
# Look up xcode_version in apple_sdk.gni
|
||||
#
|
||||
# This is here so that all files get recompiled after an Xcode update.
|
||||
# (defines are passed via the command line, and build system rebuild things
|
||||
# when their commandline changes). Nothing should ever read this define.
|
||||
#defines = [ "CR_XCODE_VERSION=$xcode_version" ]
|
||||
|
||||
swiftflags = [
|
||||
"-sdk",
|
||||
_sdk_root,
|
||||
"-target",
|
||||
_target_triplet,
|
||||
"-swift-version",
|
||||
_swift_version
|
||||
]
|
||||
}
|
||||
|
||||
config("ios_application_extension") {
|
||||
cflags_objc = [ "-fapplication-extension" ]
|
||||
cflags_objcc = [ "-fapplication-extension" ]
|
||||
|
@ -28,53 +28,3 @@ config("mac_dynamic_flags") {
|
||||
config("mac_executable_flags") {
|
||||
ldflags = [ "-Wl,-pie" ] # Position independent.
|
||||
}
|
||||
|
||||
config("compiler") {
|
||||
# swiftc -sdk flag.
|
||||
_sdk_root = mac_sdk_path
|
||||
if (create_xcode_symlinks) {
|
||||
_sdk_root = rebase_path(mac_sdk_path, root_build_dir)
|
||||
}
|
||||
|
||||
# swiftc -target flag (target triplet).
|
||||
# CPU architecture.
|
||||
if (current_cpu == "x64") {
|
||||
_triplet_cpu = "x86_64"
|
||||
} else if (current_cpu == "arm64") {
|
||||
_triplet_cpu = "arm64"
|
||||
} else {
|
||||
# x86, arm, armv7, etc.
|
||||
assert(false, "unsupported cpu: $current_cpu")
|
||||
}
|
||||
# Environment.
|
||||
_triplet_environment = ""
|
||||
# OS.
|
||||
_triplet_os = "apple-macos"
|
||||
_target_triplet = "$_triplet_cpu-$_triplet_os$mac_deployment_target$_triplet_environment"
|
||||
|
||||
# swiftc -swift-version flag.
|
||||
#
|
||||
# Swift 6 transition: As of April 2025, no public Flutter framework API is
|
||||
# authored in Swift. Swift 6 is ABI-compatible with Swift 5, but not
|
||||
# source-compatible. If any public API *is* written in Swift, it's possible
|
||||
# we may need to prepare concurrent Swift 5 and 6 builds during a transition
|
||||
# period.
|
||||
_swift_version = "5"
|
||||
|
||||
# TODO(cbracken): https://github.com/flutter/flutter/issues/167592
|
||||
# Look up xcode_version in apple_sdk.gni
|
||||
#
|
||||
# This is here so that all files get recompiled after an Xcode update.
|
||||
# (defines are passed via the command line, and build system rebuild things
|
||||
# when their commandline changes). Nothing should ever read this define.
|
||||
#defines = [ "CR_XCODE_VERSION=$xcode_version" ]
|
||||
|
||||
swiftflags = [
|
||||
"-sdk",
|
||||
_sdk_root,
|
||||
"-target",
|
||||
_target_triplet,
|
||||
"-swift-version",
|
||||
_swift_version
|
||||
]
|
||||
}
|
||||
|
@ -4,10 +4,44 @@
|
||||
|
||||
assert(is_mac || is_ios)
|
||||
|
||||
import("//build/config/apple/apple_sdk.gni")
|
||||
import("//flutter/common/config.gni")
|
||||
import("//flutter/testing/testing.gni")
|
||||
import("framework_common.gni")
|
||||
|
||||
config("config") {
|
||||
include_dirs = [ target_gen_dir ]
|
||||
if (is_ios) {
|
||||
lib_dirs = ios_swift_lib_paths
|
||||
} else if (is_mac) {
|
||||
lib_dirs = mac_swift_lib_paths
|
||||
}
|
||||
|
||||
# Allow use of @testable imports in debug builds and when tests are enabled.
|
||||
if ((is_ios && enable_ios_unittests) || (is_mac && enable_unittests)) {
|
||||
swiftflags = [ "-enable-testing" ]
|
||||
}
|
||||
}
|
||||
|
||||
config("test_config") {
|
||||
configs = [ ":config" ]
|
||||
|
||||
# Add platform frameworks directory to search path for test frameworks.
|
||||
# Add platform lib to search path for test libraries/Swift modules.
|
||||
cflags = [ "-fvisibility=default" ]
|
||||
|
||||
if (is_ios) {
|
||||
_platform_path = ios_platform_path
|
||||
} else if (is_mac) {
|
||||
_platform_path = mac_platform_path
|
||||
}
|
||||
cflags += [ "-F$_platform_path/Developer/Library/Frameworks" ]
|
||||
swiftflags = [ "-F$_platform_path/Developer/Library/Frameworks" ]
|
||||
include_dirs = [ "$_platform_path/Developer/usr/lib" ]
|
||||
framework_dirs = [ "$_platform_path/Developer/Library/Frameworks" ]
|
||||
lib_dirs = [ "$_platform_path/Developer/usr/lib" ]
|
||||
}
|
||||
|
||||
source_set("common") {
|
||||
cflags_objc = flutter_cflags_objc
|
||||
cflags_objcc = flutter_cflags_objcc
|
||||
|
@ -22,31 +22,6 @@ shell_gpu_configuration("ios_gpu_configuration") {
|
||||
enable_metal = true
|
||||
}
|
||||
|
||||
config("config_ios") {
|
||||
include_dirs = [ target_gen_dir ]
|
||||
lib_dirs = ios_swift_lib_paths
|
||||
|
||||
# Allow use of @testable imports in debug builds and when tests are enabled.
|
||||
if (enable_ios_unittests) {
|
||||
swiftflags = [ "-enable-testing" ]
|
||||
}
|
||||
}
|
||||
|
||||
config("config_ios_test") {
|
||||
configs = [ ":config_ios" ]
|
||||
|
||||
# Add platform frameworks directory to search path for test frameworks.
|
||||
# Add platform lib to search path for test libraries/Swift modules.
|
||||
cflags = [
|
||||
"-fvisibility=default",
|
||||
"-F$ios_platform_path/Developer/Library/Frameworks",
|
||||
]
|
||||
swiftflags = [ "-F$ios_platform_path/Developer/Library/Frameworks" ]
|
||||
include_dirs = [ "$ios_platform_path/Developer/usr/lib" ]
|
||||
framework_dirs = [ "$ios_platform_path/Developer/Library/Frameworks" ]
|
||||
lib_dirs = [ "$ios_platform_path/Developer/usr/lib" ]
|
||||
}
|
||||
|
||||
# The headers that will be copied to the Flutter.framework and be accessed
|
||||
# from outside the Flutter engine source root.
|
||||
_flutter_framework_headers = [
|
||||
@ -66,7 +41,7 @@ _flutter_framework_headers_copy_dir = "$_flutter_framework_dir/Headers"
|
||||
|
||||
source_set("InternalFlutterSwift") {
|
||||
visibility = [ ":*" ]
|
||||
configs += [ ":config_ios" ]
|
||||
configs += [ "//flutter/shell/platform/darwin/common:config" ]
|
||||
|
||||
sources = [
|
||||
"framework/Source/ConnectionCollection.swift",
|
||||
@ -85,7 +60,7 @@ source_set("flutter_framework_source") {
|
||||
"//flutter:config",
|
||||
]
|
||||
configs += [
|
||||
":config_ios",
|
||||
"//flutter/shell/platform/darwin/common:config",
|
||||
"//build/config/ios:ios_application_extension",
|
||||
]
|
||||
|
||||
@ -224,7 +199,7 @@ if (enable_ios_unittests) {
|
||||
source_set("ios_test_flutter_swift") {
|
||||
testonly = true
|
||||
visibility = [ ":*" ]
|
||||
configs += [ ":config_ios_test" ]
|
||||
configs += [ "//flutter/shell/platform/darwin/common:test_config" ]
|
||||
sources = [
|
||||
"framework/Source/ConnectionCollectionTest.swift",
|
||||
"framework/Source/FakeUIPressProxy.swift",
|
||||
@ -247,11 +222,14 @@ if (enable_ios_unittests) {
|
||||
ldflags =
|
||||
[ "-Wl,-install_name,@rpath/Frameworks/libios_test_flutter.dylib" ]
|
||||
frameworks = [ "XCTest.framework" ]
|
||||
configs += [ ":config_ios_test" ]
|
||||
include_dirs = [ target_gen_dir ]
|
||||
|
||||
configs += [ "//flutter/shell/platform/darwin/common:test_config" ]
|
||||
configs -= [
|
||||
"//build/config/gcc:symbol_visibility_hidden",
|
||||
"//build/config:symbol_visibility_hidden",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"framework/Source/FlutterAppDelegateTest.mm",
|
||||
"framework/Source/FlutterChannelKeyResponderTest.mm",
|
||||
|
@ -18,31 +18,6 @@ shell_gpu_configuration("macos_gpu_configuration") {
|
||||
enable_metal = true
|
||||
}
|
||||
|
||||
config("config_macos") {
|
||||
include_dirs = [ target_gen_dir ]
|
||||
lib_dirs = mac_swift_lib_paths
|
||||
|
||||
# Allow use of @testable imports in debug builds and when tests are enabled.
|
||||
if (enable_unittests) {
|
||||
swiftflags = [ "-enable-testing" ]
|
||||
}
|
||||
}
|
||||
|
||||
config("config_macos_test") {
|
||||
configs = [ ":config_macos" ]
|
||||
|
||||
# Add platform frameworks directory to search path for test frameworks.
|
||||
# Add platform lib to search path for test libraries/Swift modules.
|
||||
cflags = [
|
||||
"-fvisibility=default",
|
||||
"-F$mac_platform_path/Developer/Library/Frameworks",
|
||||
]
|
||||
swiftflags = [ "-F$mac_platform_path/Developer/Library/Frameworks" ]
|
||||
include_dirs = [ "$mac_platform_path/Developer/usr/lib" ]
|
||||
framework_dirs = [ "$mac_platform_path/Developer/Library/Frameworks" ]
|
||||
lib_dirs = [ "$mac_platform_path/Developer/usr/lib" ]
|
||||
}
|
||||
|
||||
group("macos") {
|
||||
deps = [ ":flutter_framework" ]
|
||||
if (build_glfw_shell) {
|
||||
@ -77,7 +52,7 @@ _flutter_framework_headers_copy_dir =
|
||||
|
||||
source_set("InternalFlutterSwift") {
|
||||
visibility = [ ":*" ]
|
||||
configs += [ ":config_macos" ]
|
||||
configs += [ "//flutter/shell/platform/darwin/common:config" ]
|
||||
|
||||
sources = [ "framework/Source/FlutterRunLoop.swift" ]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user