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) { 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) { 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) { 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 if (target_cpu == "arm") { 123 source = "${clang_base_path}/lib/arm-linux-ohos/libc++.so" 124 } else if (target_cpu == "arm64") { 125 source = "${clang_base_path}/lib/aarch64-linux-ohos/libc++.so" 126 } else if (target_cpu == "x86_64") { 127 source = "${clang_base_path}/lib/x86_64-linux-ohos/libc++.so" 128 } else if (target_cpu == "riscv64") { 129 source = "${clang_base_path}/lib/riscv64-linux-ohos/libc++.so" 130 } else { 131 source = "" 132 } 133 deps = [ ":musl-libcxx_unstripped_copy" ] 134 install_images = [ 135 "system", 136 "updater", 137 "ramdisk", 138 ] 139 subsystem_name = "build" 140 part_name = "build_framework" 141 innerapi_tags = [ "chipsetsdk" ] 142 relative_install_dir = "" 143} 144 145copy("musl-libcxx_unstripped_copy") { 146 if (target_cpu == "arm") { 147 sources = [ "${clang_base_path}/lib/arm-linux-ohos/libc++.so" ] 148 } else if (target_cpu == "arm64") { 149 sources = [ "${clang_base_path}/lib/aarch64-linux-ohos/libc++.so" ] 150 } else if (target_cpu == "x86_64") { 151 sources = [ "${clang_base_path}/lib/x86_64-linux-ohos/libc++.so" ] 152 } else if (target_cpu == "riscv64") { 153 sources = [ "${clang_base_path}/lib/riscv64-linux-ohos/libc++.so" ] 154 } else { 155 sources = [ "" ] 156 } 157 outputs = [ root_out_dir + "/lib.unstripped/clang/{{source_file_part}}" ] 158} 159