Add GN build for some chrome common, chrome net, and resources targets.
Slight enhancements to the grit template.
[email protected]
Review URL: https://codereview.chromium.org/335053002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277517 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/BUILD.gn b/BUILD.gn
index 3be755d..bcee8e5 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -21,7 +21,7 @@
"//apps/common/api:apps_api",
"//cc",
- #"//chrome",
+ "//chrome:resources",
"//components/favicon_base",
"//components/language_usage_metrics",
"//components/metrics",
diff --git a/build/config/features.gni b/build/config/features.gni
index 415ca77a..79fc222 100644
--- a/build/config/features.gni
+++ b/build/config/features.gni
@@ -70,3 +70,5 @@
enable_speech_input = true
use_dbus = is_linux
+
+enable_extensions = (!is_android && !is_ios)
diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn
new file mode 100644
index 0000000..3aeafb0
--- /dev/null
+++ b/chrome/BUILD.gn
@@ -0,0 +1,21 @@
+# 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/features.gni")
+
+# GYP version: chrome/chrome_resources.gyp:chrome_resources
+group("resources") {
+ deps = [
+ # Note: GYP lists some dependencies in addition to these actions. However,
+ # these are just dependencies for the actions themselves, which our actions
+ # list individually when needed.
+ "//chrome/browser:resources",
+ "//chrome/common:resources",
+ "//chrome/renderer:resources",
+ ]
+
+ if (enable_extensions) {
+ deps += [ "//chrome/common:extensions_api_resources" ]
+ }
+}
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
new file mode 100644
index 0000000..6049415
--- /dev/null
+++ b/chrome/browser/BUILD.gn
@@ -0,0 +1,60 @@
+# 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("//tools/grit/grit_rule.gni")
+
+about_credits_file = "$target_gen_dir/about_credits.html"
+additional_modules_list_file =
+ "$root_gen_dir/chrome/browser/internal/additional_modules_list.txt"
+
+# GYP version: chrome/chrome_resources.gyp:chrome_resources
+# (generate_browser_resources action)
+grit("resources") {
+ source = "browser_resources.grd"
+
+ omnibox_mojom_file = "$root_gen_dir/chrome/browser/ui/webui/omnibox/omnibox.mojom.js"
+
+ grit_flags = [
+ "-E", "about_credits_file=" +
+ rebase_path(about_credits_file, root_build_dir),
+ "-E", "additional_modules_list_file=" +
+ rebase_path(additional_modules_list_file, root_build_dir),
+ "-E", "omnibox_mojom_file=" +
+ rebase_path(omnibox_mojom_file, root_build_dir),
+ ]
+
+ deps = [
+ ":about_credits",
+ ":chrome_internal_resources_gen",
+ "//chrome/browser/ui/webui/omnibox:mojo_bindings",
+ ]
+}
+
+# GYP version: chrome/chrome_resource.gyp:about_credits
+action("about_credits") {
+ script = "//tools/licenses.py"
+
+ # TODO(phajdan.jr): input dependencies so this can be regenerated
+ # automatically when one of the credits changes. The way this should work is
+ # that licenses.py should write a .d file listing the input dependencies (see
+ # "depfile" in GN).
+ outputs = [ about_credits_file ]
+
+ args = [
+ "credits",
+ rebase_path(about_credits_file, root_build_dir),
+ ]
+}
+
+# GYP version: chrome/chrome_resource.gyp:chrome_internal_resources_gen
+# TODO(GYP) write internal action
+if (false) { #if (is_chrome_branded) {
+ action("chrome_internal_resources_gen") {
+ # TODO(GYP)
+ }
+} else {
+ group("chrome_internal_resources_gen") {
+ # Empty placeholder.
+ }
+}
diff --git a/chrome/browser/ui/webui/omnibox/BUILD.gn b/chrome/browser/ui/webui/omnibox/BUILD.gn
new file mode 100644
index 0000000..a281580
--- /dev/null
+++ b/chrome/browser/ui/webui/omnibox/BUILD.gn
@@ -0,0 +1,12 @@
+# 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("//mojo/public/tools/bindings/mojom.gni")
+
+# GYP version: chrome/chrome_web_ui_mojo_bindings.gyp:webui_mojo_bindings
+mojom("mojo_bindings") {
+ sources = [
+ "omnibox.mojom",
+ ]
+}
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index e5cb9c3..70d561b8 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -587,6 +587,7 @@
],
},
{
+ # GN version: //chrome/commoon/net:net
'target_name': 'common_net',
'type': 'static_library',
'sources': [
@@ -669,6 +670,8 @@
# Protobuf compiler / generator for the safebrowsing client
# model proto and the client-side detection (csd) request
# protocol buffer.
+
+ # GN version: //chrome/common/safe_browsing:proto
'target_name': 'safe_browsing_proto',
'type': 'static_library',
'sources': [
@@ -684,6 +687,8 @@
},
{
# Protobuf compiler / generator for UMA (User Metrics Analysis).
+
+ # GN version: //chrome/common/metrics/proto:proto
'target_name': 'metrics_proto',
'type': 'static_library',
'sources': [
diff --git a/chrome/chrome_resources.gyp b/chrome/chrome_resources.gyp
index 315079e..6991782 100644
--- a/chrome/chrome_resources.gyp
+++ b/chrome/chrome_resources.gyp
@@ -130,6 +130,7 @@
],
},
{
+ # GN version: //chrome/browser:chrome_internal_resources_gen
'target_name': 'chrome_internal_resources_gen',
'type': 'none',
'conditions': [
@@ -166,6 +167,8 @@
# to run grit would list its own .grd files, but unfortunately some
# of the static libraries currently have circular dependencies among
# generated headers.
+
+ # GN version: //chrome:resources
'target_name': 'chrome_resources',
'type': 'none',
'dependencies': [
@@ -175,6 +178,7 @@
],
'actions': [
{
+ # GN version: //chrome/browser:resources
'action_name': 'generate_browser_resources',
'variables': {
'grit_grd_file': 'browser/browser_resources.grd',
@@ -187,6 +191,7 @@
'includes': [ '../build/grit_action.gypi' ],
},
{
+ # GN version: //chrome/common:resources
'action_name': 'generate_common_resources',
'variables': {
'grit_grd_file': 'common/common_resources.grd',
@@ -194,6 +199,7 @@
'includes': [ '../build/grit_action.gypi' ],
},
{
+ # GN version: //chrome/renderer:resources
'action_name': 'generate_renderer_resources',
'variables': {
'grit_grd_file': 'renderer/resources/renderer_resources.grd',
@@ -205,6 +211,7 @@
['enable_extensions==1', {
'actions': [
{
+ # GN version: //chrome/common:extensions_api_resources
'action_name': 'generate_extensions_api_resources',
'variables': {
'grit_grd_file': 'common/extensions_api_resources.grd',
@@ -502,6 +509,7 @@
'includes': [ '../build/grit_target.gypi' ],
},
{
+ # GN version: //chrome/browser:about_credits
'target_name': 'about_credits',
'type': 'none',
'actions': [
diff --git a/chrome/chrome_web_ui_mojo_bindings.gyp b/chrome/chrome_web_ui_mojo_bindings.gyp
index 2ed9d51..4419898 100644
--- a/chrome/chrome_web_ui_mojo_bindings.gyp
+++ b/chrome/chrome_web_ui_mojo_bindings.gyp
@@ -4,6 +4,7 @@
{
'targets': [
{
+ # GN version: //chrome/browser/ui/webui/omnibox:mojo_bindings
'target_name': 'web_ui_mojo_bindings',
# The type of this target must be none. This is so that resources can
# depend upon this target for generating the js bindings files. Any
diff --git a/chrome/common/BUILD.gn b/chrome/common/BUILD.gn
new file mode 100644
index 0000000..7e4a4b1
--- /dev/null
+++ b/chrome/common/BUILD.gn
@@ -0,0 +1,22 @@
+# 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("//tools/grit/grit_rule.gni")
+
+# GYP version: chrome/chrome_resources.gyp:chrome_resources
+# (generate_common_resources action)
+grit("resources") {
+ source = "common_resources.grd"
+}
+
+# GYP version: chrome/chrome_resources.gyp:chrome_resources
+# (generate_extensions_api_resources action)
+grit("extensions_api_resources") {
+ source = "extensions_api_resources.grd"
+}
+
+# TODO(GYP) add this target.
+#static_library("common") {
+# configs += [ "//build/config/compiler:wexit_time_destructors" ]
+#}
diff --git a/chrome/common/metrics/proto/BUILD.gn b/chrome/common/metrics/proto/BUILD.gn
new file mode 100644
index 0000000..6344416
--- /dev/null
+++ b/chrome/common/metrics/proto/BUILD.gn
@@ -0,0 +1,12 @@
+# 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("//third_party/protobuf/proto_library.gni")
+
+# GYP version: chrome/chrome_common.gypi:metrics_proto
+proto_library("proto") {
+ sources = [
+ "chrome_experiments.proto",
+ }
+}
diff --git a/chrome/common/net/BUILD.gn b/chrome/common/net/BUILD.gn
new file mode 100644
index 0000000..cc62c57a
--- /dev/null
+++ b/chrome/common/net/BUILD.gn
@@ -0,0 +1,71 @@
+# 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/crypto.gni")
+
+# GYP version: chrome/chrome_common.gypi:common_net
+static_library("net") {
+ sources = [
+ "net_error_info.cc",
+ "net_error_info.h",
+ "net_resource_provider.cc",
+ "net_resource_provider.h",
+ "predictor_common.h",
+ "url_util.cc",
+ "url_util.h",
+ "x509_certificate_model.cc",
+ "x509_certificate_model.h",
+ "x509_certificate_model_nss.cc",
+ "x509_certificate_model_openssl.cc",
+ ]
+
+ deps = [
+ "//base",
+ "//chrome:resources",
+ "//chrome:strings",
+ "//crypto",
+ "//net",
+ "//net:net_resources",
+ "//third_party/icu",
+ ]
+
+ if (is_ios) {
+ sources -= [
+ "net_resource_provider.cc",
+ "x509_certificate_model.cc",
+ ]
+ } else {
+ deps += [ "//gpu:ipc" ]
+ }
+
+ if (is_win || is_mac || is_ios) {
+ sources -= [
+ "x509_certificate_model_nss.cc",
+ "x509_certificate_model_openssl.cc",
+ ]
+ }
+
+ if (is_android) {
+ sources -= [
+ "x509_certificate_model.cc",
+ "x509_certificate_model_openssl.cc",
+ ]
+ deps += [ "//third_party/openssl" ]
+ }
+
+ if (use_openssl) {
+ # networking_private_crypto.cc uses NSS functions.
+ sources -= [
+ "x509_certificate_model_nss.cc",
+ ]
+ } else {
+ sources -= [
+ "x509_certificate_model_openssl.cc",
+ ]
+ }
+
+ if (is_win) {
+ cflags = [ "/wd4267" ]
+ }
+}
diff --git a/chrome/common/safe_browsing/BUILD.gn b/chrome/common/safe_browsing/BUILD.gn
new file mode 100644
index 0000000..47805ebb
--- /dev/null
+++ b/chrome/common/safe_browsing/BUILD.gn
@@ -0,0 +1,14 @@
+# 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("//third_party/protobuf/proto_library.gni")
+
+# GYP version: chrome/chrome_common.gypi:safe_browsing_proto
+proto_library("proto") {
+ sources = [
+ "client_model.proto",
+ "crx_info.proto",
+ "csd.proto",
+ ]
+}
diff --git a/chrome/renderer/BUILD.gn b/chrome/renderer/BUILD.gn
new file mode 100644
index 0000000..72e4c15aa
--- /dev/null
+++ b/chrome/renderer/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("//tools/grit/grit_rule.gni")
+
+# GYP version: chrome/chrome_resources.gyp:chrome_resources
+# (generate_renderer_resources action)
+grit("resources") {
+ source = "resources/renderer_resources.grd"
+}
diff --git a/tools/gn/secondary/tools/grit/grit_rule.gni b/tools/gn/secondary/tools/grit/grit_rule.gni
index f375574f..6dc0a4b 100644
--- a/tools/gn/secondary/tools/grit/grit_rule.gni
+++ b/tools/gn/secondary/tools/grit/grit_rule.gni
@@ -5,13 +5,27 @@
# Instantiate grit. This will produce a script target to run grit, and a
# static library that compiles the .cc files.
#
-# Example:
+# Parameters
+#
+# source
+# Path to .grd file.
+#
+# grit_flags (optional)
+# List of strings containing extra command-line flags to pass to Grit.
+#
+# deps (optional)
+# visibility (optional)
+# Normal meaning.
+#
+# Example
+#
# grit("my_resources") {
# source = "myfile.grd" # source is required.
# grit_flags = [ "-E", "foo=bar" ] # Optional extra flags.
# # You can also put deps here if the grit source depends on generated
# # files.
# }
+import ("//build/config/features.gni")
import ("//build/config/ui.gni")
grit_defines = []
@@ -34,6 +48,15 @@
]
}
+if (enable_extensions) {
+ grit_defines += [ "-D", "enable_extensions" ]
+}
+if (enable_plugins) {
+ grit_defines += [ "-D", "enable_plugins" ]
+}
+
+# TODO(GYP) the rest of the grit_defines from the gyp build.
+
grit_resource_id_file = "//tools/gritsettings/resource_ids"
grit_info_script = "//tools/grit/grit_info.py"
@@ -102,6 +125,10 @@
] + grit_defines + grit_flags
visibility = target_visibility
+
+ if (defined(invoker.deps)) {
+ deps = invoker.deps
+ }
}
# This is the thing that people actually link with, it must be named the