blob: ac17366183b63f27429061c294d8bf41ecd22aef [file] [log] [blame]
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/buildflag_header.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//testing/test.gni")
import("features.gni")
if (is_android) {
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
}
buildflag_header("buildflags") {
header = "buildflags.h"
flags = [ "USE_PLATFORM_ICU_ALTERNATIVES=$use_platform_icu_alternatives" ]
}
component("url") {
sources = [
"gurl.cc",
"gurl.h",
"origin.cc",
"origin.h",
"scheme_host_port.cc",
"scheme_host_port.h",
"third_party/mozilla/url_parse.cc",
"third_party/mozilla/url_parse.h",
"url_canon.cc",
"url_canon.h",
"url_canon_etc.cc",
"url_canon_filesystemurl.cc",
"url_canon_fileurl.cc",
"url_canon_host.cc",
"url_canon_internal.cc",
"url_canon_internal.h",
"url_canon_internal_file.h",
"url_canon_ip.cc",
"url_canon_ip.h",
"url_canon_mailtourl.cc",
"url_canon_path.cc",
"url_canon_pathurl.cc",
"url_canon_query.cc",
"url_canon_relative.cc",
"url_canon_stdstring.cc",
"url_canon_stdstring.h",
"url_canon_stdurl.cc",
"url_constants.cc",
"url_constants.h",
"url_file.h",
"url_parse_file.cc",
"url_parse_internal.h",
"url_util.cc",
"url_util.h",
"url_util_internal.h",
]
defines = [ "IS_URL_IMPL" ]
public_deps = [ "//base" ]
deps = [
"//base/third_party/dynamic_annotations",
"//ipc:param_traits",
]
if (is_win) {
# Don't conflict with Windows' "url.dll".
output_name = "url_lib"
}
# ICU support.
if (use_platform_icu_alternatives) {
if (is_android) {
sources += [ "url_idna_icu_alternatives_android.cc" ]
deps += [
":buildflags",
":url_java",
":url_jni_headers",
"//base",
"//base/third_party/dynamic_annotations",
]
} else if (is_ios) {
sources += [ "url_idna_icu_alternatives_ios.mm" ]
} else {
assert(false,
"ICU alternative is not implemented for platform: " + target_os)
}
} else {
# Use ICU.
sources += [
"url_canon_icu.cc",
"url_canon_icu.h",
"url_idna_icu.cc",
]
deps += [
"//base:i18n",
"//third_party/icu",
]
}
}
if (is_android) {
source_set("gurl_android") {
sources = [
"android/gurl_android.cc",
"android/gurl_android.h",
"android/parsed_android.cc",
"android/parsed_android.h",
]
deps = [
":gurl_jni_headers",
":url",
"//base:base",
]
}
static_library("origin_android") {
sources = [ "android/origin_android.cc" ]
deps = [
":url",
":url_jni_headers",
"//base",
"//url/mojom:url_mojom_origin",
]
}
android_library("url_java") {
sources = [ "android/java/src/org/chromium/url/IDNStringUtil.java" ]
deps = [ "//base:base_java" ]
}
android_library("gurl_java") {
sources = [
"android/java/src/org/chromium/url/GURL.java",
"android/java/src/org/chromium/url/Parsed.java",
"android/java/src/org/chromium/url/URI.java",
]
deps = [
"//base:base_java",
"//third_party/androidx:androidx_annotation_annotation_java",
]
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
}
android_library("origin_java") {
sources = [ "android/java/src/org/chromium/url/Origin.java" ]
deps = [
"//base:base_java",
"//mojo/public/java:bindings_java",
"//mojo/public/mojom/base:base_java",
"//url/mojom:url_mojom_origin_java",
]
}
generate_jni("url_jni_headers") {
sources = [
"android/java/src/org/chromium/url/IDNStringUtil.java",
"android/java/src/org/chromium/url/Origin.java",
]
}
generate_jni("gurl_jni_headers") {
sources = [
"android/java/src/org/chromium/url/GURL.java",
"android/java/src/org/chromium/url/Parsed.java",
]
}
}
source_set("url_test_support") {
testonly = true
sources = [
"gurl_abstract_tests.h",
"origin_abstract_tests.cc",
"origin_abstract_tests.h",
]
public_deps = [
":url",
"//base",
"//base/test:test_support",
"//testing/gmock",
"//testing/gtest",
]
}
test("url_unittests") {
sources = [
"gurl_unittest.cc",
"origin_unittest.cc",
"run_all_unittests.cc",
"scheme_host_port_unittest.cc",
"url_canon_icu_unittest.cc",
"url_canon_unittest.cc",
"url_parse_unittest.cc",
"url_test_utils.h",
"url_util_unittest.cc",
]
deps = [
":url",
":url_test_support",
"//base",
"//base/test:test_support",
"//testing/gmock",
"//testing/gtest",
]
if (use_platform_icu_alternatives) {
# Unit tests that are not supported by the current ICU alternatives on Android.
if (is_android) {
sources -= [
"url_canon_icu_unittest.cc",
"url_canon_unittest.cc",
]
deps += [ ":url_java" ]
}
# Unit tests that are not supported by the current ICU alternatives on iOS.
if (is_ios) {
sources -= [
"origin_unittest.cc",
"scheme_host_port_unittest.cc",
"url_canon_icu_unittest.cc",
"url_canon_unittest.cc",
]
}
} else { # !use_platform_icu_alternatives
deps += [ "//third_party/icu:icuuc" ]
}
if (!is_ios) {
sources += [ "mojom/url_gurl_mojom_traits_unittest.cc" ]
deps += [
"//mojo/core/embedder",
"//url/ipc:url_ipc_unittests",
"//url/mojom:test_url_mojom_gurl",
]
}
}
test("url_perftests") {
sources = [
"run_all_perftests.cc",
"url_parse_perftest.cc",
]
deps = [
":url",
"//base",
"//base/test:test_support",
"//testing/gtest",
]
}
fuzzer_test("gurl_fuzzer") {
sources = [ "gurl_fuzzer.cc" ]
deps = [
":url",
"//base",
"//base:i18n",
]
dict = "gurl_fuzzer.dict"
}
if (is_android) {
source_set("gurl_android_test_helper") {
testonly = true
sources = [ "android/gurl_java_test_helper.cc" ]
deps = [
":gurl_android",
":gurl_j_test_jni_headers",
":url",
"//base/test:test_support",
"//testing/gtest",
]
}
android_library("gurl_android_test_helper_java") {
testonly = true
sources =
[ "android/javatests/src/org/chromium/url/GURLJavaTestHelper.java" ]
deps = [
":gurl_java",
"//base:base_java",
"//base:base_java_test_support",
]
}
# Targets depending on gurl_junit_test_support do not need to bypass platform
# checks.
android_library("gurl_junit_test_support") {
testonly = true
sources = [ "android/test/java/src/org/chromium/url/JUnitTestGURLs.java" ]
deps = [ ":gurl_java" ]
}
# Unlike gurl_junit_test_support targets depending on gurl_junit_shadows must
# bypass platform checks.
android_library("gurl_junit_shadows") {
# Platform checks are broken for Robolectric. See https://crbug.com/1071638.
bypass_platform_checks = true
testonly = true
sources = [ "android/test/java/src/org/chromium/url/ShadowGURL.java" ]
deps = [
":gurl_java",
":gurl_junit_test_support",
"//third_party/android_deps:robolectric_all_java",
]
}
android_library("gurl_javatests") {
testonly = true
sources = [
"android/javatests/src/org/chromium/url/GURLJavaTest.java",
"android/javatests/src/org/chromium/url/JUnitTestGURLsTest.java",
]
deps = [
":gurl_android_test_helper_java",
":gurl_java",
":gurl_junit_test_support",
"//base:base_java",
"//base:base_java_test_support",
"//content/public/test/android:content_java_test_support",
"//third_party/android_support_test_runner:rules_java",
"//third_party/android_support_test_runner:runner_java",
"//third_party/androidx:androidx_core_core_java",
"//third_party/androidx:androidx_test_runner_java",
"//third_party/junit",
"//third_party/mockito:mockito_java",
]
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
}
# See https://bugs.chromium.org/p/chromium/issues/detail?id=908819 for why we
# can't put 'java' in the name here.
generate_jni("gurl_j_test_jni_headers") {
testonly = true
sources =
[ "android/javatests/src/org/chromium/url/GURLJavaTestHelper.java" ]
}
android_library("gurl_junit_tests") {
# Platform checks are broken for Robolectric. See https://crbug.com/1071638.
bypass_platform_checks = true
testonly = true
sources = [ "android/junit/src/org/chromium/url/ShadowGURLTest.java" ]
deps = [
":gurl_java",
":gurl_junit_shadows",
":gurl_junit_test_support",
"//base:base_java",
"//base:base_java_test_support",
"//base:base_junit_test_support",
"//base/test:test_support_java",
"//third_party/android_deps:robolectric_all_java",
"//third_party/junit",
]
}
}