Debian Codegraph @

Makefile

raw symbols SCIP
1
2 gofumpt := mvdan.cc/[email protected]
3 gosimports := github.com/rinchsan/gosimports/cmd/[email protected]
4 golangci_lint := github.com/golangci/golangci-lint/cmd/[email protected]
5 asmfmt := github.com/klauspost/asmfmt/cmd/[email protected]
6 # sync this with netlify.toml!
7 hugo := github.com/gohugoio/[email protected]
8
9 # Make 3.81 doesn't support '**' globbing: Set explicitly instead of recursion.
10 all_sources := $(wildcard *.go */*.go */*/*.go */*/*/*.go */*/*/*.go */*/*/*/*.go)
11 all_testdata := $(wildcard testdata/* */testdata/* */*/testdata/* */*/testdata/*/* */*/*/testdata/*)
12 all_testing := $(wildcard internal/testing/* internal/testing/*/* internal/testing/*/*/*)
13 all_examples := $(wildcard examples/* examples/*/* examples/*/*/* */*/example/* */*/example/*/* */*/example/*/*/*)
14 all_it := $(wildcard internal/integration_test/* internal/integration_test/*/* internal/integration_test/*/*/*)
15 # main_sources exclude any test or example related code
16 main_sources := $(wildcard $(filter-out %_test.go $(all_testdata) $(all_testing) $(all_examples) $(all_it), $(all_sources)))
17 # main_packages collect the unique main source directories (sort will dedupe).
18 # Paths need to all start with ./, so we do that manually vs foreach which strips it.
19 main_packages := $(sort $(foreach f,$(dir $(main_sources)),$(if $(findstring ./,$(f)),./,./$(f))))
20
21 go_test_options ?= -timeout 300s
22
23 .PHONY: test.examples
24 test.examples:
25 @go test $(go_test_options) ./examples/... ./imports/assemblyscript/example/... ./imports/emscripten/... ./imports/wasi_snapshot_preview1/example/...
26
27 .PHONY: build.examples.as
28 build.examples.as:
29 @cd ./imports/assemblyscript/example/testdata && npm install && npm run build
30
31 %.wasm: %.zig
32 @(cd $(@D); zig build -Doptimize=ReleaseSmall)
33 @mv $(@D)/zig-out/*/$(@F) $(@D)
34
35 .PHONY: build.examples.zig
36 build.examples.zig: examples/allocation/zig/testdata/greet.wasm imports/wasi_snapshot_preview1/example/testdata/zig/cat.wasm imports/wasi_snapshot_preview1/testdata/zig/wasi.wasm
37 @cd internal/testing/dwarftestdata/testdata/zig; zig build; mv zig-out/*/main.wasm ./ # Need DWARF custom sections.
38
39 tinygo_reactor_sources_reactor := examples/basic/testdata/add.go examples/allocation/tinygo/testdata/greet.go
40 .PHONY: build.examples.tinygo_reactor
41 build.examples.tinygo_reactor: $(tinygo_sources_reactor)
42 @for f in $^; do \
43 tinygo build -o $$(echo $$f | sed -e 's/\.go/\.wasm/') -scheduler=none --no-debug --target=wasip1 -buildmode=c-shared $$f; \
44 done
45
46 tinygo_sources_clis := examples/cli/testdata/cli.go imports/wasi_snapshot_preview1/example/testdata/tinygo/cat.go imports/wasi_snapshot_preview1/testdata/tinygo/wasi.go cmd/wazero/testdata/cat/cat.go
47 .PHONY: build.examples.tinygo_clis
48 build.examples.tinygo_clis: $(tinygo_sources_clis)
49 @for f in $^; do \
50 tinygo build -o $$(echo $$f | sed -e 's/\.go/\.wasm/') -scheduler=none --no-debug --target=wasip1 $$f; \
51 done
52 @mv cmd/wazero/testdata/cat/cat.wasm cmd/wazero/testdata/cat/cat-tinygo.wasm
53
54 .PHONY: build.examples.tinygo
55 build.examples.tinygo: build.examples.tinygo_reactor build.examples.tinygo_clis
56
57 # We use zig to build C as it is easy to install and embeds a copy of zig-cc.
58 # Note: Don't use "-Oz" as that breaks our wasi sock example.
59 c_sources := imports/wasi_snapshot_preview1/example/testdata/zig-cc/cat.c imports/wasi_snapshot_preview1/testdata/zig-cc/wasi.c internal/testing/dwarftestdata/testdata/zig-cc/main.c
60 .PHONY: build.examples.zig-cc
61 build.examples.zig-cc: $(c_sources)
62 @for f in $^; do \
63 zig cc --target=wasm32-wasi -o $$(echo $$f | sed -e 's/\.c/\.wasm/') $$f; \
64 done
65
66 # Here are the emcc args we use:
67 #
68 # * `-Oz` - most optimization for code size.
69 # * `--profiling` - adds the name section.
70 # * `-s STANDALONE_WASM` - ensures wasm is built for a non-js runtime.
71 # * `-s EXPORTED_FUNCTIONS=_malloc,_free` - export allocation functions so that
72 # they can be used externally as "malloc" and "free".
73 # * `-s WARN_ON_UNDEFINED_SYMBOLS=0` - imports not defined in JavaScript error
74 # otherwise. See https://github.com/emscripten-core/emscripten/issues/13641
75 # * `-s TOTAL_STACK=8KB -s TOTAL_MEMORY=64KB` - reduce memory default from 16MB
76 # to one page (64KB). To do this, we have to reduce the stack size.
77 # * `-s ALLOW_MEMORY_GROWTH` - allows "memory.grow" instructions to succeed, but
78 # requires a function import "emscripten_notify_memory_growth".
79 emscripten_sources := $(wildcard imports/emscripten/testdata/*.cc)
80 .PHONY: build.examples.emscripten
81 build.examples.emscripten: $(emscripten_sources)
82 @for f in $^; do \
83 em++ -Oz --profiling \
84 -s STANDALONE_WASM \
85 -s EXPORTED_FUNCTIONS=_malloc,_free \
86 -s WARN_ON_UNDEFINED_SYMBOLS=0 \
87 -s TOTAL_STACK=8KB -s TOTAL_MEMORY=64KB \
88 -s ALLOW_MEMORY_GROWTH \
89 --std=c++17 -o $$(echo $$f | sed -e 's/\.cc/\.wasm/') $$f; \
90 done
91
92 %/greet.wasm : cargo_target := wasm32-unknown-unknown
93 %/cat.wasm : cargo_target := wasm32-wasip1
94 %/wasi.wasm : cargo_target := wasm32-wasip1
95
96 .PHONY: build.examples.rust
97 build.examples.rust: examples/allocation/rust/testdata/greet.wasm imports/wasi_snapshot_preview1/example/testdata/cargo-wasi/cat.wasm imports/wasi_snapshot_preview1/testdata/cargo-wasi/wasi.wasm internal/testing/dwarftestdata/testdata/rust/main.wasm.xz
98
99 # Normally, we build release because it is smaller. Testing dwarf requires the debug build.
100 internal/testing/dwarftestdata/testdata/rust/main.wasm.xz:
101 cd $(@D) && cargo build --target wasm32-wasip1
102 mv $(@D)/target/wasm32-wasip1/debug/main.wasm $(@D)
103 cd $(@D) && xz -k -f ./main.wasm # Rust's DWARF section is huge, so compress it.
104
105 # Builds rust using cargo normally
106 %.wasm: %.rs
107 @(cd $(@D); cargo build --target $(cargo_target) --release)
108 @mv $(@D)/target/$(cargo_target)/release/$(@F) $(@D)
109
110 spectest_base_dir := internal/integration_test/spectest
111
112 spectest_v1_dir := $(spectest_base_dir)/v1
113 spectest_v1_testdata_dir := $(spectest_v1_dir)/testdata
114 spec_version_v1 := wg-1.0
115
116 spectest_v2_dir := $(spectest_base_dir)/v2
117 spectest_v2_testdata_dir := $(spectest_v2_dir)/testdata
118 spec_version_v2 := wg-2.0
119
120 spectest_threads_dir := $(spectest_base_dir)/threads
121 spectest_threads_testdata_dir := $(spectest_threads_dir)/testdata
122 spec_version_threads := ff17701446d8e2086142423ef77ae947a025e26f
123
124 spectest_tail_call_dir := $(spectest_base_dir)/tail-call
125 spectest_tail_call_testdata_dir := $(spectest_tail_call_dir)/testdata
126 spec_version_tail_call := 88e97b0f742f4c3ee01fea683da130f344dd7b02
127
128 spectest_extended_const_dir := $(spectest_base_dir)/extended-const
129 spectest_extended_const_testdata_dir := $(spectest_extended_const_dir)/testdata
130
131 spectest_exception_handling_dir := $(spectest_base_dir)/exception-handling
132 spectest_exception_handling_testdata_dir := $(spectest_exception_handling_dir)/testdata
133 spec_version_exception_handling := 13734f8fb871a5dab939070f893adbd90bffe28c
134
135 spectest_typed_function_references_dir := $(spectest_base_dir)/typed-function-references
136 spectest_typed_function_references_testdata_dir := $(spectest_typed_function_references_dir)/testdata
137 spec_version_typed_function_references := 74d2ec81d15efd3c0f2fba46a023f376101d8e46
138 typed_function_references_wast_files := \
139 br_on_non_null.wast br_on_null.wast br_table.wast call_ref.wast elem.wast \
140 func.wast linking.wast local_init.wast ref.wast ref_as_non_null.wast \
141 ref_func.wast ref_is_null.wast ref_null.wast return_call_indirect.wast \
142 return_call_ref.wast return_call.wast select.wast table-sub.wast table.wast \
143 type-equivalence.wast unreached-invalid.wast unreached-valid.wast
144
145 .PHONY: build.spectest
146 build.spectest:
147 @$(MAKE) build.spectest.v1
148 @$(MAKE) build.spectest.v2
149 @$(MAKE) build.spectest.threads
150 @$(MAKE) build.spectest.tail_call
151 @$(MAKE) build.spectest.extended_const
152 @$(MAKE) build.spectest.exception_handling
153 @$(MAKE) build.spectest.typed_function_references
154
155 .PHONY: build.spectest.v1
156 build.spectest.v1: # Note: wabt by default uses >1.0 features, so wast2json flags might drift as they include more. See WebAssembly/wabt#1878
157 @rm -rf $(spectest_v1_testdata_dir)
158 @mkdir -p $(spectest_v1_testdata_dir)
159 @cd $(spectest_v1_testdata_dir) \
160 && curl -sSL 'https://api.github.com/repos/WebAssembly/spec/contents/test/core?ref=$(spec_version_v1)' | jq -r '.[]| .download_url' | grep -E ".wast" | xargs -Iurl curl -sJL url -O
161 @cd $(spectest_v1_testdata_dir) && for f in `find . -name '*.wast'`; do \
162 perl -pi -e 's/\(assert_return_canonical_nan\s(\(invoke\s"f32.demote_f64"\s\((f[0-9]{2})\.const\s[a-z0-9.+:-]+\)\))\)/\(assert_return $$1 \(f32.const nan:canonical\)\)/g' $$f; \
163 perl -pi -e 's/\(assert_return_arithmetic_nan\s(\(invoke\s"f32.demote_f64"\s\((f[0-9]{2})\.const\s[a-z0-9.+:-]+\)\))\)/\(assert_return $$1 \(f32.const nan:arithmetic\)\)/g' $$f; \
164 perl -pi -e 's/\(assert_return_canonical_nan\s(\(invoke\s"f64\.promote_f32"\s\((f[0-9]{2})\.const\s[a-z0-9.+:-]+\)\))\)/\(assert_return $$1 \(f64.const nan:canonical\)\)/g' $$f; \
165 perl -pi -e 's/\(assert_return_arithmetic_nan\s(\(invoke\s"f64\.promote_f32"\s\((f[0-9]{2})\.const\s[a-z0-9.+:-]+\)\))\)/\(assert_return $$1 \(f64.const nan:arithmetic\)\)/g' $$f; \
166 perl -pi -e 's/\(assert_return_canonical_nan\s(\(invoke\s"[a-z._0-9]+"\s\((f[0-9]{2})\.const\s[a-z0-9.+:-]+\)\))\)/\(assert_return $$1 \($$2.const nan:canonical\)\)/g' $$f; \
167 perl -pi -e 's/\(assert_return_arithmetic_nan\s(\(invoke\s"[a-z._0-9]+"\s\((f[0-9]{2})\.const\s[a-z0-9.+:-]+\)\))\)/\(assert_return $$1 \($$2.const nan:arithmetic\)\)/g' $$f; \
168 perl -pi -e 's/\(assert_return_canonical_nan\s(\(invoke\s"[a-z._0-9]+"\s\((f[0-9]{2})\.const\s[a-z0-9.+:-]+\)\s\([a-z0-9.\s+-:]+\)\))\)/\(assert_return $$1 \($$2.const nan:canonical\)\)/g' $$f; \
169 perl -pi -e 's/\(assert_return_arithmetic_nan\s(\(invoke\s"[a-z._0-9]+"\s\((f[0-9]{2})\.const\s[a-z0-9.+:-]+\)\s\([a-z0-9.\s+-:]+\)\))\)/\(assert_return $$1 \($$2.const nan:arithmetic\)\)/g' $$f; \
170 perl -pi -e 's/\(assert_return_canonical_nan\s(\(invoke\s"[a-z._0-9]+"\s\((f[0-9]{2})\.const\s[a-z0-9.+:-]+\)\))\)/\(assert_return $$1 \($$2.const nan:canonical\)\)/g' $$f; \
171 perl -pi -e 's/\(assert_return_arithmetic_nan\s(\(invoke\s"[a-z._0-9]+"\s\((f[0-9]{2})\.const\s[a-z0-9.+:-]+\)\))\)/\(assert_return $$1 \($$2.const nan:arithmetic\)\)/g' $$f; \
172 wast2json \
173 --disable-saturating-float-to-int \
174 --disable-sign-extension \
175 --disable-simd \
176 --disable-multi-value \
177 --disable-bulk-memory \
178 --disable-reference-types \
179 --debug-names $$f; \
180 done
181
182 .PHONY: build.spectest.v2
183 build.spectest.v2: # Note: SIMD cases are placed in the "simd" subdirectory.
184 @rm -rf $(spectest_v2_testdata_dir)
185 @mkdir -p $(spectest_v2_testdata_dir)
186 @cd $(spectest_v2_testdata_dir) \
187 && curl -sSL 'https://api.github.com/repos/WebAssembly/spec/contents/test/core?ref=$(spec_version_v2)' | jq -r '.[]| .download_url' | grep -E ".wast" | xargs -Iurl curl -sJL url -O
188 @cd $(spectest_v2_testdata_dir) \
189 && curl -sSL 'https://api.github.com/repos/WebAssembly/spec/contents/test/core/simd?ref=$(spec_version_v2)' | jq -r '.[]| .download_url' | grep -E ".wast" | xargs -Iurl curl -sJL url -O
190 @cd $(spectest_v2_testdata_dir) && for f in `find . -name '*.wast'`; do \
191 wast2json --debug-names --no-check $$f || true; \
192 done # Ignore the error here as some tests (e.g. comments.wast right now) are not supported by wast2json yet.
193
194 # Note: We currently cannot build the "threads" subdirectory that spawns threads due to missing support in wast2json.
195 # https://github.com/WebAssembly/wabt/issues/2348#issuecomment-1878003959
196 .PHONY: build.spectest.threads
197 build.spectest.threads:
198 @rm -rf $(spectest_threads_testdata_dir)
199 @mkdir -p $(spectest_threads_testdata_dir)
200 @cd $(spectest_threads_testdata_dir) \
201 && curl -sSL 'https://api.github.com/repos/WebAssembly/threads/contents/test/core/threads?ref=$(spec_version_threads)' | jq -r '.[]| .download_url' | grep -E "/atomic.wast" | xargs -Iurl curl -sJL url -O
202 @cd $(spectest_threads_testdata_dir) && for f in `find . -name '*.wast'`; do \
203 wast2json --enable-threads --debug-names $$f; \
204 done
205
206 .PHONY: build.spectest.extended_const
207 build.spectest.extended_const:
208 @cd $(spectest_extended_const_testdata_dir) && for f in `find . -name '*.wast'`; do \
209 wast2json --enable-extended-const --debug-names $$f; \
210 done
211
212 .PHONY: build.spectest.tail_call
213 build.spectest.tail_call:
214 @rm -rf $(spectest_tail_call_testdata_dir)
215 @mkdir -p $(spectest_tail_call_testdata_dir)
216 @cd $(spectest_tail_call_testdata_dir) \
217 && curl -sSL 'https://api.github.com/repos/WebAssembly/testsuite/contents/proposals/tail-call?ref=$(spec_version_tail_call)' | jq -r '.[]| .download_url' | grep -E ".wast" | xargs -Iurl curl -sJL url -O
218 @cd $(spectest_tail_call_testdata_dir) && for f in `find . -name '*.wast'`; do \
219 wast2json --enable-tail-call --debug-names $$f; \
220 done
221
222 .PHONY: build.spectest.exception_handling
223 build.spectest.exception_handling:
224 @rm -rf $(spectest_exception_handling_testdata_dir)
225 @mkdir -p $(spectest_exception_handling_testdata_dir)
226 @cd $(spectest_exception_handling_testdata_dir) \
227 && curl -sSL 'https://api.github.com/repos/WebAssembly/spec/contents/test/core/exceptions?ref=$(spec_version_exception_handling)' \
228 | jq -r '.[]| .download_url' | grep -E ".wast" | xargs -Iurl curl -sJL url -O
229 @cd $(spectest_exception_handling_testdata_dir) && for f in `find . -name '*.wast'`; do \
230 wasm-tools json-from-wast --wasm-dir . -o $$(basename $$f .wast).json $$f || true; \
231 done
232
233 .PHONY: build.spectest.typed_function_references
234 build.spectest.typed_function_references:
235 @rm -rf $(spectest_typed_function_references_testdata_dir)
236 @mkdir -p $(spectest_typed_function_references_testdata_dir)
237 @cd $(spectest_typed_function_references_testdata_dir) \
238 && for f in $(typed_function_references_wast_files); do \
239 curl -sJL "https://raw.githubusercontent.com/WebAssembly/function-references/$(spec_version_typed_function_references)/test/core/$$f" -O; \
240 done
241 @cd $(spectest_typed_function_references_testdata_dir) && for f in `find . -name '*.wast'`; do \
242 wasm-tools json-from-wast --wasm-dir . -o $$(basename $$f .wast).json $$f || true; \
243 done
244
245 .PHONY: test
246 test:
247 @go test $(go_test_options) ./...
248 @cd internal/version/testdata && go test $(go_test_options) ./...
249 @cd internal/integration_test/fuzz/wazerolib && CGO_ENABLED=0 WASM_BINARY_PATH=testdata/test.wasm go test ./...
250
251 .PHONY: coverage
252 # replace spaces with commas
253 coverpkg = $(shell echo $(main_packages) | tr ' ' ',')
254 coverage: ## Generate test coverage
255 @go test -coverprofile=coverage.txt -covermode=atomic --coverpkg=$(coverpkg) $(main_packages)
256 @go tool cover -func coverage.txt
257
258 golangci_lint_path := $(shell go env GOPATH)/bin/golangci-lint
259
260 $(golangci_lint_path):
261 @go install $(golangci_lint)
262
263 golangci_lint_goarch ?= $(shell go env GOARCH)
264
265 .PHONY: lint
266 lint: $(golangci_lint_path)
267 @GOARCH=$(golangci_lint_goarch) CGO_ENABLED=0 $(golangci_lint_path) run --timeout 5m -E testableexamples
268
269 .PHONY: format
270 format:
271 @go run $(gofumpt) -l -w .
272 @go run $(gosimports) -local github.com/tetratelabs/ -w $(shell find . -name '*.go' -type f)
273 @go run $(asmfmt) -w $(shell find . -name '*.s' -type f)
274
275 .PHONY: check # Pre-flight check for pull requests
276 check:
277 # The following checks help ensure our platform-specific code used for system
278 # calls safely falls back on a platform unsupported by the compiler engine.
279 # This makes sure the intepreter can be used. Most often the package that can
280 # drift here is "platform" or "sysfs":
281 #
282 # Ensure we build on plan9. See #1578
283 @GOARCH=amd64 GOOS=plan9 go build ./...
284 # Ensure we build on gojs. See #1526.
285 @GOARCH=wasm GOOS=js go build ./...
286 # Ensure we build on wasip1. See #1526.
287 @GOARCH=wasm GOOS=wasip1 go build ./...
288 # Ensure we build on aix. See #1723
289 @GOARCH=ppc64 GOOS=aix go build ./...
290 # Ensure we build on linux s390x. See #2412
291 @GOARCH=s390x GOOS=linux go build ./...
292 # Ensure we build on linux ppc64le. See #2412
293 @GOARCH=ppc64le GOOS=linux go build ./...
294 # Ensure we build on linux arm for Dapr:
295 # gh release view -R dapr/dapr --json assets --jq 'first(.assets[] | select(.name = "daprd_linux_arm.tar.gz") | {url, downloadCount})'
296 @GOARCH=arm GOOS=linux go build ./...
297 # Ensure we build on linux 386 for Trivy:
298 # gh release view -R aquasecurity/trivy --json assets --jq 'first(.assets[] | select(.name| test("Linux-32bit.*tar.gz")) | {url, downloadCount})'
299 @GOARCH=386 GOOS=linux go build ./...
300 # Ensure we build on FreeBSD amd64 for Trivy:
301 # gh release view -R aquasecurity/trivy --json assets --jq 'first(.assets[] | select(.name| test("FreeBSD-64bit.*tar.gz")) | {url, downloadCount})'
302 @GOARCH=amd64 GOOS=freebsd go build ./...
303 @$(MAKE) lint golangci_lint_goarch=arm64
304 @$(MAKE) lint golangci_lint_goarch=amd64
305 @$(MAKE) format
306 @go mod tidy
307 @if [ ! -z "`git status -s`" ]; then \
308 echo "The following differences will fail CI until committed:"; \
309 git diff --exit-code; \
310 fi
311
312 .PHONY: site
313 site: ## Serve website content
314 @git submodule update --init
315 @cd site && go run $(hugo) server --minify --disableFastRender --baseURL localhost:1313 --cleanDestinationDir -D
316
317 .PHONY: clean
318 clean: ## Ensure a clean build
319 @rm -rf dist build coverage.txt
320 @go clean -testcache
321
322 fuzz_default_flags := --no-trace-compares --sanitizer=none -- -rss_limit_mb=8192
323
324 fuzz_timeout_seconds ?= 10
325 .PHONY: fuzz
326 fuzz:
327 @cd internal/integration_test/fuzz && cargo test
328 @cd internal/integration_test/fuzz && cargo fuzz run logging_no_diff $(fuzz_default_flags) -max_total_time=$(fuzz_timeout_seconds)
329 @cd internal/integration_test/fuzz && cargo fuzz run no_diff $(fuzz_default_flags) -max_total_time=$(fuzz_timeout_seconds)
330 @cd internal/integration_test/fuzz && cargo fuzz run memory_no_diff $(fuzz_default_flags) -max_total_time=$(fuzz_timeout_seconds)
331 @cd internal/integration_test/fuzz && cargo fuzz run validation $(fuzz_default_flags) -max_total_time=$(fuzz_timeout_seconds)
332
333 libsodium:
334 cd ./internal/integration_test/libsodium/testdata && \
335 curl -s "https://api.github.com/repos/jedisct1/webassembly-benchmarks/contents/2022-12/wasm?ref=7e86d68e99e60130899fbe3b3ab6e9dce9187a7c" \
336 | jq -r '.[] | .download_url' | xargs -n 1 curl -LO
337
338 #### CLI release related ####
339
340 VERSION ?= dev
341 non_windows_platforms := darwin_amd64 darwin_arm64 linux_amd64 linux_arm64
342 non_windows_archives := $(non_windows_platforms:%=dist/wazero_$(VERSION)_%.tar.gz)
343 windows_platforms := windows_amd64 # TODO: add arm64 windows once we start testing on it.
344 windows_archives := $(windows_platforms:%=dist/wazero_$(VERSION)_%.zip)
345 checksum_txt := dist/wazero_$(VERSION)_checksums.txt
346
347 # define macros for multi-platform builds. these parse the filename being built
348 go-arch = $(if $(findstring amd64,$1),amd64,arm64)
349 go-os = $(if $(findstring .exe,$1),windows,$(if $(findstring linux,$1),linux,darwin))
350
351 build/wazero_%/wazero:
352 $(call go-build,$@,$<)
353
354 build/wazero_%/wazero.exe:
355 $(call go-build,$@,$<)
356
357 dist/wazero_$(VERSION)_%.tar.gz: build/wazero_%/wazero
358 @echo tar.gz "tarring $@"
359 @mkdir -p $(@D)
360 # On Windows, we pass the special flag `--mode='+rx' to ensure that we set the executable flag.
361 # This is only supported by GNU Tar, so we set it conditionally.
362 @tar -C $(<D) -cpzf $@ $(if $(findstring Windows_NT,$(OS)),--mode='+rx',) $(<F)
363 @echo tar.gz "ok"
364
365 define go-build
366 @echo "building $1"
367 @# $(go:go=) removes the trailing 'go', so we can insert cross-build variables
368 @$(go:go=) CGO_ENABLED=0 GOOS=$(call go-os,$1) GOARCH=$(call go-arch,$1) go build \
369 -ldflags "-s -w -X github.com/tetratelabs/wazero/internal/version.version=$(VERSION)" \
370 -o $1 $2 ./cmd/wazero
371 @echo build "ok"
372 endef
373
374 dist/wazero_$(VERSION)_%.zip: build/wazero_%/wazero.exe
375 @echo zip "zipping $@"
376 @mkdir -p $(@D)
377 @zip -qj $@ $<
378 @echo zip "ok"
379
380 # Darwin doesn't have sha256sum. See https://github.com/actions/virtual-environments/issues/90
381 sha256sum := $(if $(findstring darwin,$(shell go env GOOS)),shasum -a 256,sha256sum)
382 $(checksum_txt): $(non_windows_archives) $(windows_archives)
383 @cd $(@D); touch $(@F); $(sha256sum) * > $(@F)
384
385 dist: $(non_windows_archives) $(windows_archives) $(checksum_txt)