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

Commit

Permalink
faster compilation times!
Browse files Browse the repository at this point in the history
  • Loading branch information
Milk-Cool committed Nov 2, 2023
1 parent 253e52a commit 6f413e4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ dist
# CUSTOM ENTRIES

# Object files
flipper/**/*.o
helpers/**/*.o
**/*.o

# Test script
test.sh
Expand All @@ -161,4 +160,7 @@ wasm/
.gdb_history

# Storage
flippulator_sd
flippulator_sd

# Build timestamps
timestamps.json
28 changes: 23 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ HELPERS = helpers/
APP = flippulator_app_copy/
SOURCES = $(shell find $(LIBS) -name "*.c") $(shell find $(LIBS_HAL) -name "*.c") $(shell find $(HELPERS) -name "*.c") $(shell find $(EXT_LIB_ALL) -name "*.c")
SRC_APP = $(shell find $(APP) -name "*.c")
#OBJECTS = ${subst .c,.o,$(SOURCES)}
OBJECTS = ${subst .c,.o,$(SOURCES)} ${subst .c,.o,$(SRC_APP)}
OUT_DIR = $(shell cat /tmp/flippulator_temp_out_app_dir)
OUT_APP_NAME = $(shell cat /tmp/flippulator_temp_out_app_name)
CC_EXTRA = $(shell cat /tmp/flippulator_temp_cc_extra)
Expand All @@ -18,13 +18,16 @@ OUT_ALL = $(OUT_DIR) $(OUT_APP)
#OUT_LIB_NAME = flipper
#OUT_LIB = lib$(OUT_LIB_NAME).a
#CC_PREFIX = gcc -c -Wall# -fPIC
CC_PREFIX_FINAL = gcc -O2 -Wall -Wno-main -g -m32 -D_FLIPPULATOR
CC_PREFIX_FINAL = gcc -O2 -Wall -Wno-main -g -m32 -DFLIPPULATOR_APP_ID=\"$(OUT_APP_NAME)\" -D_FLIPPULATOR
CC_POSTFIX_FINAL = -lSDL2 -lSDL2_ttf -lm -lbsd
BUILD_LIB_heatshrink_PATH = lib/heatshrink/
BUILD_LIB_heatshrink = $(BUILD_LIB_heatshrink_PATH)libheatshrink_static.a $(BUILD_LIB_heatshrink_PATH)libheatshrink_dynamic.a
#CC_PREFIX = clang -c
CR_TEXT = \
"The FontStruction “HaxrCorp 4089” (https://fontstruct.com/fontstructions/show/192981) by “sahwar” is licensed under a Creative Commons Attribution Share Alike license (http://creativecommons.org/licenses/by-sa/3.0/)."
WASM_DIR = wasm/
TIMESTAMPS = timestamps.json
TIMESTAMPS_TMP = /tmp/flippulator_timestamps.json

all: $(OUT_ALL)

Expand All @@ -34,7 +37,22 @@ $(OUT_DIR): $(OUT_APP) $(SRC_FONT)

$(OUT_APP):
mkdir $(OUT_DIR)
$(CC_PREFIX_FINAL) $(CC_EXTRA) -I$(LIBS) -I$(LIBS_HAL) -I$(HELPERS) -I$(EXT_LIB_ALL) $(SRC_APP) $(SOURCES) -DFLIPPULATOR_APP_ID=\"$(OUT_APP_NAME)\" -lSDL2 -lSDL2_ttf -lm -lbsd -o $(OUT_APP)
touch $(TIMESTAMPS)
if [ ! -s $(TIMESTAMPS) ]; then \
echo '{}' > $(TIMESTAMPS); \
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'`; \
$(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); \
fi; \
done
$(CC_PREFIX_FINAL) $(OBJECTS) -o $(OUT_APP) $(CC_POSTFIX_FINAL)

#$(BUILD_LIB_heatshrink):
# make -C lib/heatshrink libraries
Expand All @@ -53,6 +71,6 @@ clean:
$(WASM_DIR):
mkdir $(WASM_DIR)

wasm: $(WASM_DIR)
emcc -O2 $(SOURCES) $(SRC_APP) $(CC_EXTRA) -g -s WASM=1 -s USE_SDL=2 -s USE_SDL_TTF=2 --preload-file $(SRC_FONT) -o $(WASM_DIR)index.html -I$(LIBS) -I$(LIBS_HAL) -I$(EXT_LIB_ALL) -I$(HELPERS)
#wasm: $(WASM_DIR)
# emcc -O2 $(SOURCES) $(SRC_APP) $(CC_EXTRA) -g -s WASM=1 -s USE_SDL=2 -s USE_SDL_TTF=2 --preload-file $(SRC_FONT) -o $(WASM_DIR)index.html -I$(LIBS) -I$(LIBS_HAL) -I$(EXT_LIB_ALL) -I$(HELPERS)

0 comments on commit 6f413e4

Please sign in to comment.