Commit 1982eef8 authored by sdefresne's avatar sdefresne Committed by Commit bot

[ios] Partially decouple iOS and macOS GN configuration.

Duplicates configs defined in //build/config/mac/BUILD.gn that
are shared with iOS to //build/config/ios/BUILD.gn. Remove all
conditions testing "is_mac" or "is_ios" (as they are now known
from the filename).

Change dependencies on previously shared targets to select the
correct target based on the "target_os".

BUG=635745

Review-Url: https://codereview.chromium.org/2843493002
Cr-Commit-Position: refs/heads/master@{#467680}
parent 663c648b
...@@ -288,7 +288,10 @@ config("executable_config") { ...@@ -288,7 +288,10 @@ config("executable_config") {
"//build/config/mac:mac_executable_flags", "//build/config/mac:mac_executable_flags",
] ]
} else if (is_ios) { } else if (is_ios) {
configs += [ "//build/config/ios:ios_dynamic_flags" ] configs += [
"//build/config/ios:ios_dynamic_flags",
"//build/config/ios:ios_executable_flags",
]
} else if (is_linux || is_android) { } else if (is_linux || is_android) {
configs += [ "//build/config/gcc:executable_ldconfig" ] configs += [ "//build/config/gcc:executable_ldconfig" ]
if (is_android) { if (is_android) {
......
...@@ -544,7 +544,7 @@ if (is_win) { ...@@ -544,7 +544,7 @@ if (is_win) {
# that shouldn't use the windows subsystem. # that shouldn't use the windows subsystem.
"//build/config/win:console", "//build/config/win:console",
] ]
} else if (is_mac || is_ios) { } else if (is_mac) {
_linker_configs = [ "//build/config/mac:strip_all" ] _linker_configs = [ "//build/config/mac:strip_all" ]
} else { } else {
_linker_configs = [] _linker_configs = []
......
...@@ -165,8 +165,10 @@ config("compiler") { ...@@ -165,8 +165,10 @@ config("compiler") {
configs += [ "//build/config/linux:compiler" ] configs += [ "//build/config/linux:compiler" ]
} else if (is_nacl) { } else if (is_nacl) {
configs += [ "//build/config/nacl:compiler" ] configs += [ "//build/config/nacl:compiler" ]
} else if (is_ios || is_mac) { } else if (is_mac) {
configs += [ "//build/config/mac:compiler" ] configs += [ "//build/config/mac:compiler" ]
} else if (is_ios) {
configs += [ "//build/config/ios:compiler" ]
} }
# See the definitions below. # See the definitions below.
......
...@@ -23,6 +23,53 @@ declare_args() { ...@@ -23,6 +23,53 @@ declare_args() {
enable_ios_bitcode = false enable_ios_bitcode = false
} }
# This is included by reference in the //build/config/compiler config that
# is applied to all targets. It is here to separate out the logic.
config("compiler") {
# These flags are shared between the C compiler and linker.
common_ios_flags = []
# CPU architecture.
if (current_cpu == "x64") {
common_ios_flags += [
"-arch",
"x86_64",
]
} else if (current_cpu == "x86") {
common_ios_flags += [
"-arch",
"i386",
]
} else if (current_cpu == "armv7" || current_cpu == "arm") {
common_ios_flags += [
"-arch",
"armv7",
]
} else if (current_cpu == "arm64") {
common_ios_flags += [
"-arch",
"arm64",
]
}
# 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" ]
asmflags = common_ios_flags
cflags = common_ios_flags
# Without this, the constructors and destructors of a C++ object inside
# an Objective C struct won't be called, which is very bad.
cflags_objcc = [ "-fobjc-call-cxx-cdtors" ]
cflags_c = [ "-std=c99" ]
cflags_objc = cflags_c
ldflags = common_ios_flags
}
# This is included by reference in the //build/config/compiler:runtime_library # This is included by reference in the //build/config/compiler:runtime_library
# config that is applied to all targets. It is here to separate out the logic # config that is applied to all targets. It is here to separate out the logic
# that is iOS-only. Please see that target for advice on what should go in # that is iOS-only. Please see that target for advice on what should go in
...@@ -67,6 +114,9 @@ config("runtime_library") { ...@@ -67,6 +114,9 @@ config("runtime_library") {
} }
} }
config("ios_executable_flags") {
}
config("ios_dynamic_flags") { config("ios_dynamic_flags") {
ldflags = [ "-Wl,-ObjC" ] # Always load Objective-C categories and class. ldflags = [ "-Wl,-ObjC" ] # Always load Objective-C categories and class.
} }
......
...@@ -102,25 +102,11 @@ template("lipo_binary") { ...@@ -102,25 +102,11 @@ template("lipo_binary") {
} }
if (enable_stripping) { if (enable_stripping) {
# Check whether //build/config/mac:strip_all has been removed from the args += [ "-Wcrl,strip,-x,-S" ]
# configs variables (as this is how stripping is disabled for a single if (save_unstripped_output) {
# target). outputs += [ "$root_out_dir/$_output_name.unstripped" ]
_strip_all_in_config = false args += [ "-Wcrl,unstripped," +
if (defined(invoker.configs)) { rebase_path("$root_out_dir/.", root_build_dir) ]
foreach(_config, invoker.configs) {
if (_config == "//build/config/mac:strip_all") {
_strip_all_in_config = true
}
}
}
if (_strip_all_in_config) {
args += [ "-Wcrl,strip,-x,-S" ]
if (save_unstripped_output) {
outputs += [ "$root_out_dir/$_output_name.unstripped" ]
args += [ "-Wcrl,unstripped," +
rebase_path("$root_out_dir/.", root_build_dir) ]
}
} }
} }
} }
......
...@@ -6,16 +6,8 @@ import("//build/config/sysroot.gni") ...@@ -6,16 +6,8 @@ import("//build/config/sysroot.gni")
import("//build/config/mac/mac_sdk.gni") import("//build/config/mac/mac_sdk.gni")
import("//build/config/mac/symbols.gni") import("//build/config/mac/symbols.gni")
if (is_ios) {
# This needs to be imported after mac_sdk.gni as it overrides some of the
# variables defined by it.
import("//build/config/ios/ios_sdk.gni")
}
# This is included by reference in the //build/config/compiler config that # This is included by reference in the //build/config/compiler config that
# is applied to all targets. It is here to separate out the logic. # is applied to all targets. It is here to separate out the logic.
#
# This is applied to BOTH desktop Mac and iOS targets.
config("compiler") { config("compiler") {
# These flags are shared between the C compiler and linker. # These flags are shared between the C compiler and linker.
common_mac_flags = [] common_mac_flags = []
...@@ -31,16 +23,6 @@ config("compiler") { ...@@ -31,16 +23,6 @@ config("compiler") {
"-arch", "-arch",
"i386", "i386",
] ]
} else if (current_cpu == "armv7" || current_cpu == "arm") {
common_mac_flags += [
"-arch",
"armv7",
]
} else if (current_cpu == "arm64") {
common_mac_flags += [
"-arch",
"arm64",
]
} }
# This is here so that all files get recompiled after an Xcode update. # This is here so that all files get recompiled after an Xcode update.
...@@ -60,16 +42,7 @@ config("compiler") { ...@@ -60,16 +42,7 @@ config("compiler") {
ldflags = common_mac_flags ldflags = common_mac_flags
if (is_ios && additional_toolchains != []) { if (save_unstripped_output) {
# For fat build, the generation of the dSYM happens after the fat binary has
# been created with "lipo" thus the stripping cannot happen at link time but
# after running "lipo" too.
_save_unstripped_output = false
} else {
_save_unstripped_output = save_unstripped_output
}
if (_save_unstripped_output) {
ldflags += [ "-Wcrl,unstripped," + rebase_path(root_out_dir) ] ldflags += [ "-Wcrl,unstripped," + rebase_path(root_out_dir) ]
} }
} }
...@@ -89,13 +62,11 @@ config("runtime_library") { ...@@ -89,13 +62,11 @@ config("runtime_library") {
cflags = common_flags cflags = common_flags
ldflags = common_flags ldflags = common_flags
if (is_mac) { # Prevent Mac OS X AssertMacros.h (included by system header) from defining
# Prevent Mac OS X AssertMacros.h from defining macros that collide # macros that collide with common names, like 'check', 'require', and
# with common names, like 'check', 'require', and 'verify'. # 'verify'.
# (Included by system header. Also exists on iOS but not included.) # http://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/AssertMacros.h
# http://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/AssertMacros.h defines = [ "__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0" ]
defines = [ "__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0" ]
}
} }
# On Mac, this is used for everything except static libraries. # On Mac, this is used for everything except static libraries.
...@@ -127,10 +98,7 @@ config("mac_executable_flags") { ...@@ -127,10 +98,7 @@ config("mac_executable_flags") {
# from a binary, but some targets may wish to specify a saves file to preserve # from a binary, but some targets may wish to specify a saves file to preserve
# specific symbols. # specific symbols.
config("strip_all") { config("strip_all") {
# On iOS, the final applications are assembled using lipo (to support fat if (enable_stripping) {
# builds). This configuration is thus always empty and the correct flags
# are passed to the linker_driver.py script directly during the lipo call.
if (enable_stripping && !is_ios) {
ldflags = [ "-Wcrl,strip,-x,-S" ] ldflags = [ "-Wcrl,strip,-x,-S" ]
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment