diff --git a/src/cfg/opt.c b/src/cfg/opt.c index 10d1540..6a1862f 100644 --- a/src/cfg/opt.c +++ b/src/cfg/opt.c @@ -28,6 +28,10 @@ TargetConfig default_target_config_from_args(int argc, char *argv[]) { config.print_asm = true; } else if (strcmp(option, "--print-ir") == 0) { config.print_ir = true; + } else if (strcmp(option, "--mode=app") == 0) { + config.mode = Application; + } else if (strcmp(option, "--mode=lib") == 0) { + config.mode = Library; } } @@ -40,9 +44,10 @@ void print_help(void) { "Compile file(s): gsc [files]", "Build project (build.toml): gsc [directory] [target]|all", "Options:", - " --print-ast print resulting abstract syntax tree to a file", - " --print-asm print resulting assembly language to a file", - " --print-ir print resulting LLVM-IR to a file" + " --print-ast print resulting abstract syntax tree to a file", + " --print-asm print resulting assembly language to a file", + " --print-ir print resulting LLVM-IR to a file", + " --mode=[app|lib] set the compilation mode to either application or library" }; for (unsigned int i = 0; i < sizeof(lines) / sizeof(const char *); i++) { diff --git a/src/cfg/opt.h b/src/cfg/opt.h index 5c9e6b5..cd00b62 100644 --- a/src/cfg/opt.h +++ b/src/cfg/opt.h @@ -8,11 +8,26 @@ #include #include +typedef enum TargetCompilationMode_t { + Application, + Library +} TargetCompilationMode; + typedef struct TargetConfig_t { char* name; bool print_ast; bool print_asm; bool print_ir; + // root module file which imports all submodules + char* root_module; + // output directory for binaries + char* output_directory; + // output directory for intermediate representations (LLVM-IR, Assembly, ...) + char* archive_directory; + // mode of compilation + TargetCompilationMode mode; + // number between 1 and 3 + int optimization_level; } TargetConfig; typedef struct ProjectConfig_t {