github.com/zyedidia/knit@v1.1.2-0.20230901152954-f7d4e39a0e24/Knitfile (about) 1 knit = require("knit") 2 3 version = "0.0.0-unknown" 4 knit.knit("-C tools/version") 5 version = knit.shell("./tools/version/version") 6 goflags = f"-trimpath -ldflags \"-s -w -X github.com/zyedidia/knit/info.Version=$version\"" 7 8 race = tobool(cli.race) and "-race" or "" 9 10 pkgs = ".,./rules,./expand" 11 12 return b{ 13 $ knit:B: 14 go build $goflags ./cmd/knit 15 $ build:V: knit 16 17 $ install:VB: 18 go install $goflags ./cmd/knit 19 20 $ all:V: knit-$version-linux-amd64.tar.gz \ 21 knit-$version-linux-386.tar.gz \ 22 knit-$version-linux-arm.tar.gz \ 23 knit-$version-linux-arm64.tar.gz \ 24 knit-$version-darwin-amd64.tar.gz \ 25 knit-$version-darwin-arm64.tar.gz \ 26 knit-$version-openbsd-amd64.tar.gz \ 27 knit-$version-freebsd-amd64.tar.gz \ 28 knit-$version-windows-amd64.tar.gz 29 30 $ %.tar.gz: % 31 tar czf $output $input 32 33 $ '(knit-$version-(.*)-([^\.]*))':R: knit.1 34 mkdir -p $match1 35 CGO_ENABLED=0 GOOS=$match2 GOARCH=$match3 go build $goflags -o $match1/knit ./cmd/knit 36 cp LICENSE* $match1 37 cp README.md $match1 38 cp knit.1 $match1 39 40 $ clean:VB: 41 knit :all -t clean 42 rm -rf knit-* 43 44 $ test:VB: 45 go test $race 46 47 $ check:VB: 48 if [ "$$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi 49 go vet ./... 50 staticcheck ./... 51 go test $race 52 53 $ cover.out:B: 54 go test -coverpkg=$pkgs -coverprofile cover.out . 55 56 $ cover:VB: 57 go test -coverpkg=$pkgs -cover . 58 59 $ cover-html:VB: cover.out 60 go tool cover -html=cover.out 61 62 $ tools/replace/replace: tools/replace/replace.go 63 go build -o $output $input 64 65 $ knit.1: man/knit.md tools/replace/replace 66 tools/replace/replace $input | pandoc -s -t man -o $output 67 }