| # Copyright 2019 The ChromiumOS Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| # Defines a configs of ebuild installation. |
| # Put this target into dependency tree, and it will install the files |
| # automatically. |
| # It is also created and put into dependency tree when install_path |
| # is set in |executable|, |shared_library| and |static_library| targets. |
| |
| # Default of values below follows ebuild default. |
| # See https://dev.gentoo.org/~zmedico/portage/doc/man/ebuild.5.html |
| |
| # Args: |
| # sources(required): A list of files to be installed. |
| # install_path(optional): An install destination path. |
| # options(optional): A string of options for installing files. |
| # outputs(optional): A list of new file names to be renamed to. |
| # When it is not specified, original names are used. |
| # glob(optional): A boolean to expand * and ** glob patterns. |
| # recursive(optional): A boolean to install files recursively. |
| # tree_relative_to(optional): If given, files will be installed as |
| # preserving the relative directory tree. |
| # symlinks(optional): A list of new symlinks to be created. |
| # When install_path is specified, symlinks are created |
| # in ${install_path}/${symlink}. |
| # type(optional): A target type that created this config. This was set |
| # when the install_config is defined by executable, shared_library or |
| # static_library. |
| template("install_config") { |
| group(target_name) { |
| forward_variables_from(invoker, |
| "*", |
| [ |
| "glob", |
| "install_path", |
| "metadata", |
| "options", |
| "outputs", |
| "recursive", |
| "sources", |
| "symlinks", |
| "tree_relative_to", |
| "type", |
| ]) |
| assert(defined(invoker.sources), "sources must be set") |
| if (defined(invoker.outputs)) { |
| assert(!defined(invoker.glob), "glob cannot be used with outputs") |
| assert(!defined(invoker.tree_relative_to), |
| "tree_relative_to cannot be used with outputs") |
| } |
| metadata = { |
| if (defined(invoker.metadata)) { |
| forward_variables_from(invoker.metadata, "*") |
| } |
| _install_config = [ |
| { |
| forward_variables_from(invoker, |
| [ |
| "glob", |
| "install_path", |
| "options", |
| "outputs", |
| "recursive", |
| "symlinks", |
| "type", |
| ]) |
| sources = [] |
| foreach(x, invoker.sources) { |
| # Rebase to the system absolute path. |
| sources += [ rebase_path(x, "") ] |
| } |
| if (defined(invoker.tree_relative_to)) { |
| # Rebase to the system absolute path. |
| tree_relative_to = rebase_path(invoker.tree_relative_to, "") |
| } |
| }, |
| ] |
| } |
| } |
| } |