-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Refactoring of the makefile #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e05a5ca
Executed go fmt for all files
tboerger f960b77
Simply made go vet happy, fixed tags
tboerger 648c6fd
Vet complains about "should have signature MarshalJSON() ([]byte, err…
tboerger 212a04a
Linter doesn't like uppercase variables
tboerger 5b5af7d
Made linter happy in cmd folder
tboerger eb25d1f
Regenerated bindata
tboerger 7a87008
Added a common golang gitignore
tboerger ec054ba
Totally refactored the makefile and adjusted travis config
tboerger 3dd14ee
Fixed "net.UnixAddr composite literal uses unkeyed fields"
tboerger b32776d
Dropped outdated build scripts
tboerger c524078
Extended gitignore
tboerger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,37 @@ | ||
.DS_Store | ||
# Compiled Object files, Static and Dynamic libs (Shared Objects) | ||
*.o | ||
*.a | ||
*.so | ||
|
||
# Folders | ||
_obj | ||
_test | ||
|
||
# Architecture specific extensions/prefixes | ||
*.[568vq] | ||
[568vq].out | ||
|
||
*.cgo1.go | ||
*.cgo2.c | ||
_cgo_defun.c | ||
_cgo_gotypes.go | ||
_cgo_export.* | ||
|
||
_testmain.go | ||
|
||
*.exe | ||
*.test | ||
*.prof | ||
|
||
coverage.out | ||
gitea | ||
|
||
*.db | ||
*.log | ||
log/ | ||
custom/ | ||
data/ | ||
.vendor/ | ||
.idea/ | ||
*.iml | ||
public/img/avatar/ | ||
*.exe | ||
*.exe~ | ||
/gogs | ||
profile/ | ||
*.pem | ||
output* | ||
gogs.sublime-project | ||
gogs.sublime-workspace | ||
/release | ||
|
||
/bin | ||
/dist | ||
/custom | ||
/data | ||
/log | ||
/public/img/avatar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,132 @@ | ||
LDFLAGS += -X "github.com/go-gitea/gitea/modules/setting.BuildTime=$(shell date -u '+%Y-%m-%d %I:%M:%S %Z')" | ||
LDFLAGS += -X "github.com/go-gitea/gitea/modules/setting.BuildGitHash=$(shell git rev-parse HEAD)" | ||
DIST := dist | ||
BIN := bin | ||
|
||
DATA_FILES := $(shell find conf | sed 's/ /\\ /g') | ||
LESS_FILES := $(wildcard public/less/gogs.less public/less/_*.less) | ||
GENERATED := modules/bindata/bindata.go public/css/index.css | ||
EXECUTABLE := gitea | ||
IMPORT := github.com/go-gitea/gitea | ||
|
||
TAGS = "" | ||
BUILD_FLAGS = "-v" | ||
SHA := $(shell git rev-parse --short HEAD) | ||
DATE := $(shell date -u '+%Y-%m-%d %I:%M:%S %Z') | ||
|
||
RELEASE_ROOT = "release" | ||
RELEASE_GOGS = "release/gogs" | ||
NOW = $(shell date -u '+%Y%m%d%I%M%S') | ||
GOVET = go tool vet -composites=false -methods=false -structtags=false | ||
BINDATA := $(shell find conf | sed 's/ /\\ /g') | ||
STYLESHEETS := $(wildcard public/less/index.less public/less/_*.less) | ||
JAVASCRIPTS := | ||
|
||
.PHONY: build pack release bindata clean | ||
LDFLAGS += -X "github.com/go-gitea/gitea/modules/setting.BuildTime=$(DATE)" | ||
LDFLAGS += -X "github.com/go-gitea/gitea/modules/setting.BuildGitHash=$(SHA)" | ||
|
||
.IGNORE: public/css/index.css | ||
TARGETS ?= linux/*,darwin/*,windows/* | ||
PACKAGES ?= $(shell go list ./... | grep -v /vendor/) | ||
|
||
all: build | ||
TAGS ?= | ||
|
||
check: test | ||
ifneq ($(TRAVIS_TAG),) | ||
VERSION ?= $(TRAVIS_TAG) | ||
else | ||
ifneq ($(TRAVIS_BRANCH),) | ||
VERSION ?= $(TRAVIS_BRANCH) | ||
else | ||
VERSION ?= master | ||
endif | ||
endif | ||
|
||
dist: release | ||
.PHONY: all | ||
all: clean test build | ||
|
||
govet: | ||
$(GOVET) main.go | ||
$(GOVET) models modules routers | ||
.PHONY: clean | ||
clean: | ||
go clean -i ./... | ||
rm -rf $(BIN) $(DIST) | ||
|
||
.PHONY: deps | ||
deps: | ||
@which go-bindata > /dev/null; if [ $$? -ne 0 ]; then \ | ||
go get -u github.com/jteeuwen/go-bindata/...; \ | ||
fi | ||
|
||
.PHONY: fmt | ||
fmt: | ||
go fmt $(PACKAGES) | ||
|
||
.PHONY: vet | ||
vet: | ||
go vet $(PACKAGES) | ||
|
||
.PHONY: lint | ||
lint: | ||
@which golint > /dev/null; if [ $$? -ne 0 ]; then \ | ||
go get -u github.com/golang/lint/golint; \ | ||
fi | ||
for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done; | ||
|
||
.PHONY: test | ||
test: | ||
for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done; | ||
|
||
build: $(GENERATED) | ||
go install $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -tags '$(TAGS)' | ||
cp '$(GOPATH)/bin/gogs' . | ||
.PHONY: install | ||
install: $(BIN)/$(EXECUTABLE) | ||
cp $< $(GOPATH)/bin/ | ||
|
||
build-dev: $(GENERATED) govet | ||
go install $(BUILD_FLAGS) -tags '$(TAGS)' | ||
cp '$(GOPATH)/bin/gogs' . | ||
.PHONY: build | ||
build: $(BIN)/$(EXECUTABLE) | ||
|
||
build-dev-race: $(GENERATED) govet | ||
go install $(BUILD_FLAGS) -race -tags '$(TAGS)' | ||
cp '$(GOPATH)/bin/gogs' . | ||
$(BIN)/$(EXECUTABLE): $(wildcard *.go) | ||
go build -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@ | ||
|
||
pack: | ||
rm -rf $(RELEASE_GOGS) | ||
mkdir -p $(RELEASE_GOGS) | ||
cp -r gogs LICENSE README.md README_ZH.md templates public scripts $(RELEASE_GOGS) | ||
rm -rf $(RELEASE_GOGS)/public/config.codekit $(RELEASE_GOGS)/public/less | ||
cd $(RELEASE_ROOT) && zip -r gogs.$(NOW).zip "gogs" | ||
.PHONY: release | ||
release: release-build release-copy release-check | ||
|
||
release: build pack | ||
.PHONY: release-build | ||
release-build: | ||
@which xgo > /dev/null; if [ $$? -ne 0 ]; then \ | ||
go get -u github.com/karalabe/xgo; \ | ||
fi | ||
xgo -dest $(BIN) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -targets '$(TARGETS)' -out $(EXECUTABLE)-$(VERSION) $(IMPORT) | ||
|
||
bindata: modules/bindata/bindata.go | ||
.PHONY: release-copy | ||
release-copy: | ||
mkdir -p $(DIST)/release | ||
$(foreach file,$(wildcard $(BIN)/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));) | ||
|
||
modules/bindata/bindata.go: $(DATA_FILES) | ||
go-bindata -o=$@ -ignore="\\.DS_Store|README.md|TRANSLATORS" -pkg=bindata conf/... | ||
.PHONY: release-check | ||
release-check: | ||
cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) | ||
|
||
less: public/css/index.css | ||
.PHONY: latest | ||
latest: release-build latest-copy latest-check | ||
|
||
public/css/index.css: $(LESS_FILES) | ||
lessc $< $@ | ||
.PHONY: latest-copy | ||
latest-copy: | ||
mkdir -p $(DIST)/latest | ||
$(foreach file,$(wildcard $(BIN)/$(EXECUTABLE)-*),cp $(file) $(DIST)/latest/$(subst $(EXECUTABLE)-$(VERSION),$(EXECUTABLE)-latest,$(notdir $(file)));) | ||
|
||
clean: | ||
go clean -i ./... | ||
.PHONY: latest-check | ||
latest-check: | ||
cd $(DIST)/latest; $(foreach file,$(wildcard $(DIST)/latest/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) | ||
|
||
clean-mac: clean | ||
find . -name ".DS_Store" -print0 | xargs -0 rm | ||
.PHONY: publish | ||
publish: release latest | ||
|
||
test: | ||
go test -cover -race ./... | ||
.PHONY: bindata | ||
bindata: modules/bindata/bindata.go | ||
|
||
.IGNORE: modules/bindata/bindata.go | ||
modules/bindata/bindata.go: $(BINDATA) | ||
go-bindata -o=$@ -ignore="\\.go|README.md|TRANSLATORS" -pkg=bindata conf/... | ||
go fmt $@ | ||
|
||
.PHONY: javascripts | ||
javascripts: public/js/index.js | ||
|
||
fixme: | ||
grep -rnw "FIXME" routers models modules | ||
.IGNORE: public/js/index.js | ||
public/js/index.js: $(JAVASCRIPTS) | ||
cat $< >| $@ | ||
|
||
.PHONY: stylesheets | ||
stylesheets: public/css/index.css | ||
|
||
.IGNORE: public/css/index.css | ||
public/css/index.css: $(STYLESHEETS) | ||
lessc $< $@ | ||
|
||
todo: | ||
grep -rnw "TODO" routers models modules | ||
.PHONY: generate | ||
generate: bindata javascripts stylesheets |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why skip this? (though it should be
/log
if anything ^.^)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed