Skip to content

Commit

Permalink
Add GN build for some chrome common, chrome net, and resources targets.
Browse files Browse the repository at this point in the history
Slight enhancements to the grit template.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/335053002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277517 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
brettw@chromium.org committed Jun 16, 2014
1 parent 7555225 commit 77ce802
Show file tree
Hide file tree
Showing 14 changed files with 268 additions and 2 deletions.
2 changes: 1 addition & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ group("root") {

"//apps/common/api:apps_api",
"//cc",
#"//chrome",
"//chrome:resources",
"//components/favicon_base",
"//components/language_usage_metrics",
"//components/metrics",
Expand Down
2 changes: 2 additions & 0 deletions build/config/features.gni
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@ disable_ftp_support = is_ios
enable_speech_input = true

use_dbus = is_linux

enable_extensions = (!is_android && !is_ios)
21 changes: 21 additions & 0 deletions chrome/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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" ]
}
}
60 changes: 60 additions & 0 deletions chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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.
}
}
12 changes: 12 additions & 0 deletions chrome/browser/ui/webui/omnibox/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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",
]
}
5 changes: 5 additions & 0 deletions chrome/chrome_common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@
],
},
{
# GN version: //chrome/commoon/net:net
'target_name': 'common_net',
'type': 'static_library',
'sources': [
Expand Down Expand Up @@ -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': [
Expand All @@ -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': [
Expand Down
8 changes: 8 additions & 0 deletions chrome/chrome_resources.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
],
},
{
# GN version: //chrome/browser:chrome_internal_resources_gen
'target_name': 'chrome_internal_resources_gen',
'type': 'none',
'conditions': [
Expand Down Expand Up @@ -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': [
Expand All @@ -175,6 +178,7 @@
],
'actions': [
{
# GN version: //chrome/browser:resources
'action_name': 'generate_browser_resources',
'variables': {
'grit_grd_file': 'browser/browser_resources.grd',
Expand All @@ -187,13 +191,15 @@
'includes': [ '../build/grit_action.gypi' ],
},
{
# GN version: //chrome/common:resources
'action_name': 'generate_common_resources',
'variables': {
'grit_grd_file': 'common/common_resources.grd',
},
'includes': [ '../build/grit_action.gypi' ],
},
{
# GN version: //chrome/renderer:resources
'action_name': 'generate_renderer_resources',
'variables': {
'grit_grd_file': 'renderer/resources/renderer_resources.grd',
Expand All @@ -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',
Expand Down Expand Up @@ -502,6 +509,7 @@
'includes': [ '../build/grit_target.gypi' ],
},
{
# GN version: //chrome/browser:about_credits
'target_name': 'about_credits',
'type': 'none',
'actions': [
Expand Down
1 change: 1 addition & 0 deletions chrome/chrome_web_ui_mojo_bindings.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions chrome/common/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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" ]
#}
12 changes: 12 additions & 0 deletions chrome/common/metrics/proto/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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",
}
}
71 changes: 71 additions & 0 deletions chrome/common/net/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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" ]
}
}
14 changes: 14 additions & 0 deletions chrome/common/safe_browsing/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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",
]
}
11 changes: 11 additions & 0 deletions chrome/renderer/BUILD.gn
Original file line number Diff line number Diff line change
@@ -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"
}
29 changes: 28 additions & 1 deletion tools/gn/secondary/tools/grit/grit_rule.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -34,6 +48,15 @@ if (is_android) {
]
}

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"

Expand Down Expand Up @@ -102,6 +125,10 @@ template("grit") {
] + 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
Expand Down

0 comments on commit 77ce802

Please sign in to comment.