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/config/ohos/musl.gni") 16import("//build/ohos.gni") 17 18group("musl_install") { 19 deps = [ 20 ":musl-libcxx.so", 21 ":musl_ld_path_etc_cfg", 22 "//third_party/musl:musl_libs", 23 ] 24 25 if (target_cpu == "riscv64") { 26 deps += [ 27 ":ld-musl-riscv64.so.1", 28 ":musl-libc.so", 29 ] 30 } else { 31 deps += [ ":ld-musl-arm.so.1" ] 32 } 33} 34 35if (target_cpu == "riscv64") { 36 ohos_prebuilt_shared_library("ld-musl-riscv64.so.1") { 37 deps = [ "//third_party/musl:soft_create_linker" ] 38 if (is_asan || is_tsan) { 39 asan = "-asan" 40 } else { 41 asan = "" 42 } 43 44 _muls_linker_so = 45 "${root_out_dir}/common/common/libc/ld-musl-${musl_arch}${asan}.so.1" 46 source = _muls_linker_so 47 install_enable = true 48 install_images = [ 49 "system", 50 "updater", 51 "ramdisk", 52 ] 53 subsystem_name = "build" 54 part_name = "build_framework" 55 module_install_dir = "lib" 56 } 57} else { 58 ohos_prebuilt_shared_library("ld-musl-arm.so.1") { 59 deps = [ "//third_party/musl:soft_create_linker" ] 60 if (is_asan || is_tsan) { 61 asan = "-asan" 62 } else { 63 asan = "" 64 } 65 66 _musl_linker_so = 67 "${root_out_dir}/common/common/libc/./ld-musl-${musl_arch}${asan}.so.1" 68 source = _musl_linker_so 69 install_enable = true 70 install_images = [ 71 "system", 72 "updater", 73 "ramdisk", 74 ] 75 if (target_cpu == "arm") { 76 symlink_ext = [ "lib/libc.so" ] 77 } else if (target_cpu == "arm64" || target_cpu == "x86_64") { 78 symlink_ext = [ "lib64/libc.so" ] 79 } 80 subsystem_name = "build" 81 part_name = "build_framework" 82 module_install_dir = "lib" 83 } 84} 85 86ohos_prebuilt_shared_library("musl-libc.so") { 87 deps = [ "//third_party/musl:soft_libc_musl_shared" ] 88 source = "${musl_sysroot}/usr/lib/${musl_target_triple}/libc.so" 89 install_images = [ 90 "system", 91 "updater", 92 "ramdisk", 93 ] 94 subsystem_name = "build" 95 part_name = "build_framework" 96 innerapi_tags = [ "chipsetsdk" ] 97 relative_install_dir = "" 98} 99 100ohos_prebuilt_etc("musl_ld_path_etc_cfg") { 101 if (target_cpu == "arm") { 102 source = "ld-musl-arm.path" 103 } else if (target_cpu == "riscv64") { 104 source = "ld-musl-riscv64.path" 105 } else { 106 source = "ld-musl-aarch64.path" 107 } 108 if (is_asan || is_tsan) { 109 output = string_replace(source, ".path", "-asan.path") 110 } 111 install_images = [ 112 "system", 113 "updater", 114 "ramdisk", 115 ] 116 subsystem_name = "build" 117 part_name = "build_framework" 118} 119 120ohos_prebuilt_shared_library("musl-libcxx.so") { 121 enable_strip = true 122 mini_debug = true 123 if (target_cpu == "arm") { 124 source = "${clang_base_path}/lib/arm-linux-ohos/libc++.so" 125 } else if (target_cpu == "arm64") { 126 source = "${clang_base_path}/lib/aarch64-linux-ohos/libc++.so" 127 } else if (target_cpu == "x86_64") { 128 source = "${clang_base_path}/lib/x86_64-linux-ohos/libc++.so" 129 } else if (target_cpu == "riscv64") { 130 source = "${clang_base_path}/lib/riscv64-linux-ohos/libc++.so" 131 } else if (target_cpu == "loongarch64") { 132 source = "${clang_base_path}/lib/loongarch64-linux-ohos/libc++.so" 133 } else { 134 source = "" 135 } 136 deps = [ ":musl-libcxx_unstripped_copy" ] 137 install_images = [ 138 "system", 139 "updater", 140 "ramdisk", 141 ] 142 subsystem_name = "build" 143 part_name = "build_framework" 144 innerapi_tags = [ "chipsetsdk" ] 145 relative_install_dir = "" 146} 147 148copy("musl-libcxx_unstripped_copy") { 149 if (target_cpu == "arm") { 150 sources = [ "${clang_base_path}/lib/arm-linux-ohos/libc++.so" ] 151 } else if (target_cpu == "arm64") { 152 sources = [ "${clang_base_path}/lib/aarch64-linux-ohos/libc++.so" ] 153 } else if (target_cpu == "x86_64") { 154 sources = [ "${clang_base_path}/lib/x86_64-linux-ohos/libc++.so" ] 155 } else if (target_cpu == "riscv64") { 156 sources = [ "${clang_base_path}/lib/riscv64-linux-ohos/libc++.so" ] 157 } else if (target_cpu == "loongarch64") { 158 sources = [ "${clang_base_path}/lib/loongarch64-linux-ohos/libc++.so" ] 159 } else { 160 sources = [ "" ] 161 } 162 outputs = [ root_out_dir + "/lib.unstripped/clang/{{source_file_part}}" ] 163} 164