# 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/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",
    "CHIPCertificateSet.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",
    "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/crypto",
    "${chip_root}/src/lib/asn1",
    "${chip_root}/src/lib/core",
    "${chip_root}/src/lib/support",
    "${chip_root}/src/platform",
    "${chip_root}/src/protocols:type_definitions",
    "${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",
  ]
}
