[go: nahoru, domu]

blob: b5edb89f7698f8e3d3926f10a5dcd1790b967d76 [file] [log] [blame]
# Copyright 2013 The Chromium Authors
# 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")
import("//build/config/cronet/config.gni")
import("//third_party/jni_zero/jni_zero.gni")
if (is_android || is_robolectric) {
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_non_special_url.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_features.cc",
"url_features.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" ]
deps = [ "//base/third_party/dynamic_annotations" ]
public_deps = [
"//base",
"//build:robolectric_buildflags",
]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
if (is_android || is_robolectric) {
deps += [ ":url_jni_headers" ]
if (!is_cronet_build) {
sources += [
"android/gurl_android.cc",
"android/gurl_android.h",
"android/origin_android.cc",
"android/parsed_android.cc",
"android/parsed_android.h",
]
}
}
if (is_robolectric) {
# Make jni.h available.
public_configs = [ "//third_party/jdk" ]
}
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" ]
} 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 || is_robolectric) {
generate_jni("url_jni_headers") {
sources = [ "android/java/src/org/chromium/url/IDNStringUtil.java" ]
if (!is_cronet_build) {
sources += [
"android/java/src/org/chromium/url/GURL.java",
"android/java/src/org/chromium/url/Origin.java",
"android/java/src/org/chromium/url/Parsed.java",
]
}
}
}
if (is_android && current_toolchain == default_toolchain) {
# TODO(agrieve): Remove alias once usages are removed.
java_group("gurl_java") {
deps = [ ":url_java" ]
}
android_library("url_java") {
sources = [ "android/java/src/org/chromium/url/IDNStringUtil.java" ]
srcjar_deps = [ ":url_jni_headers" ]
deps = [ "//third_party/jni_zero:jni_zero_java" ]
if (!is_cronet_build) {
sources += [
"android/java/src/org/chromium/url/GURL.java",
"android/java/src/org/chromium/url/Origin.java",
"android/java/src/org/chromium/url/Parsed.java",
"android/java/src/org/chromium/url/URI.java",
]
deps += [
"//base:base_java",
"//build/android:build_java",
"//mojo/public/java:bindings_java",
"//mojo/public/mojom/base:base_java",
"//third_party/android_deps:com_google_errorprone_error_prone_annotations_java",
"//third_party/androidx:androidx_annotation_annotation_java",
"//url/mojom:url_mojom_gurl_java",
"//url/mojom:url_mojom_origin_java",
]
}
}
}
source_set("url_test_support") {
testonly = true
sources = [
"gurl_abstract_tests.h",
"origin_abstract_tests.cc",
"origin_abstract_tests.h",
"url_canon_icu_test_helpers.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 && !is_cronet_build) {
sources += [
"mojom/scheme_host_port_mojom_traits_unittest.cc",
"mojom/url_gurl_mojom_traits_unittest.cc",
]
deps += [
"//mojo/core/embedder",
"//mojo/public/cpp/test_support:test_utils",
"//url/ipc:url_ipc_unittests",
"//url/mojom:mojom_traits",
"//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"
}
fuzzer_test("url_idna_icu_fuzzer") {
sources = [ "url_idna_icu_fuzzer.cc" ]
deps = [
":url",
"//third_party/icu:icuuc",
"//third_party/icu/fuzzers:fuzzer_support",
]
}
fuzzer_test("url_canon_icu_fuzzer") {
sources = [ "url_canon_icu_fuzzer.cc" ]
deps = [
":url",
":url_test_support",
"//third_party/icu:icuuc",
]
}
if (is_android && !is_cronet_build) {
source_set("android_test_helper") {
testonly = true
sources = [
"android/gurl_java_test_helper.cc",
"android/origin_java_test_helper.cc",
]
deps = [
":j_test_jni_headers($default_toolchain)",
":url",
"//base/test:test_support",
]
}
if (current_toolchain == default_toolchain) {
android_library("android_test_helper_java") {
testonly = true
srcjar_deps = [ ":j_test_jni_headers" ]
sources = [
"android/javatests/src/org/chromium/url/GURLJavaTestHelper.java",
"android/javatests/src/org/chromium/url/OriginJavaTestHelper.java",
]
deps = [
":url_java",
"//base:base_java_test_support",
"//third_party/jni_zero:jni_zero_java",
]
}
# 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 = [ ":url_java" ]
}
android_library("url_java_unit_tests") {
testonly = true
sources = [
"android/javatests/src/org/chromium/url/GURLJavaTest.java",
"android/javatests/src/org/chromium/url/OriginJavaTest.java",
]
deps = [
":android_test_helper_java",
":gurl_junit_test_support",
":url_java",
"//base:base_java",
"//base:base_java_test_support",
"//content/public/test/android:content_java_test_support",
"//mojo/public/mojom/base:base_java",
"//third_party/androidx:androidx_core_core_java",
"//third_party/androidx:androidx_test_runner_java",
"//third_party/jni_zero:jni_zero_java",
"//third_party/junit",
"//third_party/mockito:mockito_java",
"//url/mojom:url_mojom_gurl_java",
"//url/mojom:url_mojom_origin_java",
]
}
# See https://bugs.chromium.org/p/chromium/issues/detail?id=908819 for why we
# can't put 'java' in the name here.
generate_jni("j_test_jni_headers") {
testonly = true
sources = [
"android/javatests/src/org/chromium/url/GURLJavaTestHelper.java",
"android/javatests/src/org/chromium/url/OriginJavaTestHelper.java",
]
}
}
}
# Use this in robolectric_binary() targets if you just need GURL and //base
# functionality. Otherwise, define a custom shared_library().
if (!is_cronet_build && target_os == "android") {
shared_library_with_jni("libgurl_robolectric") {
testonly = true
enable_target = is_robolectric
java_targets = [
":gurl_java",
":url_java",
]
deps = [ ":robolectric_jni_onload($robolectric_toolchain)" ]
}
if (is_robolectric) {
# Depend on this if you need to write a custom JNI_OnLoad()
source_set("gurl_test_init") {
testonly = true
sources = [
"android/gurl_test_init.cc",
"android/gurl_test_init.h",
]
deps = [ ":url" ]
}
# Depend on this if you do not need to write a custom JNI_OnLoad()
source_set("robolectric_jni_onload") {
testonly = true
sources = [ "android/robolectric_jni_onload.cc" ]
deps = [
":gurl_test_init",
"//base",
]
# Make jni.h available.
configs += [ "//third_party/jdk" ]
}
}
}