-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
88 lines (73 loc) · 2.41 KB
/
Copy pathMakefile
File metadata and controls
88 lines (73 loc) · 2.41 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
SHELL := /bin/sh
GO ?= go
NPM ?= npm
NPX ?= npx
GRADLE ?= gradle
BIN_DIR ?= bin
DIST_DIR ?= dist
VSCODE_EXTENSION_DIR := vscode/extensions/glua-lsp
JETBRAINS_EXTENSION_DIR := jetbrains/extensions/glua-lsp
CLI_CMDS := glua gluac gluals
TARGETS := \
linux-amd64 \
linux-386 \
linux-arm64 \
linux-armv6 \
linux-armv7 \
windows-amd64 \
windows-386 \
windows-arm64 \
darwin-amd64 \
darwin-arm64 \
android-arm64
.PHONY: all build build-ls docs dist $(TARGETS) package-vscode package-jetbrains package-extensions clean
all: build
build:
@mkdir -p "$(BIN_DIR)"
@for cmd in $(CLI_CMDS); do \
echo "building $$cmd"; \
CGO_ENABLED=1 "$(GO)" build -tags native_modules -trimpath -ldflags="-s -w" -o "$(BIN_DIR)/$$cmd" "./cmd/$$cmd"; \
done
build-ls:
@mkdir -p "$(BIN_DIR)"
@echo "building gluals"
@CGO_ENABLED=1 "$(GO)" build -tags native_modules -trimpath -ldflags="-s -w" -o "$(BIN_DIR)/gluals" ./cmd/gluals
docs:
@./scripts/build-docs-site.sh
dist: $(TARGETS)
$(TARGETS):
@set -eu; \
target="$@"; \
goos="$${target%%-*}"; \
arch_part="$${target#*-}"; \
goarch="$$arch_part"; \
goarm=""; \
case "$$arch_part" in \
armv6) goarch="arm"; goarm="6" ;; \
armv7) goarch="arm"; goarm="7" ;; \
esac; \
out_dir="$(DIST_DIR)/$$target"; \
mkdir -p "$$out_dir"; \
for cmd in $(CLI_CMDS); do \
output="$$out_dir/$$cmd"; \
if [ "$$goos" = "windows" ]; then output="$$output.exe"; fi; \
echo "building $$cmd for $$target"; \
if [ -n "$$goarm" ]; then \
CGO_ENABLED=0 GOOS="$$goos" GOARCH="$$goarch" GOARM="$$goarm" "$(GO)" build -trimpath -ldflags="-s -w" -o "$$output" "./cmd/$$cmd"; \
else \
CGO_ENABLED=0 GOOS="$$goos" GOARCH="$$goarch" "$(GO)" build -trimpath -ldflags="-s -w" -o "$$output" "./cmd/$$cmd"; \
fi; \
done
package-vscode:
@mkdir -p "$(DIST_DIR)"
@cd "$(VSCODE_EXTENSION_DIR)" && "$(NPM)" ci
@cd "$(VSCODE_EXTENSION_DIR)" && "$(NPX)" @vscode/vsce package --out "../../../$(DIST_DIR)/glua-lsp-vscode.vsix"
package-jetbrains:
@cd "$(JETBRAINS_EXTENSION_DIR)" && if [ -x ./gradlew ]; then ./gradlew --no-daemon --no-configuration-cache buildPlugin; else "$(GRADLE)" --no-daemon --no-configuration-cache buildPlugin; fi
@mkdir -p "$(DIST_DIR)"
@cp "$(JETBRAINS_EXTENSION_DIR)"/build/distributions/*.zip "$(DIST_DIR)/"
package-extensions: package-vscode package-jetbrains
clean:
@rm -rf "$(BIN_DIR)" "$(DIST_DIR)"
@rm -rf "$(VSCODE_EXTENSION_DIR)"/*.vsix
@rm -rf "$(JETBRAINS_EXTENSION_DIR)"/build