-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
128 lines (105 loc) · 5.2 KB
/
Makefile
File metadata and controls
128 lines (105 loc) · 5.2 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
# Makefile for masktunnel project
.PHONY: help build clean test \
python-cffi-build python-cffi-clean \
python-clean python-install python-wheel python-test python-test-deps python-test-wrapper python-test-crash \
python-gopy-clean python-gopy-install python-gopy-wheel python-gopy-test python-gopy-test-deps python-gopy-test-wrapper python-gopy-test-crash
# Python binding targets
PYTHON_OUTPUT_DIR = _bindings/python
PYTHON_GOPY_OUTPUT_DIR = _bindings/python_gopy
PYBIN ?= python3
PIP ?= $(PYBIN) -m pip
# CFFI (Go c-shared) output
PYTHON_CFFI_DIR = $(PYTHON_OUTPUT_DIR)/masktunnel_ffi
PYTHON_CFFI_SHIM = $(PYTHON_OUTPUT_DIR)/masktunnel_go_ffi
PYTHON_CFFI_GO_PKG = ./$(PYTHON_CFFI_SHIM)
GOOS ?= $(shell go env GOOS)
ifeq ($(GOOS),darwin)
PYTHON_CFFI_LIB = $(PYTHON_CFFI_DIR)/libmasktunnel_ffi.dylib
else ifeq ($(GOOS),windows)
PYTHON_CFFI_LIB = $(PYTHON_CFFI_DIR)/masktunnel_ffi.dll
else
PYTHON_CFFI_LIB = $(PYTHON_CFFI_DIR)/libmasktunnel_ffi.so
endif
# Default target
help:
@echo "Available targets:"
@echo " build - Build Go binaries"
@echo " test - Run Go tests"
@echo " clean - Clean build artifacts"
@echo " python-cffi-build - Build Go C-ABI shared library for cffi"
@echo " python-cffi-clean - Clean Go C-ABI shared library artifacts"
@echo " python-install - Install Python package (default: cffi backend)"
@echo " python-wheel - Build Python wheel (default: cffi backend)"
@echo " python-test - Run Python tests (default: cffi backend; ignores gopy-only tests)"
@echo " python-gopy-install - Install gopy backend package (masktunnellib)"
@echo " python-gopy-test - Run gopy-backend Python tests (requires masktunnellib)"
# Go targets
build:
GOFLAGS="${GOFLAGS} -buildvcs=false" go build -o bin/masktunnel cmd/masktunnel/main.go
test:
go test -v -race -coverprofile="coverage.txt" -covermode=atomic ./tests
clean:
rm -rf bin
python-cffi-build:
@mkdir -p $(PYTHON_CFFI_DIR)
CGO_ENABLED=1 GOFLAGS="${GOFLAGS} -buildvcs=false" go build -buildmode=c-shared -o $(PYTHON_CFFI_LIB) $(PYTHON_CFFI_GO_PKG)
@rm -f $(PYTHON_OUTPUT_DIR)/masktunnellib/_masktunnellib*.so \
$(PYTHON_OUTPUT_DIR)/masktunnellib/_masktunnellib*.dylib \
$(PYTHON_OUTPUT_DIR)/masktunnellib/_masktunnellib*.dll \
$(PYTHON_OUTPUT_DIR)/masktunnellib/_masktunnellib*.pyd \
$(PYTHON_OUTPUT_DIR)/masktunnellib/_masktunnellib*.h 2>/dev/null || true
python-cffi-clean:
rm -f $(PYTHON_CFFI_DIR)/libmasktunnel_ffi.so $(PYTHON_CFFI_DIR)/libmasktunnel_ffi.dylib $(PYTHON_CFFI_DIR)/masktunnel_ffi.dll
rm -f $(PYTHON_CFFI_DIR)/libmasktunnel_ffi.h
python-clean: python-cffi-clean
rm -rf $(PYTHON_OUTPUT_DIR)/masktunnel.egg-info
rm -rf $(PYTHON_OUTPUT_DIR)/build
rm -rf $(PYTHON_OUTPUT_DIR)/dist
python-test-deps:
@echo "Installing Python dev dependencies..."
cd $(PYTHON_OUTPUT_DIR) && $(PYBIN) -m pip install -e .[dev]
python-test-wrapper: python-cffi-build
@echo "Running Python wrapper tests (cffi backend)..."
cd $(PYTHON_OUTPUT_DIR) && $(PYBIN) -m pytest tests/test_wrapper_unit.py -v --tb=short -n auto
python-test-crash: python-cffi-build
@echo "Running Python wrapper crash tests (cffi backend)..."
cd $(PYTHON_OUTPUT_DIR) && $(PYBIN) -m pytest tests/test_crash.py -v --tb=short -n auto
python-test: python-cffi-build
@echo "Running Python tests (cffi backend)..."
cd $(PYTHON_OUTPUT_DIR) && $(PYBIN) -m pytest tests -v --tb=short -n auto
python-install:
@echo "Installing Python package via pip (default: cffi backend)..."
cd $(PYTHON_OUTPUT_DIR) && $(PYBIN) -m pip install -e .
python-wheel:
@echo "Building Python wheel (default: cffi backend)..."
cd $(PYTHON_OUTPUT_DIR) && $(PYBIN) -m build --wheel
python-gopy-clean:
rm -f $(PYTHON_GOPY_OUTPUT_DIR)/masktunnellib/_masktunnellib*.so \
$(PYTHON_GOPY_OUTPUT_DIR)/masktunnellib/_masktunnellib*.dylib \
$(PYTHON_GOPY_OUTPUT_DIR)/masktunnellib/_masktunnellib*.dll \
$(PYTHON_GOPY_OUTPUT_DIR)/masktunnellib/_masktunnellib*.pyd \
$(PYTHON_GOPY_OUTPUT_DIR)/masktunnellib/*.h \
$(PYTHON_GOPY_OUTPUT_DIR)/masktunnellib/*.c \
$(PYTHON_GOPY_OUTPUT_DIR)/masktunnellib/go.py \
$(PYTHON_GOPY_OUTPUT_DIR)/masktunnellib/masktunnel.py 2>/dev/null || true
rm -rf $(PYTHON_GOPY_OUTPUT_DIR)/masktunnel.egg-info
rm -rf $(PYTHON_GOPY_OUTPUT_DIR)/build
rm -rf $(PYTHON_GOPY_OUTPUT_DIR)/dist
python-gopy-test-deps:
@echo "Installing Python dev dependencies + masktunnellib (gopy backend)..."
cd $(PYTHON_GOPY_OUTPUT_DIR) && $(PYBIN) -m pip install -e .[dev]
python-gopy-test-wrapper:
@echo "Running Python wrapper tests (gopy backend)..."
cd $(PYTHON_GOPY_OUTPUT_DIR) && $(PYBIN) -m pytest tests/test_wrapper_unit.py -v --tb=short -n auto
python-gopy-test-crash:
@echo "Running Python wrapper crash tests (gopy backend)..."
cd $(PYTHON_GOPY_OUTPUT_DIR) && $(PYBIN) -m pytest tests/test_crash.py -v --tb=short -n auto
python-gopy-test:
@echo "Running Python tests (gopy backend; requires masktunnellib)..."
cd $(PYTHON_GOPY_OUTPUT_DIR) && $(PYBIN) -m pytest tests -v --tb=short -n auto
python-gopy-install:
@echo "Installing gopy backend package via pip (masktunnellib)..."
cd $(PYTHON_GOPY_OUTPUT_DIR) && $(PYBIN) -m pip install -e .
python-gopy-wheel:
@echo "Building Python wheel (gopy backend)..."
cd $(PYTHON_GOPY_OUTPUT_DIR) && $(PYBIN) -m build --wheel