-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
276 lines (244 loc) · 10 KB
/
Copy pathjustfile
File metadata and controls
276 lines (244 loc) · 10 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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# amp-extras-rs justfile
# Use rustup's cargo (respects rust-toolchain.toml)
export PATH := env_var('HOME') + "/.cargo/bin:" + env_var('PATH')
# Default recipe (shows available commands)
default:
@just --list
# Build the Rust library and copy to lua/amp_extras/
build:
@echo "Building amp-extras-rs..."
cargo build --release
@echo "Copying library to lua/amp_extras/..."
@mkdir -p lua/amp_extras
@if [ -f target/release/libamp_extras_core.dylib ]; then \
cp target/release/libamp_extras_core.dylib lua/amp_extras/amp_extras_core.so; \
echo "✓ Copied libamp_extras_core.dylib -> lua/amp_extras/amp_extras_core.so"; \
elif [ -f target/release/libamp_extras_core.so ]; then \
cp target/release/libamp_extras_core.so lua/amp_extras/amp_extras_core.so; \
echo "✓ Copied libamp_extras_core.so -> lua/amp_extras/amp_extras_core.so"; \
elif [ -f target/release/amp_extras_core.dll ]; then \
cp target/release/amp_extras_core.dll lua/amp_extras/amp_extras_core.so; \
echo "✓ Copied amp_extras_core.dll -> lua/amp_extras/amp_extras_core.so"; \
else \
echo "✗ No library found in target/release/"; \
exit 1; \
fi
@echo "✓ Build complete!"
# Build in debug mode (faster compilation)
build-debug:
@echo "Building amp-extras-rs (debug mode)..."
cargo build
@echo "Copying library to lua/amp_extras/..."
@mkdir -p lua/amp_extras
@if [ -f target/debug/libamp_extras_core.dylib ]; then \
cp target/debug/libamp_extras_core.dylib lua/amp_extras/amp_extras_core.so; \
echo "✓ Copied libamp_extras_core.dylib -> lua/amp_extras/amp_extras_core.so"; \
elif [ -f target/debug/libamp_extras_core.so ]; then \
cp target/debug/libamp_extras_core.so lua/amp_extras/amp_extras_core.so; \
echo "✓ Copied libamp_extras_core.so -> lua/amp_extras/amp_extras_core.so"; \
elif [ -f target/debug/amp_extras_core.dll ]; then \
cp target/debug/amp_extras_core.dll lua/amp_extras/amp_extras_core.so; \
echo "✓ Copied amp_extras_core.dll -> lua/amp_extras/amp_extras_core.so"; \
else \
echo "✗ No library found in target/debug/"; \
exit 1; \
fi
@echo "✓ Debug build complete!"
# Run unit tests only (Note: may have teardown issues when running all together)
test:
@echo "Running unit tests..."
cargo test --package amp_extras_core --lib
@echo "✓ Unit tests passed!"
# Run tests with output
test-verbose:
cargo test --package amp_extras_core --lib -- --nocapture
# Run unit tests by module (avoids global state issues)
test-unit-safe:
@echo "Running unit tests by module..."
@cargo test --package amp_extras_core --lib ide_ops::
@cargo test --package amp_extras_core --lib server::
@cargo test --package amp_extras_core --lib commands::
@cargo test --package amp_extras_core --lib notifications::
@cargo test --package amp_extras_core --lib errors::
@cargo test --package amp_extras_core --lib rpc::
@cargo test --package amp_extras_core --lib lockfile::
@echo "✓ Unit tests passed!"
@echo "Note: nvim:: module tests are in test-integration (require Neovim)"
# Run nvim-oxi integration tests
test-integration:
@echo "Running nvim-oxi integration tests..."
cargo test --package amp-extras-tests
@echo "✓ Integration tests complete!"
# Run legacy Lua integration tests with Neovim headless
test-integration-lua: build-debug
@echo "Running legacy Lua integration tests (Neovim headless)..."
@if command -v nvim >/dev/null 2>&1; then \
nvim --headless -u tests/server_test.lua || true; \
echo "✓ Integration tests complete!"; \
else \
echo "✗ nvim not found"; \
echo " Install Neovim to run integration tests"; \
exit 1; \
fi
# Run notification integration tests
test-notifications: build-debug
@echo "Running notification integration tests (Neovim headless)..."
@if command -v nvim >/dev/null 2>&1; then \
nvim --headless -u tests/notification_test.lua || true; \
echo "✓ Notification tests complete!"; \
else \
echo "✗ nvim not found"; \
echo " Install Neovim to run integration tests"; \
exit 1; \
fi
# Run visual selection notification tests
test-visual: build-debug
@echo "Running visual selection tests (Neovim headless)..."
@if command -v nvim >/dev/null 2>&1; then \
nvim --headless -u tests/visual_selection_test.lua || true; \
echo "✓ Visual selection tests complete!"; \
else \
echo "✗ nvim not found"; \
echo " Install Neovim to run integration tests"; \
exit 1; \
fi
# Start WebSocket server for manual testing
test-ws-server: build-debug
@echo "Starting WebSocket test server..."
@echo "This will start Neovim with the server running."
@echo "In another terminal, use the displayed command to connect a client."
@echo ""
@nvim -u tests/automated_websocket_test.lua
# Run full integration test suite
test-integration-full: build-debug
@./tests/run_integration_tests.sh
# Run all tests (unit + integration) - uses safe unit test runner
test-all:
@echo "Running all tests..."
@just test-unit-safe
@just test-integration
@echo "✓ All tests passed!"
# Format all code (Rust + Lua)
fmt:
@echo "Formatting Rust code..."
cargo fmt --all
@echo "Formatting Lua code..."
@if command -v stylua >/dev/null 2>&1; then \
stylua lua/ plugin/; \
echo "✓ Code formatted!"; \
else \
echo "⚠ stylua not found, skipping Lua formatting"; \
echo " Install with: cargo install stylua"; \
fi
# Run clippy linter
lint:
@echo "Running clippy..."
cargo clippy --workspace --all-targets -- -D warnings
@echo "✓ No lint warnings!"
# Run clippy with auto-fix
lint-fix:
@echo "Running clippy with auto-fix..."
cargo clippy --workspace --all-targets --fix --allow-dirty --allow-staged
# Install to Neovim data directory
install: build
@echo "Installing to Neovim..."
@NVIM_DATA_DIR=$$(nvim --headless -c 'echo stdpath("data")' -c 'quit' 2>&1 | tail -n 1); \
PLUGIN_DIR="$$NVIM_DATA_DIR/lazy/amp-extras-rs"; \
echo "Installing to: $$PLUGIN_DIR"; \
mkdir -p "$$PLUGIN_DIR"; \
cp -r lua "$$PLUGIN_DIR/"; \
cp -r plugin "$$PLUGIN_DIR/"; \
echo "✓ Installed to Neovim!"
# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
cargo clean
rm -f lua/amp_extras/amp_extras_core.so
rm -f lua/amp_extras_core.so
@echo "✓ Clean complete!"
# Check for common issues
check:
@echo "Running cargo check..."
cargo check --workspace --all-targets
@echo "✓ Check passed!"
# Build documentation
doc:
@echo "Building documentation..."
cargo doc --workspace --no-deps --open
# Run benchmarks
bench:
@echo "Running benchmarks..."
cargo bench --workspace
# Watch for changes and rebuild
watch:
@echo "Watching for changes..."
@if command -v cargo-watch >/dev/null 2>&1; then \
cargo watch -x 'build --release' -s 'just build'; \
else \
echo "✗ cargo-watch not found"; \
echo " Install with: cargo install cargo-watch"; \
exit 1; \
fi
# ============================================================================
# Cross-Platform Build Commands
# ============================================================================
# Build for all supported targets (requires cross)
build-all:
@echo "Building for all targets..."
@just build-linux-x64
@just build-linux-arm64
@just build-macos-x64
@just build-macos-arm64
@echo "✓ All builds complete!"
# Build for Linux x86_64
build-linux-x64:
@echo "Building for x86_64-unknown-linux-gnu..."
cross build --release --target x86_64-unknown-linux-gnu --package amp_extras_core
@mkdir -p dist
cp target/x86_64-unknown-linux-gnu/release/libamp_extras_core.so dist/x86_64-unknown-linux-gnu.so
# Build for Linux ARM64
build-linux-arm64:
@echo "Building for aarch64-unknown-linux-gnu..."
cross build --release --target aarch64-unknown-linux-gnu --package amp_extras_core
@mkdir -p dist
cp target/aarch64-unknown-linux-gnu/release/libamp_extras_core.so dist/aarch64-unknown-linux-gnu.so
# Build for macOS Intel
build-macos-x64:
@echo "Building for x86_64-apple-darwin..."
MACOSX_DEPLOYMENT_TARGET=11.0 cargo build --release --target x86_64-apple-darwin --package amp_extras_core
@mkdir -p dist
cp target/x86_64-apple-darwin/release/libamp_extras_core.dylib dist/x86_64-apple-darwin.dylib
# Build for macOS Apple Silicon
build-macos-arm64:
@echo "Building for aarch64-apple-darwin..."
MACOSX_DEPLOYMENT_TARGET=11.0 cargo build --release --target aarch64-apple-darwin --package amp_extras_core
@mkdir -p dist
cp target/aarch64-apple-darwin/release/libamp_extras_core.dylib dist/aarch64-apple-darwin.dylib
# Install cross-compilation tools
install-cross:
@echo "Installing cross..."
cargo install cross --git https://github.com/cross-rs/cross
@echo "Adding Rust targets..."
rustup target add x86_64-unknown-linux-gnu
rustup target add aarch64-unknown-linux-gnu
rustup target add x86_64-unknown-linux-musl
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
rustup target add x86_64-pc-windows-msvc
@echo "✓ Cross-compilation tools installed!"
# ============================================================================
# Project Statistics
# ============================================================================
# Show project statistics
stats:
@echo "Project Statistics:"
@echo "=================="
@echo "Rust files:"
@find crates -name '*.rs' | wc -l | xargs echo " "
@echo "Lua files:"
@find lua plugin -name '*.lua' 2>/dev/null | wc -l | xargs echo " "
@echo ""
@echo "Lines of Rust:"
@find crates -name '*.rs' -exec wc -l {} + | tail -n 1 | awk '{print " " $1}'
@echo "Lines of Lua:"
@find lua plugin -name '*.lua' -exec wc -l {} + 2>/dev/null | tail -n 1 | awk '{print " " $1}'