updated the run function so it actually works

This commit is contained in:
Odweta
2023-12-27 17:01:38 +01:00
parent 51d046e790
commit 8ac4a0d584
3 changed files with 4 additions and 24 deletions
+1
View File
@@ -50,6 +50,7 @@ char *create_new_makefile(char src_files[][1000]) {
strcpy(makefile, "\
CC := gcc\n\
CFLAGS := -Wall -Werror\n\
LIBS := -lvector -lfile -llist -lutil\n\
LIBSPATH := -L/usr/lib/odweta/\n\
INCLUDEDIR := -I/usr/include/odweta/\n\
PATCH := -Wl,-rpath=/usr/lib/odweta/\n\
+1
View File
@@ -33,6 +33,7 @@ void makefile(char *name, char *path) {
char *payload = "\
CC := gcc\n\
CFLAGS := -Wall -Werror\n\
LIBS := -lvector -lfile -llist -lutil\n\
LIBSPATH := -L/usr/lib/odweta/\n\
INCLUDEDIR := -I/usr/include/odweta/\n\
PATCH := -Wl,-rpath=/usr/lib/odweta/\n\
+2 -24
View File
@@ -1,31 +1,9 @@
#include "../include/run.h"
#include "../include/build.h"
#include <stdio.h>
#include <stdlib.h>
int get_build_status() {
FILE *fd = fopen("./build/.build_status", "r");
if (!fd) {
fprintf(stderr, "Build the project before running it.\n");
exit(1);
}
int i;
fscanf(fd, "%d", &i);
fclose(fd);
return i; // max 10 codes (so far only 2 => 0 -> success, 1 -> failure)
}
void run_project() {
if (get_build_status() == 0) { // success
// file exists => project has been built
system("make run");
} else {
// file does not exist => project has not been built
build_project();
run_project();
}
build_project();
system("make run");
}