From abcd22dab3019637bb49377c35ee805a45ea1eba Mon Sep 17 00:00:00 2001 From: Stephen Roe Date: Mon, 1 Mar 2021 19:09:03 +0000 Subject: [PATCH] [fuchsia] Allow use_official_google_api_keys settings to override defaults. Setting use_official_google_api_keys to true or false will override the Fuchsia, Chrome-branded, and key file defaults. Leaving the variable unset will give the default value. This CL cleans up crrev.com/c/2657723, implementing a more consistent and long term fix. Bug: 1171510 Change-Id: Iad1728772cb8dc975225f6aa7a7eb8fc30b3ee24 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2657805 Reviewed-by: David Dorwin Reviewed-by: Mihai Sardarescu Commit-Queue: Stephen Roe Cr-Commit-Position: refs/heads/master@{#858639} --- google_apis/BUILD.gn | 62 +++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/google_apis/BUILD.gn b/google_apis/BUILD.gn index fddf591b69f011..67a803fdd57b48 100644 --- a/google_apis/BUILD.gn +++ b/google_apis/BUILD.gn @@ -9,27 +9,22 @@ import("//testing/test.gni") import("//third_party/protobuf/proto_library.gni") declare_args() { - # You can set the variable 'use_official_google_api_keys' to true + # 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. + # 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 when - # it exists in your checkout. + # 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. + # Leave it set to "" to have the variable implicitly set to false + # for Fuchsia builds, or to true for Chrome-branded builds or if you have + # src/google_apis/internal/google_chrome_api_keys.h in your checkout, + # and false otherwise. # - # 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. + # Note that if the variable is set to "", Chrome-branded non-Fuchsia + # builds 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 @@ -41,10 +36,9 @@ declare_args() { # 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. + # Note that 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. @@ -55,21 +49,25 @@ declare_args() { } 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 + # No override set. Determine the default behavior. + if (target_os == "fuchsia") { + use_official_google_api_keys = false + } else if (is_chrome_branded) { + use_official_google_api_keys = true + } else { + # 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/1171510): Refactor so use_official_google_api_keys can be - # used for Fuchsia. - if (!is_fuchsia && (is_chrome_branded || use_official_google_api_keys)) { + if (use_official_google_api_keys) { defines += [ "USE_OFFICIAL_GOOGLE_API_KEYS=1" ] } if (google_api_key != "") {