-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
110 lines (100 loc) · 3.52 KB
/
Makefile
File metadata and controls
110 lines (100 loc) · 3.52 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
# Variables
include .env
SRC_DIR := src
BUILD_DIR := build
TEST_DIR := tests
LINTER := luacheck
# Default target
.PHONY: all
all: env test-all build lint
# Build: Moves source files and removes and testing from submodules
.PHONY: build
build:
@echo "Building the project..."
@rm -rf $(BUILD_DIR)
@mkdir -p $(BUILD_DIR)
@cp -r $(SRC_DIR)/* $(BUILD_DIR)/
@cp $(BUILD_DIR)/lua-bus/src/* $(BUILD_DIR)
@rm -rf $(BUILD_DIR)/lua-bus
@cp -r $(BUILD_DIR)/lua-fibers/fibers $(BUILD_DIR)
@rm -rf $(BUILD_DIR)/lua-fibers
@cp $(BUILD_DIR)/lua-trie/src/* $(BUILD_DIR)
@rm -rf $(BUILD_DIR)/lua-trie
@rm -rf $(BUILD_DIR)/services/ui/local-ui
@echo "Build complete."
# Build-All: Builds the project and all submodules including ui
.PHONY: build-all
build-all:
@make build
@cd $(SRC_DIR)/services/ui/local-ui && make build
@mkdir -p $(BUILD_DIR)/www/ui
@cp -r $(SRC_DIR)/services/ui/local-ui/build/dist $(BUILD_DIR)/www/ui
@echo "Build complete."
# Test: Run the project's test suite
.PHONY: test
test:
@echo "Running project tests..."
@cd $(TEST_DIR) && luajit test.lua
@echo "Tests completed."
# Test-All: Run the project's and submodule's test suite
.PHONY: test-all
test-all:
@echo "Running all tests..."
# Devicecode tests
@cd $(TEST_DIR) && luajit test.lua
# Fiber tests
@cd $(SRC_DIR)/lua-fibers/tests && luajit test.lua
# Trie tests
@cd $(SRC_DIR)/lua-trie/tests && luajit test.lua
# Bus tests (require movement of fiber and trie then cleanup)
@cp -r $(SRC_DIR)/lua-fibers/fibers $(SRC_DIR)/lua-bus/src
@cp -r $(SRC_DIR)/lua-trie/src/* $(SRC_DIR)/lua-bus/src
@cd $(SRC_DIR)/lua-bus/tests && luajit test.lua
@rm -rf $(SRC_DIR)/lua-bus/src/fibers
@rm -rf $(SRC_DIR)/lua-bus/src/trie.lua
# UI tests
@cd $(SRC_DIR)/services/ui/local-ui && make unit-test
@echo "Tests completed."
# Env: Initialize environment and update git submodules
.PHONY: env
env:
@echo "Updating git submodules..."
@git submodule update --init --recursive
@cd $(SRC_DIR)/lua-fibers && git checkout main && git pull && git checkout $(FIBERS_VER)
@cd $(SRC_DIR)/lua-trie && git checkout main && git pull && git checkout $(TRIE_VER)
@cd $(SRC_DIR)/lua-bus && git checkout main && git pull && git checkout $(BUS_VER)
@echo "Git submodules updated."
# Includes ui
.PHONY: env-all
env-all:
@echo "Updating git submodules..."
@git submodule update --init --recursive
@cd $(SRC_DIR)/lua-fibers && git checkout main && git pull && git checkout $(FIBERS_VER)
@cd $(SRC_DIR)/lua-trie && git checkout main && git pull && git checkout $(TRIE_VER)
@cd $(SRC_DIR)/lua-bus && git checkout main && git pull && git checkout $(BUS_VER)
@cd $(SRC_DIR)/services/ui/local-ui && git checkout main && git fetch && git checkout $(UI_VER) \
&& cd client && npm install
@echo "Git submodules updated."
# Lint: Run the linter to check code quality
.PHONY: lint
lint:
@echo "Running linter..."
@$(LINTER) $(SRC_DIR) $(TEST_DIR)
@echo "Linting complete."
# Clean: Remove build artifacts
.PHONY: clean
clean:
@echo "Cleaning build artifacts..."
@rm -rf $(BUILD_DIR)
@echo "Clean complete."
# Help: Display available targets
help:
@echo "Available targets:"
@echo "all - Build, test, lint, and update submodules"
@echo "build - Build the project (removes testing code and documentation)"
@echo "test - Run project test suite"
@echo "test-all - Run project and submodules test suite"
@echo "env - Update and initialize git submodules"
@echo "lint - Run the code linter"
@echo "clean - Remove build artifacts"
@echo "help - Display this help message"