-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
153 lines (105 loc) · 8.44 KB
/
Makefile
File metadata and controls
153 lines (105 loc) · 8.44 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
# LexScript Compiler — Makefile
# Requires: Go 1.24+
BINARY := lexs
BUILD_DIR := bin
# ── OS detection ─────────────────────────────────────────────────────────────
ifeq ($(OS),Windows_NT)
EXE := .exe
MKDIR := if not exist $(BUILD_DIR) mkdir $(BUILD_DIR)
else
EXE :=
MKDIR := mkdir -p $(BUILD_DIR)
endif
.PHONY: all build run test clean deps fmt vet lint help \
compile-rental compile-software parse-rental validate-rental \
compile-rental-pdf compile-software-pdf \
fmt-rental fmt-software visualize-rental visualize-software \
compile-employment compile-employment-pdf \
compile-employment-de compile-employment-ca compile-employment-uk \
validate-employment \
lsp playground extension-install extension-build \
install-extension setup
## ── Default ─────────────────────────────────────────────────────────────────
all: deps build
## ── Build ───────────────────────────────────────────────────────────────────
build: deps ## Build the lexs binary into bin/
@$(MKDIR)
go build -o $(BUILD_DIR)/$(BINARY)$(EXE) .
@echo "built: $(BUILD_DIR)/$(BINARY)$(EXE)"
## ── Dependencies ────────────────────────────────────────────────────────────
deps: ## Download and tidy Go modules
go mod tidy
## ── Run examples ────────────────────────────────────────────────────────────
compile-rental: build ## Compile examples/rental.lxs → examples/rental.md
./$(BUILD_DIR)/$(BINARY)$(EXE) compile examples/rental.lxs -o examples/rental.md
compile-software: build ## Compile examples/software_dev.lxs
./$(BUILD_DIR)/$(BINARY)$(EXE) compile examples/software_dev.lxs -o examples/software_dev.md
parse-rental: build ## Dump AST JSON for rental.lxs (debug)
./$(BUILD_DIR)/$(BINARY)$(EXE) parse examples/rental.lxs
validate-rental: build ## Run semantic checks on rental.lxs (debug)
./$(BUILD_DIR)/$(BINARY)$(EXE) validate examples/rental.lxs
## ── Phase 2 commands ─────────────────────────────────────────────────────────
compile-rental-pdf: build ## Compile examples/rental.lxs → examples/rental.pdf (Phase 2)
./$(BUILD_DIR)/$(BINARY)$(EXE) compile examples/rental.lxs -f pdf -o examples/rental.pdf
compile-software-pdf: build ## Compile examples/software_dev.lxs → PDF (Phase 2)
./$(BUILD_DIR)/$(BINARY)$(EXE) compile examples/software_dev.lxs -f pdf -o examples/software_dev.pdf
fmt-rental: build ## Format examples/rental.lxs in-place (lexs fmt, Phase 2)
./$(BUILD_DIR)/$(BINARY)$(EXE) fmt --write examples/rental.lxs
fmt-software: build ## Format examples/software_dev.lxs in-place (Phase 2)
./$(BUILD_DIR)/$(BINARY)$(EXE) fmt --write examples/software_dev.lxs
visualize-rental: build ## Export rental.lxs FSM → examples/rental.dot (Phase 2)
./$(BUILD_DIR)/$(BINARY)$(EXE) visualize examples/rental.lxs -o examples/rental.dot
visualize-software: build ## Export software_dev.lxs FSM → .dot (Phase 2)
./$(BUILD_DIR)/$(BINARY)$(EXE) visualize examples/software_dev.lxs -o examples/software_dev.dot
## ── Phase 3 commands ─────────────────────────────────────────────────────────
compile-employment: build ## Compile examples/employment.lxs → MD (Phase 3)
./$(BUILD_DIR)/$(BINARY)$(EXE) compile examples/employment.lxs -o examples/employment.md
compile-employment-pdf: build ## Compile examples/employment.lxs → PDF (Phase 3)
./$(BUILD_DIR)/$(BINARY)$(EXE) compile examples/employment.lxs -f pdf -o examples/employment.pdf
compile-employment-de: build ## employment.lxs → MD with Delaware jurisdiction (Phase 3)
./$(BUILD_DIR)/$(BINARY)$(EXE) compile examples/employment.lxs -j delaware -o examples/employment_delaware.md
compile-employment-ca: build ## employment.lxs → MD with California jurisdiction (Phase 3)
./$(BUILD_DIR)/$(BINARY)$(EXE) compile examples/employment.lxs -j california -o examples/employment_california.md
compile-employment-uk: build ## employment.lxs → MD with UK jurisdiction (Phase 3)
./$(BUILD_DIR)/$(BINARY)$(EXE) compile examples/employment.lxs -j uk -o examples/employment_uk.md
validate-employment: build ## Validate examples/employment.lxs (Phase 3)
./$(BUILD_DIR)/$(BINARY)$(EXE) validate examples/employment.lxs
## ── Phase 4 commands ─────────────────────────────────────────────────────────
lsp: build ## Start the LSP server over stdin/stdout (Phase 4)
./$(BUILD_DIR)/$(BINARY)$(EXE) lsp
playground: build ## Start web playground on http://localhost:8080 (Phase 4)
./$(BUILD_DIR)/$(BINARY)$(EXE) serve
playground-port: build ## Start playground on custom port, e.g. make playground-port PORT=3000
./$(BUILD_DIR)/$(BINARY)$(EXE) serve -a :$(PORT)
extension-install: ## Install VS Code extension npm deps (Phase 4)
cd vscode-extension && npm install
extension-build: extension-install ## Build VS Code extension (Phase 4)
cd vscode-extension && npm run compile
install-extension: extension-build ## Rebuild .vsix from source + install (requires npm)
cd vscode-extension && npx vsce package --allow-missing-repository
code --install-extension vscode-extension/lexscript-0.4.0.vsix
setup: build ## First-time setup: build binary + install pre-built extension
code --install-extension vscode-extension/lexscript-0.4.0.vsix
@echo "Done! Reload VS Code: Ctrl+Shift+P -> Developer: Reload Window"
## ── Testing ─────────────────────────────────────────────────────────────────
test: ## Run all unit tests
go test ./... -v
test-race: ## Run tests with race detector
go test -race ./... -v
bench: ## Run benchmark tests
go test ./... -bench=. -benchmem
## ── Code quality ─────────────────────────────────────────────────────────────
fmt: ## Format all Go source files
go fmt ./...
vet: ## Run go vet
go vet ./...
lint: fmt vet ## Format, vet (add golangci-lint for full linting)
@echo "lint complete"
## ── Cleanup ─────────────────────────────────────────────────────────────────
clean: ## Remove built binary and generated outputs
rm -rf $(BUILD_DIR)
rm -f examples/*.md examples/*.pdf examples/*.dot
## ── Help ────────────────────────────────────────────────────────────────────
help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-22s\033[0m %s\n", $$1, $$2}'