-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathMakefile.vsix-rules
More file actions
237 lines (190 loc) · 6.73 KB
/
Copy pathMakefile.vsix-rules
File metadata and controls
237 lines (190 loc) · 6.73 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# -*- Makefile -*-
CP ?= cp -fl # ln -srf
DUNE_BUILD_DIR ?= _build
DUNE_BUILD_ARGS = ${DUNE_CROSS_ARGS}
ifneq ($(BUILD_PLAT),$(TARGET_PLAT))
DUNE_BUILD_DEFAULT = \
${DUNE_BUILD_DIR}/default$(strip \
$(if $(filter win32,$(TARGET_PLAT)),.windows) \
$(if $(filter darwin,$(TARGET_PLAT)),.osx))
else
DUNE_BUILD_DEFAULT = \
${DUNE_BUILD_DIR}/default
endif
DUNE_BUILD_SRCDIR = ${DUNE_BUILD_DEFAULT}/${MAIN_SRCDIR}
BUILD_PLAT = $(shell node --print process.platform 2>/dev/null || echo linux)
BUILD_ARCH = $(shell node --print process.arch 2>/dev/null || echo x64)
# TARGET_PLAT should already be defined in Makefile; conditionally assign anyway
TARGET_PLAT ?= $(BUILD_PLAT)
TARGET_ARCH ?= $(BUILD_ARCH)
ifeq ($(TARGET_PLAT),universal)
TARGET_SPEC = universal
else
TARGET_SPEC = $(TARGET_PLAT)-$(TARGET_ARCH)
endif
DOT_EXE = $(if $(filter win32,$(TARGET_PLAT)),.exe)
TARGET_PROFILE ?= release
TARGET_VSIX = $(TARGET_NAME)-$(VERSION)-$(TARGET_SPEC)-$(TARGET_PROFILE).vsix
# For `all-*` targets
TARGET_PLATFORMS ?= linux # win32 darwin
# ---
STUDIO_JS = $(STUDIO_SRCDIR)/$(STUDIO).bc.js
SUPERBOL_LSP = $(basename $(notdir $(SUPERBOL_LSP_PKG)))
ifeq ($(TARGET_PLAT),universal)
SUPERBOL_LSP_JS = $(SUPERBOL_LSP_PKG)/main.bc.js
SUPERBOL_LSP_BUILT = ${DUNE_BUILD_SRCDIR}/$(SUPERBOL_LSP_JS)
SUPERBOL_LSP_EXE = $(SUPERBOL_LSP).js
else
SUPERBOL_LSP_EXE = $(SUPERBOL_LSP)-$(TARGET_SPEC)$(DOT_EXE)
ifeq ($(TARGET_PLAT)_$(LINKING_MODE),$(BUILD_PLAT)_static)
SUPERBOL_LSP_BUILT = $(SUPERBOL_LSP)
else
SUPERBOL_LSP_BUILT = ${DUNE_BUILD_SRCDIR}/$(SUPERBOL_LSP_PKG)/main.exe
endif
endif
# Setting `GENERATE_PACKAGE_DOT_JSON` to `no` skips generation of
# `package.json` (which should always be updated/committed anyways).
# This generation requires the compilation of `$(SUPERBOL_LSP_BUILT)`,
# that itself depends on a phony target, and therefore triggers way
# too many calls to `scripts/static-build.sh` when `$(LINKING_MODE)`
# is `static`).
ifeq ($(LINKING_MODE),static)
GENERATE_PACKAGE_DOT_JSON ?= no
else
GENERATE_PACKAGE_DOT_JSON ?= yes
endif
NPX = npx $(NPX_ARGS)
NPX_ARGS ?=
VSCE_ARGS = $(if $(subst universal,,$(TARGET_PLAT)),-t $(TARGET_SPEC))
VSCE_PACKAGE_ARGS ?=
VSCE_PUBLISH_ARGS ?=
OVSX_PUBLISH_ARGS ?=
# --- leading rules ---
.PHONY: compile package
all: superbol-lsp-server
compile: superbol-lsp-server build-release
package: vsix-package
superbol-lsp-server $(SUPERBOL_LSP_EXE): $(SUPERBOL_LSP_BUILT)
# Only check/rebuild `package.json` on matching target and build platforms
ifeq ($(TARGET_PLAT),$(BUILD_PLAT))
$(CP) $(SUPERBOL_LSP_BUILT) $(SUPERBOL_LSP_EXE)
ifeq ($(GENERATE_PACKAGE_DOT_JSON),yes)
.PHONY: rebuild-package.json
rebuild-package.json package.json: $(SUPERBOL_LSP_BUILT)
cp -f package.json package.json.prev
./$(SUPERBOL_LSP_BUILT) json vscode --gen package.json
diff -u package.json.prev package.json && rm -f package.json.prev
endif
endif
ifeq ($(TARGET_PLAT),universal)
$(SUPERBOL_LSP_BUILT): vsix-dist-setup
${DUNE} build ${DUNE_ARGS} ${DUNE_CROSS_ARGS} --profile universal \
$(MAIN_SRCDIR)/$(SUPERBOL_LSP_JS)
else #platform-specific
$(SUPERBOL_LSP_BUILT): build vsix-dist-setup
.PHONY: check-package.json
check-package.json: #to be used after `build`
./$(SUPERBOL_LSP_BUILT) json vscode --gen - | diff -u package.json -
endif
.PHONY: build-debug bundle-debug
build-debug:
rm -rf _dist
${DUNE} build ${DUNE_ARGS} ${DUNE_BUILD_ARGS} $(STUDIO_JS)
@mkdir -p $(JS_OUTDIR)
$(CP) ${DUNE_BUILD_DIR}/default/$(STUDIO_JS) $(JS_OUTDIR)/
$(MAKE) bundle-debug
# Use 'make build-debug' before to copy the JS file in $(JS_OUTDIR)
bundle-debug: package.json
bundle-debug: $(JS_TARGETS)
$(NPX) esbuild $(filter %.js, $+) \
--bundle \
--external:vscode \
--outdir=_dist \
--platform=node \
--target=es6 \
--sourcemap
# the last command generated _dist/$(STUDIO).bs.js
.PHONY: build-release bundle-release
build-release:
rm -rf _dist
${DUNE} build ${DUNE_ARGS} ${DUNE_BUILD_ARGS} --profile=release \
$(STUDIO_JS)
@mkdir -p $(JS_OUTDIR)
$(CP) ${DUNE_BUILD_DIR}/default/$(STUDIO_JS) $(JS_OUTDIR)/
$(MAKE) bundle-release
# Use 'make build-release' before to copy the JS file in $(JS_OUTDIR)
bundle-release: package.json
bundle-release: $(JS_TARGETS)
$(NPX) esbuild $(filter %.js, $+) \
--bundle \
--external:vscode \
--outdir=_dist \
--platform=node \
--target=es6 \
--minify-whitespace \
--minify-syntax \
--sources-content=false
# ---
# packaging
.PHONY: vsix-dist-setup vsix-package vsix-debug vsix-release \
all-vsix-debug-packages \
all-vsix-debug \
all-vsix-release-packages \
all-vsix-release \
all-vsix-packages \
all-vsix
gnucobol-config: $(GNUCOBOL_SRCDIR)/config
@mkdir -p $@
rm -r -f $@/*.*
find $(GNUCOBOL_SRCDIR)/config -type f \
-a -regex '.*.\(conf\|conf-inc\|words\|ttbl\)' -print0 | \
xargs -0 cp -f -t $@
vsix-dist-setup:
@mkdir -p _dist
vsix-package: package.json gnucobol-config $(EXE_TARGETS) $(SUPERBOL_LSP_BUILT)
# needs 'make build-debug' or 'make build-release' before
$(CP) $(SUPERBOL_LSP_BUILT) _dist/$(SUPERBOL_LSP_EXE)
$(NPX) vsce package $(VSCE_ARGS) $(VSCE_PACKAGE_ARGS) \
--no-git-tag-version \
--no-update-package-json \
--out $(TARGET_VSIX) $(VERSION)
vsix-release: build-release
$(MAKE) vsix-package TARGET_PROFILE=release
vsix-debug: build-debug
$(MAKE) vsix-package TARGET_PROFILE=debug
all-vsix-release all-vsix-release-packages:
for plat in $(TARGET_PLATFORMS); do \
$(MAKE) vsix-release TARGET_PLAT=$${plat}; \
done
all-vsix-debug all-vsix-debug-packages:
for plat in $(TARGET_PLATFORMS); do \
$(MAKE) vsix-debug TARGET_PLAT=$${plat}; \
done
all-vsix all-vsix-packages: all-vsix-debug-packages all-vsix-release-packages
vsix-clean: clean
rm -rf $(JS_OUTDIR) gnucobol-config _dist *.vsix
# publishing (requires vsce/ovsx login)
.PHONY: ovsx-deploy vsce-deploy deploy-all
vsce-deploy:
$(NPX) vsce publish $(VSCE_ARGS) $(VSCE_PUBLISH_ARGS) \
--packagePath $(TARGET_VSIX)
ovsx-deploy:
# Note: should fail in case of duplicate version
$(NPX) ovsx publish $(VSCE_ARGS) $(OVSX_PUBLISH_ARGS) \
--packagePath $(TARGET_VSIX)
deploy-all: # Make sure to run target `all-vsix-release-packages` beforehand
# $(MAKE) all-vsix-release-packages;
for plat in $(TARGET_PLATFORMS); do \
$(MAKE) ovsx-deploy vsce-deploy TARGET_PROFILE=release; \
done
# vsix-specific cleanup
.PHONY: clean-execs
clean-execs:
rm -f $(SUPERBOL_LSP) $(wildcard $(SUPERBOL_LSP)-*-*)
distclean: clean-execs vsix-clean
clean: clean-execs
# setup
.PHONY: node-setup
node-setup:
npm install
build-deps: node-setup