Auto-detect whether internal keys should be used.
Allow overriding to explicitly use or not use internal keys, regardless of what is auto-detected. Fix a bug in the implementation, where the default value was not being used for unset tokens. BUG=145584 Review URL: https://codereview.chromium.org/10933126 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157130 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -547,6 +547,40 @@
|
||||
'use_system_libjpeg%': '<(android_build_type)',
|
||||
}],
|
||||
],
|
||||
|
||||
# Set this to 1 to use the Google-internal file containing
|
||||
# official API keys for Google Chrome even in a developer build.
|
||||
# Setting this variable explicitly to 1 will cause your build to
|
||||
# fail if the internal file is missing.
|
||||
#
|
||||
# Set this to 0 to not use the internal file, even when it
|
||||
# exists in your checkout.
|
||||
#
|
||||
# Leave set to 2 to have this variable implicitly set to 1 if
|
||||
# you have src/google_apis/internal/google_chrome_api_keys.h in
|
||||
# your checkout, and implicitly set to 0 if not.
|
||||
#
|
||||
# Note that official builds always behave as if this variable
|
||||
# was explicitly set to 1, i.e. they always use official keys,
|
||||
# and will fail to build if the internal file is missing.
|
||||
'use_official_google_api_keys%': 2,
|
||||
|
||||
# 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 1 (explicitly or
|
||||
# implicitly), these values will be ignored and the official
|
||||
# keys will be used instead.
|
||||
'google_api_key%': '',
|
||||
'google_default_client_id%': '',
|
||||
'google_default_client_secret%': '',
|
||||
},
|
||||
|
||||
# Copy conditionally-set variables out one scope.
|
||||
@ -629,6 +663,10 @@
|
||||
'use_libjpeg_turbo%': '<(use_libjpeg_turbo)',
|
||||
'use_system_libjpeg%': '<(use_system_libjpeg)',
|
||||
'android_build_type%': '<(android_build_type)',
|
||||
'use_official_google_api_keys%': '<(use_official_google_api_keys)',
|
||||
'google_api_key%': '<(google_api_key)',
|
||||
'google_default_client_id%': '<(google_default_client_id)',
|
||||
'google_default_client_secret%': '<(google_default_client_secret)',
|
||||
|
||||
# Use system yasm instead of bundled one.
|
||||
'use_system_yasm%': 0,
|
||||
@ -891,24 +929,6 @@
|
||||
'windows_sdk_default_path': '<(DEPTH)/third_party/platformsdk_win8/files',
|
||||
'directx_sdk_default_path': '<(DEPTH)/third_party/directxsdk/files',
|
||||
|
||||
# Set these to bake API keys and OAuth client IDs/secrets into
|
||||
# your build. If they are not 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 you set
|
||||
# use_official_google_api_keys to 1, these values will be ignored
|
||||
# and the official keys will be used instead.
|
||||
'google_api_key%': '',
|
||||
'google_default_client_id%': '',
|
||||
'google_default_client_secret%': '',
|
||||
|
||||
# Set this to 1 to use the Google-internal file containing
|
||||
# official API keys for Google Chrome even in a developer build.
|
||||
'use_official_google_api_keys%': 0,
|
||||
|
||||
'conditions': [
|
||||
['OS=="win" and "<!(python <(DEPTH)/build/dir_exists.py <(windows_sdk_default_path))"=="True"', {
|
||||
'windows_sdk_path%': '<(windows_sdk_default_path)',
|
||||
@ -920,6 +940,15 @@
|
||||
}, {
|
||||
'directx_sdk_path%': '$(DXSDK_DIR)',
|
||||
}],
|
||||
# If use_official_google_api_keys is already set (to 0 or 1), we
|
||||
# do none of the implicit checking. If it is set to 1 and the
|
||||
# internal keys file is missing, the build will fail at compile
|
||||
# time. If it is set to 0 and keys are not provided by other
|
||||
# means, a warning will be printed at compile time.
|
||||
['use_official_google_api_keys==2', {
|
||||
'use_official_google_api_keys%':
|
||||
'<!(python <(DEPTH)/google_apis/build/check_internal.py <(DEPTH)/google_apis/internal/google_chrome_api_keys.h)',
|
||||
}],
|
||||
['os_posix==1 and OS!="mac" and OS!="ios"', {
|
||||
# Figure out the python architecture to decide if we build pyauto.
|
||||
'python_arch%': '<!(<(DEPTH)/build/linux/python_arch.sh <(sysroot)/usr/<(system_libdir)/libpython<(python_ver).so.1.0)',
|
||||
|
20
google_apis/build/check_internal.py
Executable file
20
google_apis/build/check_internal.py
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright (c) 2012 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.
|
||||
|
||||
"""google_api's auto-internal gyp integration.
|
||||
|
||||
Takes one argument, a path. Prints 1 if the path exists, 0 if not.
|
||||
"""
|
||||
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if os.path.exists(sys.argv[1]):
|
||||
print 1
|
||||
else:
|
||||
print 0
|
@ -15,6 +15,22 @@
|
||||
#include "google_apis/internal/google_chrome_api_keys.h"
|
||||
#endif
|
||||
|
||||
// TODO(joi): Can we enable this warning without having it treated as
|
||||
// an error? We don't want to fail builds, just warn, but all warnings
|
||||
// from the preprocessor are currently treated as errors, at least in
|
||||
// Linux builds.
|
||||
#if 0
|
||||
#if !defined(GOOGLE_API_KEY) && ( \
|
||||
(!defined(GOOGLE_DEFAULT_CLIENT_ID) && \
|
||||
!defined(GOOGLE_DEFAULT_CLIENT_SECRET)) \
|
||||
|| \
|
||||
(!defined(GOOGLE_CLIENT_ID_MAIN) && \
|
||||
!defined(GOOGLE_CLIENT_SECRET_MAIN)))
|
||||
#warning You have not specified API keys; some features may not work.
|
||||
#warning See www.chromium.org/developers/how-tos/api-keys for details.
|
||||
#endif // (API keys unset)
|
||||
#endif // 0
|
||||
|
||||
// Used to indicate an unset key/id/secret. This works better with
|
||||
// various unit tests than leaving the token empty.
|
||||
#define DUMMY_API_TOKEN "dummytoken"
|
||||
@ -196,15 +212,18 @@ class APIKeyCache {
|
||||
<< " with value " << key_value << " from command-line switch.";
|
||||
}
|
||||
|
||||
if (key_value.size() == 0) {
|
||||
if (key_value == DUMMY_API_TOKEN) {
|
||||
#if defined(GOOGLE_CHROME_BUILD)
|
||||
// No key should be empty in an official build, except the
|
||||
// default keys themselves, which will have an empty default.
|
||||
CHECK(default_if_unset.size() == 0);
|
||||
// No key should be unset in an official build except the
|
||||
// GOOGLE_DEFAULT_* keys. The default keys don't trigger this
|
||||
// check as their "unset" value is not DUMMY_API_TOKEN.
|
||||
CHECK(false);
|
||||
#endif
|
||||
LOG(INFO) << "Using default value \"" << default_if_unset
|
||||
<< "\" for API key " << environment_variable_name;
|
||||
key_value = default_if_unset;
|
||||
if (default_if_unset.size() > 0) {
|
||||
LOG(INFO) << "Using default value \"" << default_if_unset
|
||||
<< "\" for API key " << environment_variable_name;
|
||||
key_value = default_if_unset;
|
||||
}
|
||||
}
|
||||
|
||||
// This should remain a debug-only log.
|
||||
|
Reference in New Issue
Block a user