Skip to content

Commit

Permalink
feat: enable preprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
diohabara committed Aug 1, 2023
1 parent ea52abd commit 7fadafd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ tmp*
# for debug
test
.gdb_history

# stages
stage1/
stage2/
stage3/
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,27 @@ ccc: $(OBJS)

$(OBJS): ccc.h

STAGES = stage1 stage2 stage3

define PROCESS_STAGE_RULE
$(1)/%.c: %.c
mkdir -p $(1)
gcc -E $$< | grep -v '^#' > $$@
endef

$(foreach stage,$(STAGES),$(eval $(call PROCESS_STAGE_RULE,$(stage))))

PROCESSED_SRCS = $(foreach stage,$(STAGES),$(addprefix $(stage)/,$(SRCS)))

process: $(PROCESSED_SRCS)

help:
@echo "Usage: make [lint|test|debug|clean]"
@echo "Usage: make [lint|test|debug|clean|process]"
@echo " lint: run c and shell checker"
@echo " test: run tests"
@echo " debug: run tests in debug mode"
@echo " clean: remove object files"
@echo " process: run the preprocessor on all source files for each stage"

lint:
clang-format -i ./*.c
Expand All @@ -33,4 +48,4 @@ testx:
clean:
rm -f ccc *.o *~ tmp*

.PHONY: help lint test lean
.PHONY: help lint test clean process

0 comments on commit 7fadafd

Please sign in to comment.