# 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("//build/ohos.gni")
import("//developtools/hdc/hdc.gni")

ohos_executable("exec_sudo") {
  if (hdc_feature_support_sudo) {
    sources = [
      "src/main.cpp",
      "src/sudo_iam.cpp",
    ]
    sanitize = {
      cfi = true
      cfi_cross_dso = true
      cfi_vcall_icall_only = true
      debug = false
    }

    deps = []

    external_deps = [
      "c_utils:utils",
      "ipc:ipc_single",
      "os_account:account_iam_innerkits",
      "os_account:os_account_innerkits",
      "pin_auth:pinauth_framework",
      "user_auth_framework:userauth_client",
      "access_control_level_manager:aclmgr_sdk",
      "i18n:intl_util",
    ]

    defines = [ "HAS_PIN_AUTH_PART" ]

    if (build_selinux) {
      external_deps += [ "selinux:libselinux" ]
      defines += [ "SURPPORT_SELINUX" ]
    }

    if (hdc_support_account_constraint) {
      defines += [ "SURPPORT_ACCOUNT_CONSTRAINT" ]
    }

    if (hdc_feature_support_usr_symlink) {
      symlink_target_name = [
        "../usr/bin/sudo",
      ]
    }

    subsystem_name = "developtools"
    output_name = "sudo"
    part_name = "hdc"
  }
}

group("sudo") {
  if (hdc_feature_support_sudo) {
    deps = [ ":exec_sudo" ]
  }
}