|
Luma 0.1.0
A low-level compiled alternative to C, C++, and more!
|
Implements command-line argument parsing, file reading, help/version/license printing, and token printing with color-highlighted token types. More...
#include <string.h>#include <sys/stat.h>#include <sys/wait.h>#include <unistd.h>#include "../c_libs/color/color.h"#include "../lsp/formatter/formatter.h"#include "../lsp/lsp.h"#include "help.h"
Functions | |
| bool | check_argc (int argc, int expected) |
| Checks if the number of command-line arguments is at least expected. | |
| const char * | read_file (const char *filename) |
| Reads entire file content into a newly allocated buffer. | |
| int | print_help () |
| Prints help message describing usage and options. | |
| int | print_version () |
| Prints version information. | |
| int | print_license () |
| Prints license information. | |
| bool | PathExist (const char *p) |
| bool | PathIsDir (const char *p) |
| bool | run_formatter (BuildConfig config, ArenaAllocator *allocator) |
| const char * | detect_target_os (void) |
| bool | parse_args (int argc, char *argv[], BuildConfig *config, ArenaAllocator *arena) |
| Parses command-line arguments and configures the build. | |
| void | print_token (const Token *t) |
| Prints a token's text and its token type with color formatting. | |
| bool | link_with_ld (const char *obj_filename, const char *exe_filename) |
| Links object file using ld to create an executable (Unix/Linux) | |
| bool | get_gcc_file_path (const char *filename, char *buffer, size_t buffer_size) |
| Get a file path from gcc. | |
| bool | get_lib_paths (char *buffer, size_t buffer_size) |
| Get the system's library search paths. | |
| bool | link_with_ld_simple (const char *obj_filename, const char *exe_filename) |
| Alternative simpler linking approach using system() | |
| void | print_progress (int step, int total, const char *stage) |
| void | ensure_clean_line () |
| void | timer_start (CompileTimer *timer) |
| void | timer_stop (CompileTimer *timer) |
| double | timer_get_elapsed_ms (CompileTimer *timer) |
| void | print_progress_with_time (int step, int total, const char *stage, CompileTimer *timer) |
Implements command-line argument parsing, file reading, help/version/license printing, and token printing with color-highlighted token types.
| bool check_argc | ( | int | argc, |
| int | expected | ||
| ) |
Checks if the number of command-line arguments is at least expected.
Prints usage info if not enough arguments.
| argc | Actual argument count. |
| expected | Minimum expected argument count. |
| const char * detect_target_os | ( | void | ) |
| void ensure_clean_line | ( | ) |
| bool get_gcc_file_path | ( | const char * | filename, |
| char * | buffer, | ||
| size_t | buffer_size | ||
| ) |
Get a file path from gcc.
| filename | The filename to search for |
| buffer | Buffer to store the result |
| buffer_size | Size of the buffer |
| bool get_lib_paths | ( | char * | buffer, |
| size_t | buffer_size | ||
| ) |
Get the system's library search paths.
| buffer | Buffer to store library paths |
| buffer_size | Size of the buffer |
| bool link_with_ld | ( | const char * | obj_filename, |
| const char * | exe_filename | ||
| ) |
Links object file using ld to create an executable (Unix/Linux)
| obj_filename | Path to the object file |
| exe_filename | Path for the output executable |
| bool link_with_ld_simple | ( | const char * | obj_filename, |
| const char * | exe_filename | ||
| ) |
Alternative simpler linking approach using system()
| obj_filename | Path to the object file |
| exe_filename | Path for the output executable |
| bool parse_args | ( | int | argc, |
| char * | argv[], | ||
| BuildConfig * | config, | ||
| ArenaAllocator * | arena | ||
| ) |
Parses command-line arguments and configures the build.
Supports options for version, help, license, build, save, clean, and debug.
| argc | Argument count. |
| argv | Argument vector. |
| config | Pointer to BuildConfig struct to fill. |
| bool PathExist | ( | const char * | p | ) |
| bool PathIsDir | ( | const char * | p | ) |
| int print_help | ( | ) |
Prints help message describing usage and options.
| int print_license | ( | ) |
Prints license information.
| void print_progress | ( | int | step, |
| int | total, | ||
| const char * | stage | ||
| ) |
| void print_progress_with_time | ( | int | step, |
| int | total, | ||
| const char * | stage, | ||
| CompileTimer * | timer | ||
| ) |
| void print_token | ( | const Token * | t | ) |
Prints a token's text and its token type with color formatting.
| t | Pointer to the Token to print. |
| int print_version | ( | ) |
Prints version information.
| const char * read_file | ( | const char * | filename | ) |
Reads entire file content into a newly allocated buffer.
The caller must free the returned buffer.
| filename | Path to the file to read. |
| bool run_formatter | ( | BuildConfig | config, |
| ArenaAllocator * | allocator | ||
| ) |
| double timer_get_elapsed_ms | ( | CompileTimer * | timer | ) |
| void timer_start | ( | CompileTimer * | timer | ) |
| void timer_stop | ( | CompileTimer * | timer | ) |