# 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",
    "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/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",
  ]
}
