# Copyright (c) 2020-2021 Project CHIP Authors
#
# 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_overrides/chip.gni")
import("//build_overrides/jsoncpp.gni")
import("//build_overrides/nlassert.gni")
import("${chip_root}/src/crypto/crypto.gni")
import("${chip_root}/src/lib/core/core.gni")
import("${chip_root}/src/platform/device.gni")

declare_args() {
  chip_build_example_creds = true
  update_last_known_good_time = false
}

action("gen_build_time_header") {
  script = "${chip_root}/build/chip/write_build_time_header.py"

  header_file = "FirmwareBuildTime.h"
  include_dir = "${root_gen_dir}/include"
  outputs = [ "${include_dir}/${header_file}" ]

  args = [
    "--output",
    header_file,
    "--gen-dir",
    rebase_path(include_dir, root_build_dir),
  ]
  if (update_last_known_good_time) {
    args += [ "--use-current-time" ]
  }

  visibility = [ ":build_time_header" ]
}

source_set("build_time_header") {
  sources = get_target_outputs(":gen_build_time_header")
  deps = [ ":gen_build_time_header" ]
}

source_set("credentials_header") {
  sources = [
    "CHIPCert.h",
    "DeviceAttestationCredsProvider.h",
  ]
}

static_library("credentials") {
  output_name = "libCredentials"

  sources = [
    "CHIPCert.cpp",
    "CHIPCert.h",
    "CHIPCertFromX509.cpp",
    "CHIPCertToX509.cpp",
    "CHIPCert_Internal.h",
    "CHIPCertificateSet.h",
    "CertificateValidityPolicy.h",
    "CertificationDeclaration.cpp",
    "CertificationDeclaration.h",
    "DeviceAttestationConstructor.cpp",
    "DeviceAttestationConstructor.h",
    "DeviceAttestationCredsProvider.cpp",
    "DeviceAttestationCredsProvider.h",
    "DeviceAttestationVendorReserved.h",
    "FabricTable.cpp",
    "FabricTable.h",
    "GenerateChipX509Cert.cpp",
    "GroupDataProvider.h",
    "GroupDataProviderImpl.cpp",
    "GroupDataProviderImpl.h",
    "LastKnownGoodTime.cpp",
    "LastKnownGoodTime.h",
    "OperationalCertificateStore.h",
    "PersistentStorageOpCertStore.cpp",
    "PersistentStorageOpCertStore.h",
    "TestOnlyLocalCertificateAuthority.h",
    "attestation_verifier/DeviceAttestationDelegate.h",
    "attestation_verifier/DeviceAttestationVerifier.cpp",
    "attestation_verifier/DeviceAttestationVerifier.h",
  ]

  if (chip_build_example_creds) {
    sources += [
      "examples/DeviceAttestationCredsExample.cpp",
      "examples/DeviceAttestationCredsExample.h",
      "examples/ExampleDACs.cpp",
      "examples/ExampleDACs.h",
      "examples/ExamplePAI.cpp",
      "examples/ExamplePAI.h",
      "examples/LastKnownGoodTimeCertificateValidityPolicyExample.h",
      "examples/StrictCertificateValidityPolicyExample.h",
    ]
  }

  # TODO: These tests files should be removed after the DeviceAttestationCredsExample implementation
  # is changed to generate it's own credentials instead of using Test credentials.
  # For some platforms test builds, which are bilding monolithic test library these files are not needed.
  import("${chip_root}/build/chip/tests.gni")
  if (!(chip_build_tests && (chip_device_platform == "mbed" ||
                             chip_device_platform == "openiotsdk" ||
                             chip_device_platform == "nrfconnect"))) {
    sources += [
      "tests/CHIPAttCert_test_vectors.cpp",
      "tests/CHIPAttCert_test_vectors.h",
    ]
  }

  if (chip_device_platform == "esp32" || chip_device_platform == "nrfconnect" ||
      chip_device_platform == "efr32" || chip_device_platform == "openiotsdk") {
    defines = [ "CURRENT_TIME_NOT_IMPLEMENTED=1" ]
  }

  cflags = [ "-Wconversion" ]

  public_deps = [
    ":build_time_header",
    "${chip_root}/src/controller:delegates",
    "${chip_root}/src/crypto",
    "${chip_root}/src/lib/asn1",
    "${chip_root}/src/lib/core",
    "${chip_root}/src/lib/core:types",
    "${chip_root}/src/lib/support",
    "${chip_root}/src/platform",
    "${chip_root}/src/protocols:type_definitions",
    "${chip_root}/src/tracing",
    "${chip_root}/src/tracing:macros",
    "${nlassert_root}:nlassert",
  ]
}

source_set("test_paa_store") {
  sources = [
    "attestation_verifier/TestPAAStore.cpp",
    "attestation_verifier/TestPAAStore.h",
  ]

  public_deps = [ "${chip_root}/src/lib/support:span" ]
}

static_library("default_attestation_verifier") {
  output_name = "libDefaultAttestationVerifier"

  sources = [
    "attestation_verifier/DacOnlyPartialAttestationVerifier.cpp",
    "attestation_verifier/DacOnlyPartialAttestationVerifier.h",
    "attestation_verifier/DefaultDeviceAttestationVerifier.cpp",
    "attestation_verifier/DefaultDeviceAttestationVerifier.h",
    "attestation_verifier/DeviceAttestationDelegate.h",
  ]

  if (chip_device_platform == "esp32" || chip_device_platform == "nrfconnect" ||
      chip_device_platform == "efr32" || chip_device_platform == "openiotsdk") {
    defines = [ "CURRENT_TIME_NOT_IMPLEMENTED=1" ]
  }

  public_deps = [
    ":credentials",
    ":test_paa_store",
    "${chip_root}/src/crypto",
    "${nlassert_root}:nlassert",
  ]
}

static_library("file_attestation_trust_store") {
  output_name = "libFileAttestationTrustStore"

  sources = [
    "attestation_verifier/FileAttestationTrustStore.cpp",
    "attestation_verifier/FileAttestationTrustStore.h",
  ]

  public_deps = [
    ":credentials",
    "${nlassert_root}:nlassert",
  ]
}

static_library("test_dac_revocation_delegate") {
  output_name = "libTestDACRevocationDelegate"

  sources = [
    "attestation_verifier/TestDACRevocationDelegateImpl.cpp",
    "attestation_verifier/TestDACRevocationDelegateImpl.h",
  ]

  public_deps = [
    ":credentials",
    jsoncpp_root,
  ]
}
