| # Copyright 2020 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/host.gni") |
| |
| if (is_host) { |
| # Copies templates to the specified output directory and generates a file |
| # containing all copied paths. |
| copy("templates") { |
| # All template files available to fx create. |
| sources = [ |
| "_copyright.tmpl", |
| "_generated.tmpl", |
| "component-default/BUILD.gn.tmpl-cpp", |
| "component-default/BUILD.gn.tmpl-rust", |
| "component-default/README.md.tmpl", |
| "component-default/main.cc.tmpl-cpp", |
| "component-default/meta/{{snake_case PROJECT_NAME}}.cml.tmpl-cpp", |
| "component-default/meta/{{snake_case PROJECT_NAME}}.cml.tmpl-rust", |
| "component-default/src/main.rs.tmpl-rust", |
| "component-default/{{snake_case PROJECT_NAME}}.cc.tmpl-cpp", |
| "component-default/{{snake_case PROJECT_NAME}}.h.tmpl-cpp", |
| "component-default/{{snake_case PROJECT_NAME}}_unittest.cc.tmpl-cpp", |
| "component-test/BUILD.gn.tmpl-cpp", |
| "component-test/BUILD.gn.tmpl-rust", |
| "component-test/README.md.tmpl", |
| "component-test/meta/{{snake_case PROJECT_NAME}}.cml.tmpl-cpp", |
| "component-test/meta/{{snake_case PROJECT_NAME}}.cml.tmpl-rust", |
| "component-test/src/lib.rs.tmpl-rust", |
| "component-test/{{snake_case PROJECT_NAME}}.cc.tmpl-cpp", |
| "driver-default/BUILD.gn.tmpl-cpp", |
| "driver-default/README.md.tmpl", |
| "driver-default/unit-tests.cc.tmpl-cpp", |
| "driver-default/{{snake_case PROJECT_NAME}}-info.json.tmpl-cpp", |
| "driver-default/{{snake_case PROJECT_NAME}}.bind.tmpl-cpp", |
| "driver-default/{{snake_case PROJECT_NAME}}.cc.tmpl-cpp", |
| "driver-default/{{snake_case PROJECT_NAME}}.h.tmpl-cpp", |
| ] |
| outputs = |
| [ "${host_tools_dir}/create_templates/{{source_target_relative}}" ] |
| |
| # Write out all the template paths to a single file as JSON. |
| # fx create will use the paths in this file as the available set of |
| # template files. |
| write_file("${host_tools_dir}/create_templates/templates.json", |
| sources, |
| "json") |
| |
| metadata = { |
| # Include the template files as test dependencies. |
| # Tests that depend on the `create` binary need to pull in the template files |
| # transitively. |
| test_runtime_deps = |
| rebase_path(sources, "", "${host_tools_dir}/create_templates") + |
| [ "${host_tools_dir}/create_templates/templates.json" ] |
| } |
| } |
| } |