Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
132 lines (113 loc) · 3.5 KB
/
Copy pathMakefile
File metadata and controls
132 lines (113 loc) · 3.5 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
.PHONY: all build build-en build-ar test clean install help lint
# Binary names
BINARY_EN=daad
BINARY_AR=ض
# Build directory
BUILD_DIR=bin
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
GOCLEAN=$(GOCMD) clean
GOMOD=$(GOCMD) mod
# Default target
all: test build
# Build both English and Arabic binaries
build: build-en build-ar
# Build English binary
build-en:
@echo "Building English binary: $(BINARY_EN)..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) -o $(BUILD_DIR)/$(BINARY_EN) .
@echo "✓ Built $(BUILD_DIR)/$(BINARY_EN)"
# Build Arabic binary
build-ar:
@echo "Building Arabic binary: $(BINARY_AR)..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) -o $(BUILD_DIR)/$(BINARY_AR) .
@echo "✓ Built $(BUILD_DIR)/$(BINARY_AR)"
# Run tests
test:
@echo "Running tests..."
$(GOTEST) -v ./...
@echo "✓ Tests passed"
# Run tests with coverage
test-coverage:
@echo "Running tests with coverage..."
$(GOTEST) -v -coverprofile=coverage.out ./...
$(GOCMD) tool cover -html=coverage.out -o coverage.html
@echo "✓ Coverage report generated: coverage.html"
# Run tests for specific package
test-lexer:
@echo "Running lexer tests..."
$(GOTEST) -v ./tests/lexer
@echo "✓ Lexer tests passed"
# Clean build artifacts
clean:
@echo "Cleaning..."
$(GOCLEAN)
rm -f $(BUILD_DIR)/$(BINARY_EN)
rm -f $(BUILD_DIR)/$(BINARY_AR)
rm -f coverage.out coverage.html
@echo "✓ Cleaned"
# Install dependencies
deps:
@echo "Installing dependencies..."
$(GOMOD) download
$(GOMOD) tidy
@echo "✓ Dependencies installed"
# Install binaries to system (requires sudo on Linux/Mac)
install: build
@echo "Installing binaries..."
install -m 755 $(BUILD_DIR)/$(BINARY_EN) /usr/local/bin/$(BINARY_EN)
install -m 755 $(BUILD_DIR)/$(BINARY_AR) /usr/local/bin/$(BINARY_AR)
@echo "✓ Installed to /usr/local/bin"
# Uninstall binaries from system
uninstall:
@echo "Uninstalling binaries..."
rm -f /usr/local/bin/$(BINARY_EN)
rm -f /usr/local/bin/$(BINARY_AR)
@echo "✓ Uninstalled"
# Format code
fmt:
@echo "Formatting code..."
$(GOCMD) fmt ./...
@echo "✓ Code formatted"
# Run linter (requires golangci-lint)
lint:
@echo "Running linter..."
golangci-lint run ./... --fix
@echo "✓ Linting complete"
# Run the English binary
run-en: build-en
$(BUILD_DIR)/$(BINARY_EN)
# Run the Arabic binary
run-ar: build-ar
$(BUILD_DIR)/$(BINARY_AR)
# Display help
help:
@echo "Daad (ض) - Arabic Programming Language"
@echo ""
@echo "Available targets:"
@echo " make - Run tests and build both binaries"
@echo " make build - Build both English and Arabic binaries"
@echo " make build-en - Build English binary (daad)"
@echo " make build-ar - Build Arabic binary (ض)"
@echo " make test - Run all tests"
@echo " make test-coverage - Run tests with coverage report"
@echo " make test-lexer - Run only lexer tests"
@echo " make clean - Remove build artifacts"
@echo " make deps - Install dependencies"
@echo " make install - Install binaries to /usr/local/bin"
@echo " make uninstall - Remove binaries from /usr/local/bin"
@echo " make fmt - Format code"
@echo " make lint - Run linter"
@echo " make run-en - Build and run English binary"
@echo " make run-ar - Build and run Arabic binary"
@echo " make help - Show this help message"
@echo ""
@echo "Examples:"
@echo " make build"
@echo " make test"
@echo " ./bin/daad tokenize tests/examples/basic_arithmetic.daad"
@echo " ./bin/ض رمز tests/examples/basic_arithmetic.daad"