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" ]
}
}
}

View File

@ -770,7 +770,7 @@ dawn_component("webgpu_dawn") {
sources = get_target_outputs(":webgpu_dawn_native_proc_gen")
deps = [
":dawn_native_static",
":static",
":webgpu_dawn_native_proc_gen",
]
}

View File

@ -79,8 +79,8 @@ static_library("dawn_wire_server_fuzzer_common") {
"${dawn_root}/src/dawn:dawncpp",
"${dawn_root}/src/dawn/common",
"${dawn_root}/src/dawn/utils",
"${dawn_root}/src/dawn_native:dawn_native_static",
"${dawn_root}/src/dawn_wire:dawn_wire_static",
"${dawn_root}/src/dawn_native:static",
"${dawn_root}/src/dawn_wire:static",
]
}

View File

@ -135,7 +135,7 @@ source_set("dawn_native_mocks_sources") {
":gmock_and_gtest",
"${dawn_root}/src/dawn/utils",
"${dawn_root}/src/dawn_native:dawn_native_sources",
"${dawn_root}/src/dawn_native:dawn_native_static",
"${dawn_root}/src/dawn_native:static",
]
# Add internal dawn_native config for internal unittests.
@ -171,7 +171,7 @@ test("dawn_unittests") {
"${dawn_root}/src/dawn/common",
"${dawn_root}/src/dawn/utils",
"${dawn_root}/src/dawn_native:dawn_native_sources",
"${dawn_root}/src/dawn_native:dawn_native_static",
"${dawn_root}/src/dawn_native:static",
"${dawn_root}/src/dawn_wire",
]
@ -329,7 +329,7 @@ source_set("dawn_end2end_tests_sources") {
# Statically linked because the end2end white_box tests use Dawn internals.
"${dawn_root}/src/dawn/utils",
"${dawn_root}/src/dawn_native:dawn_native_static",
"${dawn_root}/src/dawn_native:static",
"${dawn_root}/src/dawn_wire",
]
@ -478,7 +478,7 @@ source_set("dawn_white_box_tests_sources") {
# Statically linked because the end2end white_box tests use Dawn internals.
"${dawn_root}/src/dawn/utils",
"${dawn_root}/src/dawn_native:dawn_native_static",
"${dawn_root}/src/dawn_native:static",
"${dawn_root}/src/dawn_wire",
]
@ -552,7 +552,7 @@ test("dawn_end2end_tests") {
"${dawn_root}/src/dawn:dawncpp",
"${dawn_root}/src/dawn/common",
"${dawn_root}/src/dawn/utils",
"${dawn_root}/src/dawn_native:dawn_native_static",
"${dawn_root}/src/dawn_native:static",
"${dawn_root}/src/dawn_wire",
]