chromium/third_party/blink/renderer/core/core.gni

# Copyright 2014 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/config/chrome_build.gni")
import("//third_party/blink/renderer/config.gni")

blink_core_output_dir = "$root_gen_dir/third_party/blink/renderer/core"

# This file sets core_config_add and core_config_remove lists of configs to
# modify the default lists of configs set in the build as appropriate for core
# targets. This avoids duplicating logic across many targets.
core_config_add = [
  "//third_party/blink/renderer:config",
  "//third_party/blink/renderer:non_test_config",
  "//third_party/blink/renderer/core:config",
]
core_config_remove = []

# Compute the optimization level. `optimize_max` ensures that speed is preferred
# over size on all platforms.
# TODO(crbug.com/1125115): It's unclear if the perf vs size win here is a good
# trade-off for Android. Investigate that.
if (!is_debug && !optimize_for_size) {
  core_config_remove += [ "//build/config/compiler:default_optimization" ]
  core_config_add += [ "//build/config/compiler:optimize_max" ]
}
if (using_mismatched_sample_profile) {
  core_config_remove += [ "//build/config/compiler:afdo_optimize_size" ]
}

core_config_remove += [ "//build/config/compiler:default_symbols" ]
core_config_add += blink_symbols_config

# Use this to generate a static library or source set that gets linked into
# "core". This will either be a source_set (component build), or a static
# library.
#
# Special values (all unlisted values are forwarded to the underlying library):
#
#   configs
#      Normal meaning. The set_defaults call below will make the default value
#      of configs in the calling code take into account the core_config_add and
#      core_config_remove lists above. So you don't need to manually take these
#      into account: just modify the configs as normal for target-specific
#      overrides (or don't touch it).
#
#   deps
#      Normal meaning but "core:prerequisites" target is always added. Callers
#      shouldn't list prerequisites as a dependency.
#
#   visibility
#      Normal meaning if defined. If undefined, defaults to everything in core.
template("blink_core_sources") {
  if (is_component_build) {
    target_type = "source_set"
  } else {
    target_type = "static_library"
  }
  target(target_type, target_name) {
    # The visibility will get overridden by forward_variables_from below if the
    # invoker defined it.
    visibility = [ "//third_party/blink/renderer/core/*" ]

    deps = [ "//third_party/blink/renderer/core:prerequisites" ]
    if (defined(invoker.deps)) {
      deps += invoker.deps
    }

    public_deps = [
      "//third_party/blink/renderer/core:all_generators",
      "//third_party/blink/renderer/core:core_common",
    ]
    if (defined(invoker.public_deps)) {
      public_deps += invoker.public_deps
    }

    # Take everything else not handled above from the invoker.
    forward_variables_from(invoker,
                           "*",
                           [
                             "deps",
                             "public_deps",
                           ])
  }
}
set_defaults("blink_core_sources") {
  # This sets the default list of configs when the blink_core_sources target
  # is defined. The default_compiler_configs comes from BUILDCONFIG.gn and
  # is the list normally applied to static libraries and source sets.
  configs = default_compiler_configs - core_config_remove + core_config_add
  configs += [ "//third_party/blink/renderer/core:blink_core_pch" ]
}