Improve the Makefile

Signed-off-by: Vadim Markovtsev <vadim@sourced.tech>
This commit is contained in:
Vadim Markovtsev 2017-10-25 12:30:25 +02:00
parent db0e1e0d71
commit 8eb17ebd11

View File

@ -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