forked from x1unix/go-playground
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.mk
58 lines (49 loc) · 1.62 KB
/
build.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
GO ?= go
YARN ?= yarn
GOROOT ?= $(shell go env GOROOT)
TOOLS ?= ./tools
PUBLIC_DIR ?= $(UI)/public
WEBWORKER_PKG ?= ./cmd/webworker
.PHONY: clean
clean:
@echo ":: Cleanup..." && rm -rf $(TARGET) && rm -rf $(UI)/build
.PHONY:check-go
check-go:
@if ! command -v $(GO) >/dev/null 2>&1 ; then\
echo "ERROR: '$(GO)' binary not found. Please ensure that Go is installed or specify binary path with 'GO' variable." && \
exit 1; \
fi;
.PHONY:check-yarn
check-yarn:
@if ! command -v $(YARN) >/dev/null 2>&1 ; then\
echo "ERROR: '$(YARN)' binary not found. Please ensure that Node.js and Yarn are installed or specify binary path with 'YARN' variable." && \
exit 1; \
fi;
# Build targets
.PHONY: collect-meta
collect-meta:
@echo ":: Building Go packages index..." && \
$(GO) run $(TOOLS)/collector -goroot $(GOROOT) -out data/packages.json
.PHONY:preinstall
preinstall:
@echo ":: Checking and installing dependencies..." && \
$(YARN) --cwd="$(UI)" install --silent
.PHONY:build-server
build-server:
@echo ":: Building server..." && \
$(GO) build -o $(TARGET)/playground $(PKG)
.PHONY:build-ui
build-ui:
@echo ":: Building UI..." && \
$(YARN) --cwd="$(UI)" build
.PHONY:build-webworker
build-webworker:
@echo ":: Building Go Webworker module..." && \
GOOS=js GOARCH=wasm $(GO) build -o $(PUBLIC_DIR)/worker.wasm $(WEBWORKER_PKG) && \
cp "$(GOROOT)/misc/wasm/wasm_exec.js" $(PUBLIC_DIR)
.PHONY: build
build: check-go check-yarn clean preinstall collect-meta build-server build-webworker build-ui
@echo ":: Copying assets..." && \
cp -rfv ./data $(TARGET)/data && \
mv -v $(UI)/build $(TARGET)/public && \
echo ":: Build done - $(TARGET)"