// Part of the Crubit project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <string>

#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include "common/ffi_types.h"
#include "rs_bindings_from_cc/bazel_types.h"
#include "rs_bindings_from_cc/ir.h"
#include "rs_bindings_from_cc/ir_from_cc.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormatVariadic.h"

namespace crubit {

// LINT.IfChange
static constexpr absl::string_view kDependencyTarget = "//test:dependency";

static constexpr absl::string_view kDependencyHeaderName =
    "test/dependency_header.h";
// LINT.ThenChange(//depot/rs_bindings_from_cc/ir_testing.rs)

// This is intended to be called from Rust tests.
extern "C" FfiU8SliceBox json_from_cc_dependency(
    FfiU8Slice target_triple, FfiU8Slice header_source,
    FfiU8Slice dependency_header_source) {
  absl::StatusOr<IR> ir = IrFromCc(
      {.extra_source_code_for_testing = StringViewFromFfiU8Slice(header_source),
       .current_target = BazelLabel{"//test:testing_target"},
       .virtual_headers_contents_for_testing =
           {{HeaderName(std::string(kDependencyHeaderName)),
             std::string(StringViewFromFfiU8Slice(dependency_header_source))}},
       .headers_to_targets = {{HeaderName(std::string(kDependencyHeaderName)),
                               BazelLabel{std::string(kDependencyTarget)}}},
       .clang_args = {
           // The version should be consistent with the one passed by the C++
           // toolchain.
           "-std=gnu++20",
           "-target",
           StringViewFromFfiU8Slice(target_triple),
       }});

  // TODO(forster): For now it is good enough to just exit: We are just
  // using this from tests, which are ok to just fail. Clang has already
  // printed error messages. If we start using this for production, then we
  // should bridge the error code into Rust.
  if (!ir.ok()) {
    llvm::report_fatal_error(llvm::formatv("IrFromCc reported an error: {0}",
                                           ir.status().message()));
  }
  std::string json = llvm::formatv("{0}", ir->ToJson());
  return AllocFfiU8SliceBox(MakeFfiU8Slice(json));
}

}  // namespace crubit
