-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMakefile
More file actions
138 lines (113 loc) · 4.54 KB
/
Makefile
File metadata and controls
138 lines (113 loc) · 4.54 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
CARGO ?= cargo
PYTHON ?= python3
MANIFEST := robustone/Cargo.toml
CAPSTONE_REPO := https://github.com/capstone-engine/capstone.git
CAPSTONE_DIR := third_party/capstone
CAPSTONE_BUILD_SCRIPT := test/scripts/build_cstool.sh
PARITY_SCRIPT := test/run_tests.py
VENV_DIR := virt-py
VENV_PIP := $(VENV_DIR)/bin/pip
VENV_PYTHON := $(CURDIR)/$(VENV_DIR)/bin/python
VENV_BLACK := $(VENV_DIR)/bin/black
VENV_PYLINT := $(VENV_DIR)/bin/pylint
ifeq ($(firstword $(MAKECMDGOALS)),run)
RUN_EXTRA := $(filter-out --,$(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)))
ifneq ($(RUN_EXTRA),)
ifeq ($(origin RUN_ARGS),undefined)
RUN_ARGS := $(RUN_EXTRA)
endif
$(foreach target,$(RUN_EXTRA),$(eval $(target): ; @:))
endif
endif
RUN_ARGS ?=
.PHONY: format run build check check-clippy check-pylint check-fmt check-all ensure-capstone test test-parity test-validate test-list test-quick capstone-tests clean-help help virt-env pre-commit-install
virt-env:
$(PYTHON) -m venv virt-py
$(VENV_PIP) install -r requirements.txt
format: virt-env
$(CARGO) fmt --all
$(VENV_BLACK) test
build:
$(CARGO) build --manifest-path $(MANIFEST)
run:
$(CARGO) run --manifest-path $(MANIFEST) -- $(RUN_ARGS)
check: virt-env
$(CARGO) fmt --all -- --check
$(CARGO) clippy --workspace --all-features -- -D warnings
$(VENV_PYLINT) $$(find test/ -type f -name "*.py")
$(VENV_BLACK) --check test/
check-clippy: virt-env
$(CARGO) clippy --workspace --all-features -- -D warnings
check-pylint: virt-env
$(VENV_PYLINT) $$(find test/ -type f -name "*.py")
check-fmt: virt-env
$(CARGO) fmt --all -- --check
$(VENV_BLACK) --check test
check-all: check check-clippy check-pylint check-fmt
@echo "Running Rust workspace tests..."
$(CARGO) test --workspace --all-features
@echo "All checks passed!"
# Architectures with full decode support for CI parity testing
PARITY_TEST_ARCHES := riscv32 riscv64 capstone-riscv32-mc capstone-riscv64-mc capstone-loongarch-mc
PARITY_TEST_ARGS := $(foreach a,$(PARITY_TEST_ARCHES),--arch $(a)) --loose-match
ensure-capstone:
@mkdir -p $(dir $(CAPSTONE_DIR))
@if [ ! -d "$(CAPSTONE_DIR)" ]; then \
echo "Cloning Capstone into $(CAPSTONE_DIR)..."; \
git clone --depth 1 $(CAPSTONE_REPO) $(CAPSTONE_DIR); \
else \
echo "Capstone already present at $(CAPSTONE_DIR)."; \
fi
@bash $(CAPSTONE_BUILD_SCRIPT) $(CAPSTONE_DIR)
test: virt-env ensure-capstone
@echo "Running Python unit tests..."
@$(VENV_PYTHON) -m unittest discover -s test -p "test_*.py"
@echo "Running parity tests with new framework..."
@cd test && $(VENV_PYTHON) run_tests.py $(PARITY_TEST_ARGS)
@echo "Running Rust workspace tests..."
$(CARGO) test --workspace --all-features
test-parity: virt-env ensure-capstone
@echo "Running parity tests only..."
@cd test && $(VENV_PYTHON) run_tests.py $(PARITY_TEST_ARGS)
test-validate: virt-env
@echo "Validating test configurations..."
@cd test && $(VENV_PYTHON) scripts/validate_configs.py
test-list: virt-env
@echo "Available test architectures:"
@cd test && $(VENV_PYTHON) run_tests.py --list
test-quick: virt-env ensure-capstone
@echo "Running quick parity test (limited cases)..."
@cd test && $(VENV_PYTHON) run_tests.py $(PARITY_TEST_ARGS) --limit 20
capstone-tests: virt-env ensure-capstone
@echo "Running Capstone YAML parity tests..."
@cd test && $(VENV_PYTHON) run_tests.py $(PARITY_TEST_ARGS)
clean-help:
@echo "Available targets:"
@echo ""
@echo "Build & Check:"
@echo " build - Build the CLI crate in debug mode"
@echo " check - Run repository checks on workspace code and test harness scripts"
@echo " check-clippy - Run Rust clippy lints (with -D warnings)"
@echo " check-fmt - Check Rust and Python formatting"
@echo " check-all - Run the full repository check suite"
@echo " format - Format code with rustfmt"
@echo ""
@echo "Testing:"
@echo " test - Run full test suite (parity + workspace tests)"
@echo " test-parity - Run parity tests only"
@echo " test-validate - Validate test configurations"
@echo " test-list - List available test architectures"
@echo " test-quick - Run quick parity test (limited cases)"
@echo ""
@echo "Utility:"
@echo " run - Run the CLI with args (usage: make run -- <args>)"
@echo " help - Show this help message"
@echo " clean-help - Backward-compatible alias for help"
@echo " pre-commit-install - Install pre-commit hooks"
@echo ""
@echo "For more test options, see test/Makefile or run:"
@echo " cd test && make help"
pre-commit-install: virt-env
$(VENV_PIP) install pre-commit
$(VENV_DIR)/bin/pre-commit install --install-hooks
help: clean-help