blob: 520be6c4bf2c0efc48140f032b0831497f4b21cf [file] [log] [blame]
# 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/chrome_build.gni")
import("//build/config/features.gni")
import("//extensions/buildflags/buildflags.gni")
import("//testing/test.gni")
declare_args() {
# You can set the variable 'use_official_google_api_keys' to true
# to use the Google-internal file containing official API keys
# for Google Chrome even in a developer build. Setting this
# variable explicitly to true will cause your build to fail if the
# internal file is missing.
#
# The variable is documented here, but not handled in this file;
# see //google_apis/determine_use_official_keys.gypi for the
# implementation.
#
# Set the variable to false to not use the internal file, even when
# it exists in your checkout.
#
# Leave it unset or set to "" to have the variable
# implicitly set to true if you have
# src/google_apis/internal/google_chrome_api_keys.h in your
# checkout, and implicitly set to false if not.
#
# Note that official builds always behave as if the variable
# was explicitly set to true, i.e. they always use official keys,
# and will fail to build if the internal file is missing.
use_official_google_api_keys = ""
# Set these to bake the specified API keys and OAuth client
# IDs/secrets into your build.
#
# If you create a build without values baked in, you can instead
# set environment variables to provide the keys at runtime (see
# src/google_apis/google_api_keys.h for details). Features that
# require server-side APIs may fail to work if no keys are
# provided.
#
# Note that if you are building an official build or if
# use_official_google_api_keys has been set to trie (explicitly or
# implicitly), these values will be ignored and the official
# keys will be used instead.
google_api_key = ""
# See google_api_key.
google_default_client_id = ""
# See google_api_key.
google_default_client_secret = ""
}
if (use_official_google_api_keys == "") {
# Default behavior, check if the key file exists.
check_internal_result =
exec_script("build/check_internal.py",
[ rebase_path("internal/google_chrome_api_keys.h",
root_build_dir) ],
"value")
use_official_google_api_keys = check_internal_result == 1
}
config("key_defines") {
defines = []
if (is_chrome_branded || use_official_google_api_keys) {
defines += [ "USE_OFFICIAL_GOOGLE_API_KEYS=1" ]
}
if (google_api_key != "") {
defines += [ "GOOGLE_API_KEY=\"$google_api_key\"" ]
}
if (google_default_client_id != "") {
defines += [ "GOOGLE_DEFAULT_CLIENT_ID=\"$google_default_client_id\"" ]
}
if (google_default_client_secret != "") {
defines +=
[ "GOOGLE_DEFAULT_CLIENT_SECRET=\"$google_default_client_secret\"" ]
}
}
# Variables:
# deps: Extra dependencies
template("google_apis_tmpl") {
source_set(target_name) {
sources = [
"gaia/core_account_id.cc",
"gaia/core_account_id.h",
"gaia/gaia_auth_consumer.cc",
"gaia/gaia_auth_consumer.h",
"gaia/gaia_auth_fetcher.cc",
"gaia/gaia_auth_fetcher.h",
"gaia/gaia_auth_util.cc",
"gaia/gaia_auth_util.h",
"gaia/gaia_constants.cc",
"gaia/gaia_constants.h",
"gaia/gaia_oauth_client.cc",
"gaia/gaia_oauth_client.h",
"gaia/gaia_switches.cc",
"gaia/gaia_switches.h",
"gaia/gaia_urls.cc",
"gaia/gaia_urls.h",
"gaia/google_service_auth_error.cc",
"gaia/google_service_auth_error.h",
"gaia/oauth2_access_token_consumer.cc",
"gaia/oauth2_access_token_consumer.h",
"gaia/oauth2_access_token_fetcher.cc",
"gaia/oauth2_access_token_fetcher.h",
"gaia/oauth2_access_token_fetcher_immediate_error.cc",
"gaia/oauth2_access_token_fetcher_immediate_error.h",
"gaia/oauth2_access_token_fetcher_impl.cc",
"gaia/oauth2_access_token_fetcher_impl.h",
"gaia/oauth2_access_token_manager.cc",
"gaia/oauth2_access_token_manager.h",
"gaia/oauth2_api_call_flow.cc",
"gaia/oauth2_api_call_flow.h",
"gaia/oauth2_id_token_decoder.cc",
"gaia/oauth2_id_token_decoder.h",
"gaia/oauth2_mint_token_flow.cc",
"gaia/oauth2_mint_token_flow.h",
"gaia/oauth_multilogin_result.cc",
"gaia/oauth_multilogin_result.h",
"gaia/oauth_request_signer.cc",
"gaia/oauth_request_signer.h",
"google_api_keys.cc",
"google_api_keys.h",
]
configs += [
":key_defines",
"//build/config/compiler:no_size_t_to_int_warning",
]
deps = [
"//base",
"//base/third_party/dynamic_annotations",
"//build:branding_buildflags",
"//crypto",
"//mojo/public/cpp/bindings:struct_traits",
"//services/network/public/cpp",
]
if (is_chrome_branded || use_official_google_api_keys) {
deps += [ "internal:generate_metrics_key_header" ]
}
if (defined(invoker.deps)) {
deps += invoker.deps
}
if (is_mac || is_ios) {
set_sources_assignment_filter([])
sources += [
"google_api_keys_mac.h",
"google_api_keys_mac.mm",
]
set_sources_assignment_filter(sources_assignment_filter)
libs = [ "Foundation.framework" ]
}
}
}
google_apis_tmpl("google_apis") {
deps = [
"//net",
"//services/network/public/cpp",
]
}
static_library("test_support") {
testonly = true
sources = [
"gaia/core_account_id_for_testing.cc",
"gaia/fake_gaia.cc",
"gaia/fake_gaia.h",
"gaia/fake_oauth2_access_token_manager.cc",
"gaia/fake_oauth2_access_token_manager.h",
"gaia/oauth2_access_token_manager_test_util.cc",
"gaia/oauth2_access_token_manager_test_util.h",
]
public_deps = [
":google_apis",
"//base",
"//base/test:test_support",
"//net:test_support",
"//services/network:network_service",
"//services/network:test_support",
"//services/network/public/cpp",
]
}
source_set("run_all_unittests") {
testonly = true
sources = [ "run_all_unittests.cc" ]
deps = [
"//base/test:test_support",
"//mojo/core/embedder",
]
}
test("google_apis_unittests") {
sources = [
"gaia/gaia_auth_fetcher_unittest.cc",
"gaia/gaia_auth_util_unittest.cc",
"gaia/gaia_oauth_client_unittest.cc",
"gaia/google_service_auth_error_unittest.cc",
"gaia/oauth2_access_token_fetcher_impl_unittest.cc",
"gaia/oauth2_access_token_manager_unittest.cc",
"gaia/oauth2_api_call_flow_unittest.cc",
"gaia/oauth2_id_token_decoder_unittest.cc",
"gaia/oauth2_mint_token_flow_unittest.cc",
"gaia/oauth_multilogin_result_unittest.cc",
"gaia/oauth_request_signer_unittest.cc",
"google_api_keys_unittest.cc",
"google_api_keys_unittest.h",
]
data = [ "test/" ]
configs += [ ":key_defines" ]
deps = [
":google_apis",
":run_all_unittests",
":test_support",
"//base",
"//base/test:test_support",
"//build:branding_buildflags",
"//testing/gmock",
"//testing/gtest",
]
if (enable_extensions) {
deps += [ "//google_apis/drive:drive_unittests" ]
}
if (is_mac || is_ios) {
set_sources_assignment_filter([])
sources += [ "google_api_keys_mac_unittest.mm" ]
set_sources_assignment_filter(sources_assignment_filter)
deps += [ "//third_party/ocmock" ]
}
}