summaryrefslogtreecommitdiffhomepage
path: root/include/NeBuildKit/Detail/Config.h
blob: e292fbe530e65a595e858889df6a172e84141ef4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// ============================================================= //
// NeBuild
// Copyright (C) 2024-2025, Amlal El Mahrouss and NeKernel Authors, licensed under BSD-3 license.
// ============================================================= //

#pragma once

/// =========================================================== ///
/// @author Amlal El Mahrouss
/// =========================================================== ///

#include <rang/rang.h>
#include <cassert>
#include <iostream>

#define NEBUILD_VERSION "v0.0.8-buildkit"

#define NEBUILD_VERSION_BCD 0x0007

#define NEBUILD_VERSION_MAJOR 0
#define NEBUILD_VERSION_MINOR 0
#define NEBUILD_VERSION_PATCH 7

#define NEBUILD_EXPORT_C extern "C"

#define NEBUILD_UNUSED(X) ((void) X)

#define b_internal private

#ifdef NEBUILD_INTERNAL_SDK
#undef b_internal
#define b_internal public
#endif

namespace NeBuild {
struct BuildConfig final {
  b_internal : bool has_failed_{false};
  bool              dry_run_{false};
  std::string       path_{};

 public:
  explicit operator bool() { return has_failed_; }

  bool dry_run() { return dry_run_; }
  void dry_run(const bool dr) { dry_run_ = dr; }

  bool has_failed() { return has_failed_; }
  void has_failed(const bool dr) { has_failed_ = dr; }

  const std::string& path() { return path_; }
  void               path(const std::string& pat) { path_ = pat; }

  BuildConfig()  = default;
  ~BuildConfig() = default;
};
}  // namespace NeBuild

/// \brief Logger namespace.
namespace NeBuild::Logger {
/// @brief replacement for std::cout for NeBuild logging.
/// @todo change this to spdlog?
inline std::ostream& info() noexcept {
  auto& out = std::cout;
  out << rang::fg::red << "nebuild: " << rang::style::reset;
  return out;
}
}  // namespace NeBuild::Logger