1# Copyright (c) 2021 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
14import("//build/config/clang/clang.gni")
15import("//build/ohos.gni")
16
17ohos_prebuilt_shared_library("libclang_rt.asan.so") {
18  enable_strip = true
19  mini_debug = true
20  if (target_cpu == "arm") {
21    source = "${clang_base_path}/lib/clang/$clang_version/lib/arm-linux-ohos/libclang_rt.asan.so"
22  } else if (target_cpu == "arm64") {
23    source = "${clang_base_path}/lib/clang/$clang_version/lib/aarch64-linux-ohos/libclang_rt.asan.so"
24  } else if (target_cpu == "x86_64") {
25    source = "${clang_base_path}/lib/clang/$clang_version/lib/x86_64-linux-ohos/libclang_rt.asan.so"
26  } else if (target_cpu == "riscv64") {
27    source = "${clang_base_path}/lib/clang/$clang_version/lib/riscv64-linux-ohos/libclang_rt.asan.so"
28  } else if (target_cpu == "loongarch64") {
29    source = "${clang_base_path}/lib/clang/$clang_version/lib/loongarch64-linux-ohos/libclang_rt.asan.so"
30  } else {
31    source = ""
32  }
33  deps = [ ":asan_unstripped_copy" ]
34  install_images = [
35    "system",
36    "ramdisk",
37    "updater",
38  ]
39  subsystem_name = "build"
40  part_name = "build_framework"
41}
42
43ohos_prebuilt_shared_library("libclang_rt.hwasan.so") {
44  enable_strip = true
45  mini_debug = true
46  source = "${clang_base_path}/lib/clang/$clang_version/lib/aarch64-linux-ohos/libclang_rt.hwasan.so"
47  install_images = [
48    "system",
49    "updater",
50  ]
51  if (use_hwasan) {
52    install_images += [ "ramdisk" ]
53  }
54  subsystem_name = "build"
55  part_name = "build_framework"
56}
57
58ohos_prebuilt_shared_library("libclang_rt.tsan.so") {
59  enable_strip = true
60  mini_debug = true
61  source = "${clang_base_path}/lib/clang/$clang_version/lib/aarch64-linux-ohos/libclang_rt.tsan.so"
62  if (is_tsan) {
63    deps = [ ":tsan_unstripped_copy" ]
64  }
65
66  install_images = [
67    "system",
68    "ramdisk",
69    "updater",
70  ]
71  subsystem_name = "build"
72  part_name = "build_framework"
73}
74
75ohos_prebuilt_etc("asan.options") {
76  source = "asan.options"
77  subsystem_name = "build"
78  part_name = "build_framework"
79}
80
81ohos_prebuilt_etc("asan.cfg") {
82  source = "asan.cfg"
83  module_install_dir = "etc/init/"
84  subsystem_name = "build"
85  part_name = "build_framework"
86}
87
88ohos_shared_library("asan_helper") {
89  sources = [ "asan_helper.c" ]
90  subsystem_name = "build"
91  part_name = "build_framework"
92}
93
94copy("asan_unstripped_copy") {
95  if (target_cpu == "arm") {
96    sources = [ "${clang_base_path}/lib/clang/$clang_version/lib/arm-linux-ohos/libclang_rt.asan.so" ]
97  } else if (target_cpu == "arm64") {
98    sources = [ "${clang_base_path}/lib/clang/$clang_version/lib/aarch64-linux-ohos/libclang_rt.asan.so" ]
99  } else if (target_cpu == "x86_64") {
100    sources = [ "${clang_base_path}/lib/clang/$clang_version/lib/x86_64-linux-ohos/libclang_rt.asan.so" ]
101  } else if (target_cpu == "riscv64") {
102    sources = [ "${clang_base_path}/lib/clang/$clang_version/lib/riscv64-linux-ohos/libclang_rt.asan.so" ]
103  } else if (target_cpu == "loongarch64") {
104    sources = [ "${clang_base_path}/lib/clang/$clang_version/lib/loongarch64-linux-ohos/libclang_rt.asan.so" ]
105  } else {
106    sources = [ "" ]
107  }
108  outputs = [ root_out_dir + "/lib.unstripped/clang/{{source_file_part}}" ]
109}
110
111copy("tsan_unstripped_copy") {
112  if (target_cpu == "arm") {
113    sources = [ "${clang_base_path}/lib/clang/$clang_version/lib/arm-linux-ohos/libclang_rt.tsan.so" ]
114  } else if (target_cpu == "arm64") {
115    sources = [ "${clang_base_path}/lib/clang/$clang_version/lib/aarch64-linux-ohos/libclang_rt.tsan.so" ]
116  } else if (target_cpu == "x86_64") {
117    sources = [ "${clang_base_path}/lib/clang/$clang_version/lib/x86_64-linux-ohos/libclang_rt.tsan.so" ]
118  } else {
119    sources = [ "" ]
120  }
121  outputs = [ root_out_dir + "/lib.unstripped/clang/{{source_file_part}}" ]
122}
123
124ohos_prebuilt_etc("tsan.options") {
125  source = "tsan.options"
126  subsystem_name = "build"
127  part_name = "build_framework"
128}
129