From 5006226e945fc645e6d9b21252c9eee53cc191cc Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 23 Sep 2018 12:22:37 +0200 Subject: Fix various things, add generated zig header files to global include Fix compile_commands.json missing build steps. Fix c includes -> zig includes flags. Fix crash when running sibs new/init without defining lang. Add generated zig header files to global include so they can be used from c/c++. Add zig and zig/c (using zig and c in the same project) examples. --- examples/hello_world/.gitignore | 5 ----- examples/hello_world/project.conf | 6 ------ examples/hello_world/src/main.cpp | 7 ------- examples/hello_world/tests/main.cpp | 7 ------- examples/hello_world_c_zig/.gitignore | 5 +++++ examples/hello_world_c_zig/project.conf | 8 ++++++++ examples/hello_world_c_zig/src/foo.zig | 8 ++++++++ examples/hello_world_c_zig/src/main.c | 14 ++++++++++++++ examples/hello_world_c_zig/tests/main.c | 7 +++++++ examples/hello_world_cpp/.gitignore | 5 +++++ examples/hello_world_cpp/project.conf | 6 ++++++ examples/hello_world_cpp/src/main.cpp | 7 +++++++ examples/hello_world_cpp/tests/main.cpp | 7 +++++++ examples/hello_world_zig/.gitignore | 5 +++++ examples/hello_world_zig/project.conf | 5 +++++ examples/hello_world_zig/src/main.zig | 6 ++++++ 16 files changed, 83 insertions(+), 25 deletions(-) delete mode 100644 examples/hello_world/.gitignore delete mode 100644 examples/hello_world/project.conf delete mode 100644 examples/hello_world/src/main.cpp delete mode 100644 examples/hello_world/tests/main.cpp create mode 100644 examples/hello_world_c_zig/.gitignore create mode 100644 examples/hello_world_c_zig/project.conf create mode 100644 examples/hello_world_c_zig/src/foo.zig create mode 100644 examples/hello_world_c_zig/src/main.c create mode 100644 examples/hello_world_c_zig/tests/main.c create mode 100644 examples/hello_world_cpp/.gitignore create mode 100644 examples/hello_world_cpp/project.conf create mode 100644 examples/hello_world_cpp/src/main.cpp create mode 100644 examples/hello_world_cpp/tests/main.cpp create mode 100644 examples/hello_world_zig/.gitignore create mode 100644 examples/hello_world_zig/project.conf create mode 100644 examples/hello_world_zig/src/main.zig (limited to 'examples') diff --git a/examples/hello_world/.gitignore b/examples/hello_world/.gitignore deleted file mode 100644 index 636c6b9..0000000 --- a/examples/hello_world/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# Compiled sibs files -sibs-build/ -compile_commands.json -tests/sibs-build/ -tests/compile_commands.json diff --git a/examples/hello_world/project.conf b/examples/hello_world/project.conf deleted file mode 100644 index 4c05ce5..0000000 --- a/examples/hello_world/project.conf +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "hello_world" -type = "executable" -version = "0.1.0" -platforms = ["any"] -tests = "tests" diff --git a/examples/hello_world/src/main.cpp b/examples/hello_world/src/main.cpp deleted file mode 100644 index 28bab08..0000000 --- a/examples/hello_world/src/main.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -int main(int argc, char **argv) -{ - printf("hello, world!\n"); - return 0; -} diff --git a/examples/hello_world/tests/main.cpp b/examples/hello_world/tests/main.cpp deleted file mode 100644 index 28bab08..0000000 --- a/examples/hello_world/tests/main.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -int main(int argc, char **argv) -{ - printf("hello, world!\n"); - return 0; -} diff --git a/examples/hello_world_c_zig/.gitignore b/examples/hello_world_c_zig/.gitignore new file mode 100644 index 0000000..636c6b9 --- /dev/null +++ b/examples/hello_world_c_zig/.gitignore @@ -0,0 +1,5 @@ +# Compiled sibs files +sibs-build/ +compile_commands.json +tests/sibs-build/ +tests/compile_commands.json diff --git a/examples/hello_world_c_zig/project.conf b/examples/hello_world_c_zig/project.conf new file mode 100644 index 0000000..fa006cd --- /dev/null +++ b/examples/hello_world_c_zig/project.conf @@ -0,0 +1,8 @@ +[package] +name = "hello_world_c_zig" +type = "executable" +version = "0.1.0" +platforms = ["linux64"] +tests = "tests" + +[dependencies] diff --git a/examples/hello_world_c_zig/src/foo.zig b/examples/hello_world_c_zig/src/foo.zig new file mode 100644 index 0000000..464eadd --- /dev/null +++ b/examples/hello_world_c_zig/src/foo.zig @@ -0,0 +1,8 @@ +const warn = @import("std").debug.warn; + +extern fn baz() void; + +export fn foo() void { + warn("zig called from c!\n"); + baz(); +} diff --git a/examples/hello_world_c_zig/src/main.c b/examples/hello_world_c_zig/src/main.c new file mode 100644 index 0000000..aeaeae4 --- /dev/null +++ b/examples/hello_world_c_zig/src/main.c @@ -0,0 +1,14 @@ +#include +#include + +void baz() +{ + printf("c called from zig!\n"); +} + +int main(int argc, char **argv) +{ + printf("inside c\n"); + foo(); + return 0; +} diff --git a/examples/hello_world_c_zig/tests/main.c b/examples/hello_world_c_zig/tests/main.c new file mode 100644 index 0000000..9ad80a6 --- /dev/null +++ b/examples/hello_world_c_zig/tests/main.c @@ -0,0 +1,7 @@ +#include + +int main(int argc, char **argv) +{ + printf("hello, world!\n"); + return 0; +} diff --git a/examples/hello_world_cpp/.gitignore b/examples/hello_world_cpp/.gitignore new file mode 100644 index 0000000..636c6b9 --- /dev/null +++ b/examples/hello_world_cpp/.gitignore @@ -0,0 +1,5 @@ +# Compiled sibs files +sibs-build/ +compile_commands.json +tests/sibs-build/ +tests/compile_commands.json diff --git a/examples/hello_world_cpp/project.conf b/examples/hello_world_cpp/project.conf new file mode 100644 index 0000000..4c05ce5 --- /dev/null +++ b/examples/hello_world_cpp/project.conf @@ -0,0 +1,6 @@ +[package] +name = "hello_world" +type = "executable" +version = "0.1.0" +platforms = ["any"] +tests = "tests" diff --git a/examples/hello_world_cpp/src/main.cpp b/examples/hello_world_cpp/src/main.cpp new file mode 100644 index 0000000..28bab08 --- /dev/null +++ b/examples/hello_world_cpp/src/main.cpp @@ -0,0 +1,7 @@ +#include + +int main(int argc, char **argv) +{ + printf("hello, world!\n"); + return 0; +} diff --git a/examples/hello_world_cpp/tests/main.cpp b/examples/hello_world_cpp/tests/main.cpp new file mode 100644 index 0000000..28bab08 --- /dev/null +++ b/examples/hello_world_cpp/tests/main.cpp @@ -0,0 +1,7 @@ +#include + +int main(int argc, char **argv) +{ + printf("hello, world!\n"); + return 0; +} diff --git a/examples/hello_world_zig/.gitignore b/examples/hello_world_zig/.gitignore new file mode 100644 index 0000000..636c6b9 --- /dev/null +++ b/examples/hello_world_zig/.gitignore @@ -0,0 +1,5 @@ +# Compiled sibs files +sibs-build/ +compile_commands.json +tests/sibs-build/ +tests/compile_commands.json diff --git a/examples/hello_world_zig/project.conf b/examples/hello_world_zig/project.conf new file mode 100644 index 0000000..6ad2e1b --- /dev/null +++ b/examples/hello_world_zig/project.conf @@ -0,0 +1,5 @@ +[package] +name = "hello_world_zig" +type = "executable" +version = "0.1.0" +platforms = ["any"] diff --git a/examples/hello_world_zig/src/main.zig b/examples/hello_world_zig/src/main.zig new file mode 100644 index 0000000..c74a3de --- /dev/null +++ b/examples/hello_world_zig/src/main.zig @@ -0,0 +1,6 @@ +const warn = @import("std").debug.warn; + +pub fn main() void +{ + warn("Hello, world!\n"); +} -- cgit v1.2.3