| # Copyright 2018 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("//tools/cmc/build/cmc.gni") |
| import("//tools/cmc/build/expect_includes.gni") |
| |
| # Compiles a cml file into a cm file. |
| # |
| # Parameters |
| # |
| # manifest (required) |
| # [file] The path to the cml file that is to be compiled. |
| # |
| # output_name (optional) |
| # [path] Name for the output. |
| # If not specified, the target name is used. |
| # |
| # check_includes (optional) |
| # [boolean] Whether to check against expect_includes() in deps. |
| # Default: true |
| # |
| # deps (optional) |
| # testonly (optional) |
| # visibility (optional) |
| template("cm") { |
| if (!defined(invoker.check_includes) || invoker.check_includes) { |
| check_includes_target = "${target_name}_check_includes" |
| cmc_check_includes(check_includes_target) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "manifest", |
| "testonly", |
| ]) |
| visibility = [ ":*" ] |
| } |
| |
| if (!defined(invoker.deps)) { |
| invoker.deps = [] |
| } |
| invoker.deps += [ ":" + check_includes_target ] |
| } |
| |
| cmc(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "output_name", |
| "testonly", |
| "visibility", |
| ]) |
| |
| if (!defined(output_name)) { |
| output_name = target_name |
| } |
| |
| compiled_output = "${target_out_dir}/${output_name}" |
| inputs = [ invoker.manifest ] |
| outputs = [ compiled_output ] |
| depfile = "${target_out_dir}/${target_name}.d" |
| |
| args = [ |
| "compile", |
| rebase_path(inputs[0], root_build_dir), |
| "--output", |
| rebase_path(compiled_output, root_build_dir), |
| "--includepath", |
| rebase_path("//", root_build_dir), |
| "--depfile", |
| rebase_path(depfile, root_build_dir), |
| ] |
| } |
| } |