Luma 0.1.0
A low-level compiled alternative to C, C++, and more!
Loading...
Searching...
No Matches
Functions
help.c File Reference

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"
Include dependency graph for help.c:

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)
 

Detailed Description

Implements command-line argument parsing, file reading, help/version/license printing, and token printing with color-highlighted token types.

Function Documentation

◆ check_argc()

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.

Parameters
argcActual argument count.
expectedMinimum expected argument count.
Returns
true if argc >= expected, false otherwise.

◆ detect_target_os()

const char * detect_target_os ( void  )

◆ ensure_clean_line()

void ensure_clean_line ( )

◆ get_gcc_file_path()

bool get_gcc_file_path ( const char *  filename,
char *  buffer,
size_t  buffer_size 
)

Get a file path from gcc.

Parameters
filenameThe filename to search for
bufferBuffer to store the result
buffer_sizeSize of the buffer
Returns
true if path was found, false otherwise

◆ get_lib_paths()

bool get_lib_paths ( char *  buffer,
size_t  buffer_size 
)

Get the system's library search paths.

Parameters
bufferBuffer to store library paths
buffer_sizeSize of the buffer
Returns
true if paths were found

◆ link_with_ld()

bool link_with_ld ( const char *  obj_filename,
const char *  exe_filename 
)

Links object file using ld to create an executable (Unix/Linux)

Parameters
obj_filenamePath to the object file
exe_filenamePath for the output executable
Returns
true if linking succeeded, false otherwise

◆ link_with_ld_simple()

bool link_with_ld_simple ( const char *  obj_filename,
const char *  exe_filename 
)

Alternative simpler linking approach using system()

Parameters
obj_filenamePath to the object file
exe_filenamePath for the output executable
Returns
true if linking succeeded, false otherwise

◆ parse_args()

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.

Parameters
argcArgument count.
argvArgument vector.
configPointer to BuildConfig struct to fill.
Returns
false if help/version/license was printed or error occurred, true otherwise.

◆ PathExist()

bool PathExist ( const char *  p)

◆ PathIsDir()

bool PathIsDir ( const char *  p)

◆ print_help()

int print_help ( )

Prints help message describing usage and options.

Returns
Always returns 0.

◆ print_license()

int print_license ( )

Prints license information.

Returns
Always returns 0.

◆ print_progress()

void print_progress ( int  step,
int  total,
const char *  stage 
)

◆ print_progress_with_time()

void print_progress_with_time ( int  step,
int  total,
const char *  stage,
CompileTimer timer 
)

◆ print_token()

void print_token ( const Token t)

Prints a token's text and its token type with color formatting.

Parameters
tPointer to the Token to print.

◆ print_version()

int print_version ( )

Prints version information.

Returns
Always returns 0.

◆ read_file()

const char * read_file ( const char *  filename)

Reads entire file content into a newly allocated buffer.

The caller must free the returned buffer.

Parameters
filenamePath to the file to read.
Returns
Pointer to null-terminated file content, or NULL on failure.

◆ run_formatter()

bool run_formatter ( BuildConfig  config,
ArenaAllocator allocator 
)

◆ timer_get_elapsed_ms()

double timer_get_elapsed_ms ( CompileTimer timer)

◆ timer_start()

void timer_start ( CompileTimer timer)

◆ timer_stop()

void timer_stop ( CompileTimer timer)