blob: 727e2cc523ab1e5d840cfb1d8989e5af3426db6b [file] [log] [blame]
# Copyright 2022 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.
template("strip_install_target") {
installable_target_name = invoker.installable_target_name
installable_target_dep = invoker.installable_target_dep
assert(defined(invoker.strip_executable) && invoker.strip_executable != "",
"strip executable required for stripping")
if (invoker.type == "executable") {
install_subdir = "bin"
source_name = installable_target_name
} else if (invoker.type == "shared_library") {
install_subdir = "lib"
source_name = "lib${installable_target_name}.so"
} else {
assert(false, "You can only install an executable or shared library.")
}
action("${target_name}_run_strip") {
forward_variables_from(invoker, [ "testonly" ])
script = "//starboard/build/run_bash.py"
inputs = [ "$root_out_dir/$source_name" ]
deps = invoker.deps
deps += [ installable_target_dep ]
outputs = [ "$sb_install_output_dir/$install_subdir/$source_name" ]
# skip stripping to make sure we have some debug symbols. Refer b/307760111
if (is_devel) {
args = [
"cp",
rebase_path("$root_out_dir/$source_name", root_out_dir),
rebase_path(outputs[0], root_out_dir),
]
} else {
args = [
strip_executable,
"-o",
rebase_path(outputs[0], root_out_dir),
rebase_path("$root_out_dir/$source_name", root_out_dir),
]
}
}
}