Makefile (4107B)
1 # Copyright 2019 The CC Authors. All rights reserved. 2 # Use of this source code is governed by a BSD-style 3 # license that can be found in the LICENSE file. 4 5 .PHONY: all bench clean cover cpu editor internalError later mem nuke todo edit devbench 6 7 grep=--include=*.go --include=*.l --include=*.y --include=*.yy 8 ngrep='internalError\|TODOOK\|lexer\.go\|ast.go\|trigraphs\.go\|.*_string\.go\|stringer\.go\|testdata\/gcc' 9 testlog=testdata/testlog-$(shell echo $$GOOS)-$(shell echo $$GOARCH)-on-$(shell go env GOOS)-$(shell go env GOARCH) 10 11 all: lexer.go 12 LC_ALL=C make all_log 2>&1 | tee log 13 14 all_log: 15 date 16 go version 17 uname -a 18 ./unconvert.sh 19 gofmt -l -s -w *.go 20 GOOS=darwin GOARCH=amd64 go build 21 GOOS=darwin GOARCH=arm64 go build 22 GOOS=linux GOARCH=386 go build 23 GOOS=linux GOARCH=amd64 go build 24 GOOS=linux GOARCH=arm go build 25 GOOS=windows GOARCH=386 go build 26 GOOS=windows GOARCH=amd64 go build 27 go vet | grep -v $(ngrep) || true 28 golint | grep -v $(ngrep) || true 29 misspell *.go 30 staticcheck | grep -v 'lexer\.go' || true 31 pcregrep -nM 'FAIL|false|<nil>|:\n}' ast_test.go || true 32 33 test: 34 go version | tee $(testlog) 35 uname -a | tee -a $(testlog) 36 go test -v -timeout 24h | tee -a $(testlog) 37 grep -ni fail $(testlog) | tee -a $(testlog) || true 38 LC_ALL=C date | tee -a $(testlog) 39 grep -ni --color=always fail $(testlog) || true 40 41 test_linux_amd64: 42 GOOS=linux GOARCH=amd64 make test 43 44 test_linux_386: 45 GOOS=linux GOARCH=386 make test 46 47 test_linux_arm: 48 GOOS=linux GOARCH=arm make test 49 50 test_linux_arm64: 51 GOOS=linux GOARCH=arm64 make test 52 53 test_windows_amd64: 54 go version 55 go test -v -timeout 24h 56 57 test_windows386: 58 go version 59 go test -v -timeout 24h 60 61 build_all_targets: 62 GOOS=darwin GOARCH=amd64 go build -v ./... 63 GOOS=darwin GOARCH=arm64 go build -v ./... 64 GOOS=freebsd GOARCH=386 go build -v ./... 65 GOOS=freebsd GOARCH=amd64 go build -v ./... 66 GOOS=freebsd GOARCH=arm go build -v ./... 67 GOOS=freebsd GOARCH=arm64 go build -v ./... 68 GOOS=linux GOARCH=386 go build -v ./... 69 GOOS=linux GOARCH=amd64 go build -v ./... 70 GOOS=linux GOARCH=arm go build -v ./... 71 GOOS=linux GOARCH=arm64 go build -v ./... 72 GOOS=linux GOARCH=ppc64le go build -v ./... 73 GOOS=linux GOARCH=riscv64 go build -v ./... 74 GOOS=linux GOARCH=s390x go build -v ./... 75 GOOS=netbsd GOARCH=amd64 go build -v ./... 76 GOOS=netbsd GOARCH=arm go build -v ./... 77 GOOS=netbsd GOARCH=386 go build -v ./... 78 GOOS=openbsd GOARCH=amd64 go build -v ./... 79 GOOS=openbsd GOARCH=arm64 go build -v ./... 80 GOOS=openbsd GOARCH=386 go build -v ./... 81 GOOS=windows GOARCH=386 go build -v ./... 82 GOOS=windows GOARCH=amd64 go build -v ./... 83 GOOS=windows GOARCH=arm64 go build -v ./... 84 85 devbench: 86 date 2>&1 | tee log-devbench 87 go test -timeout 24h -dev -run @ -bench . 2>&1 | tee -a log-devbench 88 grep -n 'FAIL\|SKIP' log-devbench || true 89 90 bench: 91 date 2>&1 | tee log-bench 92 go test -timeout 24h -v -run '^[^E]' -bench . 2>&1 | tee -a log-bench 93 grep -n 'FAIL\|SKIP' log-bench || true 94 95 clean: 96 go clean 97 rm -f *~ *.test *.out 98 99 cover: 100 t=$(shell mktemp) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t 101 102 cpu: clean 103 go test -run @ -bench . -cpuprofile cpu.out 104 go tool pprof -lines *.test cpu.out 105 106 edit: 107 @touch log 108 @if [ -f "Session.vim" ]; then gvim -S & else gvim -p Makefile *.go & fi 109 110 editor: lexer.go 111 gofmt -l -s -w *.go 112 go test -o /dev/null -c 113 go install 2>&1 | tee log 114 115 ast.go lexer.go stringer.go: lexer.l parser.yy enum.go 116 go generate 117 118 later: 119 @grep -n $(grep) LATER * || true 120 @grep -n $(grep) MAYBE * || true 121 122 mem: clean 123 # go test -v -run ParserCS -csmith 2m -memprofile mem.out -timeout 24h 124 # go test -v -run @ -bench BenchmarkScanner -memprofile mem.out -timeout 24h 125 go test -v -run TestTranslateSQLite -memprofile mem.out -timeout 24h 126 go tool pprof -lines -web -alloc_space *.test mem.out 127 128 nuke: clean 129 go clean -i 130 131 todo: 132 @grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * | grep -v $(ngrep) || true 133 @grep -nr $(grep) 'TODO\|panic' * | grep -v $(ngrep) || true 134 @grep -nr $(grep) BUG * | grep -v $(ngrep) || true 135 @grep -nr $(grep) [^[:alpha:]]println * | grep -v $(ngrep) || true