Skip to content

Commit

Permalink
[fuchsia] Allow use_official_google_api_keys settings to override def…
Browse files Browse the repository at this point in the history
…aults.

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 <ddorwin@chromium.org>
Reviewed-by: Mihai Sardarescu <msarda@chromium.org>
Commit-Queue: Stephen Roe <steveroe@google.com>
Cr-Commit-Position: refs/heads/master@{#858639}
  • Loading branch information
Stephen Roe authored and Chromium LUCI CQ committed Mar 1, 2021
1 parent 6055e5e commit abcd22d
Showing 1 changed file with 30 additions and 32 deletions.
62 changes: 30 additions & 32 deletions google_apis/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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 != "") {
Expand Down

0 comments on commit abcd22d

Please sign in to comment.