added configuration options for driver
This commit is contained in:
parent
9786abc212
commit
09b3b86180
|
@ -9,6 +9,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <toml.h>
|
#include <toml.h>
|
||||||
#include <mem/cache.h>
|
#include <mem/cache.h>
|
||||||
|
#include <link/driver.h>
|
||||||
|
|
||||||
static GHashTable* args = NULL;
|
static GHashTable* args = NULL;
|
||||||
|
|
||||||
|
@ -98,6 +99,7 @@ TargetConfig* default_target_config() {
|
||||||
config->print_ast = false;
|
config->print_ast = false;
|
||||||
config->print_asm = false;
|
config->print_asm = false;
|
||||||
config->print_ir = false;
|
config->print_ir = false;
|
||||||
|
config->driver = DEFAULT_DRIVER;
|
||||||
config->mode = Application;
|
config->mode = Application;
|
||||||
config->archive_directory = mem_strdup(MemoryNamespaceOpt, "archive");
|
config->archive_directory = mem_strdup(MemoryNamespaceOpt, "archive");
|
||||||
config->output_directory = mem_strdup(MemoryNamespaceOpt, "bin");
|
config->output_directory = mem_strdup(MemoryNamespaceOpt, "bin");
|
||||||
|
@ -160,6 +162,14 @@ TargetConfig* default_target_config_from_args() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_option_set("driver")) {
|
||||||
|
const Option* opt = get_option("driver");
|
||||||
|
|
||||||
|
if (opt->value != NULL) {
|
||||||
|
config->driver = mem_strdup(MemoryNamespaceOpt, (char*) opt->value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: free vvvvvvvvvvvvv
|
// TODO: free vvvvvvvvvvvvv
|
||||||
char* cwd = g_get_current_dir();
|
char* cwd = g_get_current_dir();
|
||||||
g_array_append_val(config->link_search_paths, cwd);
|
g_array_append_val(config->link_search_paths, cwd);
|
||||||
|
@ -259,6 +269,7 @@ void print_help(void) {
|
||||||
" --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",
|
" --mode=[app|lib] set the compilation mode to either application or library",
|
||||||
" --output=name name of output files without extension",
|
" --output=name name of output files without extension",
|
||||||
|
" --driver set binary driver to use",
|
||||||
" --link-paths=[paths,] set a list of directories to for libraries in",
|
" --link-paths=[paths,] set a list of directories to for libraries in",
|
||||||
" --all-fatal-warnings treat all warnings as errors",
|
" --all-fatal-warnings treat all warnings as errors",
|
||||||
" --lld-fatal-warnings treat linker warnings as errors",
|
" --lld-fatal-warnings treat linker warnings as errors",
|
||||||
|
@ -389,6 +400,7 @@ static int parse_target(const ProjectConfig *config, const toml_table_t *target_
|
||||||
get_bool(&target_config->print_asm, target_table, "print_asm");
|
get_bool(&target_config->print_asm, target_table, "print_asm");
|
||||||
get_bool(&target_config->print_ir, target_table, "print_ir");
|
get_bool(&target_config->print_ir, target_table, "print_ir");
|
||||||
|
|
||||||
|
get_str(&target_config->driver, target_table, "driver");
|
||||||
get_str(&target_config->root_module, target_table, "root");
|
get_str(&target_config->root_module, target_table, "root");
|
||||||
get_str(&target_config->output_directory, target_table, "output");
|
get_str(&target_config->output_directory, target_table, "output");
|
||||||
get_str(&target_config->archive_directory, target_table, "archive");
|
get_str(&target_config->archive_directory, target_table, "archive");
|
||||||
|
|
|
@ -51,6 +51,8 @@ typedef struct TargetConfig_t {
|
||||||
char* output_directory;
|
char* output_directory;
|
||||||
// output directory for intermediate representations (LLVM-IR, Assembly, ...)
|
// output directory for intermediate representations (LLVM-IR, Assembly, ...)
|
||||||
char* archive_directory;
|
char* archive_directory;
|
||||||
|
// binary driver for executable generation
|
||||||
|
char* driver;
|
||||||
// mode of compilation
|
// mode of compilation
|
||||||
TargetCompilationMode mode;
|
TargetCompilationMode mode;
|
||||||
// number between 1 and 3
|
// number between 1 and 3
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#include <cfg/opt.h>
|
#include <cfg/opt.h>
|
||||||
|
|
||||||
|
#define DEFAULT_DRIVER "clang"
|
||||||
|
|
||||||
//! @brief Function a binary driver used to link files
|
//! @brief Function a binary driver used to link files
|
||||||
typedef bool (*driver_link)(TargetLinkConfig*);
|
typedef bool (*driver_link)(TargetLinkConfig*);
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ TargetLinkConfig* lld_create_link_config(__attribute__((unused)) const Target* t
|
||||||
config->fatal_warnings = target_config->lld_fatal_warnings;
|
config->fatal_warnings = target_config->lld_fatal_warnings;
|
||||||
config->object_file_names = g_array_new(FALSE, FALSE, sizeof(char*));
|
config->object_file_names = g_array_new(FALSE, FALSE, sizeof(char*));
|
||||||
config->colorize = stdout_supports_ansi_esc();
|
config->colorize = stdout_supports_ansi_esc();
|
||||||
config->driver = mem_strdup(MemoryNamespaceLld, "clang");
|
config->driver = target_config->driver;
|
||||||
|
|
||||||
// append build object file
|
// append build object file
|
||||||
char* basename = g_strjoin(".", target_config->name, "o", NULL);
|
char* basename = g_strjoin(".", target_config->name, "o", NULL);
|
||||||
|
|
Loading…
Reference in New Issue