Upload upstream chromium 67.0.3396
[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/test.gni")
7 import("//testing/libfuzzer/fuzzer_test.gni")
8 import("features.gni")
9
10 if (is_android) {
11   import("//build/config/android/rules.gni")
12 }
13
14 buildflag_header("url_features") {
15   header = "url_features.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_export.h",
51     "url_file.h",
52     "url_parse_file.cc",
53     "url_parse_internal.h",
54     "url_util.cc",
55     "url_util.h",
56     "url_util_internal.h",
57   ]
58
59   defines = [ "URL_IMPLEMENTATION" ]
60
61   configs += [
62     # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
63     "//build/config/compiler:no_size_t_to_int_warning",
64   ]
65
66   deps = [
67     "//base",
68     "//base/third_party/dynamic_annotations",
69   ]
70
71   if (is_win) {
72     # Don't conflict with Windows' "url.dll".
73     output_name = "url_lib"
74   }
75
76   # ICU support.
77   if (use_platform_icu_alternatives) {
78     if (is_android) {
79       sources += [ "url_canon_icu_alternatives_android.cc" ]
80       deps += [
81         ":url_features",
82         ":url_java",
83         ":url_jni_headers",
84         "//base",
85         "//base/third_party/dynamic_annotations",
86       ]
87     } else if (is_ios) {
88       sources += [ "url_canon_icu_alternatives_ios.mm" ]
89     } else {
90       assert(false,
91              "ICU alternative is not implemented for platform: " + target_os)
92     }
93   } else {
94     # Use ICU.
95     sources += [
96       "url_canon_icu.cc",
97       "url_canon_icu.h",
98     ]
99     deps += [ "//third_party/icu" ]
100   }
101 }
102
103 if (is_android) {
104   android_library("url_java") {
105     java_files = [ "android/java/src/org/chromium/url/IDNStringUtil.java" ]
106     deps = [
107       "//base:base_java",
108     ]
109   }
110
111   generate_jni("url_jni_headers") {
112     sources = [
113       "android/java/src/org/chromium/url/IDNStringUtil.java",
114     ]
115     jni_package = "url"
116   }
117 }
118
119 test("url_unittests") {
120   sources = [
121     "gurl_unittest.cc",
122     "origin_unittest.cc",
123     "run_all_unittests.cc",
124     "scheme_host_port_unittest.cc",
125     "url_canon_icu_unittest.cc",
126     "url_canon_unittest.cc",
127     "url_parse_unittest.cc",
128     "url_test_utils.h",
129     "url_util_unittest.cc",
130   ]
131
132   deps = [
133     ":url",
134     "//base",
135     "//base/test:test_support",
136     "//testing/gtest",
137   ]
138
139   if (!is_ios) {
140     sources += [ "mojom/url_gurl_mojom_traits_unittest.cc" ]
141   }
142
143   if (use_platform_icu_alternatives) {
144     # Unit tests that are not supported by the current ICU alternatives on Android.
145     if (is_android) {
146       sources -= [
147         "url_canon_icu_unittest.cc",
148         "url_canon_unittest.cc",
149       ]
150       deps += [ ":url_java" ]
151     }
152
153     # Unit tests that are not supported by the current ICU alternatives on iOS.
154     if (is_ios) {
155       sources -= [
156         "origin_unittest.cc",
157         "scheme_host_port_unittest.cc",
158         "url_canon_icu_unittest.cc",
159         "url_canon_unittest.cc",
160       ]
161     }
162   } else {  # !use_platform_icu_alternatives
163     deps += [ "//third_party/icu:icuuc" ]
164   }
165
166   # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
167   configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
168
169   if (!is_ios) {
170     deps += [
171       "//mojo/edk",
172       "//mojo/edk/test:test_support",
173       "//url/mojom:test_url_mojom_gurl",
174     ]
175   }
176 }
177
178 fuzzer_test("gurl_fuzzer") {
179   sources = [
180     "gurl_fuzzer.cc",
181   ]
182   deps = [
183     ":url",
184     "//base",
185     "//base:i18n",
186   ]
187   dict = "gurl_fuzzer.dict"
188 }