# Copyright (c) 2022 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.

#This was originally a compilation entry, but now "default" is added to the component dependency of build/common/bundle.json.
import("//build/ohos.gni")
group("default") {
  deps = [
    ":libstd.dylib.so",
    ":libtest.dylib.so",
  ]
}

ohos_prebuilt_shared_library("libstd.dylib.so") {
  if (current_cpu == "arm64") {
    source = "//prebuilts/rustc/linux-x86_64/current/lib/rustlib/aarch64-linux-ohos/lib/libstd.dylib.so"
  } else if (current_cpu == "arm") {
    source = "//prebuilts/rustc/linux-x86_64/current/lib/rustlib/armv7-linux-ohos/lib/libstd.dylib.so"
  } else if ((current_cpu == "x86_64" || current_cpu == "x64") &&
             current_os == "ohos") {
    source = "//prebuilts/rustc/linux-x86_64/current/lib/rustlib/x86_64-unknown-linux-ohos/lib/libstd.dylib.so"
  } else if (current_cpu == "x86_64" || current_cpu == "x64") {
    source =
        "//prebuilts/rustc/linux-x86_64/current/lib/libstd-b779f91b8eb0a330.so"
  }
  enable_strip = true
  install_images = [
    "system",
    "updater",
  ]
  output = "libstd.dylib.so"
  subsystem_name = "build"
  part_name = "build_framework"
}

ohos_prebuilt_shared_library("libtest.dylib.so") {
  if (current_cpu == "arm64") {
    source = "//prebuilts/rustc/linux-x86_64/current/lib/rustlib/aarch64-linux-ohos/lib/libtest.dylib.so"
  } else if (current_cpu == "arm") {
    source = "//prebuilts/rustc/linux-x86_64/current/lib/rustlib/armv7-linux-ohos/lib/libtest.dylib.so"
  } else if ((current_cpu == "x86_64" || current_cpu == "x64") &&
             current_os == "ohos") {
    source = "//prebuilts/rustc/linux-x86_64/current/lib/rustlib/x86_64-unknown-linux-ohos/lib/libtest.dylib.so"
  } else if (current_cpu == "x86_64" || current_cpu == "x64") {
    source =
        "//prebuilts/rustc/linux-x86_64/current/lib/libtest-167fcaac576ea811.so"
  } else {
    source = ""
  }
  install_images = [
    "system",
    "updater",
  ]
  enable_strip = true
  output = "libtest.dylib.so"
  subsystem_name = "build"
  part_name = "build_framework"
}