Upload upstream chromium 76.0.3809.146
[platform/framework/web/chromium-efl.git] / url / BUILD.gn
1 # Copyright (c) 2013 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.
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 if (is_android) {
11   import("//build/config/android/rules.gni")
12 }
13
14 buildflag_header("buildflags") {
15   header = "buildflags.h"
16   flags = [ "USE_PLATFORM_ICU_ALTERNATIVES=$use_platform_icu_alternatives" ]
17 }
18
19 component("url") {
20   sources = [
21     "gurl.cc",
22     "gurl.h",
23     "origin.cc",
24     "origin.h",
25     "scheme_host_port.cc",
26     "scheme_host_port.h",
27     "third_party/mozilla/url_parse.cc",
28     "third_party/mozilla/url_parse.h",
29     "url_canon.cc",
30     "url_canon.h",
31     "url_canon_etc.cc",
32     "url_canon_filesystemurl.cc",
33     "url_canon_fileurl.cc",
34     "url_canon_host.cc",
35     "url_canon_internal.cc",
36     "url_canon_internal.h",
37     "url_canon_internal_file.h",
38     "url_canon_ip.cc",
39     "url_canon_ip.h",
40     "url_canon_mailtourl.cc",
41     "url_canon_path.cc",
42     "url_canon_pathurl.cc",
43     "url_canon_query.cc",
44     "url_canon_relative.cc",
45     "url_canon_stdstring.cc",
46     "url_canon_stdstring.h",
47     "url_canon_stdurl.cc",
48     "url_constants.cc",
49     "url_constants.h",
50     "url_file.h",
51     "url_parse_file.cc",
52     "url_parse_internal.h",
53     "url_util.cc",
54     "url_util.h",
55     "url_util_internal.h",
56   ]
57
58   defines = [ "IS_URL_IMPL" ]
59
60   deps = [
61     "//base",
62     "//base/third_party/dynamic_annotations",
63     "//ipc:param_traits",
64   ]
65
66   if (is_win) {
67     # Don't conflict with Windows' "url.dll".
68     output_name = "url_lib"
69   }
70
71   # ICU support.
72   if (use_platform_icu_alternatives) {
73     if (is_android) {
74       sources += [ "url_idna_icu_alternatives_android.cc" ]
75       deps += [
76         ":buildflags",
77         ":url_java",
78         ":url_jni_headers",
79         "//base",
80         "//base/third_party/dynamic_annotations",
81       ]
82     } else if (is_ios) {
83       sources += [ "url_idna_icu_alternatives_ios.mm" ]
84     } else {
85       assert(false,
86              "ICU alternative is not implemented for platform: " + target_os)
87     }
88   } else {
89     # Use ICU.
90     sources += [
91       "url_canon_icu.cc",
92       "url_canon_icu.h",
93       "url_idna_icu.cc",
94     ]
95     deps += [ "//third_party/icu" ]
96   }
97 }
98
99 if (is_android) {
100   android_library("url_java") {
101     java_files = [ "android/java/src/org/chromium/url/IDNStringUtil.java" ]
102     deps = [
103       "//base:base_java",
104     ]
105   }
106
107   generate_jni("url_jni_headers") {
108     sources = [
109       "android/java/src/org/chromium/url/IDNStringUtil.java",
110     ]
111     jni_package = "url"
112   }
113 }
114
115 test("url_unittests") {
116   sources = [
117     "gurl_unittest.cc",
118     "origin_unittest.cc",
119     "run_all_unittests.cc",
120     "scheme_host_port_unittest.cc",
121     "url_canon_icu_unittest.cc",
122     "url_canon_unittest.cc",
123     "url_parse_unittest.cc",
124     "url_test_utils.h",
125     "url_util_unittest.cc",
126   ]
127
128   deps = [
129     ":url",
130     "//base",
131     "//base/test:test_support",
132     "//testing/gmock",
133     "//testing/gtest",
134   ]
135
136   if (!is_ios) {
137     sources += [ "mojom/url_gurl_mojom_traits_unittest.cc" ]
138   }
139
140   if (use_platform_icu_alternatives) {
141     # Unit tests that are not supported by the current ICU alternatives on Android.
142     if (is_android) {
143       sources -= [
144         "url_canon_icu_unittest.cc",
145         "url_canon_unittest.cc",
146       ]
147       deps += [ ":url_java" ]
148     }
149
150     # Unit tests that are not supported by the current ICU alternatives on iOS.
151     if (is_ios) {
152       sources -= [
153         "origin_unittest.cc",
154         "scheme_host_port_unittest.cc",
155         "url_canon_icu_unittest.cc",
156         "url_canon_unittest.cc",
157       ]
158     }
159   } else {  # !use_platform_icu_alternatives
160     deps += [ "//third_party/icu:icuuc" ]
161   }
162
163   if (!is_ios) {
164     deps += [
165       "//mojo/core/embedder",
166       "//url/mojom:test_url_mojom_gurl",
167     ]
168   }
169 }
170
171 test("url_perftests") {
172   sources = [
173     "run_all_perftests.cc",
174     "url_parse_perftest.cc",
175   ]
176
177   deps = [
178     ":url",
179     "//base",
180     "//base/test:test_support",
181     "//testing/gtest",
182   ]
183 }
184
185 fuzzer_test("gurl_fuzzer") {
186   sources = [
187     "gurl_fuzzer.cc",
188   ]
189   deps = [
190     ":url",
191     "//base",
192     "//base:i18n",
193   ]
194   dict = "gurl_fuzzer.dict"
195 }