summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-03-18 12:46:57 -0400
committerChristopher Speller <crspeller@gmail.com>2016-03-21 09:31:47 -0400
commita0a102d26b057f0f45e3ecb2590fba3ca8201536 (patch)
tree429329c09ff56d31420bd010753530b34b120a6e
parent6d586c7309cb0ddaca6580dd1520aef4ff554fb5 (diff)
downloadchat-a0a102d26b057f0f45e3ecb2590fba3ca8201536.tar.gz
chat-a0a102d26b057f0f45e3ecb2590fba3ca8201536.tar.bz2
chat-a0a102d26b057f0f45e3ecb2590fba3ca8201536.zip
Redo of makefile. Build files no longer need to be modified for enterprise builds.
-rw-r--r--.gitignore12
-rw-r--r--Makefile325
-rw-r--r--config/config.json6
-rw-r--r--model/version.go8
4 files changed, 150 insertions, 201 deletions
diff --git a/.gitignore b/.gitignore
index 4c343021e..422c6d5f5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,14 +9,15 @@ npm-debug.log
web/static/js/bundle*.js
web/static/js/bundle*.js.map
web/static/js/libs*.js
-.npminstall
config/active.dat
+# Enteprise imports file
+imports.go
+
# Build Targets
-.prepare
-.prepare-go
-.prepare-jsx
+.prebuild
+.npminstall
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
@@ -69,6 +70,3 @@ api/data/*
.agignore
.ctags
tags
-
-model/version.go
-model/version.go.bak
diff --git a/Makefile b/Makefile
index eb0bdc06f..5bb64638a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,47 +1,47 @@
-.PHONY: all dist dist-local dist-travis start-docker build-server package build-client test travis-init build-container stop-docker clean-docker clean nuke run run-client run-server stop stop-client stop-server setup-mac cleandb docker-build docker-run restart-server
+.PHONY: build package run stop run-client run-server stop-client stop-server restart-server restart-client start-docker clean-dist clean nuke check-style check-unit-tests test dist setup-mac prepare-enteprise
-GOPATH ?= $(GOPATH:)
-GOFLAGS ?= $(GOFLAGS:)
+# Build Flags
BUILD_NUMBER ?= $(BUILD_NUMBER:)
BUILD_DATE = $(shell date -u)
BUILD_HASH = $(shell git rev-parse HEAD)
-
-ENTERPRISE_DIR ?= ../enterprise
-BUILD_ENTERPRISE ?= true
-
-GO=$(GOPATH)/bin/godep go
-ESLINT=node_modules/eslint/bin/eslint.js
-
+# If we don't set the build number it defaults to dev
ifeq ($(BUILD_NUMBER),)
BUILD_NUMBER := dev
endif
-
-ifeq ($(TRAVIS_BUILD_NUMBER),)
- BUILD_NUMBER := dev
+BUILD_ENTERPRISE_DIR ?= ../enterprise
+BUILD_ENTERPRISE ?= true
+BUILD_ENTERPRISE_READY = false
+ifneq ($(wildcard $(BUILD_ENTERPRISE_DIR)/.),)
+ ifeq ($(BUILD_ENTERPRISE),true)
+ BUILD_ENTERPRISE_READY = true
+ else
+ BUILD_ENTERPRISE_READY = false
+ endif
else
- BUILD_NUMBER := $(TRAVIS_BUILD_NUMBER)
+ BUILD_ENTERPRISE_READY = false
endif
+BUILD_WEBAPP_DIR = ./webapp
+# Golang Flags
+GOPATH ?= $(GOPATH:)
+GOFLAGS ?= $(GOFLAGS:)
+GO=$(GOPATH)/bin/godep go
+GO_LINKER_FLAGS ?= -ldflags \
+ "-X github.com/mattermost/platform/model.BuildNumber=$(BUILD_NUMBER)\
+ -X 'github.com/mattermost/platform/model.BuildDate=$(BUILD_DATE)'\
+ -X github.com/mattermost/platform/model.BuildHash=$(BUILD_HASH)\
+ -X github.com/mattermost/platform/model.BuildEnterpriseReady=$(BUILD_ENTERPRISE_READY)"
+
+# Output paths
DIST_ROOT=dist
DIST_PATH=$(DIST_ROOT)/mattermost
+# Tests
TESTS=.
-DOCKERNAME ?= mm-dev
-DOCKER_CONTAINER_NAME ?= mm-test
-
-all: dist-local
-
-dist: | build-server build-client go-test package
- mv ./model/version.go.bak ./model/version.go
- @if [ "$(BUILD_ENTERPRISE)" = "true" ] && [ -d "$(ENTERPRISE_DIR)" ]; then \
- mv ./mattermost.go.bak ./mattermost.go; \
- mv ./config/config.json.bak ./config/config.json 2> /dev/null || true; \
- fi
-
-dist-local: | start-docker dist
+all: dist
-dist-travis: | travis-init build-container
+dist: | check-style test package
start-docker:
@echo Starting docker containers
@@ -66,107 +66,6 @@ start-docker:
sleep 10; \
fi
-build-server:
- @echo Building mattermost server
-
- rm -Rf $(DIST_ROOT)
- $(GO) clean $(GOFLAGS) -i ./...
-
- @echo GOFMT
- $(eval GOFMT_OUTPUT := $(shell gofmt -d -s api/ model/ store/ utils/ manualtesting/ mattermost.go 2>&1))
- @echo "$(GOFMT_OUTPUT)"
- @if [ ! "$(GOFMT_OUTPUT)" ]; then \
- echo "gofmt sucess"; \
- else \
- echo "gofmt failure"; \
- exit 1; \
- fi
-
- cp ./model/version.go ./model/version.go.bak
- sed -i'.make_mac_work' 's|_BUILD_NUMBER_|$(BUILD_NUMBER)|g' ./model/version.go
- sed -i'.make_mac_work' 's|_BUILD_DATE_|$(BUILD_DATE)|g' ./model/version.go
- sed -i'.make_mac_work' 's|_BUILD_HASH_|$(BUILD_HASH)|g' ./model/version.go
-
- @if [ "$(BUILD_ENTERPRISE)" = "true" ] && [ -d "$(ENTERPRISE_DIR)" ]; then \
- cp ./config/config.json ./config/config.json.bak; \
- jq -s '.[0] * .[1]' ./config/config.json $(ENTERPRISE_DIR)/config/enterprise-config-additions.json > config.json.tmp; \
- mv config.json.tmp ./config/config.json; \
- sed -e '/\/\/ENTERPRISE_IMPORTS/ {' -e 'r $(ENTERPRISE_DIR)/imports' -e 'd' -e '}' -i'.bak' mattermost.go; \
- sed -i'.make_mac_work' 's|_BUILD_ENTERPRISE_READY_|true|g' ./model/version.go; \
- else \
- sed -i'.make_mac_work' 's|_BUILD_ENTERPRISE_READY_|false|g' ./model/version.go; \
- fi
-
- rm ./model/version.go.make_mac_work
-
- $(GO) build $(GOFLAGS) ./...
- $(GO) generate $(GOFLAGS) ./...
- $(GO) install $(GOFLAGS) ./...
-
-package:
- @ echo Packaging mattermost
-
- mkdir -p $(DIST_PATH)/bin
- cp $(GOPATH)/bin/platform $(DIST_PATH)/bin
-
- cp -RL config $(DIST_PATH)/config
- cp -RL fonts $(DIST_PATH)/fonts
- touch $(DIST_PATH)/config/build.txt
- echo $(BUILD_NUMBER) | tee -a $(DIST_PATH)/config/build.txt
-
- mkdir -p $(DIST_PATH)/logs
-
- mkdir -p $(DIST_PATH)/webapp/dist
- cp -RL webapp/dist $(DIST_PATH)/webapp
-
- cp -RL templates $(DIST_PATH)
-
- cp -RL i18n $(DIST_PATH)
-
- cp build/MIT-COMPILED-LICENSE.md $(DIST_PATH)
- cp NOTICE.txt $(DIST_PATH)
- cp README.md $(DIST_PATH)
-
- mv $(DIST_PATH)/webapp/dist/bundle.js $(DIST_PATH)/webapp/dist/bundle-$(BUILD_NUMBER).js
- sed -i'.bak' 's|bundle.js|bundle-$(BUILD_NUMBER).js|g' $(DIST_PATH)/webapp/dist/root.html
- rm $(DIST_PATH)/webapp/dist/root.html.bak
-
- @if [ "$(BUILD_ENTERPRISE)" = "true" ] && [ -d "$(ENTERPRISE_DIR)" ]; then \
- sudo mv -f $(DIST_PATH)/config/config.json.bak $(DIST_PATH)/config/config.json || echo 'nomv'; \
- fi
-
- tar -C dist -czf $(DIST_PATH).tar.gz mattermost
-
-build-client:
- mkdir -p webapp/dist/files
- cd webapp && make build
-
-go-test:
- $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=180s ./api || exit 1
- $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=12s ./model || exit 1
- $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./store || exit 1
- $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./utils || exit 1
- $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./web || exit 1
-
-test: | start-docker .prepare-go go-test
-
-travis-init:
- @echo Setting up enviroment for travis
-
- if [ "$(TRAVIS_DB)" = "postgres" ]; then \
- sed -i'.bak' 's|mysql|postgres|g' config/config.json; \
- sed -i'.bak2' 's|mmuser:mostest@tcp(dockerhost:3306)/mattermost_test?charset=utf8mb4,utf8|postgres://mmuser:mostest@postgres:5432/mattermost_test?sslmode=disable\&connect_timeout=10|g' config/config.json; \
- fi
-
- if [ "$(TRAVIS_DB)" = "mysql" ]; then \
- sed -i'.bak' 's|mmuser:mostest@tcp(dockerhost:3306)/mattermost_test?charset=utf8mb4,utf8|mmuser:mostest@tcp(mysql:3306)/mattermost_test?charset=utf8mb4,utf8|g' config/config.json; \
- fi
-
-build-container:
- @echo Building in container
-
- cd .. && docker run -e TRAVIS_BUILD_NUMBER=$(TRAVIS_BUILD_NUMBER) --link mattermost-mysql:mysql --link mattermost-postgres:postgres -v `pwd`:/go/src/github.com/mattermost mattermost/builder:latest
-
stop-docker:
@echo Stopping docker containers
@@ -195,92 +94,144 @@ clean-docker:
docker rm -v mattermost-postgres > /dev/null; \
fi
-clean: stop-docker
- rm -Rf $(DIST_ROOT)
- go clean $(GOFLAGS) -i ./...
+check-style:
+ @echo Running GOFMT
+ $(eval GOFMT_OUTPUT := $(shell gofmt -d -s api/ model/ store/ utils/ manualtesting/ einterfaces/ mattermost.go 2>&1))
+ @echo "$(GOFMT_OUTPUT)"
+ @if [ ! "$(GOFMT_OUTPUT)" ]; then \
+ echo "gofmt sucess"; \
+ else \
+ echo "gofmt failure"; \
+ exit 1; \
+ fi
- cd webapp && make clean
+test: start-docker
+ $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=180s ./api || exit 1
+ $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=12s ./model || exit 1
+ $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./store || exit 1
+ $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./utils || exit 1
+ $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./web || exit 1
- rm -rf api/data
- rm -rf logs
+.prebuild:
+ @echo Preparation for running go code
+ go get $(GOFLAGS) github.com/tools/godep
- rm -rf Godeps/_workspace/pkg/
+ touch $@
- rm -f mattermost.log
- rm -f .prepare-go .prepare-jsx
+prepare-enterprise:
+ifeq ($(BUILD_ENTERPRISE_READY),true)
+ @echo Enterprise build selected, perparing
+ cp $(BUILD_ENTERPRISE_DIR)/imports.go .
+endif
-nuke: | clean clean-docker
- rm -rf data
+build: .prebuild prepare-enterprise
+ @echo Building mattermost server
-.prepare-go:
- @echo Preparation for running go code
- go get $(GOFLAGS) github.com/tools/godep
+ $(GO) clean $(GOFLAGS) -i ./...
+ $(GO) install $(GOFLAGS) $(GO_LINKER_FLAGS) ./...
- touch $@
+build-client:
+ @echo Building mattermost web app
-run: | start-docker run-server run-client
+ cd $(BUILD_WEBAPP_DIR) && make build
-run-server: .prepare-go
- @echo Starting go web server
- mkdir -p webapp/dist/files
- $(GO) run $(GOFLAGS) mattermost.go -config=config.json &
-run-client:
- @echo Starting client
+package: build build-client
+ @ echo Packaging mattermost
- cd webapp && make run
+ # Remove any old files
+ rm -Rf $(DIST_ROOT)
- @if [ "$(BUILD_ENTERPRISE)" = "true" ] && [ -d "$(ENTERPRISE_DIR)" ]; then \
- cp ./config/config.json ./config/config.json.bak; \
- jq -s '.[0] * .[1]' ./config/config.json $(ENTERPRISE_DIR)/config/enterprise-config-additions.json > config.json.tmp; \
- mv config.json.tmp ./config/config.json; \
- sed -e '/\/\/ENTERPRISE_IMPORTS/ {' -e 'r $(ENTERPRISE_DIR)/imports' -e 'd' -e '}' -i'.bak' mattermost.go; \
- sed -i'.bak' 's|_BUILD_ENTERPRISE_READY_|true|g' ./model/version.go; \
- else \
- sed -i'.bak' 's|_BUILD_ENTERPRISE_READY_|false|g' ./model/version.go; \
- fi
+ # Create needed directories
+ mkdir -p $(DIST_PATH)/bin
+ mkdir -p $(DIST_PATH)/logs
-stop: stop-server stop-client
- @if [ $(shell docker ps -a | grep -ci ${DOCKER_CONTAINER_NAME}) -eq 1 ]; then \
- echo removing dev docker container; \
- docker stop ${DOCKER_CONTAINER_NAME} > /dev/null; \
- docker rm -v ${DOCKER_CONTAINER_NAME} > /dev/null; \
- fi
+ # Copy binary
+ cp $(GOPATH)/bin/platform $(DIST_PATH)/bin
- @if [ "$(BUILD_ENTERPRISE)" = "true" ] && [ -d "$(ENTERPRISE_DIR)" ]; then \
- mv ./config/config.json.bak ./config/config.json 2> /dev/null || true; \
- mv ./mattermost.go.bak ./mattermost.go 2> /dev/null || true; \
- mv ./model/version.go.bak ./model/version.go 2> /dev/null || true; \
- fi
+ # Resource directories
+ cp -RL config $(DIST_PATH)
+ cp -RL fonts $(DIST_PATH)
+ cp -RL templates $(DIST_PATH)
+ cp -RL i18n $(DIST_PATH)
+
+ # Package webapp
+ mkdir -p $(DIST_PATH)/webapp/dist
+ cp -RL $(BUILD_WEBAPP_DIR)/dist $(DIST_PATH)/webapp
+ mv $(DIST_PATH)/webapp/dist/bundle.js $(DIST_PATH)/webapp/dist/bundle-$(BUILD_NUMBER).js
+ sed -i'.bak' 's|bundle.js|bundle-$(BUILD_NUMBER).js|g' $(DIST_PATH)/webapp/dist/root.html
+ rm $(DIST_PATH)/webapp/dist/root.html.bak
+
+ # Help files
+ifeq ($(BUILD_ENTERPRISE_READY),true)
+ cp $(BUILD_ENTERPRISE_DIR)/ENTERPRISE-EDITION-LICENSE.txt $(DIST_PATH)
+else
+ cp build/MIT-COMPILED-LICENSE.md $(DIST_PATH)
+endif
+ cp NOTICE.txt $(DIST_PATH)
+ cp README.md $(DIST_PATH)
+
+ # Create package
+ tar -C dist -czf $(DIST_PATH).tar.gz mattermost
+
+run-server: prepare-enterprise
+ @echo Running mattermost for development
+
+ mkdir -p $(BUILD_WEBAPP_DIR)/dist/files
+ $(GO) run $(GOFLAGS) $(GO_LINKER_FLAGS) *.go &
+
+run-client:
+ @echo Running mattermost client for development
+
+ cd $(BUILD_WEBAPP_DIR) && make run
+
+run: run-server run-client
stop-server:
- @for PID in $$(ps -ef | grep "go run [m]attermost.go" | awk '{ print $$2 }'); do \
+ @echo Stopping mattermost
+
+ @for PID in $$(ps -ef | grep "[g]o run" | awk '{ print $$2 }'); do \
echo stopping go $$PID; \
kill $$PID; \
done
- @for PID in $$(ps -ef | grep "go-build.*/[m]attermost" | awk '{ print $$2 }'); do \
+ @for PID in $$(ps -ef | grep "[g]o-build" | awk '{ print $$2 }'); do \
echo stopping mattermost $$PID; \
kill $$PID; \
done
stop-client:
- cd webapp && make stop
+ @echo Stopping mattermost client
-restart-server: stop-server run-server
+ cd $(BUILD_WEBAPP_DIR) && make stop
-setup-mac:
- echo $$(boot2docker ip 2> /dev/null) dockerhost | sudo tee -a /etc/hosts
-cleandb:
- @if [ $(shell docker ps -a | grep -ci mattermost-mysql) -eq 1 ]; then \
- docker stop mattermost-mysql > /dev/null; \
- docker rm -v mattermost-mysql > /dev/null; \
- fi
+stop: stop-server stop-client
+
+restart-server: | stop-server run-server
+
+restart-client: | stop-client run-client
+
+clean: stop-docker
+ @echo Cleaning
+
+ rm -Rf $(DIST_ROOT)
+ go clean $(GOFLAGS) -i ./...
+
+ cd $(BUILD_WEBAPP_DIR) && make clean
-docker-build: stop
- docker build -t ${DOCKERNAME} -f docker/local/Dockerfile .
+ rm -rf api/data
+ rm -rf logs
+
+ rm -rf Godeps/_workspace/pkg/
+
+ rm -f mattermost.log
+ rm -f .prepare-go
+
+nuke: clean clean-docker
+ @echo BOOM
-docker-run: docker-build
- docker run --name ${DOCKER_CONTAINER_NAME} -d --publish 8065:80 ${DOCKERNAME}
+ rm -rf data
+setup-mac:
+ echo $$(boot2docker ip 2> /dev/null) dockerhost | sudo tee -a /etc/hosts
diff --git a/config/config.json b/config/config.json
index 1735ca293..65a61bb72 100644
--- a/config/config.json
+++ b/config/config.json
@@ -87,8 +87,8 @@
"InviteSalt": "bjlSR4QqkXFBr7TP4oDzlfZmcNuH9YoS",
"PasswordResetSalt": "vZ4DcKyVVRlKHHJpexcuXzojkE5PZ5eL",
"SendPushNotifications": false,
- "PushNotificationContents": "generic",
- "PushNotificationServer": ""
+ "PushNotificationServer": "",
+ "PushNotificationContents": "generic"
},
"RateLimitSettings": {
"EnableRateLimiter": true,
@@ -146,4 +146,4 @@
"Directory": "./data/",
"EnableDaily": false
}
-}
+} \ No newline at end of file
diff --git a/model/version.go b/model/version.go
index 737071934..b3950dcc9 100644
--- a/model/version.go
+++ b/model/version.go
@@ -28,10 +28,10 @@ var versions = []string{
}
var CurrentVersion string = versions[0]
-var BuildNumber = "_BUILD_NUMBER_"
-var BuildDate = "_BUILD_DATE_"
-var BuildHash = "_BUILD_HASH_"
-var BuildEnterpriseReady = "_BUILD_ENTERPRISE_READY_"
+var BuildNumber string
+var BuildDate string
+var BuildHash string
+var BuildEnterpriseReady string
var versionsWithoutHotFixes []string
func init() {