Skip to content

Commit

Permalink
Add search_engines and precache components to GN build.
Browse files Browse the repository at this point in the history
R=viettrungluu@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283416 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
brettw@chromium.org committed Jul 16, 2014
1 parent b27a3c7 commit c06b844
Show file tree
Hide file tree
Showing 10 changed files with 224 additions and 0 deletions.
1 change: 1 addition & 0 deletions build/json_to_struct.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
'rules': [
{
# GN version: //tools/json_to_struct/json_to_struct.gni
'rule_name': 'genstaticinit',
'extension': 'json',
'inputs': [
Expand Down
12 changes: 12 additions & 0 deletions components/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ group("all_components") {
"//components/onc",
"//components/os_crypt",
"//components/policy",
"//components/precache/core",
"//components/precache/content",
"//components/pref_registry",
"//components/query_parser",
"//components/rappor",
"//components/resources:components_resources",
"//components/search_engines",
"//components/startup_metric_utils",
"//components/strings",
"//components/tracing",
Expand Down Expand Up @@ -91,8 +94,11 @@ group("all_components") {
"//components/history/core/test", # Should work, needs checking.
"//components/json_schema", # Should work, needs checking.
"//components/keyed_service/content", # Blocked on content.
"//components/precache/core", # Should work, needs checking.
"//components/precache/content", # Blocked on content.
"//components/policy", # Blocked on content (indirectly via autofill).
"//components/rappor", # Should work, needs checking.
"//components/search_engines", # Should work, needs checking.
"//components/translate/content/browser", # Blocked on content.
"//components/translate/content/common", # Blocked on content.
"//components/translate/content/renderer", # Blocked on content.
Expand All @@ -111,3 +117,9 @@ group("all_components") {
]
}
}

# TODO(GYP) components_unittests
#test("components_unittests") {
## # Precache tests need these defines.
# configs += [ "//components/precache/core:precache_config" ]
#}
4 changes: 4 additions & 0 deletions components/precache.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{
'targets': [
{
# GN Version: //components/precache/content
'target_name': 'precache_content',
'type': 'static_library',
'dependencies': [
Expand All @@ -17,13 +18,15 @@
'..',
],
'sources': [
# Note: sources list duplicated in GN build.
'precache/content/precache_manager.cc',
'precache/content/precache_manager.h',
'precache/content/precache_manager_factory.cc',
'precache/content/precache_manager_factory.h',
],
},
{
# GN version: //components/precache/core
'target_name': 'precache_core',
'type': 'static_library',
'dependencies': [
Expand Down Expand Up @@ -54,6 +57,7 @@
},
},
{
# GN version: //components/precache/core:proto
'target_name': 'precache_core_proto',
'type': 'static_library',
'sources': [
Expand Down
21 changes: 21 additions & 0 deletions components/precache/content/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.

static_library("content") {
sources = [
"precache_manager.cc",
"precache_manager.h",
"precache_manager_factory.cc",
"precache_manager_factory.h",
]

configs += [ "//components/precache/core:precache_config" ]

deps = [
"//base",
"//components/precache/core",
"//content/public/browser",
"//url",
]
}
46 changes: 46 additions & 0 deletions components/precache/core/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 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")

precache_config_settings_url =
"http://www.gstatic.com/chrome/wifiprefetch/precache_config"
precache_manifest_url_prefix =
"http://www.gstatic.com/chrome/wifiprefetch/precache_manifest_"

config("precache_config") {
defines = [
"PRECACHE_CONFIG_SETTINGS_URL=\"$precache_config_settings_url\"",
"PRECACHE_MANIFEST_URL_PREFIX=\"$precache_manifest_url_prefix\"",
]
}

static_library("core") {
sources = [
"precache_database.cc",
"precache_database.h",
"precache_fetcher.cc",
"precache_fetcher.h",
"precache_switches.cc",
"precache_switches.h",
"precache_url_table.cc",
"precache_url_table.h",
"url_list_provider.h",
]

# Note the GYP build sets this as direct dependent settings, but this is
# only used to share the settings with the unit tests. Instead, we just
# set this config for the necessary targets manually.
configs += [ ":precache_config" ]

deps = [
":proto",
"//base",
"//url",
]
}

proto_library("proto") {
sources = [ "proto/precache.proto" ]
}
2 changes: 2 additions & 0 deletions components/precache/precache_defines.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

{
'variables': {
# These values are duplicated in the GN build in:
# //components/precache/core:precache_config
'precache_config_settings_url%': 'http://www.gstatic.com/chrome/wifiprefetch/precache_config',
'precache_manifest_url_prefix%': 'http://www.gstatic.com/chrome/wifiprefetch/precache_manifest_',
},
Expand Down
2 changes: 2 additions & 0 deletions components/search_engines.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{
'targets': [
{
# GN version: //components/search_engines
'target_name': 'search_engines',
'type': 'static_library',
'dependencies': [
Expand All @@ -31,6 +32,7 @@
'..',
],
'sources': [
# Note: sources list duplicated in GN build.
'search_engines/default_search_manager.cc',
'search_engines/default_search_manager.h',
'search_engines/default_search_policy_handler.cc',
Expand Down
73 changes: 73 additions & 0 deletions components/search_engines/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# 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/json_to_struct/json_to_struct.gni")

static_library("search_engines") {
sources = [
"default_search_manager.cc",
"default_search_manager.h",
"default_search_policy_handler.cc",
"default_search_policy_handler.h",
"keyword_table.cc",
"keyword_table.h",
"keyword_web_data_service.cc",
"keyword_web_data_service.h",
"search_engine_type.h",
"search_engines_pref_names.cc",
"search_engines_pref_names.h",
"search_engines_switches.cc",
"search_engines_switches.h",
"search_host_to_urls_map.cc",
"search_host_to_urls_map.h",
"search_terms_data.cc",
"search_terms_data.h",
"template_url.cc",
"template_url.h",
"template_url_data.cc",
"template_url_data.h",
"template_url_fetcher.cc",
"template_url_fetcher.h",
"template_url_id.h",
"template_url_parser.cc",
"template_url_parser.h",
"template_url_prepopulate_data.cc",
"template_url_prepopulate_data.h",
"template_url_service.cc",
"template_url_service.h",
"template_url_service_client.h",
"template_url_service_observer.h",
"util.cc",
"util.h",
]

deps = [
":prepopulated_engines",
"//base",
"//components/keyed_service/core",
"//components/metrics/proto",
"//components/policy",
"//components/pref_registry",
"//components/rappor",
"//components/strings",
"//components/url_fixer",
"//components/webdata/common",
"//google_apis",
"//net",
"//sql",
"//sync",
"//third_party/libxml",
"//ui/gfx",
"//url",
#'google_core_browser', TODO(GYP)
]
}

json_to_struct("prepopulated_engines") {
visibility = ":*"

source = "prepopulated_engines.json"
schema_file = "prepopulated_engines_schema.json"
namespace = "TemplateURLPrepopulateData"
}
1 change: 1 addition & 0 deletions components/search_engines/prepopulated_engines.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{
'targets': [
{
# GN version: //components/search_engines:prepopulated_engines
'target_name': 'prepopulated_engines',
'type': 'static_library',
'sources': [
Expand Down
62 changes: 62 additions & 0 deletions tools/json_to_struct/json_to_struct.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# 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.

# Converts a .json file to a C++ struct.
#
# Variables:
#
# source (required)
# Single file name of source .json file.
#
# schema_file (required)
# Single file name of the .json file that defines the schema.
#
# namespace (required)
# Namespace name to put result in.
#
# visibility (optional)
# Normal meaning.
template("json_to_struct") {
assert(defined(invoker.source), "source required in $target_name")
assert(defined(invoker.schema_file), "schema_file required in $target_name")
assert(defined(invoker.namespace), "namespace required in $target_name")

action_name = target_name + "_action"
source_set_name = target_name

action(action_name) {
visibility = [ ":$source_set_name" ]
script = "//tools/json_to_struct/json_to_struct.py"

inputs = [
"//tools/json_to_struct/element_generator.py",
"//tools/json_to_struct/struct_generator.py",
invoker.source,
]

out_dir = get_path_info(invoker.source, "gen_dir")
out_name = get_path_info(invoker.source, "name")
outputs = [
"$out_dir/$out_name.cc",
"$out_dir/$out_name.h",
]

args = [
rebase_path(invoker.source, root_build_dir),
"--destbase=" + rebase_path(out_dir, root_build_dir),
"--namespace=" + invoker.namespace,
"--schema=" + rebase_path(invoker.schema_file, root_build_dir),
]
}

source_set(source_set_name) {
if (defined(invoker.visibility)) {
visibility = invoker.visibility
}

sources = get_target_outputs(":$action_name")

deps = [ ":$action_name" ]
}
}

0 comments on commit c06b844

Please sign in to comment.