Added print-input command line argument (#1175)

* added print-input command line argument
This commit is contained in:
Brennan Cottrell
2024-03-26 04:33:47 -04:00
committed by GitHub
parent e8f0275d8e
commit a4a85b7bbf
5 changed files with 19 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
### Changes / improvements
- Support `defer (catch err)`
- Added `print-input` command argument to print all files used for compilation
### Fixes
None

View File

@@ -360,6 +360,7 @@ typedef struct BuildOptions_
bool no_obj;
bool read_stdin;
bool print_output;
bool print_input;
const char *panicfn;
const char *benchfn;
const char *testfn;
@@ -462,6 +463,7 @@ typedef struct
bool testing;
bool read_stdin;
bool print_output;
bool print_input;
bool print_linking;
bool no_entry;
int build_threads;

View File

@@ -167,6 +167,7 @@ static void usage(void)
OUTPUT(" --list-type-properties - List all type properties.");
OUTPUT("");
OUTPUT(" --print-output - Print the object files created to stdout.");
OUTPUT(" --print-input - Print inputted C3 files to stdout.");
OUTPUT("");
OUTPUT(" --winsdk <dir> - Set the directory for Windows system library files for cross compilation.");
OUTPUT(" --wincrt=<option> - Windows CRT linking: none, static, dynamic (default).");
@@ -885,6 +886,11 @@ static void parse_option(BuildOptions *options)
options->print_output = true;
return;
}
if (match_longopt("print-input"))
{
options->print_input = true;
return;
}
if (match_longopt("no-entry"))
{
options->no_entry = true;

View File

@@ -285,6 +285,7 @@ static void update_build_target_from_options(BuildTarget *target, BuildOptions *
if (options->emit_stdlib != EMIT_STDLIB_NOT_SET) target->emit_stdlib = options->emit_stdlib;
if (options->no_entry) target->no_entry = true;
target->print_output = options->print_output;
target->print_input = options->print_input;
target->emit_llvm = options->emit_llvm;
target->build_threads = options->build_threads;
target->emit_asm = options->emit_asm;

View File

@@ -289,6 +289,10 @@ void compiler_parse(void)
// Load and parse all files.
bool has_error = false;
if (active_target.print_input)
{
puts("# input-files-begin");
}
VECEACH(global_context.sources, i)
{
bool loaded = false;
@@ -297,6 +301,11 @@ void compiler_parse(void)
if (!file) error_exit(error);
if (loaded) continue;
if (!parse_file(file)) has_error = true;
if (active_target.print_input) puts(file->full_path);
}
if (active_target.print_input)
{
puts("# input-files-end");
}
if (active_target.read_stdin)
{