-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
190 lines (154 loc) · 6.84 KB
/
Makefile
File metadata and controls
190 lines (154 loc) · 6.84 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
# NimbyScript LSP Build System
# Targets: macOS ARM64, macOS x86_64, Windows x86_64, Linux x86_64
CARGO = cargo
EXTENSION_DIR = editors/vscode
NEOVIM_DIR = editors/neovim
SERVER_DIR = $(EXTENSION_DIR)/server
RELEASE_DIR = release
TREESITTER_QUERIES = crates/tree-sitter-nimbyscript/queries
# Rust target triples
TARGET_MACOS_ARM64 = aarch64-apple-darwin
TARGET_MACOS_X64 = x86_64-apple-darwin
TARGET_WINDOWS_X64 = x86_64-pc-windows-gnu
TARGET_LINUX_X64 = x86_64-unknown-linux-gnu
# VSCode platform targets
VSCODE_DARWIN_ARM64 = darwin-arm64
VSCODE_DARWIN_X64 = darwin-x64
VSCODE_WIN32_X64 = win32-x64
VSCODE_LINUX_X64 = linux-x64
# Binary names
BINARY_NAME = nimbyscript-lsp
BINARY_NAME_WIN = $(BINARY_NAME).exe
VERSION := $(shell grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
.PHONY: all clean install-targets build-all package-all \
build-macos-arm64 build-macos-x64 build-windows-x64 build-linux-x64 \
package-macos-arm64 package-macos-x64 package-windows-x64 package-linux-x64 \
extension-deps dev test check clippy fmt lint sync-queries install-lsp
#===============================================================================
# Main targets
#===============================================================================
all: build-all package-all
clean:
$(CARGO) clean
rm -rf $(RELEASE_DIR)
rm -f $(SERVER_DIR)/$(BINARY_NAME) $(SERVER_DIR)/$(BINARY_NAME_WIN)
rm -f $(EXTENSION_DIR)/*.vsix
#===============================================================================
# Prerequisites
#===============================================================================
install-targets:
rustup target add $(TARGET_MACOS_ARM64)
rustup target add $(TARGET_MACOS_X64)
rustup target add $(TARGET_WINDOWS_X64)
rustup target add $(TARGET_LINUX_X64)
extension-deps:
cd $(EXTENSION_DIR) && npm install
#===============================================================================
# Build targets
#===============================================================================
build-macos-arm64:
$(CARGO) build --release --target $(TARGET_MACOS_ARM64)
mkdir -p $(RELEASE_DIR)/$(VSCODE_DARWIN_ARM64)
cp target/$(TARGET_MACOS_ARM64)/release/$(BINARY_NAME) \
$(RELEASE_DIR)/$(VSCODE_DARWIN_ARM64)/
build-macos-x64:
$(CARGO) build --release --target $(TARGET_MACOS_X64)
mkdir -p $(RELEASE_DIR)/$(VSCODE_DARWIN_X64)
cp target/$(TARGET_MACOS_X64)/release/$(BINARY_NAME) \
$(RELEASE_DIR)/$(VSCODE_DARWIN_X64)/
# Cross-compilation requires additional toolchains
# Install with: brew install mingw-w64
# Or use GitHub Actions for native Windows builds
build-windows-x64:
$(CARGO) build --release --target $(TARGET_WINDOWS_X64)
mkdir -p $(RELEASE_DIR)/$(VSCODE_WIN32_X64)
cp target/$(TARGET_WINDOWS_X64)/release/$(BINARY_NAME_WIN) \
$(RELEASE_DIR)/$(VSCODE_WIN32_X64)/
# Linux cross-compilation from macOS is challenging
# Consider using Docker or GitHub Actions for native Linux builds
build-linux-x64:
$(CARGO) build --release --target $(TARGET_LINUX_X64)
mkdir -p $(RELEASE_DIR)/$(VSCODE_LINUX_X64)
cp target/$(TARGET_LINUX_X64)/release/$(BINARY_NAME) \
$(RELEASE_DIR)/$(VSCODE_LINUX_X64)/
# Build for macOS platforms only (can be done natively on macOS)
build-macos: build-macos-arm64 build-macos-x64
build-all: build-macos-arm64 build-macos-x64 build-windows-x64 build-linux-x64
#===============================================================================
# Package targets (create platform-specific VSIX files)
#===============================================================================
package-macos-arm64: extension-deps
rm -f $(SERVER_DIR)/$(BINARY_NAME) $(SERVER_DIR)/$(BINARY_NAME_WIN)
cp $(RELEASE_DIR)/$(VSCODE_DARWIN_ARM64)/$(BINARY_NAME) $(SERVER_DIR)/
chmod +x $(SERVER_DIR)/$(BINARY_NAME)
cd $(EXTENSION_DIR) && npx vsce package --target $(VSCODE_DARWIN_ARM64)
mkdir -p $(RELEASE_DIR)
mv $(EXTENSION_DIR)/*.vsix $(RELEASE_DIR)/ 2>/dev/null || true
package-macos-x64: extension-deps
rm -f $(SERVER_DIR)/$(BINARY_NAME) $(SERVER_DIR)/$(BINARY_NAME_WIN)
cp $(RELEASE_DIR)/$(VSCODE_DARWIN_X64)/$(BINARY_NAME) $(SERVER_DIR)/
chmod +x $(SERVER_DIR)/$(BINARY_NAME)
cd $(EXTENSION_DIR) && npx vsce package --target $(VSCODE_DARWIN_X64)
mkdir -p $(RELEASE_DIR)
mv $(EXTENSION_DIR)/*.vsix $(RELEASE_DIR)/ 2>/dev/null || true
package-windows-x64: extension-deps
rm -f $(SERVER_DIR)/$(BINARY_NAME) $(SERVER_DIR)/$(BINARY_NAME_WIN)
cp $(RELEASE_DIR)/$(VSCODE_WIN32_X64)/$(BINARY_NAME_WIN) $(SERVER_DIR)/
cd $(EXTENSION_DIR) && npx vsce package --target $(VSCODE_WIN32_X64)
mkdir -p $(RELEASE_DIR)
mv $(EXTENSION_DIR)/*.vsix $(RELEASE_DIR)/ 2>/dev/null || true
package-linux-x64: extension-deps
rm -f $(SERVER_DIR)/$(BINARY_NAME) $(SERVER_DIR)/$(BINARY_NAME_WIN)
cp $(RELEASE_DIR)/$(VSCODE_LINUX_X64)/$(BINARY_NAME) $(SERVER_DIR)/
chmod +x $(SERVER_DIR)/$(BINARY_NAME)
cd $(EXTENSION_DIR) && npx vsce package --target $(VSCODE_LINUX_X64)
mkdir -p $(RELEASE_DIR)
mv $(EXTENSION_DIR)/*.vsix $(RELEASE_DIR)/ 2>/dev/null || true
package-all: package-macos-arm64 package-macos-x64 package-windows-x64 package-linux-x64
#===============================================================================
# Development helpers
#===============================================================================
# Build and package for current platform only
dev: sync-queries
$(CARGO) build --release
rm -f $(SERVER_DIR)/$(BINARY_NAME) $(SERVER_DIR)/$(BINARY_NAME_WIN)
cp target/release/$(BINARY_NAME) $(SERVER_DIR)/ 2>/dev/null || \
cp target/release/$(BINARY_NAME_WIN) $(SERVER_DIR)/ 2>/dev/null
chmod +x $(SERVER_DIR)/$(BINARY_NAME) 2>/dev/null || true
cd $(EXTENSION_DIR) && npx vsce package
# Run tests
test:
$(CARGO) test --all
# Check compilation for all crates
check:
$(CARGO) check --all-targets
# Run clippy
clippy:
$(CARGO) clippy --all-targets -- -D warnings
# Format code
fmt:
$(CARGO) fmt --all
# Run all linters and checks
lint:
$(CARGO) check --all-targets
$(CARGO) fmt --all --check
$(CARGO) clippy --all-targets -- -D warnings
cd $(EXTENSION_DIR) && npm run lint
luacheck --config $(NEOVIM_DIR)/.luacheckrc $(NEOVIM_DIR)
# Install extension locally (after running dev)
install: dev
rm -f $(EXTENSION_DIR)/nimbyscript-*.vsix
cd $(EXTENSION_DIR) && npx vsce package
code --install-extension $(EXTENSION_DIR)/nimbyscript-$(VERSION).vsix --force
# Build and install LSP binary to ~/.cargo/bin as 'nimbyscript'
install-lsp:
$(CARGO) install --path crates/nimbyscript-lsp --locked
rm -f $(HOME)/.cargo/bin/nimbyscript
mv $(HOME)/.cargo/bin/$(BINARY_NAME) $(HOME)/.cargo/bin/nimbyscript
#===============================================================================
# Neovim support
#===============================================================================
# Sync tree-sitter queries to neovim plugin
sync-queries:
mkdir -p $(NEOVIM_DIR)/queries/nimbyscript
cp $(TREESITTER_QUERIES)/highlights.scm $(NEOVIM_DIR)/queries/nimbyscript/