blob: ac44cb9bfd47c2e314de837a4c49683a13b59ab9 [file] [log] [blame] [edit]
# 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 (host_toolchain == current_toolchain) {
# 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-v1/BUILD.gn.tmpl-cpp",
"component-v1/BUILD.gn.tmpl-rust",
"component-v1/README.md.tmpl",
"component-v1/main.cc.tmpl-cpp",
"component-v1/meta/{{PROJECT_NAME}}.cmx.tmpl-cpp",
"component-v1/meta/{{PROJECT_NAME}}.cmx.tmpl-rust",
"component-v1/src/main.rs.tmpl-rust",
"component-v1/{{snake_case PROJECT_NAME}}.cc.tmpl-cpp",
"component-v1/{{snake_case PROJECT_NAME}}.h.tmpl-cpp",
"component-v1/{{snake_case PROJECT_NAME}}_unittest.cc.tmpl-cpp",
"component-v2/BUILD.gn.tmpl-cpp",
"component-v2/BUILD.gn.tmpl-rust",
"component-v2/README.md.tmpl",
"component-v2/main.cc.tmpl-cpp",
"component-v2/meta/{{PROJECT_NAME}}-unittests.cml.tmpl-cpp",
"component-v2/meta/{{PROJECT_NAME}}-unittests.cml.tmpl-rust",
"component-v2/meta/{{PROJECT_NAME}}.cml.tmpl-cpp",
"component-v2/meta/{{PROJECT_NAME}}.cml.tmpl-rust",
"component-v2/src/main.rs.tmpl-rust",
"component-v2/{{snake_case PROJECT_NAME}}.cc.tmpl-cpp",
"component-v2/{{snake_case PROJECT_NAME}}.h.tmpl-cpp",
"component-v2/{{snake_case PROJECT_NAME}}_unittest.cc.tmpl-cpp",
"driver/BUILD.gn.tmpl-cpp",
"driver/README.md.tmpl",
"driver/unit-tests.cc.tmpl-cpp",
"driver/{{snake_case PROJECT_NAME}}.bind.tmpl-cpp",
"driver/{{snake_case PROJECT_NAME}}.cc.tmpl-cpp",
"driver/{{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" ]
}
}
}