From 3eea219548e84efdbc3148ce378fcba865f97a01 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Fri, 6 Dec 2013 14:15:43 -0800 Subject: Add basic source formatting tools --- real.make | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'real.make') diff --git a/real.make b/real.make index 72957ce..3ae013b 100644 --- a/real.make +++ b/real.make @@ -106,6 +106,8 @@ endif include Makefile # for variables - this is handled VERY carefully +export PATH:=$(realpath ${SRC_DIR}/tools):${PATH} + # bash is needed for 'set -o pipefail' below - I have had real bugs there! # It's just not worth the bother to see if another shell works when it # needs to *and* fails when it needs to. Just use bash. @@ -245,7 +247,7 @@ obj/%.d: src/%.cpp set -o pipefail; \ ${CXX} ${CPPFLAGS} -DGENERATING_DEPENDENCIES ${CXXFLAGS} -MG -MP -MM $< \ -MT '$(patsubst %.d,%.ii,$@) $(patsubst %.d,%.ll,$@) $(patsubst %.d,%.bc,$@) $(patsubst %.d,%.s,$@) $(patsubst %.d,%.o,$@) $@' \ - | sed -e ':again; s:/[^/ ]*/\.\./:/:; t again' \ + | sed -e ':again; s:/[^/. ]*/\.\./:/:; t again' \ -e 's: ${SRC_DIR}/: :g' \ > $@ endif @@ -348,27 +350,15 @@ include ${SRC_DIR}/version.make # This is complicated and still isn't optimal. conf-raw/int-%.h: FORCE $(MKDIR_FIRST) - @grep -s -q '^$(value $*)$$' $@ \ - || { \ - echo "#define $* \\"; \ - echo '$(value $*)'; \ - } > $@ + echo '#define $* $(value $*)' | maybe-replace $@ bool_yes := true bool_no := false conf-raw/bool-%.h: FORCE $(MKDIR_FIRST) - @grep -s -q '^$(bool_$(value $*))$$' $@ \ - || { \ - echo "#define $* \\"; \ - echo '$(bool_$(value $*))'; \ - } > $@ + echo '#define $* $(bool_$(value $*))' | maybe-replace $@ conf-raw/str-%.h: FORCE $(MKDIR_FIRST) - @grep -s -q '^"$(value $*)"$$' $@ \ - || { \ - echo "#define $* \\"; \ - echo '"$(value $*)"'; \ - } > $@ + echo '#define $* "$(value $*)"' | maybe-replace $@ FORCE: ; override CPPFLAGS += -I . @@ -393,3 +383,7 @@ dist/%-bundled.tar: dist/%-src.tar dist/%-attoconf-only.tar dist: dist/tmwa-${VERSION_FULL}-src.tar dist/tmwa-${VERSION_FULL}-bundled.tar .PHONY: dist + +format: + cd ${SRC_DIR} && apply-filter 'pp-indent | bs-align' ${REAL_SOURCES} ${REAL_HEADERS} ${LEXERS} ${PARSERS} +.PHONY: format -- cgit v1.2.3-60-g2f50