diff --git a/Makefile b/Makefile index e716807..5927d41 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,8 @@ SRC_DIR := src SOURCES != find '$(SRC_DIR)' -iname '*.v' V_PATH ?= v -V := $(V_PATH) -showcc -gc boehm -W -d use_openssl +# We need to use GCC because TCC doesn't like the way we use C bindings +V := $(V_PATH) -showcc -gc boehm -W -d use_openssl -cc gcc all: vieter diff --git a/src/package/c/package.c b/src/package/c/package.c index a248c92..d2e3c94 100644 --- a/src/package/c/package.c +++ b/src/package/c/package.c @@ -9,7 +9,7 @@ static char *ignored_names[5] = { }; static int ignored_words_len = sizeof(ignored_names) / sizeof(char *); -inline Pkg *package_init() { +Pkg *package_init() { return calloc(sizeof(PkgInfo), 1); } diff --git a/src/package/package.c.v b/src/package/package.c.v new file mode 100644 index 0000000..a9c4784 --- /dev/null +++ b/src/package/package.c.v @@ -0,0 +1,13 @@ +module package + +#flag -I @VMODROOT/c + +// We need to specify *every* C file here. Otherwise, Vieter doesn't compile. +#flag @VMODROOT/c/package.o +#flag @VMODROOT/c/package_info.o + +#include "package.h" + +struct C.Pkg{} + +fn C.package_read_archive(pkg_path &char) &C.pkg diff --git a/src/package/v.mod b/src/package/v.mod new file mode 100644 index 0000000..dc06e78 --- /dev/null +++ b/src/package/v.mod @@ -0,0 +1,3 @@ +Module{ + name: 'package' +} diff --git a/src/package/c/dynarray.c b/src/util/c/dynarray.c similarity index 100% rename from src/package/c/dynarray.c rename to src/util/c/dynarray.c diff --git a/src/package/c/dynarray.h b/src/util/c/dynarray.h similarity index 100% rename from src/package/c/dynarray.h rename to src/util/c/dynarray.h diff --git a/src/util/util.c.v b/src/util/util.c.v new file mode 100644 index 0000000..997a18d --- /dev/null +++ b/src/util/util.c.v @@ -0,0 +1,7 @@ +module util + +#flag -I @VMODROOT/c + +// This makes the V compiler include this object file when linking, allowing +// all other C parts of the codebase to use it as well. +#flag @VMODROOT/c/dynarray.o diff --git a/src/util/v.mod b/src/util/v.mod new file mode 100644 index 0000000..39a57af --- /dev/null +++ b/src/util/v.mod @@ -0,0 +1,3 @@ +Module{ + name: 'util' +}