Skip to content

Commit

Permalink
In monitor mode, changes to _minibuild_ files cause a restart.
Browse files Browse the repository at this point in the history
  • Loading branch information
rajamukherji committed Jul 1, 2018
1 parent e69ee08 commit be960cc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion minilang
Submodule minilang updated 1 files
+1 −0 minilang.c
12 changes: 11 additions & 1 deletion rabs.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ static int EchoCommands = 0;

static stringmap_t Globals[1] = {STRINGMAP_INIT};
static stringmap_t Defines[1] = {STRINGMAP_INIT};
static int SavedArgc;
static char **SavedArgv;

static ml_value_t *rabs_ml_get(void *Data, const char *Name) {
ml_value_t *Value = context_symb_get(CurrentContext, Name);
Expand Down Expand Up @@ -55,6 +57,7 @@ static ml_value_t *rabs_ml_global(void *Data, const char *Name) {
}

static void load_file(const char *FileName) {
if (MonitorFiles) targetwatch_add(FileName, (target_t *)-1);
ml_value_t *Closure = ml_load(rabs_ml_global, NULL, FileName);
if (Closure->Type == MLErrorT) {
printf("\e[31mError: %s\n\e[0m", ml_error_message(Closure));
Expand Down Expand Up @@ -335,7 +338,14 @@ static ml_value_t *debug(void *Data, int Count, ml_value_t **Args) {
return MLNil;
}

int main(int Argc, const char **Argv) {
void restart() {
cache_close();
execv(SavedArgv[0], SavedArgv);
}

int main(int Argc, char **Argv) {
SavedArgc = Argc;
SavedArgv = Argv;
GC_INIT();
ml_init();
AppendMethod = ml_method("append");
Expand Down
1 change: 1 addition & 0 deletions rabs.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@

extern const char *RootPath, *SystemName;
extern __thread const char *CurrentPath;
void restart();

#endif
1 change: 1 addition & 0 deletions target.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ void target_update(target_t *Target) {
}

void target_recheck(target_t *Target) {
if (Target == (target_t *)-1) restart();
printf("Rechecking %s\n", Target->Id);
cache_bump_version();
++QueuedTargets;
Expand Down

0 comments on commit be960cc

Please sign in to comment.