Skip to content

Commit 56d1118

Browse files
committed
Refactor headers
1 parent 23ad251 commit 56d1118

43 files changed

Lines changed: 887 additions & 740 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ FetchContent_Declare(
8989
GIT_SHALLOW TRUE
9090
)
9191

92+
# Fetch packages without setup commands
9293
FetchContent_MakeAvailable(fmt tomlplusplus)
9394

9495
# Add source files

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ spdlog = "1.12.0"
117117
| `cforge run` | Build and run the project |
118118
| `cforge clean` | Clean build artifacts |
119119
| `cforge install` | Install project to system |
120+
| `cforge circular` | Check for circular dependencies |
120121

121122
### Dependencies
122123

include/cforge/log.hpp

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file log.hpp
33
* @brief Cargo-style logging utilities for cforge
44
*
5-
* Output format matches Rust's Cargo:
5+
* Output format matches Rust's CARGO:
66
* - 12-character right-aligned status word (colored)
77
* - Message follows in default color
88
* - No emojis, no brackets
@@ -62,16 +62,16 @@ enum class log_verbosity {
6262
* @class logger
6363
* @brief Static class providing Cargo-style logging functionality
6464
*
65-
* All output follows Cargo's format:
65+
* All output follows CARGO's format:
6666
* {status:>12} {message}
6767
*
6868
* Where status is a colored action word like "Compiling", "Building", etc.
6969
*/
7070
class logger {
7171
public:
72-
// ============================================================
72+
7373
// Configuration
74-
// ============================================================
74+
7575

7676
/**
7777
* @brief Sets the global verbosity level for logging
@@ -85,9 +85,8 @@ class logger {
8585
*/
8686
static log_verbosity get_verbosity();
8787

88-
// ============================================================
89-
// Cargo-style status messages (right-aligned status word)
90-
// ============================================================
88+
// CARGO-style status messages (right-aligned status word)
89+
9190

9291
/**
9392
* @brief Print a status message with custom action word
@@ -104,7 +103,7 @@ class logger {
104103
/**
105104
* @brief Print a cyan status message (info/progress)
106105
*
107-
* Common actions: "Checking", "Fetching", "Updating", "Running"
106+
* Common actions: "Checking", "Fetching", "Updating", "RUNNING"
108107
*/
109108
static void print_status(const std::string &message);
110109

@@ -130,9 +129,7 @@ class logger {
130129
*/
131130
static void print_verbose(const std::string &message);
132131

133-
// ============================================================
134-
// Specific action helpers (Cargo-style)
135-
// ============================================================
132+
// Specific action helpers (CARGO-style)
136133

137134
/**
138135
* @brief Print "Compiling {target}"
@@ -145,7 +142,7 @@ class logger {
145142
static void building(const std::string &target);
146143

147144
/**
148-
* @brief Print "Running {command}"
145+
* @brief Print "RUNNING {command}"
149146
*/
150147
static void running(const std::string &command);
151148

@@ -214,17 +211,17 @@ class logger {
214211
*/
215212
static void cleaning(const std::string &target);
216213

217-
// ============================================================
214+
218215
// Build progress display (Rust-style)
219-
// ============================================================
216+
220217

221218
/**
222219
* @brief Print "Compiling {file}" with optional timing
223220
* @param file The file being compiled
224221
* @param duration_secs Optional duration in seconds (for completed files)
225222
*/
226223
static void compiling_file(const std::string &file,
227-
double duration_secs = -1.0);
224+
cforge_double_t duration_secs = -1.0);
228225

229226
/**
230227
* @brief Display a progress bar
@@ -245,12 +242,12 @@ class logger {
245242
* @param slowest_files Vector of (filename, duration) pairs for slowest files
246243
*/
247244
static void print_timing_summary(
248-
double total_duration,
249-
const std::vector<std::pair<std::string, double>> &slowest_files);
245+
cforge_double_t total_duration,
246+
const std::vector<std::pair<std::string, cforge_double_t>> &slowest_files);
247+
250248

251-
// ============================================================
252249
// Legacy compatibility (maps to new style)
253-
// ============================================================
250+
254251

255252
/**
256253
* @brief Print a header/banner (simplified, no box drawing)
@@ -275,7 +272,7 @@ class logger {
275272
private:
276273
static log_verbosity s_verbosity;
277274

278-
// Status width for right-alignment (Cargo uses 12)
275+
// Status width for right-alignment (CARGO uses 12)
279276
static constexpr int STATUS_WIDTH = 12;
280277

281278
/**

include/core/build_progress.hpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#pragma once
77

8+
#include "types.h"
9+
810
#include <chrono>
911
#include <functional>
1012
#include <mutex>
@@ -20,7 +22,7 @@ struct file_timing {
2022
std::string filename;
2123
std::chrono::steady_clock::time_point start_time;
2224
std::chrono::steady_clock::time_point end_time;
23-
double duration_seconds = 0.0;
25+
cforge_double_t duration_seconds = 0.0;
2426
};
2527

2628
/**
@@ -50,17 +52,17 @@ class build_progress {
5052
/**
5153
* @brief Get the current progress as a fraction (0.0 to 1.0)
5254
*/
53-
double get_progress() const;
55+
cforge_double_t get_progress() const;
5456

5557
/**
5658
* @brief Get current step number
5759
*/
58-
int get_current_step() const;
60+
cforge_int_t get_current_step() const;
5961

6062
/**
6163
* @brief Get total steps
6264
*/
63-
int get_total_steps() const;
65+
cforge_int_t get_total_steps() const;
6466

6567
/**
6668
* @brief Check if progress information is available
@@ -76,7 +78,7 @@ class build_progress {
7678
* @brief Get the slowest files (sorted by duration, descending)
7779
* @param count Maximum number of files to return
7880
*/
79-
std::vector<file_timing> get_slowest_files(size_t count = 5) const;
81+
std::vector<file_timing> get_slowest_files(cforge_size_t count = 5) const;
8082

8183
/**
8284
* @brief Called when a file starts compiling
@@ -91,8 +93,8 @@ class build_progress {
9193
private:
9294
mutable std::mutex mutex_;
9395
std::string current_file_;
94-
int current_step_ = 0;
95-
int total_steps_ = 0;
96+
cforge_int_t current_step_ = 0;
97+
cforge_int_t total_steps_ = 0;
9698
bool has_progress_ = false;
9799

98100
std::vector<file_timing> timings_;
@@ -126,7 +128,7 @@ class build_progress {
126128
* @param width Width of the progress bar in characters
127129
* @param show_percentage Whether to show percentage
128130
*/
129-
void display_progress_bar(int current, int total, int width = 20,
131+
void display_progress_bar(cforge_int_t current, cforge_int_t total, cforge_int_t width = 20,
130132
bool show_percentage = true);
131133

132134
/**

include/core/build_utils.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ bool run_cmake_build(const std::filesystem::path &build_dir,
136136
const std::string &target = "", cforge_int_t num_jobs = 0,
137137
bool verbose = false);
138138

139-
// =============================================================================
139+
140140
// Smart Rebuild Utilities
141-
// =============================================================================
141+
142142

143143
/**
144144
* @brief Check if a file is newer than another file

include/core/config_resolver.hpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ namespace cforge {
2222
/**
2323
* @brief Enumeration of supported platforms
2424
*/
25-
enum class Platform {
26-
Windows,
27-
Linux,
28-
MacOS,
29-
Unknown
25+
enum class platform {
26+
WINDOWS,
27+
LINUX,
28+
MACOS,
29+
UNKNOWN
3030
};
3131

3232
/**
3333
* @brief Enumeration of supported compilers
3434
*/
35-
enum class Compiler {
35+
enum class compiler {
3636
MSVC,
3737
GCC,
38-
Clang,
39-
AppleClang,
40-
MinGW,
41-
Unknown
38+
CLANG,
39+
APPLE_CLANG,
40+
MINGW,
41+
UNKNOWN
4242
};
4343

4444
/**
@@ -57,41 +57,41 @@ struct resolved_config {
5757
* @brief Get the current platform
5858
* @return The detected platform
5959
*/
60-
Platform get_current_platform();
60+
platform get_current_platform();
6161

6262
/**
6363
* @brief Get the platform name as a string
6464
* @param platform The platform enum value
6565
* @return The platform name (lowercase)
6666
*/
67-
std::string platform_to_string(Platform platform);
67+
std::string platform_to_string(platform platform);
6868

6969
/**
7070
* @brief Parse a platform string to enum
7171
* @param str The platform string (case-insensitive)
7272
* @return The platform enum value
7373
*/
74-
Platform string_to_platform(const std::string &str);
74+
platform string_to_platform(const std::string &str);
7575

7676
/**
7777
* @brief Get the current compiler based on environment/detection
7878
* @return The detected compiler
7979
*/
80-
Compiler detect_compiler();
80+
compiler detect_compiler();
8181

8282
/**
8383
* @brief Get the compiler name as a string
8484
* @param compiler The compiler enum value
8585
* @return The compiler name (lowercase with underscores)
8686
*/
87-
std::string compiler_to_string(Compiler compiler);
87+
std::string compiler_to_string(compiler compiler);
8888

8989
/**
9090
* @brief Parse a compiler string to enum
9191
* @param str The compiler string (case-insensitive)
9292
* @return The compiler enum value
9393
*/
94-
Compiler string_to_compiler(const std::string &str);
94+
compiler string_to_compiler(const std::string &str);
9595

9696
/**
9797
* @brief Check if a platform list contains the current platform
@@ -125,13 +125,13 @@ class config_resolver {
125125
* @brief Set the target platform (defaults to current platform)
126126
* @param platform The target platform
127127
*/
128-
void set_platform(Platform platform);
128+
void set_platform(platform platform);
129129

130130
/**
131131
* @brief Set the target compiler (defaults to detected compiler)
132132
* @param compiler The target compiler
133133
*/
134-
void set_compiler(Compiler compiler);
134+
void set_compiler(compiler compiler);
135135

136136
/**
137137
* @brief Resolve defines for a given build configuration
@@ -183,17 +183,17 @@ class config_resolver {
183183
/**
184184
* @brief Get the current platform
185185
*/
186-
Platform get_platform() const { return platform_; }
186+
platform get_platform() const { return platform_; }
187187

188188
/**
189189
* @brief Get the current compiler
190190
*/
191-
Compiler get_compiler() const { return compiler_; }
191+
compiler get_compiler() const { return compiler_; }
192192

193193
private:
194194
const toml_reader &config_;
195-
Platform platform_;
196-
Compiler compiler_;
195+
platform platform_;
196+
compiler compiler_;
197197

198198
/**
199199
* @brief Merge string arrays (append unique values)

include/core/constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define DEFAULT_OBJ_DIR "obj"
2222
#define VCPKG_DEFAULT_DIR "~/.vcpkg"
2323
#define CMAKE_MIN_VERSION "3.15"
24-
#define WORKSPACE_FILE "cforge.workspace.toml"
24+
#define WORKSPACE_FILE "cforge.workspace.toml" // <-- Deprecated
2525

2626
#ifdef _MSC_VER
2727
#pragma warning(disable : 4996)

include/core/dependency_hash.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include "types.h"
4+
35
#include <chrono>
46
#include <cstdint>
57
#include <filesystem>
@@ -119,7 +121,7 @@ class dependency_hash {
119121
* @param size Size of data in bytes
120122
* @return 64-bit hash value
121123
*/
122-
static uint64_t fnv1a_hash(const void *data, size_t size);
124+
static uint64_t fnv1a_hash(const void *data, cforge_size_t size);
123125

124126
/**
125127
* @brief Convert 64-bit hash to hex string
@@ -143,10 +145,10 @@ class dependency_hash {
143145
* @brief Trim whitespace from string
144146
*/
145147
static std::string trim(const std::string &str) {
146-
size_t start = str.find_first_not_of(" \t\r\n");
148+
cforge_size_t start = str.find_first_not_of(" \t\r\n");
147149
if (start == std::string::npos)
148150
return "";
149-
size_t end = str.find_last_not_of(" \t\r\n");
151+
cforge_size_t end = str.find_last_not_of(" \t\r\n");
150152
return str.substr(start, end - start + 1);
151153
}
152154
};

0 commit comments

Comments
 (0)