diff --git a/config/BUILDCONFIG.gn b/config/BUILDCONFIG.gn index 38da66cef..671bdee93 100644 --- a/config/BUILDCONFIG.gn +++ b/config/BUILDCONFIG.gn @@ -80,6 +80,10 @@ declare_args() { # When running in gyp-generating mode, this is the root of the build tree. gyp_output_dir = "out" + + # When running in gyp-generating mode, this flag indicates if the current GYP + # generator is xcode. Can only be true when building for iOS). + is_gyp_xcode_generator = false } # ============================================================================= @@ -161,9 +165,8 @@ if (os == "win") { is_nacl = false is_posix = true is_win = false - if (!is_clang) { + if (!is_gyp_xcode_generator) { # Always use clang on iOS when using ninja - # (which is always true when using GN). is_clang = true } } else if (os == "linux") { @@ -332,10 +335,13 @@ native_compiler_configs = [ "//build/config/compiler:runtime_library", ] if (is_win) { - native_compiler_configs += [ - "//build/config/win:sdk", - ] -} else if (is_clang) { + native_compiler_configs += [ "//build/config/win:sdk", ] +} else if (is_mac) { + native_compiler_configs += [ "//build/config/mac:sdk", ] +} else if (is_ios) { + native_compiler_configs += [ "//build/config/ios:sdk", ] +} +if (is_clang) { native_compiler_configs += [ "//build/config/clang:find_bad_constructs" ] } diff --git a/config/compiler/BUILD.gn b/config/compiler/BUILD.gn index e0e107354..3ed78f3ba 100644 --- a/config/compiler/BUILD.gn +++ b/config/compiler/BUILD.gn @@ -3,7 +3,6 @@ # found in the LICENSE file. import("//build/config/android/config.gni") -import("//build/config/sysroot.gni") if (cpu_arch == "arm") { import("//build/config/arm.gni") } @@ -63,12 +62,7 @@ config("compiler") { # ---------------------------------- if (is_mac || is_ios) { # These flags are shared between the C compiler and linker. - common_mac_flags = [ "-isysroot", sysroot ] - if (is_mac) { - common_mac_flags += [ "-mmacosx-version-min=10.6" ] - } else { - cflags += [ "-mios-simulator-version-min=6.0" ] - } + common_mac_flags = [] # CPU architecture. if (cpu_arch == "x64") { @@ -175,17 +169,6 @@ config("compiler") { ] } - if (sysroot != "") { - cflags += [ "--sysroot=" + sysroot ] - ldflags += [ "--sysroot=" + sysroot ] - - # Need to get some linker flags out of the sysroot. - ldflags += [ exec_script("../linux/sysroot_ld_path.py", - [rebase_path("../../linux/sysroot_ld_path.sh", ".", root_build_dir), - sysroot], - "value") ] - } - ldflags += [ "-fPIC", "-pthread", diff --git a/config/ios/BUILD.gn b/config/ios/BUILD.gn new file mode 100644 index 000000000..0886be458 --- /dev/null +++ b/config/ios/BUILD.gn @@ -0,0 +1,19 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/config/sysroot.gni") +import("//build/config/ios/ios_sdk.gni") + +config("sdk") { + common_flags = [ "-isysroot", sysroot ] + + cflags = common_flags + ldflags = common_flags + + if (use_ios_simulator) { + cflags += [ "-mios-simulator-version-min=$ios_deployment_target" ] + } else { + cflags += [ "-miphoneos-version-min=$ios_deployment_target" ] + } +} diff --git a/config/ios/ios_sdk.gni b/config/ios/ios_sdk.gni index f941f3ce0..7acbaaa17 100644 --- a/config/ios/ios_sdk.gni +++ b/config/ios/ios_sdk.gni @@ -2,9 +2,31 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# TODO(brettw) support "iphoneos" in addition to the simulator. May also need -# support for common.gypi's "ios_sdk" variable (seems to be a version number) -# and ios_sdk_path (argument that overrides the one returned below). -ios_sdk_result = - exec_script("ios_sdk.py", [ "iphonesimulator" ], "list lines") -ios_sdk_path = ios_sdk_result[0] +declare_args() { + # SDK path to use. When empty this will use the default SDK based on the + # value of use_ios_simulator. + ios_sdk_path = "" + + # Set to true when targeting a simulator build on iOS. False means that the + # target is for running on the device. + use_ios_simulator = true + + ios_deployment_target = "6.0" +} + +if (!is_gyp_xcode_generator) { + # The Ninja build currently only targets the simulator. + assert(use_ios_simulator, "You can't do an iOS device build using Ninja yet.") +} + +if (ios_sdk_path == "") { + # Compute default target. + if (use_ios_simulator) { + _ios_sdk_to_query = "iphonesimulator" + } else { + _ios_sdk_to_query = "iphoneos" + } + _ios_sdk_result = + exec_script("ios_sdk.py", [ _ios_sdk_to_query ], "list lines") + ios_sdk_path = _ios_sdk_result[0] +} diff --git a/config/linux/BUILD.gn b/config/linux/BUILD.gn index 29b446ae0..d166ac792 100644 --- a/config/linux/BUILD.gn +++ b/config/linux/BUILD.gn @@ -3,6 +3,20 @@ # found in the LICENSE file. import("//build/config/linux/pkg_config.gni") +import("//build/config/sysroot.gni") + +config("sdk") { + if (sysroot != "") { + cflags = [ "--sysroot=" + sysroot ] + ldflags = [ "--sysroot=" + sysroot ] + + # Need to get some linker flags out of the sysroot. + ldflags += [ exec_script("sysroot_ld_path.py", + [ rebase_path("//build/linux/sysroot_ld_path.sh", ".", root_build_dir), + sysroot ], + "value") ] + } +} # Sets up the dynamic library search path to include our "lib" directory. config("executable_ldconfig") { diff --git a/config/mac/BUILD.gn b/config/mac/BUILD.gn index 78c106aeb..b6db8e0b7 100644 --- a/config/mac/BUILD.gn +++ b/config/mac/BUILD.gn @@ -2,6 +2,18 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/config/sysroot.gni") + +config("sdk") { + common_flags = [ + "-isysroot", sysroot, + "-mmacosx-version-min=10.6" + ] + + cflags = common_flags + ldflags = common_flags +} + # On Mac, this is used for everything except static libraries. config("mac_dynamic_flags") { ldflags = [ diff --git a/gyp_chromium b/gyp_chromium index 8713b4340..9034c823e 100755 --- a/gyp_chromium +++ b/gyp_chromium @@ -223,7 +223,8 @@ def GetArgsStringForGN(supplemental_files): gn_args += ' ' + i[2] # These string arguments get passed directly as GN strings. - for v in ['android_src', 'windows_sdk_path', 'arm_float_abi']: + for v in ['android_src', 'arm_float_abi', 'ios_deployment_target', + 'ios_sdk_path', 'windows_sdk_path']: if v in vars_dict: gn_args += ' ' + v + '=' + EscapeStringForGN(vars_dict[v]) @@ -231,6 +232,14 @@ def GetArgsStringForGN(supplemental_files): if 'gomadir' in vars_dict: gn_args += ' goma_dir=%s' % EscapeStringForGN(vars_dict['gomadir']) + # Clear the "use_ios_simulator" flag if the ios_sdk_path is set and is + # not a simulator SDK. This duplicates code done in GYP's xcode emulation. + if 'ios_sdk_path' in vars_dict: + if not os.path.basename(vars_dict['ios_sdk_path']).lower().startswith( + 'iphonesimulator'): + gn_args += ' use_ios_simulator=false' + + # These arguments get passed directly as integers (avoiding the quoting and # escaping of the string ones above). for v in ['arm_version']: