Code Review
/
src
/
xds
/
xds-agent.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Add build release (REL=1 make all)
[src/xds/xds-agent.git]
/
Makefile
diff --git
a/Makefile
b/Makefile
index
4246133
..
fc6a603
100644
(file)
--- a/
Makefile
+++ b/
Makefile
@@
-29,6
+29,11
@@
HOST_GOARCH=$(shell go env GOARCH)
ARCH=$(HOST_GOOS)-$(HOST_GOARCH)
REPOPATH=github.com/iotbzh/xds-agent
ARCH=$(HOST_GOOS)-$(HOST_GOARCH)
REPOPATH=github.com/iotbzh/xds-agent
+EXT=
+ifeq ($(HOST_GOOS), windows)
+ EXT=.exe
+endif
+
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
ROOT_SRCDIR := $(patsubst %/,%,$(dir $(mkfile_path)))
ROOT_GOPRJ := $(abspath $(ROOT_SRCDIR)/../../../..)
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
ROOT_SRCDIR := $(patsubst %/,%,$(dir $(mkfile_path)))
ROOT_GOPRJ := $(abspath $(ROOT_SRCDIR)/../../../..)
@@
-42,11
+47,21
@@
export PATH := $(PATH):$(LOCAL_TOOLSDIR)
VERBOSE_1 := -v
VERBOSE_2 := -v -x
VERBOSE_1 := -v
VERBOSE_2 := -v -x
+# Release or Debug mode
+ifeq ($(filter 1,$(RELEASE) $(REL)),)
+ GORELEASE=
+ BUILD_MODE="Debug mode"
+else
+ # optimized code without debug info
+ GORELEASE= -s -w
+ BUILD_MODE="Release mode"
+endif
+
all: tools/syncthing build
build: vendor tools/syncthing/copytobin
all: tools/syncthing build
build: vendor tools/syncthing/copytobin
- @echo "### Build XDS agent (version $(VERSION), subversion $(SUB_VERSION))";
- @cd $(ROOT_SRCDIR); $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o $(LOCAL_BINDIR)/xds-agent
-ldflags "
-X main.AppVersion=$(VERSION) -X main.AppSubVersion=$(SUB_VERSION)" .
+ @echo "### Build XDS agent (version $(VERSION), subversion $(SUB_VERSION))
- $(BUILD_MODE)
";
+ @cd $(ROOT_SRCDIR); $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o $(LOCAL_BINDIR)/xds-agent
$(EXT) -ldflags "$(GORELEASE)
-X main.AppVersion=$(VERSION) -X main.AppSubVersion=$(SUB_VERSION)" .
package: clean build
@mkdir -p $(PACKAGE_DIR)/xds-agent
package: clean build
@mkdir -p $(PACKAGE_DIR)/xds-agent
@@
-64,10
+79,10
@@
fmt: tools/glide
go fmt $(shell ./tools/glide novendor)
run: build/xds tools/syncthing/copytobin
go fmt $(shell ./tools/glide novendor)
run: build/xds tools/syncthing/copytobin
- $(LOCAL_BINDIR)/xds-agent --log info -c agent-config.json.in
+ $(LOCAL_BINDIR)/xds-agent
$(EXT)
--log info -c agent-config.json.in
debug: build/xds tools/syncthing/copytobin
debug: build/xds tools/syncthing/copytobin
- $(LOCAL_BINDIR)/xds-agent --log debug -c agent-config.json.in
+ $(LOCAL_BINDIR)/xds-agent
$(EXT)
--log debug -c agent-config.json.in
.PHONY: clean
clean:
.PHONY: clean
clean:
@@
-75,7
+90,7
@@
clean:
.PHONY: distclean
distclean: clean
.PHONY: distclean
distclean: clean
- rm -rf $(LOCAL_BINDIR) tools glide.lock vendor
+ rm -rf $(LOCAL_BINDIR) tools glide.lock vendor
$(ROOT_SRCDIR)/*.zip
.PHONY: install
install: all
.PHONY: install
install: all
@@
-91,7
+106,7
@@
tools/glide:
.PHONY: tools/syncthing
tools/syncthing:
.PHONY: tools/syncthing
tools/syncthing:
- @test -e $(LOCAL_TOOLSDIR)/syncthing
-a -e $(LOCAL_TOOLSDIR)/syncthing-inotify
|| { \
+ @test -e $(LOCAL_TOOLSDIR)/syncthing
$(EXT) -a -e $(LOCAL_TOOLSDIR)/syncthing-inotify$(EXT)
|| { \
mkdir -p $(LOCAL_TOOLSDIR); \
DESTDIR=$(LOCAL_TOOLSDIR) \
SYNCTHING_VERSION=$(SYNCTHING_VERSION) \
mkdir -p $(LOCAL_TOOLSDIR); \
DESTDIR=$(LOCAL_TOOLSDIR) \
SYNCTHING_VERSION=$(SYNCTHING_VERSION) \
@@
-100,9
+115,9
@@
tools/syncthing:
.PHONY:
tools/syncthing/copytobin:
.PHONY:
tools/syncthing/copytobin:
- @test -e $(LOCAL_TOOLSDIR)/syncthing
-a -e $(LOCAL_TOOLSDIR)/syncthing-inotify
|| { echo "Please execute first: make tools/syncthing\n"; exit 1; }
+ @test -e $(LOCAL_TOOLSDIR)/syncthing
$(EXT) -a -e $(LOCAL_TOOLSDIR)/syncthing-inotify$(EXT)
|| { echo "Please execute first: make tools/syncthing\n"; exit 1; }
@mkdir -p $(LOCAL_BINDIR)
@mkdir -p $(LOCAL_BINDIR)
- @cp -f $(LOCAL_TOOLSDIR)/syncthing
*
$(LOCAL_BINDIR)
+ @cp -f $(LOCAL_TOOLSDIR)/syncthing
$(EXT) $(LOCAL_TOOLSDIR)/syncthing-inotify$(EXT)
$(LOCAL_BINDIR)
.PHONY: help
help:
.PHONY: help
help: