Skip to content
Snippets Groups Projects
Commit 8417372e authored by Patrick Baudin's avatar Patrick Baudin
Browse files

[Lint] using generic rules as much as possible

parent db7513a5
No related branches found
No related tags found
No related merge requests found
...@@ -128,28 +128,19 @@ endif ...@@ -128,28 +128,19 @@ endif
.PHONY: clean-lint .PHONY: clean-lint
clean-lint: clean-lint:
echo "Cleaning LINT targets..." echo "Cleaning LINT targets..."
$(RM) -r .lint rm -rf .lint
clean:: clean-lint clean:: clean-lint
.PHONY: clean-check-eoleof #### clean-check-XXX targets
clean-check-eoleof:
echo "Cleaning LINT $(patsubst clean-%,%,$@) targets..."
find .lint -type f -name \*.$(patsubst clean-%,%,$@) | xargs -n 10 $(RM)
.PHONY: clean-check-utf8 LINT.clean-targets= \
clean-check-utf8: clean-check-eoleof clean-check-utf8 clean-check-syntax clean-check-ident
echo "Cleaning LINT $(patsubst clean-%,%,$@) targets..." .PHONY: clean-check-eoleof clean-check-utf8 clean-check-syntax clean-check-ident
find .lint -type f -name \*.$(patsubst clean-%,%,$@) | xargs -n 10 $(RM)
.PHONY: clean-check-syntax # Generic rule
clean-check-syntax: $(LINT.clean-targets):
echo "Cleaning LINT $(patsubst clean-%,%,$@) targets..." echo "[LINT] Cleaning $(patsubst clean-%,%,$@) targets..."
find .lint -type f -name \*.$(patsubst clean-%,%,$@) | xargs -n 10 $(RM)
.PHONY: clean-check-ident
clean-check-indent:
echo "Cleaning LINT $(patsubst clean-%,%,$@) targets..."
find .lint -type f -name \*.$(patsubst clean-%,%,$@) | xargs -n 10 $(RM) find .lint -type f -name \*.$(patsubst clean-%,%,$@) | xargs -n 10 $(RM)
############################### ###############################
...@@ -160,69 +151,34 @@ ifeq ($(LINT_FILE),) ...@@ -160,69 +151,34 @@ ifeq ($(LINT_FILE),)
LINT.dir=$(wildcard $(LINT_DIR)) LINT.dir=$(wildcard $(LINT_DIR))
.PHONY: check-utf8 #### check-XXX targets
check-utf8:
echo "Checking UTF8..."
$(GIT) ls-files $(LINT.dir) -z \
| $(GIT) check-attr --stdin -z $@ \
| $(SED) -zne 'x;n;n;s/^set$$//;t print;b;:print;x;p' \
| xargs --null -IXX sh -c '$(LINT.make) LINT_FILE="XX" $@ || exit 255'
.PHONY: fix-utf8 LINT.check-targets= \
fix-utf8: check-syntax check-indent check-eoleof check-utf8
echo "Fixing UTF8..." .PHONY: check-syntax check-indent check-eoleof check-utf8
$(GIT) ls-files $(LINT.dir) -z \
| $(GIT) check-attr --stdin -z $(patsubst fix-%,check-%,$@) \
| $(SED) -zne 'x;n;n;s/^set$$//;t print;b;:print;x;p' \
| xargs --null -IXX sh -c '$(LINT.make) LINT_FILE="XX" $@ || exit 255'
.PHONY: check-eoleof # Generic rule
check-eoleof: $(LINT.check-targets):
echo "Checking EOL EOF..." echo "[LINT] Checking from GIT attribute $@..."
$(GIT) ls-files $(LINT.dir) -z \ $(GIT) ls-files $(LINT.dir) -z \
| $(GIT) check-attr --stdin -z $@ \ | $(GIT) check-attr --stdin -z $@ \
| $(SED) -zne 'x;n;n;s/^set$$//;t print;b;:print;x;p' \ | $(SED) -zne 'x;n;n;s/^set$$//;t print;b;:print;x;p' \
| xargs --null -IXX sh -c '$(LINT.make) LINT_FILE="XX" $@ || exit 255' | xargs --null -IXX sh -c '$(LINT.make) LINT_FILE="XX" $@ || exit 255'
.PHONY: fix-eoleof #### fix-XXX targets
fix-eoleof:
echo "Fixing EOL EOF..."
$(GIT) ls-files $(LINT.dir) -z \
| $(GIT) check-attr --stdin -z $(patsubst fix-%,check-%,$@) \
| $(SED) -zne 'x;n;n;s/^set$$//;t print;b;:print;x;p' \
| xargs --null -IXX sh -c '$(LINT.make) LINT_FILE="XX" $@ || exit 255'
.PHONY: check-syntax LINT.fix-targets= \
check-syntax: fix-eoleof fix-utf8 fix-syntax fix-ident
echo "Checking syntax..." .PHONY: fix-eoleof fix-utf8 fix-syntax fix-ident
$(GIT) ls-files $(LINT.dir) -z \
| $(GIT) check-attr --stdin -z $@ \
| $(SED) -zne 'x;n;n;s/^set$$//;t print;b;:print;x;p' \
| xargs --null -IXX sh -c '$(LINT.make) LINT_FILE="XX" $@ || exit 255'
.PHONY: fix-syntax # Generic rule
fix-syntax: $(LINT.fix-targets):
echo "Fixing syntax..." echo "[LINT] Fixing from GIT attribute $(patsubst fix-%,check-%,$@)..."
$(GIT) ls-files $(LINT.dir) -z \ $(GIT) ls-files $(LINT.dir) -z \
| $(GIT) check-attr --stdin -z $(patsubst fix-%,check-%,$@) \ | $(GIT) check-attr --stdin -z $(patsubst fix-%,check-%,$@) \
| $(SED) -zne 'x;n;n;s/^set$$//;t print;b;:print;x;p' \ | $(SED) -zne 'x;n;n;s/^set$$//;t print;b;:print;x;p' \
| xargs --null -IXX sh -c '$(LINT.make) LINT_FILE="XX" $@ || exit 255' | xargs --null -IXX sh -c '$(LINT.make) LINT_FILE="XX" $@ || exit 255'
.PHONY: check-indent
check-indent:
echo "Checking indent..."
$(GIT) ls-files $(LINT.dir) -z \
| $(GIT) check-attr --stdin -z $@ \
| $(SED) -zne 'x;n;n;s/^set$$//;t print;b;:print;x;p' \
| xargs --null -IXX sh -c '$(LINT.make) LINT_FILE="XX" $@ || exit 255'
.PHONY: fix-indent
fix-indent:
echo "Fixing indent..."
$(GIT) ls-files $(LINT.dir) -z \
| $(GIT) check-attr --stdin -z $(patsubs fix-,check-,$@) \
| $(SED) -zne 'x;n;n;s/^set$$//;t print;b;:print;x;p' \
| xargs --null -IXX sh -c '$(LINT.make) LINT_FILE="XX" $@ || exit 255'
else # LINT_FILE are given else # LINT_FILE are given
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment