2017-07-11 16:32:01 +02:00
|
|
|
# Package configuration
|
|
|
|
PROJECT = enry
|
|
|
|
COMMANDS = cli/enry
|
|
|
|
|
|
|
|
# Including ci Makefile
|
|
|
|
MAKEFILE = Makefile.main
|
|
|
|
CI_REPOSITORY = https://github.com/src-d/ci.git
|
|
|
|
CI_FOLDER = .ci
|
|
|
|
|
|
|
|
# If you need to build more than one dockerfile, you can do so like this:
|
|
|
|
# DOCKERFILES = Dockerfile_filename1:repositoryname1 Dockerfile_filename2:repositoryname2 ...
|
|
|
|
|
|
|
|
$(MAKEFILE):
|
|
|
|
@git clone --quiet $(CI_REPOSITORY) $(CI_FOLDER); \
|
|
|
|
cp $(CI_FOLDER)/$(MAKEFILE) .;
|
|
|
|
|
|
|
|
-include $(MAKEFILE)
|
2017-06-27 10:42:46 +02:00
|
|
|
|
2017-04-05 18:38:42 +02:00
|
|
|
LINGUIST_PATH = .linguist
|
2016-07-13 22:21:18 +02:00
|
|
|
|
2017-07-07 11:20:54 +02:00
|
|
|
# build CLI
|
2017-07-11 16:32:01 +02:00
|
|
|
LOCAL_TAG := $(shell git describe --tags --abbrev=0)
|
|
|
|
LOCAL_COMMIT := $(shell git rev-parse --short HEAD)
|
|
|
|
LOCAL_BUILD := $(shell date +"%m-%d-%Y_%H_%M_%S")
|
|
|
|
LOCAL_LDFLAGS = -s -X main.version=$(LOCAL_TAG) -X main.build=$(LOCAL_BUILD) -X main.commit=$(LOCAL_COMMIT)
|
2017-07-07 11:20:54 +02:00
|
|
|
|
2017-08-08 12:02:27 +02:00
|
|
|
# shared objects
|
|
|
|
RESOURCES_DIR=./.shared
|
|
|
|
LINUX_DIR=$(RESOURCES_DIR)/linux-x86-64
|
|
|
|
LINUX_SHARED_LIB=$(LINUX_DIR)/libenry.so
|
|
|
|
DARWIN_DIR=$(RESOURCES_DIR)/darwin
|
|
|
|
DARWIN_SHARED_LIB=$(DARWIN_DIR)/libenry.dylib
|
|
|
|
HEADER_FILE=libenry.h
|
|
|
|
NATIVE_LIB=./shared/enry.go
|
|
|
|
|
2017-04-05 18:38:42 +02:00
|
|
|
$(LINGUIST_PATH):
|
2017-04-05 19:27:19 +02:00
|
|
|
git clone https://github.com/github/linguist.git $@
|
2017-04-05 18:38:42 +02:00
|
|
|
|
2017-07-11 16:32:01 +02:00
|
|
|
clean-linguist:
|
|
|
|
rm -rf $(LINGUIST_PATH)
|
|
|
|
|
2017-08-08 12:02:27 +02:00
|
|
|
clean-shared:
|
|
|
|
rm -rf $(RESOURCES_DIR)
|
|
|
|
|
|
|
|
clean: clean-linguist clean-shared
|
2017-06-27 10:42:46 +02:00
|
|
|
|
2017-04-05 18:38:42 +02:00
|
|
|
code-generate: $(LINGUIST_PATH)
|
2017-06-08 12:28:36 +02:00
|
|
|
mkdir -p data
|
2017-04-05 18:38:42 +02:00
|
|
|
go run internal/code-generator/main.go
|
|
|
|
|
2017-06-28 13:01:36 +02:00
|
|
|
benchmarks: $(LINGUIST_PATH)
|
2017-07-10 17:08:21 +02:00
|
|
|
go test -run=NONE -bench=. && benchmarks/linguist-total.sh
|
2017-06-28 13:01:36 +02:00
|
|
|
|
|
|
|
benchmarks-samples: $(LINGUIST_PATH)
|
2017-07-10 17:08:21 +02:00
|
|
|
go test -run=NONE -bench=. -benchtime=5us && benchmarks/linguist-samples.rb
|
2017-06-28 13:01:36 +02:00
|
|
|
|
|
|
|
benchmarks-slow: $(LINGUST_PATH)
|
2017-07-10 17:08:21 +02:00
|
|
|
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
|
2017-06-28 13:01:36 +02:00
|
|
|
|
2017-07-07 11:20:54 +02:00
|
|
|
build-cli:
|
2017-07-11 16:32:01 +02:00
|
|
|
go build -o enry -ldflags "$(LOCAL_LDFLAGS)" cli/enry/main.go
|
2017-08-08 12:02:27 +02:00
|
|
|
|
|
|
|
linux-shared: $(LINUX_SHARED_LIB)
|
|
|
|
|
|
|
|
darwin-shared: $(DARWIN_SHARED_LIB)
|
|
|
|
|
|
|
|
$(DARWIN_SHARED_LIB):
|
|
|
|
mkdir -p $(DARWIN_DIR) && \
|
|
|
|
GOOS=darwin GOARCH=amd64 go build -buildmode=c-shared -o $(DARWIN_SHARED_LIB) $(NATIVE_LIB) && \
|
|
|
|
mv $(DARWIN_DIR)/$(HEADER_FILE) $(RESOURCES_DIR)/$(HEADER_FILE)
|
|
|
|
|
|
|
|
$(LINUX_SHARED_LIB):
|
|
|
|
mkdir -p $(LINUX_DIR) && \
|
|
|
|
GOOS=linux GOARCH=amd64 go build -buildmode=c-shared -o $(LINUX_SHARED_LIB) $(NATIVE_LIB) && \
|
|
|
|
mv $(LINUX_DIR)/$(HEADER_FILE) $(RESOURCES_DIR)/$(HEADER_FILE)
|