diff --git a/resources/testproject/hello_world.c3 b/resources/testproject/hello_world.c3 index 97c720056..495a8acdf 100644 --- a/resources/testproject/hello_world.c3 +++ b/resources/testproject/hello_world.c3 @@ -2,6 +2,7 @@ module hello_world; import std; import bar; import clib; +import clib2; fn int test_doubler(int x) @if(env::WIN32) => x * x; extern fn int test_doubler(int) @if(!env::WIN32); @@ -14,5 +15,6 @@ fn int main() printf("Hello double: %d\n", test_doubler(11)); if ($feature(ABCD)) io::printn("ABCD"); clib::hello_from_c(); + clib2::hello_from_c_zip(); return 0; } \ No newline at end of file diff --git a/resources/testproject/lib/clib.c3l/hello.c b/resources/testproject/lib/clib.c3l/hello2.c similarity index 100% rename from resources/testproject/lib/clib.c3l/hello.c rename to resources/testproject/lib/clib.c3l/hello2.c diff --git a/resources/testproject/lib/clib.c3l/manifest.json b/resources/testproject/lib/clib.c3l/manifest.json index 8169c6505..afaf59e3e 100644 --- a/resources/testproject/lib/clib.c3l/manifest.json +++ b/resources/testproject/lib/clib.c3l/manifest.json @@ -1,6 +1,6 @@ { "provides" : "clib", - "c-sources" : ["hello.c"], + "c-sources" : ["hello2.c"], "targets" : { "macos-x64" : { }, diff --git a/resources/testproject/lib/clib2.c3l b/resources/testproject/lib/clib2.c3l new file mode 100644 index 000000000..0e64c8eba Binary files /dev/null and b/resources/testproject/lib/clib2.c3l differ diff --git a/resources/testproject/project.json b/resources/testproject/project.json index 8cf0853fe..485a5d562 100644 --- a/resources/testproject/project.json +++ b/resources/testproject/project.json @@ -12,7 +12,7 @@ "./**" ], "dependency-search-paths": [ "./lib" ], - "dependencies": ["clib"], + "dependencies": ["clib", "clib2"], "features": ["ABCD"], diff --git a/src/compiler/compiler.c b/src/compiler/compiler.c index 00d122250..73df7246b 100644 --- a/src/compiler/compiler.c +++ b/src/compiler/compiler.c @@ -253,12 +253,13 @@ static void free_arenas(void) if (debug_stats) print_arena_status(); } -static int compile_cfiles(const char *compiler, const char **files, const char *flags, const char **out_files) +static int compile_cfiles(const char *compiler, const char **files, const char *flags, const char **out_files, + const char *output_subdir) { int total = 0; FOREACH(const char *, file, files) { - out_files[total++] = cc_compiler(compiler, file, flags); + out_files[total++] = cc_compiler(compiler, file, flags, output_subdir); } return total; } @@ -468,14 +469,15 @@ void compiler_compile(void) if (cfiles) { - int compiled = compile_cfiles(active_target.cc, active_target.csources, active_target.cflags, &obj_files[output_file_count]); + int compiled = compile_cfiles(active_target.cc, active_target.csources, active_target.cflags, &obj_files[output_file_count], "tmp_c_compile"); assert(cfiles == compiled); (void)compiled; } const char **obj_file_next = &obj_files[output_file_count + cfiles]; FOREACH(LibraryTarget *, lib, active_target.ccompling_libraries) { - obj_file_next += compile_cfiles(lib->cc ? lib->cc : active_target.cc, lib->csources, lib->cflags, obj_file_next); + obj_file_next += compile_cfiles(lib->cc ? lib->cc : active_target.cc, lib->csources, + lib->cflags, obj_file_next, lib->parent->provides); } Task **tasks = NULL; diff --git a/src/compiler/compiler_internal.h b/src/compiler/compiler_internal.h index 0afb4dfde..6438c0527 100644 --- a/src/compiler/compiler_internal.h +++ b/src/compiler/compiler_internal.h @@ -3504,7 +3504,7 @@ bool static_lib_linker(const char *output_file, const char **files, unsigned fil bool dynamic_lib_linker(const char *output_file, const char **files, unsigned file_count); bool linker(const char *output_file, const char **files, unsigned file_count); void platform_linker(const char *output_file, const char **files, unsigned file_count); -const char *cc_compiler(const char *cc, const char *file, const char *flags); +const char *cc_compiler(const char *cc, const char *file, const char *flags, const char *output_subdir); const char *arch_to_linker_arch(ArchType arch); #define CAT(a,b) CAT2(a,b) // force expand diff --git a/src/compiler/linker.c b/src/compiler/linker.c index 155f8337a..779e1bf59 100644 --- a/src/compiler/linker.c +++ b/src/compiler/linker.c @@ -761,11 +761,12 @@ void platform_linker(const char *output_file, const char **files, unsigned file_ printf("Program linked to executable '%s'.\n", output_file); } -const char *cc_compiler(const char *cc, const char *file, const char *flags) +const char *cc_compiler(const char *cc, const char *file, const char *flags, const char *output_subdir) { const char *dir = active_target.object_file_dir; if (!dir) dir = active_target.build_dir; - + if (output_subdir) dir = file_append_path(dir, output_subdir); + dir_make(dir); bool is_cl_exe = str_eq(cc, "cl.exe"); char *filename = NULL; bool split_worked = file_namesplit(file, &filename, NULL);