# Copyright 2022 The Pigweed 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
#
#     https://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/pigweed.gni")
import("$dir_pw_build/python.gni")
import("$dir_pw_build/target_types.gni")

import("$pw_external_emboss/emboss.gni")

config("default_config") {
  # EMBOSS_DCHECK is used as an assert() for logic embedded in Emboss, where
  # EMBOSS_CHECK is used to check preconditions on application logic (e.g.
  # Write() checks the [requires: ...] attribute).
  defines = [
    "EMBOSS_CHECK=PW_DASSERT",
    "EMBOSS_CHECK_ABORTS",
    "EMBOSS_DCHECK=PW_DASSERT",
    "EMBOSS_DCHECK_ABORTS",
  ]
  cflags_cc = [
    "-include",
    rebase_path("$dir_pw_assert/public/pw_assert/assert.h", root_build_dir),
  ]
}

pw_source_set("default_overrides") {
  public_configs = [ ":default_config" ]
  public_deps = [ "$dir_pw_assert" ]
}

pw_source_set("cpp_utils") {
  # emboss depends on a separate checkout not included in pigweed, so
  # ignore gn check for this module.
  check_includes = false
  public = [
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_arithmetic.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_arithmetic_all_known_generated.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_arithmetic_maximum_operation_generated.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_array_view.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_bit_util.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_constant_view.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_cpp_types.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_cpp_util.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_defines.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_enum_view.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_maybe.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_memory_util.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_prelude.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_text_util.h",
    "$dir_pw_third_party_emboss/runtime/cpp/emboss_view_parameters.h",
  ]
  public_deps = [ pw_third_party_emboss_CONFIG ]
  visibility = [ "*" ]
}

# Exists solely to satisfy presubmit. embossc_runner.py is used for real in
# build_defs.gni.
action("embossc_runner") {
  script = "embossc_runner.py"
  visibility = []
  outputs = [ "$target_gen_dir/foo" ]
}
