aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2020-03-09 01:11:39 +0100
committerGitHub <noreply@github.com>2020-03-08 21:11:39 -0300
commit11f7fc5621629624034916b118b4b4ef368f8418 (patch)
tree664474cb3f1772bd132aca6126818601ace15e5e /Makefile
parent8a0da9ea78ac5412e594ca47eb183a53bbb36862 (diff)
downloadgitea-11f7fc5621629624034916b118b4b4ef368f8418.tar.gz
gitea-11f7fc5621629624034916b118b4b4ef368f8418.zip
Use whitelist to find go files, run find only once (#10594)
- Use a whitelist-based approach to find *.go files so we can use standard find syntax. Also included is a change that files no longer pass a leading './' which should help performance further. - Instead of running `find` multiple times in make because of the lazy evaluation, run it only once and add the bindata files when the bindata tag is present This is another huge speedup on my machine of around 2000%. Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile29
1 files changed, 15 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index 9b3b44dcaa..a4d1ac51ce 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,7 @@ GO ?= go
SED_INPLACE := sed -i
SHASUM ?= shasum -a 256
HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
+COMMA := ,
ifeq ($(HAS_GO), GO)
GOPATH ?= $(shell $(GO) env GOPATH)
@@ -16,22 +17,14 @@ endif
ifeq ($(OS), Windows_NT)
EXECUTABLE ?= gitea.exe
- FIND_PWD_REGEXP := find . -regextype posix-egrep
else
EXECUTABLE ?= gitea
UNAME_S := $(shell uname -s)
- FIND_PWD_REGEXP := find . -regextype posix-egrep
- BUSYBOX := $(shell find --help 2>&1 | grep -o BusyBox)
ifeq ($(UNAME_S),Darwin)
SED_INPLACE := sed -i ''
- FIND_PWD_REGEXP := find -E .
endif
ifeq ($(UNAME_S),FreeBSD)
SED_INPLACE := sed -i ''
- FIND_PWD_REGEXP := find -E .
- endif
- ifeq ($(BUSYBOX),BusyBox)
- FIND_PWD_REGEXP := find .
endif
endif
@@ -71,9 +64,6 @@ LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(G
PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations/migration-test,$(filter-out code.gitea.io/gitea/integrations,$(shell GO111MODULE=on $(GO) list -mod=vendor ./... | grep -v /vendor/)))
-GO_SOURCES ?= $(shell $(FIND_PWD_REGEXP) -regex '\./(node_modules|docs|public|options|contrib|data)' -prune -o -name "*.go" -type f -print)
-GO_SOURCES_OWN := $(filter-out ./vendor/% %/bindata.go, $(GO_SOURCES))
-
WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f)
WEBPACK_CONFIGS := webpack.config.js .eslintrc .stylelintrc
WEBPACK_DEST := public/js/index.js public/css/index.css
@@ -82,13 +72,24 @@ WEBPACK_DEST_DIRS := public/js public/css
BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST))
+TAGS ?=
+TAGS_SPLIT := $(subst $(COMMA), ,$(TAGS))
+TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags
+
+GO_DIRS := cmd integrations models modules routers scripts services vendor
+GO_SOURCES := $(wildcard *.go)
+GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go" -not -path modules/options/bindata.go -not -path modules/public/bindata.go -not -path modules/templates/bindata.go)
+
+ifeq ($(filter $(TAGS_SPLIT),bindata),bindata)
+ GO_SOURCES += $(BINDATA_DEST)
+endif
+
+GO_SOURCES_OWN := $(filter-out vendor/% %/bindata.go, $(GO_SOURCES))
+
FOMANTIC_CONFIGS := semantic.json web_src/fomantic/theme.config.less web_src/fomantic/_site/globals/site.variables
FOMANTIC_DEST := public/fomantic/semantic.min.js public/fomantic/semantic.min.css
FOMANTIC_DEST_DIR := public/fomantic
-TAGS ?=
-TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags
-
#To update swagger use: GO111MODULE=on go get -u github.com/go-swagger/go-swagger/cmd/swagger@v0.20.1
SWAGGER := GO111MODULE=on $(GO) run -mod=vendor github.com/go-swagger/go-swagger/cmd/swagger
SWAGGER_SPEC := templates/swagger/v1_json.tmpl