updated the run function so it actually works
This commit is contained in:
@@ -50,6 +50,7 @@ char *create_new_makefile(char src_files[][1000]) {
|
|||||||
strcpy(makefile, "\
|
strcpy(makefile, "\
|
||||||
CC := gcc\n\
|
CC := gcc\n\
|
||||||
CFLAGS := -Wall -Werror\n\
|
CFLAGS := -Wall -Werror\n\
|
||||||
|
LIBS := -lvector -lfile -llist -lutil\n\
|
||||||
LIBSPATH := -L/usr/lib/odweta/\n\
|
LIBSPATH := -L/usr/lib/odweta/\n\
|
||||||
INCLUDEDIR := -I/usr/include/odweta/\n\
|
INCLUDEDIR := -I/usr/include/odweta/\n\
|
||||||
PATCH := -Wl,-rpath=/usr/lib/odweta/\n\
|
PATCH := -Wl,-rpath=/usr/lib/odweta/\n\
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ void makefile(char *name, char *path) {
|
|||||||
char *payload = "\
|
char *payload = "\
|
||||||
CC := gcc\n\
|
CC := gcc\n\
|
||||||
CFLAGS := -Wall -Werror\n\
|
CFLAGS := -Wall -Werror\n\
|
||||||
|
LIBS := -lvector -lfile -llist -lutil\n\
|
||||||
LIBSPATH := -L/usr/lib/odweta/\n\
|
LIBSPATH := -L/usr/lib/odweta/\n\
|
||||||
INCLUDEDIR := -I/usr/include/odweta/\n\
|
INCLUDEDIR := -I/usr/include/odweta/\n\
|
||||||
PATCH := -Wl,-rpath=/usr/lib/odweta/\n\
|
PATCH := -Wl,-rpath=/usr/lib/odweta/\n\
|
||||||
|
|||||||
@@ -1,31 +1,9 @@
|
|||||||
#include "../include/run.h"
|
#include "../include/run.h"
|
||||||
#include "../include/build.h"
|
#include "../include/build.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.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() {
|
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();
|
build_project();
|
||||||
run_project();
|
system("make run");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user