summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-27 07:41:23 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-27 07:41:23 +0000
commit5aa8210fe7b367f2fc6eeaf8a8e36ff1a0658bde (patch)
tree9044b2169042936eb3a2e51a3e29fc493ee9e56e
parentb0c5d4200882807fdad4760294585bb387801148 (diff)
downloadchromium_src-5aa8210fe7b367f2fc6eeaf8a8e36ff1a0658bde.zip
chromium_src-5aa8210fe7b367f2fc6eeaf8a8e36ff1a0658bde.tar.gz
chromium_src-5aa8210fe7b367f2fc6eeaf8a8e36ff1a0658bde.tar.bz2
GN build fixes, mostly for Mac.
This hooks up detection for the "-arch" flag on Mac to set the GYP "ARCH" xcode variable. GN then removes the -arch argument from the compiler args, since GYP will then re-add it based on the ARCH value. Previously, not doing this resulting in mutliple "-arch" arguments to the compiler since GYP would always insert its own. Disables some warnings on Windows for the re2 target to match the GYP build. The third warning (4018) that the GYP build sets is disabled globally so there's no need to do it for this target. Hooks up some iOS SDK stuff. BUG=336667 TBR=thakis@chromium.org Review URL: https://codereview.chromium.org/141433015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247206 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--build/config/BUILDCONFIG.gn5
-rw-r--r--build/config/clang/BUILD.gn2
-rw-r--r--build/config/compiler/BUILD.gn12
-rw-r--r--build/config/ios/ios_sdk.gni10
-rw-r--r--build/config/ios/ios_sdk.py19
-rw-r--r--build/config/sysroot.gni3
-rw-r--r--third_party/re2/BUILD.gn5
-rw-r--r--tools/gn/gyp_binary_target_writer.cc36
8 files changed, 85 insertions, 7 deletions
diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn
index c4a57b0..38da66c 100644
--- a/build/config/BUILDCONFIG.gn
+++ b/build/config/BUILDCONFIG.gn
@@ -161,6 +161,11 @@ if (os == "win") {
is_nacl = false
is_posix = true
is_win = false
+ if (!is_clang) {
+ # Always use clang on iOS when using ninja
+ # (which is always true when using GN).
+ is_clang = true
+ }
} else if (os == "linux") {
is_android = false
is_chromeos = false
diff --git a/build/config/clang/BUILD.gn b/build/config/clang/BUILD.gn
index 9f99755..c3ee5da 100644
--- a/build/config/clang/BUILD.gn
+++ b/build/config/clang/BUILD.gn
@@ -15,7 +15,7 @@ config("find_bad_constructs") {
"-Xclang",
]
- if (is_mac) {
+ if (is_mac || is_ios) {
cflags += [ rebase_path(
"//third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.dylib",
".", root_build_dir) ]
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
index 8a8ba2e..78ddeea 100644
--- a/build/config/compiler/BUILD.gn
+++ b/build/config/compiler/BUILD.gn
@@ -61,12 +61,14 @@ config("compiler") {
# Mac-specific compiler flags setup.
# ----------------------------------
- if (is_mac) {
+ if (is_mac || is_ios) {
# These flags are shared between the C compiler and linker.
- common_mac_flags = [
- "-isysroot", sysroot,
- "-mmacosx-version-min=10.6",
- ]
+ common_mac_flags = [ "-isysroot", sysroot ]
+ if (is_mac) {
+ common_mac_flags += [ "-mmacosx-version-min=10.6" ]
+ } else {
+ cflags += [ "-mios-simulator-version-min=6.0" ]
+ }
# CPU architecture.
if (cpu_arch == "x64") {
diff --git a/build/config/ios/ios_sdk.gni b/build/config/ios/ios_sdk.gni
new file mode 100644
index 0000000..f941f3c
--- /dev/null
+++ b/build/config/ios/ios_sdk.gni
@@ -0,0 +1,10 @@
+# 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.
+
+# 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]
diff --git a/build/config/ios/ios_sdk.py b/build/config/ios/ios_sdk.py
new file mode 100644
index 0000000..dfec4db
--- /dev/null
+++ b/build/config/ios/ios_sdk.py
@@ -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 subprocess
+import sys
+
+# This script returns the path to the SDK of the given type. Pass the type of
+# SDK you want, which is typically "iphone" or "iphonesimulator".
+#
+# In the GYP build, this is done inside GYP itself based on the SDKROOT
+# variable.
+
+if len(sys.argv) != 2:
+ print "Takes one arg (SDK to find)"
+ sys.exit(1)
+
+print subprocess.check_output(['xcodebuild', '-version', '-sdk',
+ sys.argv[1], 'Path']).strip()
diff --git a/build/config/sysroot.gni b/build/config/sysroot.gni
index 4d3958a..6340c3a7 100644
--- a/build/config/sysroot.gni
+++ b/build/config/sysroot.gni
@@ -43,6 +43,9 @@ if (is_android) {
import("//build/config/mac/mac_sdk.gni")
sysroot = mac_sdk_path
+} else if (is_ios) {
+ import("//build/config/ios/ios_sdk.gni")
+ sysroot = ios_sdk_path
} else {
sysroot = ""
}
diff --git a/third_party/re2/BUILD.gn b/third_party/re2/BUILD.gn
index 67b4378..1259048 100644
--- a/third_party/re2/BUILD.gn
+++ b/third_party/re2/BUILD.gn
@@ -71,7 +71,10 @@ static_library("re2") {
if (is_win) {
include_dirs = [ "mswin" ]
- # TODO(brettw) 'msvs_disabled_warnings': [ 4018, 4722, 4267 ],
+ cflags = [
+ "/wd4267", # Conversion from size_t.
+ "/wd4722", # Destructor never terminates.
+ ]
} else {
sources -= [ "mswin/stdint.h" ]
}
diff --git a/tools/gn/gyp_binary_target_writer.cc b/tools/gn/gyp_binary_target_writer.cc
index e32c60b..cb6b4e0 100644
--- a/tools/gn/gyp_binary_target_writer.cc
+++ b/tools/gn/gyp_binary_target_writer.cc
@@ -7,6 +7,7 @@
#include <set>
#include "base/logging.h"
+#include "base/strings/string_util.h"
#include "tools/gn/builder_record.h"
#include "tools/gn/config_values_extractors.h"
#include "tools/gn/err.h"
@@ -66,6 +67,32 @@ std::string GetVCOptimization(std::vector<std::string>* cflags) {
return "'2'"; // Default value.
}
+// Returns the value from the already-filled in cflags for the processor
+// architecture to set in the GYP file. Additionally, this removes the flag
+// from the given vector so we don't get duplicates.
+std::string GetMacArch(std::vector<std::string>* cflags) {
+ // Searches for the "-arch" option and returns the corresponding GYP value.
+ for (size_t i = 0; i < cflags->size(); i++) {
+ const std::string& cur = (*cflags)[i];
+ if (cur == "-arch") {
+ // This is the first part of a list with ["-arch", "i386"], return the
+ // following item, and delete both of them.
+ if (i < cflags->size() - 1) {
+ std::string ret = (*cflags)[i + 1];
+ cflags->erase(cflags->begin() + i, cflags->begin() + i + 2);
+ return ret;
+ }
+ } else if (StartsWithASCII(cur, "-arch ", true)) {
+ // The arch was passed as one GN string value, e.g. "-arch i386". Return
+ // the stuff following the space and delete the item.
+ std::string ret = cur.substr(6);
+ cflags->erase(cflags->begin() + i);
+ return ret;
+ }
+ }
+ return std::string();
+}
+
// Finds all values from the given getter from all configs in the given list,
// and adds them to the given result vector.
template<typename T>
@@ -350,6 +377,15 @@ void GypBinaryTargetWriter::WriteMacFlags(Flags& flags, int indent) {
Indent(indent) << "'xcode_settings': {\n";
+ // Architecture. GYP uses this to write the -arch flag passed to the
+ // compiler, it doesn't look at our -arch flag. So we need to specify it in
+ // this special var and not in the cflags to avoid duplicates or conflicts.
+ std::string arch = GetMacArch(&flags.cflags);
+ if (arch == "i386")
+ Indent(indent + kExtraIndent) << "'ARCHS': [ 'i386' ],\n";
+ else if (arch == "x86_64")
+ Indent(indent + kExtraIndent) << "'ARCHS': [ 'x86_64' ],\n";
+
// C/C++ flags.
if (!flags.cflags.empty() || !flags.cflags_c.empty() ||
!flags.cflags_objc.empty()) {