added option to compile for app or lib

This commit is contained in:
Sven Vogel 2024-05-31 16:55:43 +02:00
parent c527c99392
commit 5fb10bca88
2 changed files with 23 additions and 3 deletions

View File

@ -28,6 +28,10 @@ TargetConfig default_target_config_from_args(int argc, char *argv[]) {
config.print_asm = true; config.print_asm = true;
} else if (strcmp(option, "--print-ir") == 0) { } else if (strcmp(option, "--print-ir") == 0) {
config.print_ir = true; config.print_ir = true;
} else if (strcmp(option, "--mode=app") == 0) {
config.mode = Application;
} else if (strcmp(option, "--mode=lib") == 0) {
config.mode = Library;
} }
} }
@ -42,7 +46,8 @@ void print_help(void) {
"Options:", "Options:",
" --print-ast print resulting abstract syntax tree to a file", " --print-ast print resulting abstract syntax tree to a file",
" --print-asm print resulting assembly language to a file", " --print-asm print resulting assembly language to a file",
" --print-ir print resulting LLVM-IR 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++) { for (unsigned int i = 0; i < sizeof(lines) / sizeof(const char *); i++) {

View File

@ -8,11 +8,26 @@
#include <toml.h> #include <toml.h>
#include <glib.h> #include <glib.h>
typedef enum TargetCompilationMode_t {
Application,
Library
} TargetCompilationMode;
typedef struct TargetConfig_t { typedef struct TargetConfig_t {
char* name; char* name;
bool print_ast; bool print_ast;
bool print_asm; bool print_asm;
bool print_ir; 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; } TargetConfig;
typedef struct ProjectConfig_t { typedef struct ProjectConfig_t {