summaryrefslogtreecommitdiffstats
path: root/tools/gn/secondary
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-13 17:10:56 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-13 17:10:56 +0000
commitc0822d7f9288ed13dce228ae3c3ed080e9712e3f (patch)
tree0bd24ec61541fa5013a1e4a2ba935279fe63779d /tools/gn/secondary
parentf661bb53f2baf0f52c83e5c3f82efab6b9fc053b (diff)
downloadchromium_src-c0822d7f9288ed13dce228ae3c3ed080e9712e3f.zip
chromium_src-c0822d7f9288ed13dce228ae3c3ed080e9712e3f.tar.gz
chromium_src-c0822d7f9288ed13dce228ae3c3ed080e9712e3f.tar.bz2
Split apart various target type code.
This splits apart the "generators" that fill the Target objects from script, and the "writers" that write the .ninja files. These now have different objects and files for the basic target types. The result is that it looks like much more stuff due to the extra files, but it should be easier to follow what's happening and to make additions in the future. Remove some extra loadable module stuff I missed in the previous removal. Adds more support for the Linux build. Not everything is working yet, but most of base compiles. This actually writes .ninja files and targets for "group" types, and removes the "none" target type which this mapped to before. This way you can make a target group and actually compile that set of stuff by typing its name. BUG= R=scottmg@chromium.org Review URL: https://codereview.chromium.org/22488015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217279 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/gn/secondary')
-rw-r--r--tools/gn/secondary/base/BUILD.gn15
-rw-r--r--tools/gn/secondary/build/config/BUILDCONFIG.gn2
-rw-r--r--tools/gn/secondary/build/config/compiler/BUILD.gn148
-rw-r--r--tools/gn/secondary/build/config/linux/BUILD.gn47
-rw-r--r--tools/gn/secondary/build/config/linux/system/BUILD.gn31
-rw-r--r--tools/gn/secondary/build/config/linux/system/pkg-config.py8
-rw-r--r--tools/gn/secondary/build/config/mac/BUILD.gn1
-rw-r--r--tools/gn/secondary/third_party/icu/BUILD.gn5
8 files changed, 195 insertions, 62 deletions
diff --git a/tools/gn/secondary/base/BUILD.gn b/tools/gn/secondary/base/BUILD.gn
index c0013bb..5fd3f52 100644
--- a/tools/gn/secondary/base/BUILD.gn
+++ b/tools/gn/secondary/base/BUILD.gn
@@ -689,6 +689,10 @@ component("base") {
"sys_info_openbsd.cc",
]
+ # So we can append below without worrying about whether it has been
+ # previously defined or not.
+ all_dependent_configs = []
+
if (!is_chromeos) {
sources -= [
"sys_info_chromeos.cc",
@@ -731,6 +735,17 @@ component("base") {
sources -= "files/file_path_watcher_kqueue.cc"
}
+ if (is_linux) {
+ # TODO(brettw) these will need to be parameterized at some point.
+ linux_configs = [
+ "//build/config/linux/system:glib",
+ "//build/config/linux/system:gtk",
+ "//build/config/linux/system:x11",
+ ]
+ configs += linux_configs
+ all_dependent_configs += linux_configs
+ }
+
# Non-Mac Unix stuff.
if (is_mac) { #!is_posix || is_mac) {
sources -= [
diff --git a/tools/gn/secondary/build/config/BUILDCONFIG.gn b/tools/gn/secondary/build/config/BUILDCONFIG.gn
index d203677..6494a15 100644
--- a/tools/gn/secondary/build/config/BUILDCONFIG.gn
+++ b/tools/gn/secondary/build/config/BUILDCONFIG.gn
@@ -197,6 +197,8 @@ set_defaults("shared_library") {
if (is_win) {
set_default_toolchain("//build/config/win:32")
+} else if (is_linux) {
+ set_default_toolchain("//build/config/linux:gcc")
} else if (is_mac) {
set_default_toolchain("//build/config/mac:clang")
}
diff --git a/tools/gn/secondary/build/config/compiler/BUILD.gn b/tools/gn/secondary/build/config/compiler/BUILD.gn
index 04f73e0..f84e5c7 100644
--- a/tools/gn/secondary/build/config/compiler/BUILD.gn
+++ b/tools/gn/secondary/build/config/compiler/BUILD.gn
@@ -11,67 +11,93 @@ config("compiler") {
"/Od", "/WX", "/Zi", "/Gy", "/GS", "/RTC1", "/EHsc",
]
} else {
+ # Common GCC compiler flags setup.
+ # --------------------------------
cflags = [
- # TODO(brettw) obviously this needs to be parameterized.
- "-arch i386",
-
- # See http://crbug.com/32204
- "-fno-strict-aliasing",
-
+ "-fno-strict-aliasing", # See http://crbug.com/32204
"-fno-threadsafe-statics",
- "-fstack-protector-all",
"-fvisibility=hidden",
"-fvisibility-inlines-hidden",
- ]
- # !!! Please keep additions sorted alphabetically.
-
- # TODO(brettw) these should be clang-only.
- # if (is_clang) {
- cflags += [
- "-fcolor-diagnostics",
- ]
- #}
+ # GCC turns on -Wsign-compare for C++ under -Wall, but clang doesn't,
+ # so we specify it explicitly.
+ # TODO(fischman): remove this if http://llvm.org/PR10448 obsoletes it.
+ # http://code.google.com/p/chromium/issues/detail?id=90453
+ "-Wsign-compare",
+ ]
cflags_c = [
- "-std=c99",
]
-
cflags_cc = [
"-fno-exceptions",
- "-std=gnu++11",
]
- }
+ ldflags = [
+ ]
- if (is_mac) {
- # These are used for both compiler and linker flags on Mac.
- common_mac_flags = [
- # TODO(brettw) obviously this needs to be parameterized.
- "-arch i386",
+ # Stack protection.
+ # TODO(brettw) why do we have different values for all of these cases?
+ if (is_mac) {
+ cflags += "-fstack-protector-all"
+ } else if (is_chromeos) {
+ cflags += "-fstack-protector-strong"
+ } else if (is_linux) {
+ cflags += [ "-fstack-protector", "--param=ssp-buffer-size=4" ]
+ }
- # Set which SDK to use.
- # TODO(brettw) this needs to be configurable somehow.
- "-isysroot", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk",
+ # Mac-specific compiler flags setup.
+ # ----------------------------------
+ if (is_mac) {
+ # These flags are shared between the C compiler and linker.
+ common_mac_flags = [
+ # TODO(brettw) obviously this arch flag needs to be parameterized.
+ "-arch i386",
- "-mmacosx-version-min=10.6",
- ]
+ # Set which SDK to use.
+ # TODO(brettw) this needs to be configurable somehow.
+ "-isysroot", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk",
- # Mac compiler flags.
- cflags += [
- # Without this, the constructors and destructors of a C++ object inside
- # an Objective C struct won't be called, which is very bad.
- "-fobjc-call-cxx-cdtors",
- ]
- cflags += common_mac_flags
+ "-mmacosx-version-min=10.6",
+ ]
- # Mac linker flags.
- ldflags = [
- "-L.",
+ cflags += common_mac_flags + [
+ # Without this, the constructors and destructors of a C++ object inside
+ # an Objective C struct won't be called, which is very bad.
+ "-fobjc-call-cxx-cdtors",
+ ]
- # TODO(brettW) I don't understand these options.
- "-Wl,-rpath,@loader_path/.",
- "-Wl,-rpath,@loader_path/../../..",
- ]
- ldflags += common_mac_flags
+ cflags_c += [ "-std=c99" ]
+ cflags_cc += [ "-std=gnu++11" ]
+
+ ldflags += common_mac_flags + [
+ "-L.",
+
+ # TODO(brettW) I don't understand these options.
+ "-Wl,-rpath,@loader_path/.",
+ "-Wl,-rpath,@loader_path/../../..",
+ ]
+ }
+
+ # Linux-specific compiler flags setup.
+ # ------------------------------------
+ if (is_linux) {
+ cflags += [
+ "-pthread",
+ "-pipe", # Use pipes for communicating between sub-processes. Faster.
+ ]
+ ldflags += [
+ "-pthread",
+ "-Wl,-z,noexecstack",
+ ]
+ }
+
+ # Clang-specific compiler flags setup.
+ # ------------------------------------
+ # TODO(brettw) these should be clang-only. For now, make it mac-only since
+ # that's where we always use clang.
+ if (is_mac) { # if (is_clang) {
+ cflags += [
+ "-fcolor-diagnostics",
+ ]
+ }
}
}
@@ -134,7 +160,7 @@ config("chromium_code") {
cflags = [
"/W4", # Warning level 4.
]
- } else if (is_mac) {
+ } else {
cflags = [
"-Wall",
"-Werror",
@@ -211,26 +237,26 @@ config("default_warnings") {
"/wd4706", # Assignment within conditional expression.
"/wd4819", # Character not in the current code page.
]
- }
-
- # TODO(brettw) this should probably be if(clang).
- if (is_mac) {
+ } else {
+ # Common GCC warning setup.
cflags = [
- # Warn for weird old-style text after an #endif.
- "-Wendif-labels",
-
- "-Wnewline-eof",
-
- # Don't warn about the "struct foo f = {0};" initialization pattern.
- "-Wno-missing-field-initializers",
+ # Enables.
+ "-Wendif-labels", # Weird old-style text after an #endif.
- # Don't warn about unused function parameters.
- "-Wno-unused-parameter",
+ # Disables.
+ "-Wno-missing-field-initializers", # "struct foo f = {0};"
+ "-Wno-unused-parameter", # Unused function parameters.
]
+ if (is_mac) {
+ cflags += [
+ "-Wnewline-eof",
+ ]
+ }
+
# TODO(brettw) Ones below here should be clang-only when we have a flag
# for it.
- #if (is_clang) {
+ if (is_mac) { #if (is_clang) {
cflags += [
"-Wheader-hygiene",
@@ -260,6 +286,6 @@ config("default_warnings") {
# Warns when a const char[] is converted to bool.
"-Wstring-conversion",
]
- #} #is_clang
+ }
}
}
diff --git a/tools/gn/secondary/build/config/linux/BUILD.gn b/tools/gn/secondary/build/config/linux/BUILD.gn
new file mode 100644
index 0000000..d03165a
--- /dev/null
+++ b/tools/gn/secondary/build/config/linux/BUILD.gn
@@ -0,0 +1,47 @@
+# Copyright (c) 2013 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.
+
+cc = "gcc"
+cxx = "g++"
+ld = cxx
+
+toolchain("gcc") {
+ tool("cc") {
+ # cflags_pch_c
+ command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c -c \$in -o \$out"
+ description = "CC \$out"
+ depfile = "\$out.d"
+ deps = "gcc"
+ }
+ tool("cxx") {
+ # cflags_pch_cc
+ command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -c \$in -o \$out"
+ description = "CXX \$out"
+ depfile = "\$out.d"
+ deps = "gcc"
+ }
+ tool("alink") {
+ command = "rm -f \$out && ar rcs \$out \$in"
+ description = "AR \$out"
+ }
+ tool("solink") {
+ command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then \$ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.TOC; else \$ld -shared \$ldflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.tmp && if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tmp \${lib}.TOC ; fi; fi"
+ description = "SOLINK \$lib"
+ #pool = "link_pool"
+ restat = "1"
+ }
+ tool("link") {
+ command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--end-group \$libs"
+ description = "LINK \$out"
+ #pool = "link_pool"
+ }
+ tool("stamp") {
+ command = "\${postbuilds}touch \$out"
+ description = "STAMP \$out"
+ }
+ tool("copy") {
+ command = "ln -f \$in \$out 2>/dev/null || (rm -rf \$out && cp -af \$in \$out)"
+ description = "COPY \$in \$out"
+ }
+}
diff --git a/tools/gn/secondary/build/config/linux/system/BUILD.gn b/tools/gn/secondary/build/config/linux/system/BUILD.gn
new file mode 100644
index 0000000..3cecca8
--- /dev/null
+++ b/tools/gn/secondary/build/config/linux/system/BUILD.gn
@@ -0,0 +1,31 @@
+# Copyright (c) 2013 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.
+
+pkg_script = "pkg-config.py"
+
+config("glib") {
+ glib_packages = "glib-2.0 gmodule-2.0 gobject-2.0 gthread-2.0"
+
+ cflags = exec_script(pkg_script, [ "--cflags", glib_packages ], "list lines")
+ ldflags = exec_script(pkg_script, [ "--libs", glib_packages ], "list lines")
+ # if (use_x11) { # TODO(brettw) need to add use_x11
+ ldflags += "-lXtst"
+ #}
+}
+
+config("gtk") {
+ # Gtk requires gmodule, but it does not list it as a dependency in some
+ # misconfigured systems.
+ gtk_packages = "gmodule-2.0 gtk+-2.0 gthread-2.0"
+
+ cflags = exec_script(pkg_script, [ "--cflags", gtk_packages ], "list lines")
+ ldflags = exec_script(pkg_script, [ "--libs", gtk_packages ], "list lines")
+}
+
+config("x11") {
+ x11_packages = "x11 xi"
+
+ cflags = exec_script(pkg_script, [ "--cflags", x11_packages ], "list lines")
+ ldflags = exec_script(pkg_script, [ "--libs", x11_packages ], "list lines")
+}
diff --git a/tools/gn/secondary/build/config/linux/system/pkg-config.py b/tools/gn/secondary/build/config/linux/system/pkg-config.py
new file mode 100644
index 0000000..1cee448
--- /dev/null
+++ b/tools/gn/secondary/build/config/linux/system/pkg-config.py
@@ -0,0 +1,8 @@
+# Copyright (c) 2013 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
+
+sys.exit(subprocess.call(["pkg-config"] + sys.argv[1:]))
diff --git a/tools/gn/secondary/build/config/mac/BUILD.gn b/tools/gn/secondary/build/config/mac/BUILD.gn
index 55ffd03..cc33e51 100644
--- a/tools/gn/secondary/build/config/mac/BUILD.gn
+++ b/tools/gn/secondary/build/config/mac/BUILD.gn
@@ -9,7 +9,6 @@ config("mac_dynamic_flags") {
]
}
-
cc = "../../third_party/llvm-build/Release+Asserts/bin/clang"
cxx = "../../third_party/llvm-build/Release+Asserts/bin/clang++"
ld = cxx
diff --git a/tools/gn/secondary/third_party/icu/BUILD.gn b/tools/gn/secondary/third_party/icu/BUILD.gn
new file mode 100644
index 0000000..3fa919e
--- /dev/null
+++ b/tools/gn/secondary/third_party/icu/BUILD.gn
@@ -0,0 +1,5 @@
+
+component("icui18n") {
+}
+component("icuuc") {
+}