# 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
}

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),
  ]

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