aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlendi <slendi@socopon.com>2024-01-13 00:08:46 +0200
committerSlendi <slendi@socopon.com>2024-01-13 00:09:48 +0200
commitcea318f986ae5252c5ae06625effcde9dc35b111 (patch)
tree865551a0a3161aa1214af3a49a6e9adffd819d8a
parentf30b68d27370d8c95e214d241cd65da69ab2bddc (diff)
Add README.md and install script
Signed-off-by: Slendi <slendi@socopon.com>
-rw-r--r--README.md38
-rwxr-xr-xinstall.sh7
-rwxr-xr-xtest_project/build.c3
3 files changed, 46 insertions, 2 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..6f20da4
--- /dev/null
+++ b/README.md
@@ -0,0 +1,38 @@
+# Ebuild
+
+A build system fully made in C, with configuration in C as well.
+
+It's pretty simple to use, just put the `.c` and `.h` files in your include path, and then include the header file.
+You can then write a small C program, I personally call it `build.c` which contains something like this:
+```c
+#if 0
+tcc -run build.c $@
+exit
+#endif
+
+#define CBUILD_IMPLEMENTATION
+#include <cbuild.h>
+
+int main(int argc, char **argv) {
+ project_t proj = create_project("Sample project", "v1.0", LANG_C);
+ char *sources;
+ if (find_sources_in_directory(".*\\.c", "src", &sources) == false) {
+ fprintf(stderr, "No sources found\n");
+ exit(1);
+ }
+ executable_t exe = create_executable("hello", sources);
+ add_target(&proj, &exe);
+ if (argc > 1) {
+ if (strcmp(argv[1], "clean") == 0) {
+ clean(proj);
+ return 0;
+ }
+ }
+ build(proj);
+ return 0;
+}
+```
+As you can see, you can either use this as a header-only library, or you can compile the `.c` file and have it as a shared library somewhere.
+
+After that, you can either run the compiler manually in the CLI, or, if you're on Linux, just make the file executable and run it with `./build.c` or whatever you named your file.
+
diff --git a/install.sh b/install.sh
new file mode 100755
index 0000000..7f17f08
--- /dev/null
+++ b/install.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+set -ex
+
+install -m 644 -D cbuild.h /usr/local/include/cbuild.h
+install -m 644 -D cbuild_impl.c /usr/local/include/cbuild_impl.c
+
diff --git a/test_project/build.c b/test_project/build.c
index 911b7fc..b85b016 100755
--- a/test_project/build.c
+++ b/test_project/build.c
@@ -1,6 +1,5 @@
#if 0
-#How to compile and run
-tcc -I.. -run build.c $@
+tcc -run build.c $@
exit
#endif