-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
103 lines (83 loc) · 3.02 KB
/
makefile
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
# Makefile
VENV_DIR = venv
PYTHON = python3
PIP = pip3
VENV_BIN = $(VENV_DIR)/bin
VENV_ACTIVATE = source $(VENV_BIN)/activate
VENV_CHECK = $(shell $(PYTHON) -m virtualenv --version > /dev/null 2>&1; echo $$?)
VERSION_PKG ?= 0.0.1-beta
all: check_venv create_venv install_requirements run_tool success
set_version_pkg:
@echo "Set version package: $(VERSION_PKG)"
@sed -i.bak "s/__version__ = [\"'].*[\"']/__version__ = '$(VERSION_PKG)'/" setup.py
@sed -i.bak "s/version=[\"'].*[\"']/version='$(VERSION_PKG)'/" setup.py
@rm -f setup.py.bak
build_pkg: set_version_pkg
@echo "Build package..."
@$(PYTHON) setup.py sdist bdist_wheel
@echo "Package built successfully!"
clean_pkg:
@echo "Clean package..."
@rm -rf build dist nakalator.egg-info
@echo "Package cleaned successfully!"
upload_pkg_test: build_pkg
@echo "Upload package to test pypi..."
@$(VENV_ACTIVATE) && python3 -m twine upload --repository testpypi dist/*
@echo "Package uploaded successfully!"
upload_pkg: build_pkg
@echo "Upload package to pypi..."
@$(VENV_ACTIVATE) && twine upload dist/*
@echo "Package uploaded successfully!"
check_venv:
@if [ $(VENV_CHECK) -eq 1 ]; then \
echo "virtualenv setup..."; \
$(PIP) install virtualenv; \
else \
echo "virtualenv is already installed..."; \
fi
create_venv:
@echo "Create new virtualenv..."
@$(PYTHON) -m virtualenv $(VENV_DIR)
install_requirements: create_venv
@echo "Packages setup..."
@$(VENV_ACTIVATE) && $(PIP) install -r requirements-dev.txt
run_tool:
@echo "Run tool with help command..."
@$(VENV_ACTIVATE) && $(PYTHON) nakalator.py --help
success:
@echo "Success! You can activate the virtual environment by running the following command:"
@echo "source $(VENV_BIN)/activate"
@echo "Then you can run the tool with the following command:"
@echo "$(PYTHON) nakalator.py"
build_go:
@echo "Initialize Go module if not already initialized..."
@if [ ! -f lib/bridge/go.mod ]; then \
cd lib/bridge && go mod init lib/bridge && \
echo "Fetching dependencies..." && \
go mod tidy; \
else \
echo "go.mod already exists. Skipping initialization."; \
cd lib/bridge && \
echo "Fetching dependencies..." && \
go mod tidy; \
fi && \
echo "Building Go binary..."
@if [ "$(shell uname)" = "Darwin" ]; then \
echo "Building for Darwin platform..." && \
cd lib/bridge && \
export CGO_ENABLED=1 && \
export GOOS=darwin && \
export GOARCH=arm64 && \
go build -o nakala_request.dylib -buildmode=c-shared && \
echo "Go binary built successfully!"; \
fi
@if [ "$(shell uname)" = "Linux" ]; then \
echo "Building for Linux platform..." && \
cd lib/bridge && \
export CGO_ENABLED=1 && \
export GOOS=linux && \
export GOARCH=amd64 && \
go build -o nakala_request.so -buildmode=c-shared && \
echo "Go binary built successfully!"; \
fi
.PHONY: all check_venv create_venv install_requirements run_tool success build_go set_version_pkg build_pkg clean_pkg upload_pkg_test upload_pkg