blob: cf74ac4fd117e05c641bed9adfbf8a0290d69bbf [file] [log] [blame]
# Copyright 2021 The Cobalt Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
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
# executable. In order to make tests pass we need to overload the install
# subdir and install content subdir.
if (invoker.type == "executable") {
# install_subdir = "bin"
install_subdir = installable_target_name
source_name = installable_target_name
} else if (invoker.type == "shared_library") {
install_subdir = "lib"
if (installable_target_name == "starboard") {
source_name =
"lib${installable_target_name}.${starboard_shared_library_extension}"
} else {
source_name = "lib${installable_target_name}.so"
}
} else {
assert(false, "You can only install an executable or shared library.")
}
output = "$sb_install_output_dir/$install_subdir/$source_name"
input = "$root_out_dir/$source_name"
if (is_gold || cobalt_fastbuild) {
action(target_name) {
forward_variables_from(invoker, [ "testonly" ])
script = "//starboard/build/run_bash.py"
strip_executable = gcc_toolchain_strip
inputs = [ input ]
deps = invoker.deps
deps += [ invoker.installable_target_dep ]
outputs = [ output ]
args = [
rebase_path(strip_executable, root_build_dir),
"-o",
rebase_path(outputs[0], root_build_dir),
rebase_path(inputs[0], root_build_dir),
]
}
} else {
copy(target_name) {
forward_variables_from(invoker, [ "testonly" ])
sources = [ input ]
outputs = [ output ]
deps = invoker.deps
deps += [ invoker.installable_target_dep ]
}
}
}