Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Commit

Permalink
#3: abscence of object files did not force makefile to recompile file
Browse files Browse the repository at this point in the history
  • Loading branch information
Milk-Cool committed Nov 28, 2023
1 parent c70ee82 commit c529902
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ $(OUT_APP):
fi
# $(CC_PREFIX_FINAL) $(CC_EXTRA) -I$(LIBS) -I$(LIBS_HAL) -I$(HELPERS) -I$(EXT_LIB_ALL) $(SRC_APP) $(SOURCES) -lSDL2 -lSDL2_ttf -lm -lbsd -o $(OUT_APP)
for file in $(SRC_APP) $(SOURCES); do \
dateextr=`date -r "$$file" +%s`; \
datejson=`jq '.["'$$file'"]' $(TIMESTAMPS) | sed 's/"//g'`; \
if [ "$$dateextr" != "$$datejson" ]; then \
objname=`echo "$$file" | sed 's/\.c/\.o/g'`; \
jsout=$$(node compile.js $$file); \
objname=$$(echo $$jsout | jq -r '.obj'); \
dateextr=$$(echo $$jsout | jq -r '.time'); \
if [ $$objname ]; then \
$(CC_PREFIX_FINAL) -c $(CC_EXTRA) -I$(LIBS) -I$(LIBS_HAL) -I$(HELPERS) -I$(EXT_LIB_ALL) "$$file" -o $$objname $(CC_POSTFIX_FINAL); \
echo CC: $$file = $$objname; \
jq '.["'$$file'"] = "'$$dateextr'"' $(TIMESTAMPS) > $(TIMESTAMPS_TMP); mv $(TIMESTAMPS_TMP) $(TIMESTAMPS); \
Expand Down
15 changes: 15 additions & 0 deletions compile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const fs = require("fs");

const file = process.argv[process.argv.length - 1];
const obj = file.replaceAll(".c", ".o");

const timestamps = require("./timestamps.json");
const time = timestamps[file];

const et = Math.floor(fs.statSync(file).ctime / 1000);

if(!fs.existsSync(obj) || time != et)
console.log(JSON.stringify({
"obj": obj,
"time": et
}));

0 comments on commit c529902

Please sign in to comment.