Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / google_apis / BUILD.gn
blob58cfa1d13576ca745d3e61752d8ee8b5cce5754f
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import("//build/config/features.gni")
6 import("//testing/test.gni")
8 declare_args() {
9   # You can set the variable 'use_official_google_api_keys' to true
10   # to use the Google-internal file containing official API keys
11   # for Google Chrome even in a developer build.  Setting this
12   # variable explicitly to true will cause your build to fail if the
13   # internal file is missing.
14   #
15   # The variable is documented here, but not handled in this file;
16   # see //google_apis/determine_use_official_keys.gypi for the
17   # implementation.
18   #
19   # Set the variable to false to not use the internal file, even when
20   # it exists in your checkout.
21   #
22   # Leave it unset or set to "" to have the variable
23   # implicitly set to true if you have
24   # src/google_apis/internal/google_chrome_api_keys.h in your
25   # checkout, and implicitly set to false if not.
26   #
27   # Note that official builds always behave as if the variable
28   # was explicitly set to true, i.e. they always use official keys,
29   # and will fail to build if the internal file is missing.
30   use_official_google_api_keys = ""
32   # Set these to bake the specified API keys and OAuth client
33   # IDs/secrets into your build.
34   #
35   # If you create a build without values baked in, you can instead
36   # set environment variables to provide the keys at runtime (see
37   # src/google_apis/google_api_keys.h for details).  Features that
38   # require server-side APIs may fail to work if no keys are
39   # provided.
40   #
41   # Note that if you are building an official build or if
42   # use_official_google_api_keys has been set to trie (explicitly or
43   # implicitly), these values will be ignored and the official
44   # keys will be used instead.
45   google_api_key = ""
47   # See google_api_key.
48   google_default_client_id = ""
50   # See google_api_key.
51   google_default_client_secret = ""
54 if (use_official_google_api_keys == "") {
55   # Default behavior, check if the key file exists.
56   check_internal_result =
57       exec_script("build/check_internal.py",
58                   [ rebase_path("internal/google_chrome_api_keys.h",
59                                 root_build_dir) ],
60                   "value")
61   use_official_google_api_keys = check_internal_result == 1
64 config("key_defines") {
65   defines = []
66   if (use_official_google_api_keys) {
67     defines += [ "USE_OFFICIAL_GOOGLE_API_KEYS=1" ]
68   }
69   if (google_api_key != "") {
70     defines += [ "GOOGLE_API_KEY=\"$google_api_key\"" ]
71   }
72   if (google_default_client_id != "") {
73     defines += [ "GOOGLE_DEFAULT_CLIENT_ID=\"$google_default_client_id\"" ]
74   }
75   if (google_default_client_secret != "") {
76     defines +=
77         [ "GOOGLE_DEFAULT_CLIENT_SECRET=\"$google_default_client_secret\"" ]
78   }
81 source_set("google_apis") {
82   sources = [
83     "gaia/account_tracker.cc",
84     "gaia/account_tracker.h",
85     "gaia/gaia_auth_consumer.cc",
86     "gaia/gaia_auth_consumer.h",
87     "gaia/gaia_auth_fetcher.cc",
88     "gaia/gaia_auth_fetcher.h",
89     "gaia/gaia_auth_util.cc",
90     "gaia/gaia_auth_util.h",
91     "gaia/gaia_constants.cc",
92     "gaia/gaia_constants.h",
93     "gaia/gaia_oauth_client.cc",
94     "gaia/gaia_oauth_client.h",
95     "gaia/gaia_switches.cc",
96     "gaia/gaia_switches.h",
97     "gaia/gaia_urls.cc",
98     "gaia/gaia_urls.h",
99     "gaia/google_service_auth_error.cc",
100     "gaia/google_service_auth_error.h",
101     "gaia/identity_provider.cc",
102     "gaia/identity_provider.h",
103     "gaia/oauth2_access_token_consumer.h",
104     "gaia/oauth2_access_token_fetcher.cc",
105     "gaia/oauth2_access_token_fetcher.h",
106     "gaia/oauth2_access_token_fetcher_immediate_error.cc",
107     "gaia/oauth2_access_token_fetcher_immediate_error.h",
108     "gaia/oauth2_access_token_fetcher_impl.cc",
109     "gaia/oauth2_access_token_fetcher_impl.h",
110     "gaia/oauth2_api_call_flow.cc",
111     "gaia/oauth2_api_call_flow.h",
112     "gaia/oauth2_mint_token_flow.cc",
113     "gaia/oauth2_mint_token_flow.h",
114     "gaia/oauth2_token_service.cc",
115     "gaia/oauth2_token_service.h",
116     "gaia/oauth2_token_service_delegate.cc",
117     "gaia/oauth2_token_service_delegate.h",
118     "gaia/oauth2_token_service_request.cc",
119     "gaia/oauth2_token_service_request.h",
120     "gaia/oauth_request_signer.cc",
121     "gaia/oauth_request_signer.h",
122     "gaia/ubertoken_fetcher.cc",
123     "gaia/ubertoken_fetcher.h",
124     "google_api_keys.cc",
125     "google_api_keys.h",
126   ]
128   configs += [
129     ":key_defines",
130     "//build/config/compiler:no_size_t_to_int_warning",
131   ]
133   deps = [
134     "//base",
135     "//base/third_party/dynamic_annotations",
136     "//crypto",
137     "//net",
138     "//third_party/libxml",
139   ]
141   if (enable_extensions) {
142     sources += [
143       "drive/auth_service.cc",
144       "drive/auth_service.h",
145       "drive/auth_service_interface.h",
146       "drive/auth_service_observer.h",
147       "drive/base_requests.cc",
148       "drive/base_requests.h",
149       "drive/drive_api_error_codes.cc",
150       "drive/drive_api_error_codes.h",
151       "drive/drive_api_parser.cc",
152       "drive/drive_api_parser.h",
153       "drive/drive_api_requests.cc",
154       "drive/drive_api_requests.h",
155       "drive/drive_api_url_generator.cc",
156       "drive/drive_api_url_generator.h",
157       "drive/drive_common_callbacks.h",
158       "drive/files_list_request_runner.cc",
159       "drive/files_list_request_runner.h",
160       "drive/request_sender.cc",
161       "drive/request_sender.h",
162       "drive/request_util.cc",
163       "drive/request_util.h",
164       "drive/task_util.cc",
165       "drive/task_util.h",
166       "drive/time_util.cc",
167       "drive/time_util.h",
168     ]
169   }
172 source_set("test_support") {
173   testonly = true
174   sources = [
175     "gaia/fake_gaia.cc",
176     "gaia/fake_gaia.h",
177     "gaia/fake_identity_provider.cc",
178     "gaia/fake_identity_provider.h",
179     "gaia/fake_oauth2_token_service_delegate.cc",
180     "gaia/fake_oauth2_token_service_delegate.h",
181     "gaia/fake_oauth2_token_service.cc",
182     "gaia/fake_oauth2_token_service.h",
183     "gaia/mock_url_fetcher_factory.h",
184     "gaia/oauth2_token_service_test_util.cc",
185     "gaia/oauth2_token_service_test_util.h",
186   ]
188   public_deps = [
189     "//base",
190     "//base/test:test_support",
191     "//net",
192     "//net:test_support",
193   ]
195   deps = [
196     ":google_apis",
197   ]
198   if (enable_extensions) {
199     sources += [
200       "drive/dummy_auth_service.cc",
201       "drive/dummy_auth_service.h",
202       "drive/test_util.cc",
203       "drive/test_util.h",
204     ]
205   }
208 test("google_apis_unittests") {
209   sources = [
210     "gaia/gaia_auth_fetcher_unittest.cc",
211     "gaia/gaia_auth_util_unittest.cc",
212     "gaia/gaia_oauth_client_unittest.cc",
213     "gaia/google_service_auth_error_unittest.cc",
214     "gaia/oauth2_access_token_fetcher_impl_unittest.cc",
215     "gaia/oauth2_api_call_flow_unittest.cc",
216     "gaia/oauth2_mint_token_flow_unittest.cc",
217     "gaia/oauth2_token_service_unittest.cc",
218     "gaia/oauth_request_signer_unittest.cc",
219     "gaia/ubertoken_fetcher_unittest.cc",
220     "google_api_keys_unittest.cc",
221   ]
223   configs += [ ":key_defines" ]
225   deps = [
226     ":google_apis",
227     ":test_support",
228     "//base",
229     "//base/test:run_all_unittests",
230     "//testing/gmock",
231     "//testing/gtest",
232   ]
234   if (enable_extensions) {
235     sources += [
236       "drive/base_requests_server_unittest.cc",
237       "drive/base_requests_unittest.cc",
238       "drive/drive_api_parser_unittest.cc",
239       "drive/drive_api_requests_unittest.cc",
240       "drive/drive_api_url_generator_unittest.cc",
241       "drive/request_sender_unittest.cc",
242       "drive/request_util_unittest.cc",
243       "drive/time_util_unittest.cc",
244     ]
245   }