123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- # 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")
- import("//third_party/protobuf/proto_library.gni")
- declare_args() {
- # Set the variable 'use_official_google_api_keys' to true
- # to use the Google-internal file containing official API keys
- # even in a developer build. Setting this variable explicitly to
- # true will cause the build to fail if the internal file is missing.
- #
- # Set the variable to false to not use the internal file, even for
- # Chrome-branded builds or 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 Chrome-branded 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 when building a Chrome-branded build or if
- # `use_official_google_api_keys` has been set to `true` (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 = []
- # TODO(crbug.com/1294915): Refactor so use_official_google_api_keys can be
- # used for Fuchsia.
- if (!is_fuchsia && (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_access_token_fetcher.cc",
- "gaia/gaia_access_token_fetcher.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_config.cc",
- "gaia/gaia_config.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" ]
- deps = [
- ":oauth2_mint_token_consent_result_proto",
- "//base",
- "//base/third_party/dynamic_annotations",
- "//build:branding_buildflags",
- "//build:chromeos_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_apple) {
- sources += [
- "google_api_keys_mac.h",
- "google_api_keys_mac.mm",
- ]
- frameworks = [ "Foundation.framework" ]
- }
- }
- }
- google_apis_tmpl("google_apis") {
- deps = [
- "//net",
- "//services/network/public/cpp",
- "//services/network/public/mojom",
- ]
- }
- proto_library("oauth2_mint_token_consent_result_proto") {
- sources = [ "gaia/oauth2_mint_token_consent_result.proto" ]
- }
- 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_config_unittest.cc",
- "gaia/gaia_oauth_client_unittest.cc",
- "gaia/gaia_urls_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",
- ]
- configs += [ ":key_defines" ]
- deps = [
- ":google_apis",
- ":oauth2_mint_token_consent_result_proto",
- ":run_all_unittests",
- ":test_support",
- "//base",
- "//base/test:test_support",
- "//build:branding_buildflags",
- "//build:chromeos_buildflags",
- "//google_apis/calendar:calendar_unittests",
- "//google_apis/common:common_unittests",
- "//testing/gmock",
- "//testing/gtest",
- ]
- if (is_ios) {
- deps += [ ":google_apis_unittest_bundle_data" ]
- } else {
- data = [ "test/" ]
- }
- if (is_android) {
- deps += [ "//net/android:net_java" ]
- }
- if (is_fuchsia) {
- use_cfv1 = false
- additional_manifest_fragments =
- [ "//build/config/fuchsia/test/network.shard.test-cml" ]
- }
- if (enable_extensions) {
- deps += [ "//google_apis/drive:drive_unittests" ]
- }
- if (is_apple) {
- sources += [ "google_api_keys_mac_unittest.mm" ]
- deps += [ "//third_party/ocmock" ]
- }
- }
- bundle_data("google_apis_unittest_bundle_data") {
- testonly = true
- sources = [
- "test/data/calendar/event_self_response_statuses.json",
- "test/data/calendar/event_statuses.json",
- "test/data/calendar/events.json",
- "test/data/calendar/invalid_events.json",
- "test/data/gaia/all_base_urls.json",
- "test/data/gaia/all_urls.json",
- "test/data/gaia/api_keys.json",
- "test/data/gaia/bad_url.json",
- "test/data/gaia/bad_url_key.json",
- "test/data/gaia/bad_urls_key.json",
- "test/data/gaia/not_a_json.txt",
- "test/data/gaia/one_base_url.json",
- "test/data/gaia/one_url.json",
- ]
- outputs = [ "{{bundle_resources_dir}}/" +
- "{{source_root_relative_dir}}/{{source_file_part}}" ]
- }
|