11# Paths to packages
22GO =$(shell which go)
3+ NPM =$(shell which npm)
34
45# Paths to locations, etc
56BUILD_DIR = "build"
7+ PLUGIN_DIR = $(wildcard plugin/* )
8+ NPM_DIR = $(wildcard npm/* )
9+
10+ # Build flags
611BUILD_MODULE = "github.com/djthorpe/go-server"
712BUILD_LD_FLAGS += -X $(BUILD_MODULE ) /pkg/config.GitSource=${BUILD_MODULE}
813BUILD_LD_FLAGS += -X $(BUILD_MODULE ) /pkg/config.GitTag=$(shell git describe --tags)
914BUILD_LD_FLAGS += -X $(BUILD_MODULE ) /pkg/config.GitBranch=$(shell git name-rev HEAD --name-only --always)
1015BUILD_LD_FLAGS += -X $(BUILD_MODULE ) /pkg/config.GitHash=$(shell git rev-parse HEAD)
1116BUILD_LD_FLAGS += -X $(BUILD_MODULE ) /pkg/config.GoBuildTime=$(shell date -u '+% Y-% m-% dT% H:% M:% SZ')
1217BUILD_FLAGS = -ldflags "-s -w $(BUILD_LD_FLAGS ) "
13- BUILD_VERSION = $(shell git describe --tags)
14- PLUGIN_DIR = $(wildcard plugin/* )
1518
16- .PHONY : all server plugins dependencies mkdir clean
19+ .PHONY : all server npm plugins dependencies mkdir clean
1720
18- all : clean plugins server
21+ all : clean plugins server npm
1922
2023server : dependencies mkdir
2124 @echo Build server
2225 @${GO} build -o ${BUILD_DIR} /server ${BUILD_FLAGS} github.com/djthorpe/go-server/cmd/server
2326
27+ npm : $(NPM_DIR )
28+
29+ $(NPM_DIR ) : FORCE
30+ @echo Build npm $(notdir $@ )
31+ @cd $@ && ${NPM} run build
32+
2433plugins : $(PLUGIN_DIR )
2534 @echo Build plugin httpserver
2635 @${GO} build -buildmode=plugin -o ${BUILD_DIR} /httpserver.plugin ${BUILD_FLAGS} github.com/djthorpe/go-server/plugin/httpserver
2736 @echo Build plugin log
2837 @${GO} build -buildmode=plugin -o ${BUILD_DIR} /log.plugin ${BUILD_FLAGS} github.com/djthorpe/go-server/plugin/log
38+ @echo Build plugin static
39+ @${GO} build -buildmode=plugin -o ${BUILD_DIR} /static.plugin ${BUILD_FLAGS} github.com/djthorpe/go-server/plugin/static
2940
3041$(PLUGIN_DIR ) : FORCE
3142 @echo Build plugin $(notdir $@ )
@@ -37,6 +48,9 @@ dependencies:
3748ifeq (,${GO})
3849 $(error "Missing go binary")
3950endif
51+ ifeq (,${NPM})
52+ $(error "Missing npm binary")
53+ endif
4054
4155mkdir :
4256 @install -d ${BUILD_DIR}
0 commit comments