summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-02-16 19:28:59 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-02-16 19:28:59 -0500
commitc7ada136f97941e0f8ab727bc424b5d90eadfaf2 (patch)
tree75bcd8be0642c20782f560c9554ab57f6d90b227
parente10e68bfd7adda727d18dca27196798400f1a119 (diff)
fix :build, add `cargo build`
-rw-r--r--build.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/build.c b/build.c
index 1ff93e5..04c6250 100644
--- a/build.c
+++ b/build.c
@@ -9,13 +9,31 @@ static void build_clear(Ted *ted) {
static void build_start(Ted *ted) {
// get rid of any old build errors
build_clear(ted);
-
+
+ bool cargo = false;
+
chdir(ted->cwd);
+
+ if (fs_file_exists("Cargo.toml")) {
+ cargo = true;
+ } else if (fs_file_exists(".." PATH_SEPARATOR_STR "Cargo.toml")) {
+ chdir("..");
+ cargo = true;
+ } else if (fs_file_exists(".." PATH_SEPARATOR_STR ".." PATH_SEPARATOR_STR "Cargo.toml")) {
+ chdir(".." PATH_SEPARATOR_STR "..");
+ cargo = true;
+ }
+
#if __unix__
char *program = "/bin/sh";
- char *argv[] = {
- program, "-c", "make", NULL
+ char *argv[5] = {
+ program, "-c", NULL, NULL, NULL
};
+ if (cargo) {
+ argv[2] = "cargo build";
+ } else {
+ argv[2] = "make";
+ }
#else
#error "TODO"
#endif
@@ -83,7 +101,7 @@ static void build_frame(Ted *ted, float x1, float y1, float x2, float y2) {
bool any_text_inserted = false;
while (1) {
char incomplete[4];
- memcpy(ted->build_incomplete_codepoint, incomplete, sizeof incomplete);
+ memcpy(incomplete, ted->build_incomplete_codepoint, sizeof incomplete);
*ted->build_incomplete_codepoint = 0;
i64 bytes_read = (i64)process_read(process, buf + 3, sizeof buf - 3);