# Copyright (c) 2024 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("//base/startup/appspawn/appspawn.gni")
import("//build/ohos.gni")

config("exported_header_files") {
  visibility = [ ":*" ]
  include_dirs = [ "${appspawn_innerkits_path}/include" ]
}

if (!defined(ohos_lite)) {
  ohos_shared_library("appspawn_client") {
    branch_protector_ret = "pac_ret"
    sources = [
      "${appspawn_path}/modules/sandbox/appspawn_permission.c",
      "../permission/appspawn_mount_permission.c",
      "appspawn_client.c",
      "appspawn_msg.c",
    ]
    include_dirs = [
      ".",
      "../include",
      "../permission",
      "${appspawn_path}/modules/module_engine/include",
      "${appspawn_path}",
      "${appspawn_path}/modules/sandbox",
      "${appspawn_path}/util/include",
    ]

    defines = [
      "APPSPAWN_CLIENT",
      "APPSPAWN_LABEL=\"APPSPAWN_CLIENT\"",
    ]

    if (defined(appspawn_sandbox_new) && appspawn_sandbox_new) {
      defines += [ "APPSPAWN_SANDBOX_NEW" ]
    }
    if (is_asan) {
      defines += [ "APPSPAWN_ASAN" ]
    }
    if (asan_detector || is_asan) {
      defines += [ "ASAN_DETECTOR" ]
    }
    public_configs = [ ":exported_header_files" ]
    version_script = "libappspawn_client.versionscript"

    deps = [ "${appspawn_path}/util:libappspawn_util" ]
    external_deps = [
      "cJSON:cjson",
      "c_utils:utils",
      "config_policy:configpolicy_util",
      "hilog:libhilog",
      "init:libbegetutil",
    ]
    subsystem_name = "${subsystem_name}"
    part_name = "${part_name}"
  }
} else {
  group("appspawn_client") {
  }
}