15f9996aaSopenharmony_ci# Copyright (c) 2022 Huawei Device Co., Ltd.
25f9996aaSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
35f9996aaSopenharmony_ci# you may not use this file except in compliance with the License.
45f9996aaSopenharmony_ci# You may obtain a copy of the License at
55f9996aaSopenharmony_ci#
65f9996aaSopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
75f9996aaSopenharmony_ci#
85f9996aaSopenharmony_ci# Unless required by applicable law or agreed to in writing, software
95f9996aaSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
105f9996aaSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
115f9996aaSopenharmony_ci# See the License for the specific language governing permissions and
125f9996aaSopenharmony_ci# limitations under the License.
135f9996aaSopenharmony_ci
145f9996aaSopenharmony_ciif (is_ohos) {
155f9996aaSopenharmony_ci  import("//build/config/ohos/config.gni")
165f9996aaSopenharmony_ci  import("//build/ohos.gni")
175f9996aaSopenharmony_ci  group("ubsan") {
185f9996aaSopenharmony_ci    deps = [
195f9996aaSopenharmony_ci      ":libclang_rt.ubsan_minimal.so",
205f9996aaSopenharmony_ci      ":libclang_rt.ubsan_standalone.so",
215f9996aaSopenharmony_ci      ":ubsan.cfg",
225f9996aaSopenharmony_ci    ]
235f9996aaSopenharmony_ci  }
245f9996aaSopenharmony_ci
255f9996aaSopenharmony_ci  ohos_prebuilt_etc("ubsan.cfg") {
265f9996aaSopenharmony_ci    source = "ubsan.cfg"
275f9996aaSopenharmony_ci    module_install_dir = "etc/init/"
285f9996aaSopenharmony_ci    subsystem_name = "build"
295f9996aaSopenharmony_ci    part_name = "build_framework"
305f9996aaSopenharmony_ci  }
315f9996aaSopenharmony_ci
325f9996aaSopenharmony_ci  ohos_prebuilt_shared_library("libclang_rt.ubsan_standalone.so") {
335f9996aaSopenharmony_ci    enable_strip = true
345f9996aaSopenharmony_ci    mini_debug = true
355f9996aaSopenharmony_ci    source =
365f9996aaSopenharmony_ci        "${clang_lib_base_path}/${abi_target}/libclang_rt.ubsan_standalone.so"
375f9996aaSopenharmony_ci    install_images = [
385f9996aaSopenharmony_ci      "system",
395f9996aaSopenharmony_ci      "updater",
405f9996aaSopenharmony_ci    ]
415f9996aaSopenharmony_ci    innerapi_tags = [
425f9996aaSopenharmony_ci      "platformsdk",
435f9996aaSopenharmony_ci      "chipsetsdk",
445f9996aaSopenharmony_ci    ]
455f9996aaSopenharmony_ci    deps = [ ":ubsan_standalone_unstripped_copy" ]
465f9996aaSopenharmony_ci    subsystem_name = "build"
475f9996aaSopenharmony_ci    part_name = "build_framework"
485f9996aaSopenharmony_ci  }
495f9996aaSopenharmony_ci
505f9996aaSopenharmony_ci  ohos_prebuilt_shared_library("libclang_rt.ubsan_minimal.so") {
515f9996aaSopenharmony_ci    enable_strip = true
525f9996aaSopenharmony_ci    mini_debug = true
535f9996aaSopenharmony_ci    source = "${clang_lib_base_path}/${abi_target}/libclang_rt.ubsan_minimal.so"
545f9996aaSopenharmony_ci    install_images = [
555f9996aaSopenharmony_ci      "system",
565f9996aaSopenharmony_ci      "updater",
575f9996aaSopenharmony_ci    ]
585f9996aaSopenharmony_ci    deps = [ ":ubsan_minimal_unstripped_copy" ]
595f9996aaSopenharmony_ci    innerapi_tags = [
605f9996aaSopenharmony_ci      "platformsdk",
615f9996aaSopenharmony_ci      "chipsetsdk",
625f9996aaSopenharmony_ci    ]
635f9996aaSopenharmony_ci    subsystem_name = "build"
645f9996aaSopenharmony_ci    part_name = "build_framework"
655f9996aaSopenharmony_ci  }
665f9996aaSopenharmony_ci}
675f9996aaSopenharmony_ci
685f9996aaSopenharmony_cicopy("ubsan_standalone_unstripped_copy") {
695f9996aaSopenharmony_ci  sources =
705f9996aaSopenharmony_ci      [ "${clang_lib_base_path}/${abi_target}/libclang_rt.ubsan_standalone.so" ]
715f9996aaSopenharmony_ci  outputs = [ root_out_dir + "/lib.unstripped/clang/{{source_file_part}}" ]
725f9996aaSopenharmony_ci}
735f9996aaSopenharmony_ci
745f9996aaSopenharmony_cicopy("ubsan_minimal_unstripped_copy") {
755f9996aaSopenharmony_ci  sources =
765f9996aaSopenharmony_ci      [ "${clang_lib_base_path}/${abi_target}/libclang_rt.ubsan_minimal.so" ]
775f9996aaSopenharmony_ci  outputs = [ root_out_dir + "/lib.unstripped/clang/{{source_file_part}}" ]
785f9996aaSopenharmony_ci}
79