gn: Trim target prefix from static and shared libraries

If the target name matches the package directory.
Reduces stuttering in target names.

Change-Id: I6cf01ac22c4998f4b862135b13b8503bdd92bdd0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79080
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Ben Clayton
2022-02-04 12:51:25 +00:00
parent 902ad1f9b2
commit 7d5badd9f4
4 changed files with 27 additions and 16 deletions

View File

@@ -23,8 +23,12 @@ import("dawn_overrides_with_defaults.gni")
# Template that produces static and shared versions of the same library as well
# as a target similar to Chromium's component targets.
# - The shared version exports symbols and has dependent import the symbols
# as libname.so with target name libname_shared
# - The static library doesn't export symbols nor make dependents import them
# as libname.so. If the target name matches the package directory name, then
# the shared library target will be named 'shared', otherwise
# '${target_name}_shared'.
# - The static library doesn't export symbols nor make dependents import them.
# If the target name matches the package directory name, then the static
# library target will be named 'static', otherwise '${target_name}_static'.
# - The libname target is similar to a Chromium component and is an alias for
# either the static or the shared library.
#
@@ -51,9 +55,16 @@ template("dawn_component") {
# definition of targets.
name = target_name
prefix = "${name}_"
# Remove prefix if the target name matches directory
if (get_label_info(get_label_info(":$target_name", "dir"), "name") == name) {
prefix = ""
}
# The config that will apply to dependents of the shared library so they know
# they should "import" the symbols
config("${name}_shared_public_config") {
config("${prefix}shared_public_config") {
defines = [ "${invoker.DEFINE_PREFIX}_SHARED_LIBRARY" ]
# Executable needs an rpath to find our shared libraries on OSX and Linux
@@ -68,7 +79,7 @@ template("dawn_component") {
}
}
shared_library("${name}_shared") {
shared_library("${prefix}shared") {
# The "tool" for creating shared libraries will automatically add the "lib" prefix
output_name = name
@@ -90,7 +101,7 @@ template("dawn_component") {
if (!defined(public_configs)) {
public_configs = []
}
public_configs += [ ":${name}_shared_public_config" ]
public_configs += [ ":${prefix}shared_public_config" ]
# Tell sources of this library to export the symbols (and not import)
if (!defined(defines)) {
@@ -107,7 +118,7 @@ template("dawn_component") {
}
}
static_library("${name}_static") {
static_library("${prefix}static") {
output_name = name + "_static"
complete_static_lib = dawn_complete_static_libs
@@ -121,9 +132,9 @@ template("dawn_component") {
group(name) {
if (is_component_build) {
public_deps = [ ":${name}_shared" ]
public_deps = [ ":${prefix}shared" ]
} else {
public_deps = [ ":${name}_static" ]
public_deps = [ ":${prefix}static" ]
}
}
}