• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2022 HiHope Open Source Organization .
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
14if (ohos_kernel_type == "liteos_m") {
15  import("//build/lite/config/component/lite_component.gni")
16  import("//build/lite/config/subsystem/lite_subsystem.gni")
17  import("//kernel/liteos_m/liteos.gni")
18  module_name = get_path_info(rebase_path("."), "name")
19  module_group(module_name) {
20    modules = [ "board" ]
21  }
22
23  # global config
24  out_product_path = "${ohos_root_path}out/${board_name}/${product_name}"
25
26  # config bin from vendor/<board_name>/<product_name>/config.json
27  foreach(bin_file, bin_list) {
28    build_enable = bin_file.enable
29    out_bin_path = "${out_product_path}/bin/"
30
31    exe_bin = "${bin_file.elf_name}_${board_name}"
32    print("build", exe_bin, ":", build_enable)
33
34    # generate execute bin
35    executable(exe_bin) {
36      output_name = exe_bin
37      output_extension = "elf"
38
39      ldflags = [
40        "-Wl,--gc-sections",
41        "-Wl,-Map=bin/$output_name.map",
42      ]
43
44      deps = []
45
46      if (build_enable == "true") {
47        # force link invisible function ,which ar to lib
48        ldflags += [
49          "-L" + "${out_product_path}/libs",
50          "-Wl,--whole-archive",
51        ]
52        foreach(force_link_lib, bin_file.force_link_libs) {
53          ldflags += [ "-l${force_link_lib}" ]
54        }
55        ldflags += [ "-Wl,--no-whole-archive" ]
56
57        deps += [ "//test/xts/tools/lite:tools" ]
58        deps += [ "//test/xts/acts/build_lite:acts" ]
59      }
60      deps += [ "//build/lite:ohos" ]
61      deps += [ "//build/lite:product" ]
62      deps += [ "//base/startup/init/interfaces/innerkits:libbegetutil" ]
63    }
64
65    build_ext_component("build_kernel_image") {
66      deps = [ ":${exe_bin}" ]
67
68      output_name = exe_bin
69      exec_path = out_bin_path
70
71      objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix"
72      objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
73
74      command = "$objcopy -O binary $output_name.elf $output_name.bin"
75      command += " && sh -c '$objdump -t $output_name.elf | sort >$output_name.sym.sorted'"
76      command += " && sh -c '$objdump -d $output_name.elf >$output_name.asm'"
77    }
78
79    build_ext_component("build_image") {
80      deps = [ ":build_kernel_image" ]
81
82      exec_path = "${ohos_root_path}${ohos_vendor_adapter_dir}"
83
84      print("out_bin_path:", out_bin_path)
85      command = "./tools/aft_build_project.sh ${exe_bin} ${out_bin_path}"
86    }
87  }
88}
89