1# Copyright (c) 2023 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14template("check_target") {
15  forward_variables_from(invoker,
16                         [
17                           "part_name",
18                           "subsystem_name",
19                           "target_path",
20                         ])
21
22  action(target_name) {
23    script = "//build/templates/common/check_build_target.py"
24    depfile = "${target_gen_dir}/$target_name.d"
25    outputs = [ "${target_out_dir}/${target_name}.txt" ]
26    _compile_standard_allow_file =
27        "$preloader_output_dir/compile_standard_whitelist.json"
28    args = [
29      "--part-name",
30      part_name,
31      "--subsystem-name",
32      subsystem_name,
33      "--target-path",
34      target_path,
35      "--depfile",
36      rebase_path(depfile, root_build_dir),
37      "--output",
38      rebase_path(outputs[0], root_build_dir),
39      "--compile-standard-allow-file",
40      rebase_path(_compile_standard_allow_file, root_build_dir),
41    ]
42
43    if (defined(invoker.skip_check_subsystem) &&
44        invoker.skip_check_subsystem == true) {
45      args += [ "--skip-check-subsystem" ]
46    }
47
48    if (defined(invoker.module_deps)) {
49      dep_labels = []
50      foreach(label, invoker.module_deps) {
51        dep_labels += [ get_label_info(label, "label_no_toolchain") ]
52      }
53      args += [ "--deps" ]
54      args += dep_labels
55    }
56
57    if (defined(invoker.module_ex_deps)) {
58      args += [ "--external-deps" ]
59      args += invoker.module_ex_deps
60    }
61  }
62}
63