mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-17 07:35:45 +01:00
rework makefile logging to be more readable
added the log categories explicitly, removing the need for specifying the log colour with each log
This commit is contained in:
23
makefile
23
makefile
@@ -59,34 +59,39 @@ DIR_OBJ := obj/$(ARCH)/$(PROF)
|
|||||||
BIN := $(DIR_BIN)/$(NAME)$(EXT)
|
BIN := $(DIR_BIN)/$(NAME)$(EXT)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
define wr_colour
|
define log_col
|
||||||
@printf "\033[%sm%s\033[0m\n" $(2) $(1)
|
@printf "\033[%sm%s\033[0m\n" $(2) $(1)
|
||||||
endef
|
endef
|
||||||
|
comp = $(call log_col,$(1),92)
|
||||||
|
mesg = $(call log_col,$(1),94)
|
||||||
|
warn = $(call log_col,$(1),93)
|
||||||
|
fail = $(call log_col,$(1),91)
|
||||||
|
|
||||||
# compiles and executes the produced binary
|
# compiles and executes the produced binary
|
||||||
run: compile
|
run: compile
|
||||||
./$(BIN)
|
./$(BIN)
|
||||||
compile: compile_commands.json $(BIN)
|
compile: compile_commands.json $(BIN)
|
||||||
clean:
|
clean:
|
||||||
|
@$(call warn,"cleaning!")
|
||||||
rm -rf bin/ obj/ target/ compile_commands.json
|
rm -rf bin/ obj/ target/ compile_commands.json
|
||||||
# TODO: write a structure for the unit tests in this
|
# TODO: write a structure for the unit tests in this
|
||||||
|
|
||||||
# create the binary (linking step)
|
# create the binary (linking step)
|
||||||
$(BIN): $(C_OBJ) $(RS_LIB)
|
$(BIN): $(C_OBJ) $(RS_LIB)
|
||||||
@$(call wr_colour,"RUSTC: '$(RUSTC)'",94)
|
@$(call mesg,"RUSTC: '$(RUSTC)'")
|
||||||
@$(call wr_colour,"CC: '$(CC)'",94)
|
@$(call mesg,"CC: '$(CC)'")
|
||||||
@$(call wr_colour,"CFLAGS: '$(CFLAGS)'",94)
|
@$(call mesg,"CFLAGS: '$(CFLAGS)'")
|
||||||
@$(call wr_colour,"RSFLAGS: '$(RSFLAGS)'",94)
|
@$(call mesg,"RSFLAGS: '$(RSFLAGS)'")
|
||||||
@$(call wr_colour,"LDFLAGS: '$(LDFLAGS)'",94)
|
@$(call mesg,"LDFLAGS: '$(LDFLAGS)'")
|
||||||
@$(call wr_colour,"linking to: '$@'",92)
|
@$(call comp,"linking to: '$@'")
|
||||||
|
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
@$(CC) $(LDFLAGS) -o $@ $(C_OBJ) $(RS_LIB)
|
@$(CC) $(LDFLAGS) -o $@ $(C_OBJ) $(RS_LIB)
|
||||||
@$(call wr_colour,"current profile: '$(PROF)'",93)
|
@$(call warn,"current profile: '$(PROF)'")
|
||||||
|
|
||||||
# create .o and .d files for C sources
|
# create .o and .d files for C sources
|
||||||
$(DIR_OBJ)/%.o: src/%.c
|
$(DIR_OBJ)/%.o: src/%.c
|
||||||
@$(call wr_colour,"compiling $(notdir $@) from $(notdir $<)",92)
|
@$(call comp,"compiling $(notdir $@) from $(notdir $<)")
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
@$(CC) $(CFLAGS) -c -MD -MP -std=$(CSTD) -x c -o $@ $<
|
@$(CC) $(CFLAGS) -c -MD -MP -std=$(CSTD) -x c -o $@ $<
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user