• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2013 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import("//build/config/clang/clang.gni")
6import("//build/config/ohos/config.gni")
7import("//build/toolchain/gcc_toolchain.gni")
8
9declare_args() {
10  # Whether unstripped binaries, i.e. compiled with debug symbols, should be
11  # considered runtime_deps rather than stripped ones.
12  ohos_unstripped_runtime_outputs = true
13}
14
15# The ohos clang toolchains share most of the same parameters, so we have this
16# wrapper around gcc_toolchain to avoid duplication of logic.
17#
18# Parameters:
19#  - toolchain_root
20#      Path to cpu-specific toolchain within the ndk.
21#  - sysroot
22#      Sysroot for this architecture.
23#  - lib_dir
24#      Subdirectory inside of sysroot where libs go.
25#  - binary_prefix
26#      Prefix of compiler executables.
27template("ohos_clang_toolchain") {
28  gcc_toolchain(target_name) {
29    assert(defined(invoker.toolchain_args),
30           "toolchain_args must be defined for ohos_clang_toolchain()")
31    toolchain_args = invoker.toolchain_args
32    toolchain_args.current_os = "ohos"
33
34    # Output linker map files for binary size analysis.
35    enable_linker_map = true
36
37    ohos_libc_dir =
38        rebase_path(invoker.sysroot + "/" + invoker.lib_dir, root_build_dir)
39    libs_section_prefix = "${ohos_libc_dir}/Scrt1.o"
40    libs_section_prefix += " ${ohos_libc_dir}/crti.o"
41    libs_section_postfix = "${ohos_libc_dir}/crtn.o"
42
43    _prefix = rebase_path("${clang_base_path}/bin", root_build_dir)
44    cc = "${_prefix}/clang"
45    cxx = "${_prefix}/clang++"
46    ar = "${_prefix}/llvm-ar"
47    ld = cxx
48    readelf = "${_prefix}/llvm-readobj"
49    nm = "${_prefix}/llvm-nm"
50    strip = rebase_path("${clang_base_path}/bin/llvm-strip", root_build_dir)
51    use_unstripped_as_runtime_outputs = ohos_unstripped_runtime_outputs
52
53    # Don't use .cr.so for loadable_modules since they are always loaded via
54    # absolute path.
55    loadable_module_extension = ".so"
56  }
57}
58