1# Copyright (c) 2020 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.
13import("//build/lite/lite_target_list.gni")
14import("//build/lite/ndk/ndk.gni")
15
16# gn version >= 1714 required.
17assert(gn_version >= 1714, "GN version 1714 required, please upgrade!")
18
19# write version info.
20version_info = [
21  "VERSION=\"$ohos_version\"",
22  "BUILD_TIME=\"$ohos_build_datetime\"",
23]
24write_file("$root_build_dir/etc/version-info", version_info)
25
26group("prebuilts") {
27  public_deps = [ "//third_party/musl:sysroot_lite" ]
28}
29
30group("ohos") {
31  deps = []
32  if (ohos_build_target == "") {
33    remove_target_list = []
34    if (!ohos_build_userspace_only ||
35        (ohos_build_userspace_only && subsystem_name != "kernel" &&
36         subsystem_name != "vendor")) {
37      if (ohos_kernel_type == "liteos_m") {
38        remove_target_list = [ "${ohos_kernel_path}:build_kernel_image" ]
39      } else if (product_configed_component.component == "uniproton") {
40        remove_target_list = [ "//kernel/uniproton:build_kernel_image" ]
41      }
42    }
43    build_target_list = filter_exclude(lite_target_list, remove_target_list)
44    deps += build_target_list
45  } else {
46    deps += string_split(ohos_build_target, "&&")
47  }
48}
49
50group("product") {
51  deps = []
52
53  # build product, skip build single component scenario.
54  if (ohos_build_target == "") {
55    deps += [ "${product_path}" ]
56  }
57}
58
59group("ndk") {
60  # Add native API targets.
61  deps = []
62  if (ohos_build_ndk) {
63    deps += [ "//build/lite/ndk:ndk" ]
64  }
65}
66
67if (ohos_build_type == "debug" && product != "") {
68  action("gen_testfwk_info") {
69    outputs = [ "$root_out_dir/gen_testfwk_info.log" ]
70    script = "//build/lite/testfwk/gen_testfwk_info.py"
71    archive_dir_name = "test_info"
72    args = [
73      "--component-info-file",
74      rebase_path("${product_path}/config.json"),
75      "--output-json-fold",
76      rebase_path("${root_out_dir}/${archive_dir_name}/build_configs/"),
77      "--output-json-file-name",
78      "infos_for_testfwk.json",
79      "--output-module-list-files-fold",
80      rebase_path("${root_out_dir}/${archive_dir_name}/module_list_files/"),
81    ]
82  }
83}
84