-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
185 lines (155 loc) · 6.93 KB
/
Makefile
File metadata and controls
185 lines (155 loc) · 6.93 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
# Makefile for ModelSDKGo
#
# Usage:
# make build - Build mxcli for current platform
# make release - Build mxcli for all platforms (macOS, Windows, Linux)
# make test - Run unit tests
# make test-mdl - Run MDL integration tests (requires Docker)
# make grammar - Regenerate ANTLR parser
# make sbom - Generate CycloneDX SBOM (Go + TypeScript)
# make sbom-report - Generate Markdown dependency report
# make clean - Remove build artifacts
BINARY_NAME = mxcli
BUILD_DIR = bin
CMD_PATH = ./cmd/mxcli
# Version info (can be overridden)
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILD_TIME = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS = -ldflags "-X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)"
.PHONY: build release clean test test-mdl grammar completions sync-skills sync-commands sync-lint-rules sync-changelog sync-all docs documentation vscode-ext vscode-install source-tree sbom sbom-report
# Helper: copy file only if content differs (avoids mtime updates that invalidate go build cache)
# Usage: $(call copy-if-changed,src,dst)
define copy-if-changed
@if [ ! -f $(2) ] || ! cmp -s $(1) $(2); then cp $(1) $(2); fi
endef
# Sync skills from .claude/skills/mendix to cmd/mxcli/skills for embedding
sync-skills:
@mkdir -p cmd/mxcli/skills
@changed=0; for f in .claude/skills/mendix/*.md; do \
dst="cmd/mxcli/skills/$$(basename $$f)"; \
if [ ! -f "$$dst" ] || ! cmp -s "$$f" "$$dst"; then \
cp "$$f" "$$dst"; changed=$$((changed + 1)); \
fi; \
done; \
if [ $$changed -gt 0 ]; then echo "Synced $$changed skill file(s)"; fi
# Sync commands from .claude/commands/mendix to cmd/mxcli/commands for embedding
sync-commands:
@mkdir -p cmd/mxcli/commands
@changed=0; for f in .claude/commands/mendix/*.md; do \
dst="cmd/mxcli/commands/$$(basename $$f)"; \
if [ ! -f "$$dst" ] || ! cmp -s "$$f" "$$dst"; then \
cp "$$f" "$$dst"; changed=$$((changed + 1)); \
fi; \
done; \
if [ $$changed -gt 0 ]; then echo "Synced $$changed command file(s)"; fi
# Sync lint rules from .claude/lint-rules to cmd/mxcli/lint-rules for embedding
sync-lint-rules:
@mkdir -p cmd/mxcli/lint-rules
@changed=0; for f in .claude/lint-rules/*.star; do \
dst="cmd/mxcli/lint-rules/$$(basename $$f)"; \
if [ ! -f "$$dst" ] || ! cmp -s "$$f" "$$dst"; then \
cp "$$f" "$$dst"; changed=$$((changed + 1)); \
fi; \
done; \
if [ $$changed -gt 0 ]; then echo "Synced $$changed lint rule file(s)"; fi
# Sync VS Code extension (.vsix) for embedding
sync-vsix:
@if [ -f vscode-mdl/vscode-mdl-*.vsix ]; then \
src=$$(ls vscode-mdl/vscode-mdl-*.vsix | head -1); \
if [ ! -f cmd/mxcli/vscode-mdl.vsix ] || ! cmp -s "$$src" cmd/mxcli/vscode-mdl.vsix; then \
cp "$$src" cmd/mxcli/vscode-mdl.vsix; \
echo "Synced vscode-mdl.vsix"; \
fi; \
elif [ ! -f cmd/mxcli/vscode-mdl.vsix ]; then \
echo "Warning: No .vsix found. Creating empty placeholder."; \
touch cmd/mxcli/vscode-mdl.vsix; \
fi
# Sync changelog to cmd/mxcli for embedding
sync-changelog:
$(call copy-if-changed,CHANGELOG.md,cmd/mxcli/changelog.md)
# Sync skills, commands, lint rules, and changelog
sync-all: sync-skills sync-commands sync-lint-rules sync-vsix sync-changelog
# Generate LSP completion items from grammar (only rewrites file if content changed)
completions:
@CGO_ENABLED=0 go run ./cmd/gen-completions -lexer mdl/grammar/MDLLexer.g4 -output cmd/mxcli/lsp_completions_gen.go.tmp
@if [ ! -f cmd/mxcli/lsp_completions_gen.go ] || ! cmp -s cmd/mxcli/lsp_completions_gen.go.tmp cmd/mxcli/lsp_completions_gen.go; then \
mv cmd/mxcli/lsp_completions_gen.go.tmp cmd/mxcli/lsp_completions_gen.go; \
echo "Updated cmd/mxcli/lsp_completions_gen.go"; \
else \
rm cmd/mxcli/lsp_completions_gen.go.tmp; \
fi
# Build for current platform (auto-syncs skills and commands)
build: sync-all completions
@mkdir -p $(BUILD_DIR)
CGO_ENABLED=0 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) $(CMD_PATH)
CGO_ENABLED=0 go build -o $(BUILD_DIR)/source_tree ./cmd/source_tree
@echo "Built $(BUILD_DIR)/$(BINARY_NAME) $(BUILD_DIR)/source_tree"
# Build for all platforms (CGO_ENABLED=0 for cross-compilation)
release: clean sync-all
@mkdir -p $(BUILD_DIR)
@echo "Building release binaries..."
@echo " -> Linux (amd64)"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 $(CMD_PATH)
@echo " -> Linux (arm64)"
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 $(CMD_PATH)
@echo " -> macOS (amd64 - Intel)"
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 $(CMD_PATH)
@echo " -> macOS (arm64 - Apple Silicon)"
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 $(CMD_PATH)
@echo " -> Windows (amd64)"
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe $(CMD_PATH)
@echo " -> Windows (arm64)"
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-arm64.exe $(CMD_PATH)
@echo ""
@echo "Release binaries:"
@ls -lh $(BUILD_DIR)/
# Run tests
test:
CGO_ENABLED=0 go test ./...
# Run MDL integration tests (requires Docker and a Mendix project)
# Usage: make test-mdl MPR=path/to/app.mpr
MPR ?= app.mpr
test-mdl: build
$(BUILD_DIR)/$(BINARY_NAME) test mdl-examples/doctype-tests/microflow-spec.test.mdl -p $(MPR)
# Regenerate ANTLR parser from MDLLexer.g4 and MDLParser.g4
grammar:
$(MAKE) -C mdl/grammar generate
# Clean build artifacts
clean:
rm -rf $(BUILD_DIR)
go clean
# Build VS Code extension (.vsix) with build-time version info
vscode-ext:
@echo "Building VS Code extension..."
cd vscode-mdl && bun install && \
bunx esbuild src/extension.ts --bundle --outfile=dist/extension.js \
--external:vscode --format=cjs --platform=node \
--define:__BUILD_TIME__="'$(BUILD_TIME)'" \
--define:__GIT_COMMIT__="'$(VERSION)'" && \
bunx @vscode/vsce package --no-dependencies
@echo "Built vscode-mdl/$$(ls vscode-mdl/*.vsix)"
# Install VS Code extension
vscode-install: vscode-ext
code --install-extension vscode-mdl/vscode-mdl-*.vsix
@echo "Extension installed. Reload VS Code to activate."
# Generate documentation from ANTLR4 grammar
docs: documentation
documentation:
@echo "Generating MDL grammar documentation..."
@mkdir -p docs/06-mdl-reference
@CGO_ENABLED=0 go run ./cmd/grammardoc \
-grammar mdl/grammar/MDLParser.g4 \
-lexer mdl/grammar/MDLLexer.g4 \
-output docs/06-mdl-reference/grammar-reference.md \
-title "MDL Grammar Reference"
@echo "Documentation generated at docs/06-mdl-reference/grammar-reference.md"
# Generate CycloneDX SBOM (Go + TypeScript dependencies)
sbom:
@scripts/generate-sbom.sh
# Generate Markdown dependency report from SBOM
sbom-report: sbom
@scripts/generate-sbom-report.sh
# Generate source tree overview
source-tree: build
@$(BUILD_DIR)/source_tree --all > source_tree.txt
@echo "Generated source_tree.txt"