From 59ec653fd3d24b5da664352732becbb44c01d767 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Mon, 28 Jun 2021 09:11:20 +0200 Subject: [PATCH] Fix issue resolving paths for builds. Changed default output to a.out as per @gdm85's suggestion. Fixes to test project from @gdm85's pull req. --- resources/testproject/bar.c3 | 4 ++-- resources/testproject/foo.c3 | 8 ++++---- resources/testproject/zab.c3 | 2 +- src/build/build_options.h | 1 + src/build/builder.c | 2 +- src/build/project.c | 2 +- src/compiler/compiler.c | 8 ++++---- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/resources/testproject/bar.c3 b/resources/testproject/bar.c3 index 3ced5c41f..e04d163e5 100644 --- a/resources/testproject/bar.c3 +++ b/resources/testproject/bar.c3 @@ -1,9 +1,9 @@ module bar; import baz::foo; -import testbaz; +import testbaz::zab; -public func void test() +func void test() { Foo x; baz::foo::test(); diff --git a/resources/testproject/foo.c3 b/resources/testproject/foo.c3 index e66e33cee..d12d25903 100644 --- a/resources/testproject/foo.c3 +++ b/resources/testproject/foo.c3 @@ -2,19 +2,19 @@ module baz::foo; import bar; -public struct Foo +struct Foo { int a; } extern func void printf(char *hello); -func void ofke() +private func void ofke() {} -func void exple() {} +private func void exple() {} -public func void test() +func void test() { printf("Hello from baz::foo::test()!\n"); } \ No newline at end of file diff --git a/resources/testproject/zab.c3 b/resources/testproject/zab.c3 index 35071ee76..2b7f18c25 100644 --- a/resources/testproject/zab.c3 +++ b/resources/testproject/zab.c3 @@ -1,6 +1,6 @@ module testbaz::zab; -public struct Zab +struct Zab { double a; } \ No newline at end of file diff --git a/src/build/build_options.h b/src/build/build_options.h index c411b79eb..9c92bd3e8 100644 --- a/src/build/build_options.h +++ b/src/build/build_options.h @@ -206,6 +206,7 @@ typedef struct const char *name; const char *version; const char *langrev; + const char **source_dirs; const char **sources; const char **libraries; const char *cpu; diff --git a/src/build/builder.c b/src/build/builder.c index 60f921bc2..997be37a4 100644 --- a/src/build/builder.c +++ b/src/build/builder.c @@ -119,7 +119,7 @@ void init_default_build_target(BuildTarget *target, BuildOptions *options, const { *target = (BuildTarget) { .type = TARGET_TYPE_EXECUTABLE, - .sources = options->files, + .source_dirs = options->files, .name = name, .optimization_level = OPTIMIZATION_DEFAULT, .size_optimization_level = SIZE_OPTIMIZATION_NONE, diff --git a/src/build/project.c b/src/build/project.c index 6ee6b9ef7..21d756d2d 100644 --- a/src/build/project.c +++ b/src/build/project.c @@ -152,7 +152,7 @@ void project_add_target(Project *project, TomlValue *wrapped_table, const char * target->version = get_valid_string(table, "version", type, false); if (!target->version) target->version = "1.0.0"; target->langrev = get_valid_string(table, "langrev", type, false); - target->sources = get_valid_array(table, "sources", type, true); + target->source_dirs = get_valid_array(table, "sources", type, true); target->libraries = get_valid_array(table, "libs", type, false); static const char *debug_infos[3] = { [DEBUG_INFO_FULL] = "full", diff --git a/src/compiler/compiler.c b/src/compiler/compiler.c index 137c76249..30a9be8d9 100644 --- a/src/compiler/compiler.c +++ b/src/compiler/compiler.c @@ -444,9 +444,9 @@ void compiler_compile(void) static void target_expand_source_names(BuildTarget *target) { const char **files = NULL; - VECEACH(target->sources, i) + VECEACH(target->source_dirs, i) { - const char *name = target->sources[i]; + const char *name = target->source_dirs[i]; size_t name_len = strlen(name); if (name_len < 1) goto INVALID_NAME; if (name[name_len - 1] == '*') @@ -482,7 +482,7 @@ static void target_expand_source_names(BuildTarget *target) void compile_target(BuildOptions *options) { - init_default_build_target(&active_target, options, "foo.out"); + init_default_build_target(&active_target, options, "a.out"); compile(); } @@ -494,9 +494,9 @@ void compile_file_list(BuildOptions *options) void compile() { + target_expand_source_names(&active_target); global_context.sources = active_target.sources; symtab_init(active_target.symtab_size ? active_target.symtab_size : 64 * 1024); - target_expand_source_names(&active_target); target_setup(&active_target); if (!vec_size(active_target.sources)) error_exit("No files to compile.");