-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (64 loc) · 2.46 KB
/
Copy pathMakefile
File metadata and controls
79 lines (64 loc) · 2.46 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
NIM := $(shell which nim 2>/dev/null || echo $(HOME)/.nimble/bin/nim)
BIN = bin/nimcode
SRC = src/nimcode.nim
TESTS = $(wildcard tests/test_*.nim)
TEST_BINS = $(patsubst %.nim,%,$(TESTS))
NIMCACHE_DIR = .nimcache
BUILD_CACHE = $(NIMCACHE_DIR)/build
RELEASE_CACHE = $(NIMCACHE_DIR)/release
THREAD_OFF_CACHE = $(NIMCACHE_DIR)/threads-off
THREAD_TESTS = tests/test_cron.nim
.PHONY: all build release release-binary clean test-clean run test test-threads-off package-deb package-npm cross-compile help
all: build
build:
$(NIM) c -d:ssl --nimcache:$(BUILD_CACHE) -o:$(BIN) $(SRC)
release-binary:
$(NIM) c -d:ssl -d:release --nimcache:$(RELEASE_CACHE) -o:$(BIN) $(SRC)
clean: test-clean
rm -f $(BIN)
rm -f src/nimcode.out nimcode
rm -rf $(NIMCACHE_DIR)
test-clean:
rm -f $(TEST_BINS) tests/test_*.out
rm -rf tests/nimcache $(NIMCACHE_DIR)
run: build
./$(BIN)
test:
@for test_file in $(TESTS); do \
cache_dir="tests/nimcache/$$(basename $$test_file .nim)"; \
echo "Running $$test_file..."; \
$(NIM) c --nimcache:$$cache_dir -r -d:ssl $$test_file || exit 1; \
done
@echo "All tests passed!"
test-threads-off:
@for test_file in $(THREAD_TESTS); do \
cache_dir="tests/nimcache/$$(basename $$test_file .nim)-threads-off"; \
echo "Running $$test_file with --threads:off..."; \
$(NIM) c --nimcache:$$cache_dir -r -d:ssl --threads:off $$test_file || exit 1; \
done
@$(NIM) c --nimcache:$(THREAD_OFF_CACHE) -d:ssl --threads:off $(SRC)
@echo "Threads-off checks passed!"
package-deb:
@echo "Building Debian package..."
@./scripts/build-deb.sh
package-npm:
@echo "Building npm package..."
@./scripts/npm-publish.sh
cross-compile:
@echo "Building cross-platform binaries..."
@./scripts/build-cross-platform.sh
release:
@echo "Building full release artifacts..."
@./scripts/release-all.sh
help:
@echo "Targets:"
@echo " build - Debug build (default)"
@echo " release - Build full release artifacts (.deb, npm, cross-platform)"
@echo " cross-compile - Build binaries for all supported platforms"
@echo " package-deb - Build Debian package for host architecture"
@echo " package-npm - Build npm package (no publish)"
@echo " clean - Remove binary and test executables"
@echo " run - Build and run"
@echo " test-clean - Remove test executables and local Nim test cache"
@echo " test - Run all tests/test_*.nim tests"
@echo " test-threads-off - Run thread-sensitive tests and compile with --threads:off"