Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
163 lines (136 loc) · 5.3 KB
/
Copy pathMakefile
File metadata and controls
163 lines (136 loc) · 5.3 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# ==================================================================================== #
# DEVELOPMENT
# ==================================================================================== #
## run: run html2md
.PHONY: run/html2md
run/html2md:
go run ./cmd/html2md
## run: run encode
.PHONY: run/encode
run/encode:
go run ./cmd/decode-encode -encode
## run: run decode
.PHONY: run/decode
run/decode:
go run ./cmd/decode-encode -decode
## run: run pdf-ocr
.PHONY: run/pdf-ocr
run/pdf-ocr:
go run ./cmd/pdf-ocr
## run: run html2text
.PHONY: run/html2text
run/html2text:
go run ./cmd/html2text
## run: run utc2local
.PHONY: run/utc2local
run/utc2local:
go run ./cmd/utc2local -utc="2025-07-09T00:00:00Z"
## run: run http-middleware
.PHONY: run/http-middleware
run/http-middleware:
go run ./cmd/examples/http-middleware
## run: run spinner
.PHONY: run/spinner
run/spinner:
go run ./cmd/spinner
## run/rmbg: run rmbg on a sample image
# Directories searched before the inherited LD_LIBRARY_PATH. Override these to
# point at the CUDA toolkit and a single cuDNN 9 install (keep the whole cuDNN
# set from one release together, or ONNX Runtime aborts with a sublibrary
# version mismatch).
CUDA_LIB_DIRS ?= /usr/local/cuda/lib64
CUDNN_LIB_DIRS ?= /opt/cudnn/current/lib
.PHONY: run/rmbg
run/rmbg:
LD_LIBRARY_PATH=$(CUDNN_LIB_DIRS):$(CUDA_LIB_DIRS):$$LD_LIBRARY_PATH \
ONNXRUNTIME_LIB=$(CURDIR)/lib/libonnxruntime.so \
go run ./cmd/rmbg -i input/sample.png -o output/sample.png -v
# ==================================================================================== #
# BUILD DEBUG
# ==================================================================================== #
## build/debug/html2md: build the api with debugging flags enabled
.PHONY: build/debug/html2md
build/debug/html2md:
@echo 'Building cmd/html2md...'
go build -gcflags=all="-N -l" -o=./bin/html2md-debug ./cmd/html2md
## build/debug/decode-encode: build the api with debugging flags enabled
.PHONY: build/debug/decode-encode
build/debug/decode-encode:
@echo 'Building cmd/decode-encode...'
go build -gcflags=all="-N -l" -o=./bin/decode-encode-debug ./cmd/decode-encode
## build/debug/pdf-ocr: build the api with debugging flags enabled
.PHONY: build/debug/pdf-ocr
build/debug/pdf-ocr:
@echo 'Building cmd/pdf-ocr...'
go build -gcflags=all="-N -l" -o=./bin/pdf-ocr-debug ./cmd/pdf-ocr
## build/debug/html2text: build the api with debugging flags enabled
.PHONY: build/debug/html2text
build/debug/html2text:
@echo 'Building cmd/html2text...'
go build -gcflags=all="-N -l" -o=./bin/html2text-debug ./cmd/html2text
## build/debug/utc2local: build the api with debugging flags enabled
.PHONY: build/debug/utc2local
build/debug/utc2local:
@echo 'Building cmd/utc2local...'
go build -gcflags=all="-N -l" -o=./bin/utc2local-debug ./cmd/utc2local
## build/debug/rmbg: build the cmd/rmbg application with debugging flags enabled
.PHONY: build/debug/rmbg
build/debug/rmbg:
@echo 'Building cmd/rmbg...'
CGO_ENABLED=1 go build -gcflags=all="-N -l" -o=./bin/rmbg-debug ./cmd/rmbg
# ==================================================================================== #
# BUILD
# ==================================================================================== #
## build/utc2local: build the cmd/utc2local application
.PHONY: build/utc2local
build/utc2local:
@echo 'Building cmd/utc2local...'
go build -ldflags="-s -w" -gcflags=all=-l -o=./bin/utc2local ./cmd/utc2local
GOOS=linux go build -ldflags="-s -w" -gcflags=all=-l -o=./bin/linux/utc2local ./cmd/utc2local
# ONNX Runtime version. Must match the C API version the pinned
# onnxruntime_go release supports (it is built against ORT 1.29 headers, and
# ORT keeps the older C API available in newer releases).
ORT_VERSION ?= 1.31.0
# GPU build flavour: cuda13 (CUDA 13.x + cuDNN 9) or cuda12 (CUDA 12.8 + cuDNN 9).
ORT_CUDA ?= cuda13
## build/rmbg: build the cmd/rmbg application (requires ./lib/libonnxruntime.so at runtime)
.PHONY: build/rmbg
build/rmbg:
@echo 'Building cmd/rmbg...'
CGO_ENABLED=1 go build -ldflags="-s -w" -o=./bin/rmbg ./cmd/rmbg
## ort/cpu: download the ONNX Runtime CPU build into ./lib
.PHONY: ort/cpu
ort/cpu:
@mkdir -p lib
curl -fsSL https://github.com/microsoft/onnxruntime/releases/download/v$(ORT_VERSION)/onnxruntime-linux-x64-$(ORT_VERSION).tgz | tar -xz -C lib --strip-components=2
## ort/gpu: download the ONNX Runtime GPU build (ORT_CUDA=cuda13|cuda12) into ./lib
.PHONY: ort/gpu
ort/gpu:
@mkdir -p lib
curl -fsSL https://github.com/microsoft/onnxruntime/releases/download/v$(ORT_VERSION)/onnxruntime-linux-x64-gpu_$(ORT_CUDA)-$(ORT_VERSION).tgz | tar -xz -C lib --strip-components=2
# ==================================================================================== #
# QUALITY CONTROL
# ==================================================================================== #
## audit: tidy dependencies and format, vet and test all code
.PHONY: audit
audit: tidy
@echo 'Formatting code...'
go fmt ./...
@echo 'Vetting code...'
go vet ./...
staticcheck ./...
@echo 'Running tests...'
go test -race -vet=off ./...
## vendor: tidy and vendor dependencies
.PHONY: vendor
vendor:
@echo 'Tidying and verifying module dependencies...'
go mod tidy
go mod verify
@echo 'Vendoring dependencies...'
go mod vendor
.PHONY: tidy
tidy:
@echo 'Tidying and verifying module dependencies...'
go mod tidy
go mod verify