-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
107 lines (80 loc) · 2.64 KB
/
Makefile
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
SRC_DIR := $(shell "pwd")
TARGET_DIR := $(shell "pwd")/target
PROJECT_VERS := $(shell "$(SRC_DIR)/util/version.sh" --short)
PROJECT_VERS_NO_COMMITN := $(shell "$(SRC_DIR)/util/version.sh" --short --no-commitn) # necessary for extension packaging
CARGO := cargo
CARGOFLAGS :=
CARGO_TOML := $(SRC_DIR)/Cargo.toml
NPM := npm
NODE := node
VSCE := vsce
VSCE_SUBCOMMAND := package
VSCE_FLAGS := --no-update-package-json --no-git-tag-version
VSCODE_EXT_PREFIX := $(SRC_DIR)/integration/vscode-ext
VSCODE_EXT_NPM_SCRIPT := build:dev
VSCODE_EXT_DIST_DIR := $(VSCODE_EXT_PREFIX)/dist
# this ensures `all` is run by default despite not being the first target in the Makefile
.DEFAULT_GOAL := all
# check for dependencies
.PHONY: validate_cargo
validate_cargo:
$(if \
$(shell which $(CARGO)),\
$(info Cargo located at $(shell command -v $(CARGO))),\
$(error Cargo not found in PATH, but is required to build devinit))
validate_npm:
$(if \
$(shell which $(NPM)),\
$(info npm located at $(shell command -v $(NPM))),\
$(error npm not found in PATH, but is required to build the devinit VS Code extension))
$(if \
$(shell which $(NODE)),\
$(info Node.js located at $(shell command -v $(NODE))),\
$(error Node.js not found in PATH, but is required to build the devinit VS Code extension))
validate_vsce:
$(if \
$(shell which $(VSCE)),\
$(info vsce located at $(shell command -v $(VSCE))),\
$(error vsce not found in PATH, but is required to build the devinit VS Code extension))
# run with DEBUG=1 to use debug configuration
ifneq "$(DEBUG)" "1"
CARGOFLAGS += --release
VSCODE_EXT_NPM_SCRIPT = build:prod
vscode_ext: | validate_vsce
endif
# use EXT_PUBLISH=1 to publish extensions to relevant marketplaces
ifeq "$(EXT_PUBLISH)" "1"
VSCE_SUBCOMMAND = publish
else
VSCE_FLAGS += --out=$(VSCODE_EXT_DIST_DIR)
endif
.PHONY: devinit vscode_ext
.PHONY: clean
#
# All targets
#
all: devinit vscode_ext
#
# Compile the devinit executable
#
devinit: $(CARGO_TOML) | validate_cargo
DEVINITVERS=$(PROJECT_VERS) \
$(CARGO) build $(CARGOFLAGS) --manifest-path=$(CARGO_TOML)
#
# Bundle the VS Code extension
#
$(VSCODE_EXT_PREFIX)/node_modules:
$(NPM) install --prefix=$(VSCODE_EXT_PREFIX)
vscode_ext: | validate_npm $(VSCODE_EXT_PREFIX)/node_modules
$(NPM) run $(VSCODE_EXT_NPM_SCRIPT) --prefix=$(VSCODE_EXT_PREFIX)
cp $(SRC_DIR)/LICENCE $(VSCODE_EXT_PREFIX)/LICENSE
cp $(SRC_DIR)/resources/icon.png $(VSCODE_EXT_DIST_DIR)/icon.png
cd $(VSCODE_EXT_PREFIX) && \
$(VSCE) $(VSCE_SUBCOMMAND) $(VSCE_FLAGS) $(subst v,,$(PROJECT_VERS_NO_COMMITN))
#
# Remove build artifacts
#
clean:
rm -rf $(TARGET_DIR)
rm -rf $(VSCODE_EXT_DIST_DIR)
rm -rf $(VSCODE_EXT_PREFIX)/LICENSE