# 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") 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 (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/account_tracker.cc", "gaia/account_tracker.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/identity_provider.cc", "gaia/identity_provider.h", "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_api_call_flow.cc", "gaia/oauth2_api_call_flow.h", "gaia/oauth2_mint_token_flow.cc", "gaia/oauth2_mint_token_flow.h", "gaia/oauth2_token_service.cc", "gaia/oauth2_token_service.h", "gaia/oauth2_token_service_delegate.cc", "gaia/oauth2_token_service_delegate.h", "gaia/oauth2_token_service_request.cc", "gaia/oauth2_token_service_request.h", "gaia/oauth_request_signer.cc", "gaia/oauth_request_signer.h", "gaia/ubertoken_fetcher.cc", "gaia/ubertoken_fetcher.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", "//crypto", "//third_party/libxml", ] if (defined(invoker.deps)) { deps += invoker.deps } if (enable_extensions) { sources += [ "drive/auth_service.cc", "drive/auth_service.h", "drive/auth_service_interface.h", "drive/auth_service_observer.h", "drive/base_requests.cc", "drive/base_requests.h", "drive/drive_api_error_codes.cc", "drive/drive_api_error_codes.h", "drive/drive_api_parser.cc", "drive/drive_api_parser.h", "drive/drive_api_requests.cc", "drive/drive_api_requests.h", "drive/drive_api_url_generator.cc", "drive/drive_api_url_generator.h", "drive/drive_common_callbacks.h", "drive/files_list_request_runner.cc", "drive/files_list_request_runner.h", "drive/request_sender.cc", "drive/request_sender.h", "drive/request_util.cc", "drive/request_util.h", "drive/task_util.cc", "drive/task_util.h", "drive/time_util.cc", "drive/time_util.h", ] } } } google_apis_tmpl("google_apis") { deps = [ "//net", ] } if (is_android) { google_apis_tmpl("google_apis_small") { deps = [ "//net:net_small", ] } } source_set("test_support") { testonly = true sources = [ "gaia/fake_gaia.cc", "gaia/fake_gaia.h", "gaia/fake_identity_provider.cc", "gaia/fake_identity_provider.h", "gaia/fake_oauth2_token_service.cc", "gaia/fake_oauth2_token_service.h", "gaia/fake_oauth2_token_service_delegate.cc", "gaia/fake_oauth2_token_service_delegate.h", "gaia/mock_url_fetcher_factory.h", "gaia/oauth2_token_service_test_util.cc", "gaia/oauth2_token_service_test_util.h", ] public_deps = [ ":google_apis", "//base", "//base/test:test_support", "//net", "//net:test_support", ] if (enable_extensions) { sources += [ "drive/dummy_auth_service.cc", "drive/dummy_auth_service.h", "drive/test_util.cc", "drive/test_util.h", ] } } bundle_data("google_apis_unittests_bundle_data") { testonly = true sources = [ "test", ] outputs = [ "{{bundle_resources_dir}}/" + "{{source_root_relative_dir}}/{{source_file_part}}", ] } 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_api_call_flow_unittest.cc", "gaia/oauth2_mint_token_flow_unittest.cc", "gaia/oauth2_token_service_unittest.cc", "gaia/oauth_request_signer_unittest.cc", "gaia/ubertoken_fetcher_unittest.cc", "google_api_keys_unittest.cc", ] data = [ "test/", ] configs += [ ":key_defines" ] deps = [ ":google_apis", ":google_apis_unittests_bundle_data", ":test_support", "//base", "//base/test:run_all_unittests", "//testing/gmock", "//testing/gtest", ] if (enable_extensions) { sources += [ "drive/base_requests_server_unittest.cc", "drive/base_requests_unittest.cc", "drive/drive_api_parser_unittest.cc", "drive/drive_api_requests_unittest.cc", "drive/drive_api_url_generator_unittest.cc", "drive/request_sender_unittest.cc", "drive/request_util_unittest.cc", "drive/time_util_unittest.cc", ] } }