forked from DamengDB/dmPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (53 loc) · 2.42 KB
/
Makefile
File metadata and controls
64 lines (53 loc) · 2.42 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
.PHONY: go-bridge wheel wheel-delocated universal2 clean test-install dpi-headers-secret release-preflight
# Go bridge library
GO_BRIDGE_DIR = dpi_bridge
DYLIB = $(GO_BRIDGE_DIR)/libdmdpi.dylib
# Detect architecture
ARCH := $(shell uname -m)
go-bridge: $(DYLIB)
$(DYLIB): $(wildcard $(GO_BRIDGE_DIR)/*.go) $(GO_BRIDGE_DIR)/go.mod
cd $(GO_BRIDGE_DIR) && go build -buildmode=c-shared -o libdmdpi.dylib .
install_name_tool -id @rpath/libdmdpi.dylib $(DYLIB)
# Build wheel (triggers Go build automatically via setup.py)
wheel:
python -m build --wheel
# Build + delocate for production wheel
wheel-delocated: wheel
mkdir -p dist_fixed
DYLD_LIBRARY_PATH=$(GO_BRIDGE_DIR) delocate-wheel -w dist_fixed dist/*.whl -v
# Build universal2 wheel (ARM64 + x86_64)
universal2:
# Build ARM64 Go bridge
cd $(GO_BRIDGE_DIR) && CGO_ENABLED=1 GOARCH=arm64 go build -buildmode=c-shared -o libdmdpi_arm64.dylib .
# Build x86_64 Go bridge
cd $(GO_BRIDGE_DIR) && CGO_ENABLED=1 GOARCH=amd64 go build -buildmode=c-shared -o libdmdpi_amd64.dylib .
# Create universal binary
lipo -create $(GO_BRIDGE_DIR)/libdmdpi_arm64.dylib $(GO_BRIDGE_DIR)/libdmdpi_amd64.dylib -output $(DYLIB)
install_name_tool -id @rpath/libdmdpi.dylib $(DYLIB)
# Build wheel with pre-built library
DMPYTHON_SKIP_GO_BUILD=1 python -m build --wheel
mkdir -p dist_fixed
DYLD_LIBRARY_PATH=$(GO_BRIDGE_DIR) delocate-wheel -w dist_fixed dist/*.whl -v
# Clean up arch-specific dylibs
rm -f $(GO_BRIDGE_DIR)/libdmdpi_arm64.dylib $(GO_BRIDGE_DIR)/libdmdpi_amd64.dylib
# Test install in a temporary venv
test-install:
@echo "Creating temporary venv..."
python -m venv /tmp/dmpython_test_venv
/tmp/dmpython_test_venv/bin/pip install dist_fixed/*.whl
/tmp/dmpython_test_venv/bin/python -c "import dmPython; print('dmPython version:', dmPython.version); print('OK')"
@echo "Test passed! Cleaning up..."
rm -rf /tmp/dmpython_test_venv
# Release preflight checks (optional: make release-preflight TAG=v2.5.31)
release-preflight:
./scripts/release_preflight.sh $(TAG)
# Package DPI headers as base64 for GitHub Secret
dpi-headers-secret:
@tar czf - -C dpi_include . | base64 | pbcopy
@echo "Base64 copied to clipboard. Paste as GitHub secret DPI_HEADERS_TAR_B64"
# Clean build artifacts
clean:
rm -rf build/ dist/ dist_fixed/ *.egg-info
rm -f $(GO_BRIDGE_DIR)/libdmdpi.dylib $(GO_BRIDGE_DIR)/libdmdpi.h
rm -f $(GO_BRIDGE_DIR)/libdmdpi_arm64.dylib $(GO_BRIDGE_DIR)/libdmdpi_amd64.dylib
rm -f dmPython*.so