# Copyright (c) 2023-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")

config("common_config") {
  cflags = [
    "-Wall",
    "-Wundef",
    "-Wdeclaration-after-statement",
    "-Wimplicit-fallthrough",
    "-Wmissing-field-initializers",
    "-Wmissing-prototypes",
    "-Wstrict-prototypes",
    "-Wunused-parameter",
    "-Wvla",
    "-Wno-deprecated-declarations",
  ]
}

config("libfsverity_public_config") {
  include_dirs = [
    "include",
    "common",
  ]
}

ohos_shared_library("libfsverity_utils") {
  branch_protector_ret = "pac_ret"
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }
  sources = [
    "lib/compute_digest.c",
    "lib/enable.c",
    "lib/hash_algs.c",
    "lib/sign_digest.c",
    "lib/utils.c",
  ]
  external_deps = [ "openssl:libcrypto_shared" ]
  configs = [ ":common_config" ]
  public_configs = [ ":libfsverity_public_config" ]
  install_enable = true

  output_name = "libfsverity_utils"
  part_name = "fsverity-utils"
  subsystem_name = "thirdparty"
  install_images = [ "system" ]
}

ohos_static_library("libfsverity_utils_static") {
  branch_protector_ret = "pac_ret"
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }
  sources = [
    "lib/compute_digest.c",
    "lib/enable.c",
    "lib/hash_algs.c",
    "lib/sign_digest.c",
    "lib/utils.c",
  ]
  include_dirs = [
    "include",
    "common",
  ]
  configs = [ ":common_config" ]
  external_deps = [ "openssl:libcrypto_static" ]
}