mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
Support c-file compilation in libraries.
This commit is contained in:
5
.github/workflows/main.yml
vendored
5
.github/workflows/main.yml
vendored
@@ -45,7 +45,7 @@ jobs:
|
||||
|
||||
- name: Build testproject
|
||||
run: |
|
||||
set PATH=%PATH%;"C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64"
|
||||
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
|
||||
cd resources/testproject
|
||||
..\..\build\${{ matrix.build_type }}\c3c.exe --debug-log --emit-llvm run hello_world_win32
|
||||
dir build\llvm_ir
|
||||
@@ -56,6 +56,7 @@ jobs:
|
||||
- name: Build testproject lib
|
||||
run: |
|
||||
cd resources/testproject
|
||||
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
|
||||
..\..\build\${{ matrix.build_type }}\c3c.exe --debug-log build hello_world_win32_lib
|
||||
|
||||
- name: Vendor-fetch
|
||||
@@ -142,7 +143,7 @@ jobs:
|
||||
- name: Build testproject lib
|
||||
run: |
|
||||
cd resources/testproject
|
||||
../../build/c3c build hello_world_lib --debug-log
|
||||
../../build/c3c build hello_world_lib --cc cc --debug-log
|
||||
|
||||
- name: run compiler tests
|
||||
run: |
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
"targets": {
|
||||
"hello_world": {
|
||||
"type": "executable",
|
||||
"cc" : "cc",
|
||||
"c-sources-override": [
|
||||
"./csource/**"
|
||||
],
|
||||
@@ -27,12 +28,12 @@
|
||||
},
|
||||
"hello_world_win32": {
|
||||
"type": "executable",
|
||||
"cc" : "cl.exe",
|
||||
"c-sources-override": [
|
||||
]
|
||||
},
|
||||
"hello_world_lib": {
|
||||
"type": "static-lib",
|
||||
"cc" : "cc",
|
||||
"c-sources-override": [
|
||||
"./csource/**"
|
||||
]
|
||||
|
||||
@@ -782,19 +782,9 @@ const char *cc_compiler(const char *cc, const char *file, const char *flags)
|
||||
len -= 2;
|
||||
filename[len] = 0;
|
||||
}
|
||||
const char *out_name;
|
||||
if (is_cl_exe)
|
||||
{
|
||||
out_name = dir
|
||||
? str_printf("/Fo:\"%s\\%s%s\"", dir, filename, get_object_extension())
|
||||
: str_printf("/Fo:\"%s%s\"", filename, get_object_extension());
|
||||
}
|
||||
else
|
||||
{
|
||||
out_name = dir
|
||||
? str_printf("%s/%s%s", dir, filename, get_object_extension())
|
||||
: str_printf("%s%s", filename, get_object_extension());
|
||||
}
|
||||
const char *out_name = dir
|
||||
? str_printf("%s/%s%s", dir, filename, get_object_extension())
|
||||
: str_printf("%s%s", filename, get_object_extension());;
|
||||
const char **parts = NULL;
|
||||
vec_add(parts, cc);
|
||||
|
||||
@@ -812,8 +802,15 @@ const char *cc_compiler(const char *cc, const char *file, const char *flags)
|
||||
vec_add(parts, is_cl_exe ? "/c" : "-c");
|
||||
if (flags) vec_add(parts, flags);
|
||||
vec_add(parts, file);
|
||||
if (!is_cl_exe) vec_add(parts, "-o");
|
||||
vec_add(parts, out_name);
|
||||
if (is_cl_exe)
|
||||
{
|
||||
vec_add(parts, str_printf("/Fo:\"%s\"", out_name));
|
||||
}
|
||||
else
|
||||
{
|
||||
vec_add(parts, "-o");
|
||||
vec_add(parts, out_name);
|
||||
}
|
||||
|
||||
const char *output = concat_string_parts(parts);
|
||||
DEBUG_LOG("Compiling c sources using '%s'", output);
|
||||
|
||||
Reference in New Issue
Block a user