| # 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. |
| |
| template("install_target") { |
| if (invoker.type == "executable") { |
| install_subdir = "bin" |
| } else if (invoker.type == "shared_library") { |
| install_subdir = "lib" |
| } else { |
| assert(false, "You can only install an executable or shared library.") |
| } |
| |
| copy("copy_" + target_name) { |
| forward_variables_from(invoker, |
| [ |
| "installable_target_name", |
| "testonly", |
| ]) |
| deps = [ ":$installable_target_name" ] |
| |
| sources = [ "$root_out_dir/$installable_target_name" ] |
| outputs = [ "$root_out_dir/install/$install_subdir/{{source_file_part}}" ] |
| } |
| |
| if (defined(invoker.content)) { |
| copy("copy_content_" + target_name) { |
| forward_variables_from(invoker, [ "testonly" ]) |
| sources = invoker.content |
| outputs = [ "$root_out_dir/install/usr/share/cobalt/{{source_root_relative_dir}}/{{source_file_part}}" ] |
| } |
| } |
| } |