Skip to content

Commit

Permalink
Cherry pick PR #1795: [GN] Pass shared library name to exe install st…
Browse files Browse the repository at this point in the history
…eps (#2164)

Refer to the original PR: #1795

When running the install steps for executables that are built as a
result of the shared library (i.e. loaders), sometimes the name of the
original shared library that invoked it is needed in the install_target
context in order to create necessary dependencies on the shared_library
install_target counterparts.

b/246855300

Co-authored-by: Arjun Menon <[email protected]>
  • Loading branch information
cobalt-github-releaser-bot and arjungm authored Jan 5, 2024
1 parent 62ca80a commit b63a367
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
25 changes: 23 additions & 2 deletions starboard/build/config/BUILDCONFIG.gn
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,15 @@ template("evergreen_loader") {
}

template("executable") {
not_needed(invoker, [ "build_loader" ])
not_needed(invoker,
[
"build_loader",

# TODO(b/305091479): Investigate when this variable is unneeded
# so that we can refactor this to avoid the not_needed
# declaration.
"shared_library_target_name",
])

target_with_platform_configs(target_name) {
target_type = "executable"
Expand Down Expand Up @@ -446,7 +454,16 @@ template("executable") {
}

install_target(target_name + "_install") {
forward_variables_from(invoker, [ "testonly" ])
# "shared_library_target_name" is used when this executable install_target
# is invoked from within a shared_library target that is building a loader
# In this case, it allows the install_target to determine the inputs/deps
# for the corresponding shared_library install_target.
forward_variables_from(invoker,
[
"testonly",
"shared_library_target_name",
])

installable_target_name = executable_target_name
installable_target_dep = ":$executable_target_name"
not_needed([ "installable_target_dep" ])
Expand Down Expand Up @@ -511,6 +528,10 @@ template("shared_library") {
])
sources = [ "//$starboard_path/starboard_loader.cc" ]

# Forwards the "shared_library_target_name" to allow this loader install
# target to depend the corresponding shared_library install_target outputs.
shared_library_target_name = actual_target_name

if (defined(extra_platform_loader_sources)) {
sources += extra_platform_loader_sources
}
Expand Down
2 changes: 2 additions & 0 deletions starboard/build/install/install_target.gni
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import("//starboard/build/config/install.gni")
import("//starboard/build/config/starboard_target_type.gni")

template("install_target") {
not_needed(invoker, [ "shared_library_target_name" ])

installable_target_name = invoker.installable_target_name
installable_target_dep = invoker.installable_target_dep

Expand Down
2 changes: 2 additions & 0 deletions starboard/raspi/shared/install_target.gni
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import("//starboard/build/config/starboard_target_type.gni")
import("//starboard/raspi/shared/toolchain/raspi_shared_toolchain.gni")

template("install_target") {
not_needed(invoker, [ "shared_library_target_name" ])

installable_target_name = invoker.installable_target_name

# TODO(b/218889313): raspi relies on install_content being adjacent to the
Expand Down

0 comments on commit b63a367

Please sign in to comment.