Android: Exclude google drive code.
[chromium-blink-merge.git] / google_apis / BUILD.gn
blobf5d5a2e9304a4ec292b9c5d9133f0dd92ea6d7af
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/crypto.gni")
6 import("//build/config/features.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 = exec_script(
57     "build/check_internal.py",
58     [ rebase_path("internal/google_chrome_api_keys.h", root_build_dir) ],
59     "value")
60   use_official_google_api_keys = (check_internal_result == 1)
63 config("key_defines") {
64   defines = []
65   if (use_official_google_api_keys) {
66     defines += [ "USE_OFFICIAL_GOOGLE_API_KEYS=1" ]
67   }
68   if (google_api_key != "") {
69     defines += [ "GOOGLE_API_KEY=$google_api_key" ]
70   }
71   if (google_default_client_id != "") {
72     defines += [ "GOOGLE_DEFAULT_CLIENT_ID=$google_default_client_id" ]
73   }
74   if (google_default_client_secret != "") {
75     defines += [ "GOOGLE_DEFAULT_CLIENT_SECRET=$google_default_client_secret" ]
76   }
79 source_set("google_apis") {
80   sources = [
81     "cup/client_update_protocol.cc",
82     "cup/client_update_protocol.h",
83     "gaia/gaia_auth_consumer.cc",
84     "gaia/gaia_auth_consumer.h",
85     "gaia/gaia_auth_fetcher.cc",
86     "gaia/gaia_auth_fetcher.h",
87     "gaia/gaia_auth_util.cc",
88     "gaia/gaia_auth_util.h",
89     "gaia/gaia_constants.cc",
90     "gaia/gaia_constants.h",
91     "gaia/gaia_oauth_client.cc",
92     "gaia/gaia_oauth_client.h",
93     "gaia/gaia_switches.cc",
94     "gaia/gaia_switches.h",
95     "gaia/gaia_urls.cc",
96     "gaia/gaia_urls.h",
97     "gaia/google_service_auth_error.cc",
98     "gaia/google_service_auth_error.h",
99     "gaia/identity_provider.cc",
100     "gaia/identity_provider.h",
101     "gaia/merge_session_helper.cc",
102     "gaia/merge_session_helper.h",
103     "gaia/oauth_request_signer.cc",
104     "gaia/oauth_request_signer.h",
105     "gaia/oauth2_access_token_consumer.h",
106     "gaia/oauth2_access_token_fetcher.h",
107     "gaia/oauth2_access_token_fetcher.cc",
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/ubertoken_fetcher.cc",
117     "gaia/ubertoken_fetcher.h",
118     "google_api_keys.cc",
119     "google_api_keys.h",
120   ]
122   if (is_win) {
123     cflags = [ "/wd4267" ]  # size_t -> int
124   }
126   configs += [ ":key_defines" ]
128   deps = [
129     "//base",
130     "//crypto",
131     "//crypto:platform",
132     "//net",
133     "//third_party/libxml",
134   ]
136   if (use_openssl) {
137     sources += [ "cup/client_update_protocol_openssl.cc" ]
138   } else {
139     sources += [ "cup/client_update_protocol_nss.cc" ]
140   }
142   if (enable_extensions) {
143     sources += [
144       "drive/auth_service.cc",
145       "drive/auth_service.h",
146       "drive/auth_service_interface.h",
147       "drive/auth_service_observer.h",
148       "drive/base_requests.cc",
149       "drive/base_requests.h",
150       "drive/drive_api_parser.cc",
151       "drive/drive_api_parser.h",
152       "drive/drive_api_requests.cc",
153       "drive/drive_api_requests.h",
154       "drive/drive_api_url_generator.cc",
155       "drive/drive_api_url_generator.h",
156       "drive/drive_common_callbacks.h",
157       "drive/drive_entry_kinds.h",
158       "drive/gdata_errorcode.cc",
159       "drive/gdata_errorcode.h",
160       "drive/gdata_wapi_requests.cc",
161       "drive/gdata_wapi_requests.h",
162       "drive/gdata_wapi_parser.cc",
163       "drive/gdata_wapi_parser.h",
164       "drive/gdata_wapi_url_generator.cc",
165       "drive/gdata_wapi_url_generator.h",
166       "drive/request_sender.cc",
167       "drive/request_sender.h",
168       "drive/request_util.cc",
169       "drive/request_util.h",
170       "drive/task_util.cc",
171       "drive/task_util.h",
172       "drive/time_util.cc",
173       "drive/time_util.h",
174     ]
175   }
178 source_set("test_support") {
179   sources = [
180     "gaia/fake_gaia.cc",
181     "gaia/fake_gaia.h",
182     "gaia/fake_identity_provider.cc",
183     "gaia/fake_identity_provider.h",
184     "gaia/fake_oauth2_token_service.cc",
185     "gaia/fake_oauth2_token_service.h",
186     "gaia/mock_url_fetcher_factory.h",
187     "gaia/oauth2_token_service_test_util.cc",
188     "gaia/oauth2_token_service_test_util.h",
189   ]
191   deps = [
192     "//base",
193     "//base/test:test_support",
194     "//net",
195     "//net:test_support",
196   ]
197   forward_dependent_configs_from = deps
199   if (enable_extensions) {
200     sources += [
201       "drive/dummy_auth_service.cc",
202       "drive/dummy_auth_service.h",
203       "drive/test_util.cc",
204       "drive/test_util.h",
205     ]
206   }
209 test("google_apis_unittest") {
210   sources = [
211     "google_api_keys_unittest.cc",
212     "cup/client_update_protocol_unittest.cc",
213     "gaia/gaia_auth_fetcher_unittest.cc",
214     "gaia/gaia_auth_util_unittest.cc",
215     "gaia/gaia_oauth_client_unittest.cc",
216     "gaia/google_service_auth_error_unittest.cc",
217     "gaia/merge_session_helper_unittest.cc",
218     "gaia/oauth_request_signer_unittest.cc",
219     "gaia/oauth2_access_token_fetcher_impl_unittest.cc",
220     "gaia/oauth2_api_call_flow_unittest.cc",
221     "gaia/oauth2_mint_token_flow_unittest.cc",
222     "gaia/oauth2_token_service_unittest.cc",
223     "gaia/ubertoken_fetcher_unittest.cc",
224   ]
226   configs += [ ":key_defines" ]
228   deps = [
229     ":google_apis",
230     ":test_support",
231     "//base",
232     "//base/test:run_all_unittests",
233     "//testing/gmock",
234     "//testing/gtest",
235   ]
237   if (enable_extensions) {
238     sources += [
239       "drive/base_requests_server_unittest.cc",
240       "drive/base_requests_unittest.cc",
241       "drive/drive_api_parser_unittest.cc",
242       "drive/drive_api_requests_unittest.cc",
243       "drive/drive_api_url_generator_unittest.cc",
244       "drive/gdata_wapi_parser_unittest.cc",
245       "drive/gdata_wapi_requests_unittest.cc",
246       "drive/gdata_wapi_url_generator_unittest.cc",
247       "drive/request_sender_unittest.cc",
248       "drive/request_util_unittest.cc",
249       "drive/time_util_unittest.cc",
250     ]
251   }