1# Copyright (c) 2022 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
14if (is_ohos) {
15  import("//build/config/ohos/config.gni")
16  import("//build/ohos.gni")
17  group("ubsan") {
18    deps = [
19      ":libclang_rt.ubsan_minimal.so",
20      ":libclang_rt.ubsan_standalone.so",
21      ":ubsan.cfg",
22    ]
23  }
24
25  ohos_prebuilt_etc("ubsan.cfg") {
26    source = "ubsan.cfg"
27    module_install_dir = "etc/init/"
28    subsystem_name = "build"
29    part_name = "build_framework"
30  }
31
32  ohos_prebuilt_shared_library("libclang_rt.ubsan_standalone.so") {
33    enable_strip = true
34    mini_debug = true
35    source =
36        "${clang_lib_base_path}/${abi_target}/libclang_rt.ubsan_standalone.so"
37    install_images = [
38      "system",
39      "updater",
40    ]
41    innerapi_tags = [
42      "platformsdk",
43      "chipsetsdk",
44    ]
45    deps = [ ":ubsan_standalone_unstripped_copy" ]
46    subsystem_name = "build"
47    part_name = "build_framework"
48  }
49
50  ohos_prebuilt_shared_library("libclang_rt.ubsan_minimal.so") {
51    enable_strip = true
52    mini_debug = true
53    source = "${clang_lib_base_path}/${abi_target}/libclang_rt.ubsan_minimal.so"
54    install_images = [
55      "system",
56      "updater",
57    ]
58    deps = [ ":ubsan_minimal_unstripped_copy" ]
59    innerapi_tags = [
60      "platformsdk",
61      "chipsetsdk",
62    ]
63    subsystem_name = "build"
64    part_name = "build_framework"
65  }
66}
67
68copy("ubsan_standalone_unstripped_copy") {
69  sources =
70      [ "${clang_lib_base_path}/${abi_target}/libclang_rt.ubsan_standalone.so" ]
71  outputs = [ root_out_dir + "/lib.unstripped/clang/{{source_file_part}}" ]
72}
73
74copy("ubsan_minimal_unstripped_copy") {
75  sources =
76      [ "${clang_lib_base_path}/${abi_target}/libclang_rt.ubsan_minimal.so" ]
77  outputs = [ root_out_dir + "/lib.unstripped/clang/{{source_file_part}}" ]
78}
79