From 8eb17ebd111cc2f58650406c03c6329a2b83c97c Mon Sep 17 00:00:00 2001 From: Vadim Markovtsev Date: Wed, 25 Oct 2017 12:30:25 +0200 Subject: [PATCH] Improve the Makefile Signed-off-by: Vadim Markovtsev --- Makefile | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 2c435c7..4d6eeb8 100644 --- a/Makefile +++ b/Makefile @@ -38,6 +38,12 @@ DARWIN_SHARED_LIB=$(DARWIN_DIR)/libenry.dylib HEADER_FILE=libenry.h NATIVE_LIB=./shared/enry.go +# source files to be patched for using "rubex" instead of "regexp" +RUBEX_PATCHED := internal/code-generator/generator/heuristics.go internal/tokenizer/tokenize.go common.go +RUBEX_ORIG := $(RUBEX_PATCHED:=.orig) + +.PHONY: revert-onigumura + $(LINGUIST_PATH): git clone https://github.com/github/linguist.git $@ @@ -63,15 +69,14 @@ benchmarks-slow: $(LINGUST_PATH) mkdir -p benchmarks/output && go test -run=NONE -bench=. -slow -benchtime=100ms -timeout=100h >benchmarks/output/enry_samples.bench && \ benchmarks/linguist-samples.rb 5 >benchmarks/output/linguist_samples.bench -onigumura: - sed -i.orig -e 's/"regexp"/regexp "github.com\/moovweb\/rubex"/g' internal/code-generator/generator/heuristics.go - sed -i.orig -e 's/"regexp"/regexp "github.com\/moovweb\/rubex"/g' internal/tokenizer/tokenize.go - sed -i.orig -e 's/"regexp"/regexp "github.com\/moovweb\/rubex"/g' common.go +$(RUBEX_ORIG): %.orig : % + sed -i.orig -e 's/"regexp"/regexp "github.com\/moovweb\/rubex"/g' $< + @touch $@ + +onigumura: $(RUBEX_ORIG) revert-onigumura: - mv internal/code-generator/generator/heuristics.go.orig internal/code-generator/generator/heuristics.go - mv internal/tokenizer/tokenize.go.orig internal/tokenizer/tokenize.go - mv common.go.orig common.go + @for file in $(RUBEX_PATCHED); do if [ -e "$$file.orig" ]; then mv "$$file.orig" "$$file" && echo mv "$$file.orig" "$$file"; fi; done build-cli: go build -o enry -ldflags "$(LOCAL_LDFLAGS)" cli/enry/main.go