-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
46 lines (39 loc) · 2.01 KB
/
Copy pathMakefile
File metadata and controls
46 lines (39 loc) · 2.01 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
GOROOT := $(shell go env GOROOT)
build:
go build -o minml ./go/markup/minml/cmd/
gen-parser:
cd dev/tree-sitter && tree-sitter generate
build-lsp:
cp -R dev/tree-sitter/queries go/markup/minml/lsp/queries
go build -o minml-lsp ./go/markup/minml/cmd/lsp/
EXT_NAME := $(shell node -p "require('./dev/vscode/minml-preview/package.json').publisher + '.' + require('./dev/vscode/minml-preview/package.json').name + '-' + require('./dev/vscode/minml-preview/package.json').version")
# Detect OS for VS Code extensions directory
ifeq ($(OS),Windows_NT)
VSCODE_EXT_DIR := $(USERPROFILE)/.vscode/extensions/$(EXT_NAME)
VSCODE_EXT_GLOB := $(USERPROFILE)/.vscode/extensions/
else
VSCODE_EXT_DIR := $(HOME)/.vscode/extensions/$(EXT_NAME)
VSCODE_EXT_GLOB := $(HOME)/.vscode/extensions/
endif
build-wasm:
cp "$(GOROOT)/lib/wasm/wasm_exec.js" ./out/wasm/wasm_exec.js
GOOS=js GOARCH=wasm go build -o ./out/wasm/main.wasm ./go/wasm/main.go
cp ./out/wasm/wasm_exec.js ./dev/vscode/minml-preview/media/wasm_exec.js
cp ./out/wasm/main.wasm ./dev/vscode/minml-preview/media/main.wasm
vscode-live-preview: build-wasm build-lsp
@echo "Checking for npm..."
@npm --version > /dev/null 2>&1 || (echo "Error: npm is not installed. Please install Node.js and npm." && exit 1)
@echo "Building VS Code extension..."
cd dev/vscode/minml-preview && npm ci && npm run compile
@echo "Installing extension to $(VSCODE_EXT_DIR)..."
@echo "Removing stale minml extension installations..."
rm -rf "$(VSCODE_EXT_DIR)"
@find "$(VSCODE_EXT_GLOB)" -maxdepth 1 -name "*minml*" ! -path "$(VSCODE_EXT_DIR)" -exec rm -rf {} + 2>/dev/null || true
mkdir -p "$(VSCODE_EXT_DIR)"
cp -R dev/vscode/minml-preview/dist "$(VSCODE_EXT_DIR)/"
cp -R dev/vscode/minml-preview/media "$(VSCODE_EXT_DIR)/"
cp dev/vscode/minml-preview/package.json "$(VSCODE_EXT_DIR)/"
cp dev/vscode/minml-preview/language-configuration.json "$(VSCODE_EXT_DIR)/"
cp minml-lsp "$(VSCODE_EXT_DIR)/"
chmod +x "$(VSCODE_EXT_DIR)/minml-lsp"
@echo "Done! Please restart VS Code to use the extension."