Hhlzhangajfix arm64
fde687c3创建于 3月15日历史提交
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License

import("//build/config/clang/clang.gni")
import("//build/config/ohos/musl.gni")
import("//build/ohos.gni")

group("musl_install") {
  deps = [
    ":musl-libcxx.so",
    ":musl_ld_path_etc_cfg",
    "//third_party/musl:musl_libs",
  ]

  if (target_cpu == "riscv64") {
    deps += [
      ":ld-musl-riscv64.so.1",
      ":musl-libc.so",
    ]
  } else if (musl_arch == "aarch64") {
    deps += [
      ":ld-musl-arm.so.1",
      ":ld-musl-arm.so.1_arm64e",
      ":musl-libcxx.so_arm64e",
    ]
  } else {
    deps += [
      ":ld-musl-arm.so.1" 
    ]
  }
}

if (target_cpu == "riscv64") {
  ohos_prebuilt_shared_library("ld-musl-riscv64.so.1") {
    deps = [ "//third_party/musl:soft_create_linker" ]
    if (is_asan || is_tsan) {
      asan = "-asan"
    } else {
      asan = ""
    }

    _muls_linker_so =
        "${root_out_dir}/common/common/libc/ld-musl-${musl_arch}${asan}.so.1"
    source = _muls_linker_so
    install_enable = true
    install_images = [
      "system",
      "updater",
      "ramdisk",
    ]
    subsystem_name = "build"
    part_name = "build_framework"
    module_install_dir = "lib"
  }
} else {
  ohos_prebuilt_shared_library("ld-musl-arm.so.1") {
    innerapi_tags = [ "llndk" ]
    deps = [ "//third_party/musl:soft_create_linker" ]
    if (musl_arch == "aarch64") {
      deps += [ "//third_party/musl:soft_create_linker_sp" ]
    }
    if (is_asan || is_tsan) {
      asan = "-asan"
    } else {
      asan = ""
    }

    _musl_linker_so =
        "${root_out_dir}/common/common/libc/./ld-musl-${musl_arch}${asan}.so.1"
    source = _musl_linker_so
    install_enable = true
    install_images = [
      "system",
      "updater",
      "ramdisk",
    ]
    if (target_cpu == "arm") {
      symlink_ext = [ "lib/libc.so" ]
    } else if (target_cpu == "arm64" || target_cpu == "x86_64") {
      symlink_ext = [ "lib64/libc.so" ]
    }
    subsystem_name = "build"
    part_name = "build_framework"
    module_install_dir = "lib"
  }
  
  if (musl_arch == "aarch64") {
    ohos_prebuilt_shared_library("ld-musl-arm.so.1_arm64e") {
      innerapi_tags = [ "llndk" ]
      deps = [ "//third_party/musl:soft_create_linker" ]
      if (musl_arch == "aarch64") {
        deps += [ "//third_party/musl:soft_create_linker_sp" ]
      }
      if (is_asan || is_tsan) {
        asan = "-asan"
      } else {
        asan = ""
      }

      _musl_linker_so =
          "${root_out_dir}/common/common/libc/./arm64e/ld-musl-${musl_arch}${asan}.so.1"
      source = _musl_linker_so
      install_enable = true
      install_images = [
        "system_arm64e"
      ]
      if (target_cpu == "arm") {
        symlink_ext = [ "lib/libc.so" ]
      } else if (target_cpu == "arm64" || target_cpu == "x86_64") {
        symlink_ext = [ "lib64/libc.so" ]
      }
      subsystem_name = "build"
      part_name = "build_framework"
      module_install_dir = "lib"
    }
  }
}

ohos_prebuilt_shared_library("musl-libc.so") {
  deps = [ "//third_party/musl:soft_libc_musl_shared" ]
  source = "${musl_sysroot}/usr/lib/${musl_target_triple}/libc.so"
  install_images = [
    "system",
    "updater",
    "ramdisk",
  ]
  subsystem_name = "build"
  part_name = "build_framework"
  innerapi_tags = [ "chipsetsdk" ]
  relative_install_dir = ""
}

ohos_prebuilt_etc("musl_ld_path_etc_cfg") {
  if (target_cpu == "arm") {
    source = "ld-musl-arm.path"
  } else if (target_cpu == "riscv64") {
    source = "ld-musl-riscv64.path"
  } else {
    source = "ld-musl-aarch64.path"
  }
  if (is_asan || is_tsan) {
    output = string_replace(source, ".path", "-asan.path")
  }
  install_images = [
    "system",
    "updater",
    "ramdisk",
  ]
  subsystem_name = "build"
  part_name = "build_framework"
}

ohos_prebuilt_shared_library("musl-libcxx.so") {
  enable_strip = true
  mini_debug = true
  if (is_asan == true && use_hwasan == true && target_cpu == "arm64") {
    source = "${clang_base_path}/lib/aarch64-linux-ohos/hwasan/libc++.so"
  } else {
    source = "${standard_clang_path}/libc++.so"
  }
  deps = [ ":musl-libcxx_unstripped_copy" ]
  install_images = [
    "system",
    "updater",
    "ramdisk",
  ]
  subsystem_name = "build"
  part_name = "build_framework"
  innerapi_tags = [ "chipsetsdk_sp" ]
}

ohos_prebuilt_shared_library("musl-libcxx.so_arm64e") {
  enable_strip = true
  mini_debug = true
  if (is_asan == true && use_hwasan == true && target_cpu == "arm64") {
    source = "${clang_base_path}/lib/aarch64-linux-ohos/hwasan/arm64e/libc++.so"
  } else {
    source = "${standard_clang_path}/libc++.so"
    output = "${standard_clang_path}/arm64e/libc++.so"
  }
  deps = [ ":musl-libcxx_arm64e_unstripped_copy" ]
  install_images = [
    "system_arm64e"
  ]
  subsystem_name = "build"
  part_name = "build_framework"
  innerapi_tags = [ "chipsetsdk_sp" ]
}

copy("musl-libcxx_unstripped_copy") {
  sources = [ "${standard_clang_path}/libc++.so" ]
  outputs = [ root_out_dir + "/lib.unstripped/clang/{{source_file_part}}" ]
}

copy("musl-libcxx_arm64e_unstripped_copy") {
  sources = [ "${standard_clang_path}/libc++.so" ]
  outputs = [ root_out_dir + "/lib.unstripped/clang/arm64e/{{source_file_part}}" ]
}