# Copyright (c) 2020 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/build.gni")
import("//build_overrides/chip.gni")

import("${chip_root}/build/chip/tools.gni")
import("${chip_root}/examples/chip-tool/chip-tool.gni")
import("${chip_root}/src/lib/core/core.gni")

if (config_use_interactive_mode) {
  import("//build_overrides/editline.gni")
}

assert(chip_build_tools)

config("config") {
  include_dirs = [
    ".",
    "${chip_root}/examples/common",
    "${chip_root}/zzz_generated/app-common/app-common",
    "${chip_root}/zzz_generated/chip-tool",
    "${chip_root}/src/lib",
  ]

  defines = [
    "CONFIG_USE_LOCAL_STORAGE=${config_use_local_storage}",
    "CONFIG_USE_SEPARATE_EVENTLOOP=${config_use_separate_eventloop}",
    "CONFIG_USE_INTERACTIVE_MODE=${config_use_interactive_mode}",
    "CONFIG_ENABLE_YAML_TESTS=${config_enable_yaml_tests}",
  ]

  cflags = [ "-Wconversion" ]
}

static_library("chip-tool-utils") {
  sources = [
    "${chip_root}/src/app/tests/suites/include/ConstraintsChecker.h",
    "${chip_root}/src/app/tests/suites/include/ValueChecker.h",
    "${chip_root}/src/controller/ExamplePersistentStorage.cpp",
    "${chip_root}/src/controller/ExamplePersistentStorage.h",
    "${chip_root}/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp",
    "${chip_root}/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp",
    "commands/clusters/ModelCommand.cpp",
    "commands/clusters/ModelCommand.h",
    "commands/common/CHIPCommand.cpp",
    "commands/common/CHIPCommand.h",
    "commands/common/Command.cpp",
    "commands/common/Command.h",
    "commands/common/Commands.cpp",
    "commands/common/Commands.h",
    "commands/common/CredentialIssuerCommands.h",
    "commands/common/HexConversion.h",
    "commands/common/RemoteDataModelLogger.cpp",
    "commands/common/RemoteDataModelLogger.h",
    "commands/delay/SleepCommand.cpp",
    "commands/delay/WaitForCommissioneeCommand.cpp",
    "commands/discover/DiscoverCommand.cpp",
    "commands/discover/DiscoverCommissionablesCommand.cpp",
    "commands/discover/DiscoverCommissionersCommand.cpp",
    "commands/pairing/OpenCommissioningWindowCommand.cpp",
    "commands/pairing/OpenCommissioningWindowCommand.h",
    "commands/pairing/PairingCommand.cpp",
    "commands/pairing/ToTLVCert.cpp",
    "commands/payload/AdditionalDataParseCommand.cpp",
    "commands/payload/SetupPayloadGenerateCommand.cpp",
    "commands/payload/SetupPayloadParseCommand.cpp",
    "commands/payload/SetupPayloadVerhoeff.cpp",
    "commands/session-management/CloseSessionCommand.cpp",
    "commands/session-management/CloseSessionCommand.h",
    "commands/storage/StorageManagementCommand.cpp",
  ]

  deps = []

  if (config_use_interactive_mode) {
    sources += [ "commands/interactive/InteractiveCommands.cpp" ]
    deps += [
      "${chip_root}/examples/common/websocket-server",
      "${editline_root}:editline",
    ]
  }

  if (config_enable_yaml_tests) {
    sources += [ "commands/tests/TestCommand.cpp" ]
  }

  if (chip_device_platform == "darwin") {
    sources += [ "commands/common/DeviceScanner.cpp" ]
  }

  public_deps = [
    "${chip_root}/src/app/server",
    "${chip_root}/src/app/tests/suites/commands/commissioner",
    "${chip_root}/src/app/tests/suites/commands/delay",
    "${chip_root}/src/app/tests/suites/commands/discovery",
    "${chip_root}/src/app/tests/suites/commands/interaction_model",
    "${chip_root}/src/app/tests/suites/commands/log",
    "${chip_root}/src/app/tests/suites/commands/system",
    "${chip_root}/src/app/tests/suites/pics",
    "${chip_root}/src/controller/data_model",
    "${chip_root}/src/credentials:file_attestation_trust_store",
    "${chip_root}/src/lib",
    "${chip_root}/src/lib/support/jsontlv",
    "${chip_root}/src/platform",
    "${chip_root}/src/tracing",
    "${chip_root}/src/tracing/log_json",
    "${chip_root}/third_party/inipp",
    "${chip_root}/third_party/jsoncpp",
  ]

  public_configs = [ ":config" ]

  if (chip_enable_transport_trace) {
    public_deps +=
        [ "${chip_root}/examples/common/tracing:trace_handlers_decoder" ]
  }

  output_dir = root_out_dir
}

executable("chip-tool") {
  sources = [ "main.cpp" ]

  deps = [
    ":chip-tool-utils",
    "${chip_root}/src/platform/logging:force_stdio",
  ]

  output_dir = root_out_dir
}

group("default") {
  deps = [ ":chip-tool" ]
}
