blob: 485f4acebc05b7cfc0f59904ff923728dc0acbb6 [file] [log] [blame]
# Copyright 2014 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/config/features.gni")
gypi_values = exec_script("//build/gypi_to_gn.py",
[ rebase_path("cld_2.gyp") ],
"scope",
[ "cld_2.gyp" ])
# This variable controls which dependency is resolved by the pass-through
# target 'cld2_platform_impl', and allows the embedder to choose which
# kind of CLD2 support is required at build time:
#
# - If the value is 'static', then the cld2_platform_impl target will depend
# upon the cld2_static target
# - If the value is 'dynamic', then the cld2_platform_impl target will
# depend upon the cld2_dynamic target.
#
# High-level targets for Chromium unit tests hard-code a dependency upon
# cld2_static because doing so makes sense for use cases that aren't
# affected by the loading of language detection data; however, most other
# targets (e.g. the final executables and interactive UI tests) should be
# linked against whatever the embedder needs.
#
# Maintainers:
# This value may be reasonably tweaked on a per-platform basis.
# Don't forget to update this file as well to match:
# components/translate/content/browser/browser_cld_utils.cc
# components/translate/content/renderer/renderer_cld_utils.cc
cld2_platform_support = "static"
cld2_table_size = 2
source_set("cld2_data") {
sources = gypi_values.cld2_data_sources
if (cld2_table_size == 0) {
sources += gypi_values.cld2_data_smallest_sources
} else if (cld2_table_size == 2) {
sources += gypi_values.cld2_data_largest_sources
}
include_dirs = [
"src/internal",
"src/public",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
}
# As in the corresponding gyp file, this just builds the core interfaces for
# CLD2. You must still declare a dependency on a specific data set, either
# cld2_dynamic or cld2_static.
source_set("cld_2") {
sources = gypi_values.cld2_core_sources
include_dirs = [
"src/internal",
"src/public",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
}
source_set("cld2_platform_impl") {
deps = []
if (cld2_platform_support == "static") {
deps += [ ":cld2_static" ]
} else if (cld2_platform_support == "dynamic") {
deps += [ ":cld2_dynamic" ]
}
}
static_library("cld2_static") {
sources = gypi_values.cld2_core_impl_sources
include_dirs = [
"src/internal",
"src/public",
]
deps = [
":cld_2",
":cld2_data",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
}
config("cld2_dynamic_mode_config") {
defines = [ "CLD2_DYNAMIC_MODE" ]
}
static_library("cld2_dynamic") {
sources = gypi_values.cld2_core_sources + gypi_values.cld2_core_impl_sources +
gypi_values.cld2_dynamic_data_loader_sources
include_dirs = [
"src/internal",
"src/public",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
":cld2_dynamic_mode_config",
"//build/config/compiler:no_chromium_code",
]
}
# Does not build on Windows.
if (!is_win) {
executable("cld_2_dynamic_data_tool") {
sources = [
"src/internal/cld2_dynamic_data_extractor.cc",
"src/internal/cld2_dynamic_data_extractor.h",
"src/internal/cld2_dynamic_data_tool.cc",
]
include_dirs = [
"src/internal",
"src/public",
]
deps = [
":cld2_data",
":cld2_dynamic",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
":cld2_dynamic_mode_config",
"//build/config/compiler:no_chromium_code",
]
}
}