Fix FullScreen crash in Webapp
[platform/framework/web/chromium-efl.git] / google_apis / BUILD.gn
1 # Copyright 2014 The Chromium Authors
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import("//build/buildflag_header.gni")
6 import("//build/config/chrome_build.gni")
7 import("//build/config/chromeos/ui_mode.gni")
8 import("//build/config/features.gni")
9 import("//extensions/buildflags/buildflags.gni")
10 import("//testing/test.gni")
11 import("//third_party/protobuf/proto_library.gni")
12
13 declare_args() {
14   # Set the variable 'use_official_google_api_keys' to true
15   # to use the Google-internal file containing official API keys
16   # even in a developer build.  Setting this variable explicitly to
17   # true will cause the build to fail if the internal file is missing.
18   #
19   # Set the variable to false to not use the internal file, even for
20   # Chrome-branded builds or when it exists in your checkout.
21   #
22   # Leave it set to "" to have the variable implicitly set to true for
23   # Chrome-branded builds or if
24   # //src/google_apis/internal/google_chrome_api_keys.h is present and false
25   # otherwise.
26   # This does not apply to iOS builds, which use different mechanisms and always
27   # evaluate to use_official_google_api_keys=false.
28   # See https://crbug.com/1183709.
29   use_official_google_api_keys = ""
30
31   # Set these to bake the specified API keys and OAuth client
32   # IDs/secrets into your build.
33   #
34   # If you create a build without values baked in, you can instead
35   # set environment variables to provide the keys at runtime (see
36   # src/google_apis/google_api_keys.h for details).  Features that
37   # require server-side APIs may fail to work if no keys are
38   # provided.
39   #
40   # Note that if `use_official_google_api_keys` has been set to true
41   # (explicitly or implicitly), these values will be ignored and the official
42   # keys will be used instead.
43   google_api_key = ""
44
45   # See google_api_key.
46   google_default_client_id = ""
47
48   # See google_api_key.
49   google_default_client_secret = ""
50 }
51
52 if (use_official_google_api_keys == "") {
53   # No override set. Determine the default behavior.
54   if (is_chrome_branded) {
55     # Chrome-branded builds default to behaving as if
56     #`use_official_google_api_keys` was explicitly set to true and will fail to
57     # build if the file is missing.
58     use_official_google_api_keys = true
59   } else {
60     # Check if the key file exists.
61     check_internal_result =
62         exec_script("build/check_internal.py",
63                     [ rebase_path("internal/google_chrome_api_keys.h",
64                                   root_build_dir) ],
65                     "value")
66     use_official_google_api_keys = check_internal_result == 1
67   }
68 }
69
70 # Official API keys should always be used for Chrome-branded builds except on
71 # iOS (see https://crbug.com/1183709) and Fuchsia (see the description of
72 # https://crbug.com/1171510 for background).
73 assert(
74     use_official_google_api_keys || !is_chrome_branded || is_ios || is_fuchsia)
75
76 declare_args() {
77   # Whether the SetAPIKey() method is defined.
78   # iOS and Fuchsia builds that do not use the built-in key use this.
79   support_external_google_api_key =
80       is_ios || (is_fuchsia && !use_official_google_api_keys)
81 }
82
83 # internal:generate_metrics_key_header must be a deps when
84 # USE_OFFICIAL_GOOGLE_API_KEYS` is defined. Use this variable for both.
85 # On iOS, Chrome branding had been overriding use_official_google_api_keys.
86 # TODO(crbug.com/1362160): Fix this logic on iOS. Can this variable be replaced
87 # with just use_official_google_api_keys?
88 _use_official_google_keys_and_generate_metrics_key_header =
89     use_official_google_api_keys || (is_ios && is_chrome_branded)
90
91 buildflag_header("buildflags") {
92   header = "buildflags.h"
93   flags = [ "SUPPORT_EXTERNAL_GOOGLE_API_KEY=$support_external_google_api_key" ]
94 }
95
96 config("key_defines") {
97   defines = []
98
99   if (_use_official_google_keys_and_generate_metrics_key_header) {
100     defines += [ "USE_OFFICIAL_GOOGLE_API_KEYS=1" ]
101   }
102   if (google_api_key != "") {
103     defines += [ "GOOGLE_API_KEY=\"$google_api_key\"" ]
104   }
105   if (google_default_client_id != "") {
106     defines += [ "GOOGLE_DEFAULT_CLIENT_ID=\"$google_default_client_id\"" ]
107   }
108   if (google_default_client_secret != "") {
109     defines +=
110         [ "GOOGLE_DEFAULT_CLIENT_SECRET=\"$google_default_client_secret\"" ]
111   }
112 }
113
114 component("google_apis") {
115   sources = [
116     "credentials_mode.cc",
117     "credentials_mode.h",
118     "gaia/core_account_id.cc",
119     "gaia/core_account_id.h",
120     "gaia/gaia_access_token_fetcher.cc",
121     "gaia/gaia_access_token_fetcher.h",
122     "gaia/gaia_auth_consumer.cc",
123     "gaia/gaia_auth_consumer.h",
124     "gaia/gaia_auth_fetcher.cc",
125     "gaia/gaia_auth_fetcher.h",
126     "gaia/gaia_auth_util.cc",
127     "gaia/gaia_auth_util.h",
128     "gaia/gaia_config.cc",
129     "gaia/gaia_config.h",
130     "gaia/gaia_constants.cc",
131     "gaia/gaia_constants.h",
132     "gaia/gaia_oauth_client.cc",
133     "gaia/gaia_oauth_client.h",
134     "gaia/gaia_switches.cc",
135     "gaia/gaia_switches.h",
136     "gaia/gaia_urls.cc",
137     "gaia/gaia_urls.h",
138     "gaia/google_service_auth_error.cc",
139     "gaia/google_service_auth_error.h",
140     "gaia/oauth2_access_token_consumer.cc",
141     "gaia/oauth2_access_token_consumer.h",
142     "gaia/oauth2_access_token_fetcher.cc",
143     "gaia/oauth2_access_token_fetcher.h",
144     "gaia/oauth2_access_token_fetcher_immediate_error.cc",
145     "gaia/oauth2_access_token_fetcher_immediate_error.h",
146     "gaia/oauth2_access_token_fetcher_impl.cc",
147     "gaia/oauth2_access_token_fetcher_impl.h",
148     "gaia/oauth2_access_token_manager.cc",
149     "gaia/oauth2_access_token_manager.h",
150     "gaia/oauth2_api_call_flow.cc",
151     "gaia/oauth2_api_call_flow.h",
152     "gaia/oauth2_id_token_decoder.cc",
153     "gaia/oauth2_id_token_decoder.h",
154     "gaia/oauth2_mint_access_token_fetcher_adapter.cc",
155     "gaia/oauth2_mint_access_token_fetcher_adapter.h",
156     "gaia/oauth2_mint_token_flow.cc",
157     "gaia/oauth2_mint_token_flow.h",
158     "gaia/oauth_multilogin_result.cc",
159     "gaia/oauth_multilogin_result.h",
160     "gaia/oauth_request_signer.cc",
161     "gaia/oauth_request_signer.h",
162     "google_api_keys.cc",
163     "google_api_keys.h",
164   ]
165
166   configs += [
167     ":key_defines",
168     "//build/config/compiler:wexit_time_destructors",
169   ]
170
171   public_deps = [
172     ":buildflags",
173     "//base",
174     "//build:chromeos_buildflags",
175     "//services/network/public/cpp",
176   ]
177
178   deps = [
179     ":oauth2_mint_token_consent_result_proto",
180     "//base/third_party/dynamic_annotations",
181     "//build:branding_buildflags",
182     "//build:chromeos_buildflags",
183     "//crypto",
184     "//mojo/public/cpp/bindings:struct_traits",
185     "//net",
186     "//services/network/public/mojom",
187   ]
188
189   if (_use_official_google_keys_and_generate_metrics_key_header) {
190     deps += [ "internal:generate_metrics_key_header" ]
191   }
192
193   if (is_apple) {
194     sources += [
195       "google_api_keys_mac.h",
196       "google_api_keys_mac.mm",
197     ]
198
199     frameworks = [ "Foundation.framework" ]
200   }
201
202   defines = [ "IS_GOOGLE_APIS_IMPL" ]
203 }
204
205 proto_library("oauth2_mint_token_consent_result_proto") {
206   sources = [ "gaia/oauth2_mint_token_consent_result.proto" ]
207 }
208
209 static_library("test_support") {
210   testonly = true
211   sources = [
212     "gaia/fake_gaia.cc",
213     "gaia/fake_gaia.h",
214     "gaia/fake_oauth2_access_token_manager.cc",
215     "gaia/fake_oauth2_access_token_manager.h",
216     "gaia/gaia_auth_test_util.cc",
217     "gaia/gaia_auth_test_util.h",
218     "gaia/gaia_urls_overrider_for_testing.cc",
219     "gaia/gaia_urls_overrider_for_testing.h",
220     "gaia/oauth2_access_token_manager_test_util.cc",
221     "gaia/oauth2_access_token_manager_test_util.h",
222   ]
223
224   public_deps = [
225     ":google_apis",
226     ":oauth2_mint_token_consent_result_proto",
227     "//base",
228     "//base/test:test_support",
229     "//net:test_support",
230     "//services/network:network_service",
231     "//services/network:test_support",
232     "//services/network/public/cpp",
233   ]
234 }
235
236 source_set("run_all_unittests") {
237   testonly = true
238   sources = [ "run_all_unittests.cc" ]
239
240   deps = [
241     "//base/test:test_support",
242     "//mojo/core/embedder",
243   ]
244 }
245
246 test("google_apis_unittests") {
247   sources = [
248     "gaia/gaia_auth_fetcher_unittest.cc",
249     "gaia/gaia_auth_util_unittest.cc",
250     "gaia/gaia_config_unittest.cc",
251     "gaia/gaia_oauth_client_unittest.cc",
252     "gaia/gaia_urls_unittest.cc",
253     "gaia/google_service_auth_error_unittest.cc",
254     "gaia/oauth2_access_token_fetcher_impl_unittest.cc",
255     "gaia/oauth2_access_token_manager_unittest.cc",
256     "gaia/oauth2_api_call_flow_unittest.cc",
257     "gaia/oauth2_id_token_decoder_unittest.cc",
258     "gaia/oauth2_mint_access_token_fetcher_adapter_unittest.cc",
259     "gaia/oauth2_mint_token_flow_unittest.cc",
260     "gaia/oauth_multilogin_result_unittest.cc",
261     "gaia/oauth_request_signer_unittest.cc",
262     "google_api_keys_unittest.cc",
263     "google_api_keys_unittest.h",
264   ]
265
266   configs += [ ":key_defines" ]
267
268   deps = [
269     ":google_apis",
270     ":oauth2_mint_token_consent_result_proto",
271     ":run_all_unittests",
272     ":test_support",
273     "//base",
274     "//base/test:test_support",
275     "//build:branding_buildflags",
276     "//build:chromeos_buildflags",
277     "//google_apis/calendar:calendar_unittests",
278     "//google_apis/common:common_unittests",
279     "//testing/gmock",
280     "//testing/gtest",
281   ]
282
283   if (is_ios) {
284     deps += [ ":google_apis_unittest_bundle_data" ]
285   } else {
286     data = [ "test/" ]
287   }
288
289   if (is_android) {
290     deps += [ "//net/android:net_java" ]
291   }
292
293   if (is_fuchsia) {
294     additional_manifest_fragments =
295         [ "//build/config/fuchsia/test/network.shard.test-cml" ]
296   }
297
298   if (enable_extensions) {
299     deps += [ "//google_apis/drive:drive_unittests" ]
300   }
301
302   if (is_apple) {
303     sources += [ "google_api_keys_mac_unittest.mm" ]
304
305     deps += [ "//third_party/ocmock" ]
306   }
307
308   if (is_chromeos) {
309     deps += [
310       "//google_apis/classroom:classroom_unittests",
311       "//google_apis/tasks:tasks_unittests",
312     ]
313   }
314 }
315
316 bundle_data("google_apis_unittest_bundle_data") {
317   testonly = true
318   sources = [
319     "test/data/calendar/event_self_response_statuses.json",
320     "test/data/calendar/event_statuses.json",
321     "test/data/calendar/event_with_invalid_conference_data_uri.json",
322     "test/data/calendar/event_with_missing_entry_point_type.json",
323     "test/data/calendar/events.json",
324     "test/data/calendar/invalid_events.json",
325     "test/data/gaia/all_base_urls.json",
326     "test/data/gaia/all_urls.json",
327     "test/data/gaia/api_keys.json",
328     "test/data/gaia/bad_url.json",
329     "test/data/gaia/bad_url_key.json",
330     "test/data/gaia/bad_urls_key.json",
331     "test/data/gaia/not_a_json.txt",
332     "test/data/gaia/one_base_url.json",
333     "test/data/gaia/one_url.json",
334     "test/data/tasks/task.json",
335     "test/data/tasks/task_lists.json",
336     "test/data/tasks/tasks.json",
337   ]
338   outputs = [ "{{bundle_resources_dir}}/" +
339               "{{source_root_relative_dir}}/{{source_file_part}}" ]
340 }