[M120 Migration] Set IO|GPU thread type with higher priorites
[platform/framework/web/chromium-efl.git] / url / BUILD.gn
1 # Copyright 2013 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("//testing/libfuzzer/fuzzer_test.gni")
7 import("//testing/test.gni")
8 import("features.gni")
9
10 import("//build/config/cronet/config.gni")
11 import("//third_party/jni_zero/jni_zero.gni")
12
13 if (is_android || is_robolectric) {
14   import("//build/config/android/rules.gni")
15 }
16
17 buildflag_header("buildflags") {
18   header = "buildflags.h"
19   flags = [ "USE_PLATFORM_ICU_ALTERNATIVES=$use_platform_icu_alternatives" ]
20 }
21
22 component("url") {
23   sources = [
24     "gurl.cc",
25     "gurl.h",
26     "origin.cc",
27     "origin.h",
28     "scheme_host_port.cc",
29     "scheme_host_port.h",
30     "third_party/mozilla/url_parse.cc",
31     "third_party/mozilla/url_parse.h",
32     "url_canon.cc",
33     "url_canon.h",
34     "url_canon_etc.cc",
35     "url_canon_filesystemurl.cc",
36     "url_canon_fileurl.cc",
37     "url_canon_host.cc",
38     "url_canon_internal.cc",
39     "url_canon_internal.h",
40     "url_canon_internal_file.h",
41     "url_canon_ip.cc",
42     "url_canon_ip.h",
43     "url_canon_mailtourl.cc",
44     "url_canon_path.cc",
45     "url_canon_pathurl.cc",
46     "url_canon_query.cc",
47     "url_canon_relative.cc",
48     "url_canon_stdstring.cc",
49     "url_canon_stdstring.h",
50     "url_canon_stdurl.cc",
51     "url_constants.cc",
52     "url_constants.h",
53     "url_features.cc",
54     "url_features.h",
55     "url_file.h",
56     "url_parse_file.cc",
57     "url_parse_internal.h",
58     "url_util.cc",
59     "url_util.h",
60     "url_util_internal.h",
61   ]
62
63   defines = [ "IS_URL_IMPL" ]
64
65   deps = [ "//base/third_party/dynamic_annotations" ]
66
67   public_deps = [
68     "//base",
69     "//build:robolectric_buildflags",
70   ]
71
72   configs += [ "//build/config/compiler:wexit_time_destructors" ]
73
74   if (is_android || is_robolectric) {
75     deps += [ ":url_jni_headers" ]
76     if (!is_cronet_build) {
77       sources += [
78         "android/gurl_android.cc",
79         "android/gurl_android.h",
80         "android/origin_android.cc",
81         "android/parsed_android.cc",
82         "android/parsed_android.h",
83       ]
84     }
85   }
86
87   if (is_robolectric) {
88     # Make jni.h available.
89     public_configs = [ "//third_party/jdk" ]
90   }
91
92   if (is_win) {
93     # Don't conflict with Windows' "url.dll".
94     output_name = "url_lib"
95   }
96
97   # ICU support.
98   if (use_platform_icu_alternatives) {
99     if (is_android) {
100       sources += [ "url_idna_icu_alternatives_android.cc" ]
101       deps += [ ":buildflags" ]
102     } else if (is_ios) {
103       sources += [ "url_idna_icu_alternatives_ios.mm" ]
104     } else {
105       assert(false,
106              "ICU alternative is not implemented for platform: " + target_os)
107     }
108   } else {
109     # Use ICU.
110     sources += [
111       "url_canon_icu.cc",
112       "url_canon_icu.h",
113       "url_idna_icu.cc",
114     ]
115     deps += [
116       "//base:i18n",
117       "//third_party/icu",
118     ]
119   }
120 }
121
122 if (is_android || is_robolectric) {
123   generate_jni("url_jni_headers") {
124     sources = [ "android/java/src/org/chromium/url/IDNStringUtil.java" ]
125     if (!is_cronet_build) {
126       sources += [
127         "android/java/src/org/chromium/url/GURL.java",
128         "android/java/src/org/chromium/url/Origin.java",
129         "android/java/src/org/chromium/url/Parsed.java",
130       ]
131     }
132   }
133 }
134 if (is_android && current_toolchain == default_toolchain) {
135   # TODO(agrieve): Remove alias once usages are removed.
136   java_group("gurl_java") {
137     deps = [ ":url_java" ]
138   }
139
140   android_library("url_java") {
141     sources = [ "android/java/src/org/chromium/url/IDNStringUtil.java" ]
142     srcjar_deps = [ ":url_jni_headers" ]
143     deps = [ "//third_party/jni_zero:jni_zero_java" ]
144     if (!is_cronet_build) {
145       sources += [
146         "android/java/src/org/chromium/url/GURL.java",
147         "android/java/src/org/chromium/url/Origin.java",
148         "android/java/src/org/chromium/url/Parsed.java",
149         "android/java/src/org/chromium/url/URI.java",
150       ]
151       deps += [
152         "//base:base_java",
153         "//build/android:build_java",
154         "//mojo/public/java:bindings_java",
155         "//mojo/public/mojom/base:base_java",
156         "//third_party/android_deps:com_google_errorprone_error_prone_annotations_java",
157         "//third_party/androidx:androidx_annotation_annotation_java",
158         "//url/mojom:url_mojom_gurl_java",
159         "//url/mojom:url_mojom_origin_java",
160       ]
161     }
162   }
163 }
164
165 source_set("url_test_support") {
166   testonly = true
167
168   sources = [
169     "gurl_abstract_tests.h",
170     "origin_abstract_tests.cc",
171     "origin_abstract_tests.h",
172   ]
173
174   public_deps = [
175     ":url",
176     "//base",
177     "//base/test:test_support",
178     "//testing/gmock",
179     "//testing/gtest",
180   ]
181 }
182
183 test("url_unittests") {
184   sources = [
185     "gurl_unittest.cc",
186     "origin_unittest.cc",
187     "run_all_unittests.cc",
188     "scheme_host_port_unittest.cc",
189     "url_canon_icu_unittest.cc",
190     "url_canon_unittest.cc",
191     "url_parse_unittest.cc",
192     "url_test_utils.h",
193     "url_util_unittest.cc",
194   ]
195
196   deps = [
197     ":url",
198     ":url_test_support",
199     "//base",
200     "//base/test:test_support",
201     "//testing/gmock",
202     "//testing/gtest",
203   ]
204
205   if (use_platform_icu_alternatives) {
206     # Unit tests that are not supported by the current ICU alternatives on Android.
207     if (is_android) {
208       sources -= [
209         "url_canon_icu_unittest.cc",
210         "url_canon_unittest.cc",
211       ]
212       deps += [ ":url_java" ]
213     }
214
215     # Unit tests that are not supported by the current ICU alternatives on iOS.
216     if (is_ios) {
217       sources -= [
218         "origin_unittest.cc",
219         "scheme_host_port_unittest.cc",
220         "url_canon_icu_unittest.cc",
221         "url_canon_unittest.cc",
222       ]
223     }
224   } else {  # !use_platform_icu_alternatives
225     deps += [ "//third_party/icu:icuuc" ]
226   }
227
228   if (!is_ios && !is_cronet_build) {
229     sources += [
230       "mojom/scheme_host_port_mojom_traits_unittest.cc",
231       "mojom/url_gurl_mojom_traits_unittest.cc",
232     ]
233     deps += [
234       "//mojo/core/embedder",
235       "//mojo/public/cpp/test_support:test_utils",
236       "//url/ipc:url_ipc_unittests",
237       "//url/mojom:mojom_traits",
238       "//url/mojom:test_url_mojom_gurl",
239     ]
240   }
241 }
242
243 test("url_perftests") {
244   sources = [
245     "run_all_perftests.cc",
246     "url_parse_perftest.cc",
247   ]
248
249   deps = [
250     ":url",
251     "//base",
252     "//base/test:test_support",
253     "//testing/gtest",
254   ]
255 }
256
257 fuzzer_test("gurl_fuzzer") {
258   sources = [ "gurl_fuzzer.cc" ]
259   deps = [
260     ":url",
261     "//base",
262     "//base:i18n",
263   ]
264   dict = "gurl_fuzzer.dict"
265 }
266
267 if (is_android && !is_cronet_build) {
268   source_set("android_test_helper") {
269     testonly = true
270     sources = [
271       "android/gurl_java_test_helper.cc",
272       "android/origin_java_test_helper.cc",
273     ]
274     deps = [
275       ":j_test_jni_headers($default_toolchain)",
276       ":url",
277       "//base/test:test_support",
278     ]
279   }
280
281   if (current_toolchain == default_toolchain) {
282     android_library("android_test_helper_java") {
283       testonly = true
284
285       srcjar_deps = [ ":j_test_jni_headers" ]
286       sources = [
287         "android/javatests/src/org/chromium/url/GURLJavaTestHelper.java",
288         "android/javatests/src/org/chromium/url/OriginJavaTestHelper.java",
289       ]
290       deps = [
291         ":url_java",
292         "//base:base_java_test_support",
293         "//third_party/jni_zero:jni_zero_java",
294       ]
295     }
296
297     # Targets depending on gurl_junit_test_support do not need to bypass platform
298     # checks.
299     android_library("gurl_junit_test_support") {
300       testonly = true
301       sources = [ "android/test/java/src/org/chromium/url/JUnitTestGURLs.java" ]
302       deps = [ ":url_java" ]
303     }
304
305     android_library("url_java_unit_tests") {
306       testonly = true
307       sources = [
308         "android/javatests/src/org/chromium/url/GURLJavaTest.java",
309         "android/javatests/src/org/chromium/url/OriginJavaTest.java",
310       ]
311       deps = [
312         ":android_test_helper_java",
313         ":gurl_junit_test_support",
314         ":url_java",
315         "//base:base_java",
316         "//base:base_java_test_support",
317         "//content/public/test/android:content_java_test_support",
318         "//mojo/public/mojom/base:base_java",
319         "//third_party/androidx:androidx_core_core_java",
320         "//third_party/androidx:androidx_test_runner_java",
321         "//third_party/jni_zero:jni_zero_java",
322         "//third_party/junit",
323         "//third_party/mockito:mockito_java",
324         "//url/mojom:url_mojom_gurl_java",
325         "//url/mojom:url_mojom_origin_java",
326       ]
327     }
328
329     # See https://bugs.chromium.org/p/chromium/issues/detail?id=908819 for why we
330     # can't put 'java' in the name here.
331     generate_jni("j_test_jni_headers") {
332       testonly = true
333       sources = [
334         "android/javatests/src/org/chromium/url/GURLJavaTestHelper.java",
335         "android/javatests/src/org/chromium/url/OriginJavaTestHelper.java",
336       ]
337     }
338   }
339 }
340
341 # Use this in robolectric_binary() targets if you just need GURL and //base
342 # functionality. Otherwise, define a custom shared_library().
343 if (!is_cronet_build && target_os == "android") {
344   shared_library_with_jni("libgurl_robolectric") {
345     testonly = true
346     enable_target = is_robolectric
347     java_targets = [
348       ":gurl_java",
349       ":url_java",
350     ]
351     deps = [ ":robolectric_jni_onload($robolectric_toolchain)" ]
352   }
353   if (is_robolectric) {
354     # Depend on this if you need to write a custom JNI_OnLoad()
355     source_set("gurl_test_init") {
356       testonly = true
357       sources = [
358         "android/gurl_test_init.cc",
359         "android/gurl_test_init.h",
360       ]
361       deps = [ ":url" ]
362     }
363
364     # Depend on this if you do not need to write a custom JNI_OnLoad()
365     source_set("robolectric_jni_onload") {
366       testonly = true
367       sources = [ "android/robolectric_jni_onload.cc" ]
368       deps = [
369         ":gurl_test_init",
370         "//base",
371       ]
372
373       # Make jni.h available.
374       configs += [ "//third_party/jdk" ]
375     }
376   }
377 }