modernc.org/z@v1.7.4/Makefile (about)

     1  # Copyright 2021 The Zlib-Go 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
     8  ngrep='TODOOK\|internalError\|testdata\|scanner.go\|parser.go\|ast.go\|assets.go\|TODO-'
     9  
    10  
    11  all:
    12  	@LC_ALL=C date
    13  	@go version 2>&1 | tee log
    14  	@gofmt -l -s -w *.go
    15  	@go install -v ./...
    16  	@go test -i
    17  	@go test 2>&1 -timeout 1h | tee -a log
    18  	@go vet 2>&1 | grep -v $(ngrep) || true
    19  	@golint 2>&1 | grep -v $(ngrep) || true
    20  	@make todo
    21  	@misspell *.go
    22  	@staticcheck | grep -v 'scanner\.go' || true
    23  	@maligned || true
    24  	@grep -n --color=always 'FAIL\|PASS' log 
    25  	LC_ALL=C date 2>&1 | tee -a log
    26  
    27  # generate on current host
    28  generate:
    29  	go generate 2>&1 | tee log-generate
    30  	go build -v
    31  
    32  build_all_targets:
    33  	GOOS=darwin GOARCH=amd64 go build -v
    34  	GOOS=darwin GOARCH=arm64 go build -v
    35  	GOOS=freebsd GOARCH=386 go build -v
    36  	GOOS=freebsd GOARCH=arm64 go build -v
    37  	GOOS=freebsd GOARCH=arm go build -v
    38  	GOOS=freebsd GOARCH=arm64 go build -v
    39  	GOOS=linux GOARCH=386 go build -v
    40  	GOOS=linux GOARCH=amd64 go build -v
    41  	GOOS=linux GOARCH=arm go build -v
    42  	GOOS=linux GOARCH=arm64 go build -v
    43  	GOOS=linux GOARCH=ppc64le go build -v
    44  	GOOS=linux GOARCH=riscv64 go build -v
    45  	GOOS=linux GOARCH=s390x go build -v
    46  	GOOS=netbsd GOARCH=arm64 go build -v
    47  	GOOS=openbsd GOARCH=arm64 go build -v
    48  	GOOS=windows GOARCH=386 go build -v
    49  	GOOS=windows GOARCH=amd64 go build -v
    50  	GOOS=windows GOARCH=arm64 go build -v
    51  	echo done
    52  
    53  # only on darwin host
    54  darwin_amd64:
    55  	make generate
    56  	go test -v
    57  
    58  # only on s390x
    59  linux_s390x:
    60  	@echo "Should be executed only on darwin/amd64."
    61  	AR=$$(which ar) make generate
    62  	go test -v
    63  
    64  # only on darwin host
    65  darwin_arm64:
    66  	@echo "Should be executed only on darwin/arm64."
    67  	AR=$$(which ar) make generate
    68  	go test -v
    69  
    70  # only on freebsd host
    71  freebsd_amd64:
    72  	@echo "Should be executed only on freebsd/amd64."
    73  	AR=$$(which ar) make generate
    74  	go test -v
    75  
    76  # only on freebsd host
    77  freebsd_386:
    78  	@echo "Should be executed only on freebsd/386."
    79  	AR=$$(which ar) make generate
    80  	go test -v
    81  
    82  # only on freebsd host
    83  freebsd_arm:
    84  	@echo "Should be executed only on freebsd/arm."
    85  	AR=$$(which ar) make generate
    86  	go test -v
    87  
    88  # only on netbsd host
    89  netbsd_amd64:
    90  	@echo "Should be executed only on netbsd/amd64."
    91  	AR=$$(which ar) make generate
    92  	go test -v
    93  
    94  # on linux/amd64
    95  linux_amd64:
    96  	TARGET_GOOS=linux TARGET_GOARCH=amd64 make generate
    97  	GOOS=linux GOARCH=amd64 go test -v
    98  
    99  # on linux/amd64
   100  linux_386:
   101  	CCGO_CPP=i686-linux-gnu-cpp GO_GENERATE_CC=i686-linux-gnu-gcc TARGET_GOOS=linux TARGET_GOARCH=386 make generate
   102  	GOOS=linux GOARCH=386 go test -v
   103  
   104  # on linux/amd64
   105  linux_arm:
   106  	CCGO_CPP=arm-linux-gnueabi-cpp GO_GENERATE_CC=arm-linux-gnueabi-gcc TARGET_GOOS=linux TARGET_GOARCH=arm make generate
   107  	GOOS=linux GOARCH=arm go test -v
   108  
   109  # on linux/amd64
   110  linux_arm64:
   111  	CCGO_CPP=aarch64-linux-gnu-cpp GO_GENERATE_CC=aarch64-linux-gnu-gcc TARGET_GOOS=linux TARGET_GOARCH=arm64 make generate
   112  	GOOS=linux GOARCH=arm64 go test -v
   113  
   114  # only on linux/riscv64
   115  linux_riscv64:
   116  	@echo "Should be executed only on linux/riscv64."
   117  	make generate
   118  	go test -v
   119  
   120  # only on linux/ppc64le
   121  linux_ppc64le:
   122  	@echo "Should be executed only on linux/ppc64le."
   123  	make generate
   124  	go test -v
   125  
   126  # only on openbsd host
   127  openbsd_amd64:
   128  	@echo "Should be executed only on openbsd/amd64."
   129  	CC=$$(which cc) AR=$$(which ar) make generate
   130  	go test -v
   131  
   132  # only on openbsd host
   133  openbsd_arm64:
   134  	@echo "Should be executed only on openbsd/arm64."
   135  	CC=$$(which cc) AR=$$(which ar) make generate
   136  	go test -v
   137  
   138  # only on windows host with mingw gcc installed
   139  windows_amd64:
   140  	@echo "Should be executed only on windows/amd64."
   141  	make generate
   142  	go test -v
   143  
   144  # only on windows host with mingw gcc installed
   145  windows_arm64:
   146  	@echo "Should be executed only on windows/arm64."
   147  	make generate
   148  	go test -v
   149  
   150  # only on windows host with mingw gcc installed
   151  windows_386:
   152  	make generate
   153  	go test -v
   154  
   155  devbench:
   156  	date 2>&1 | tee log-devbench
   157  	go test -timeout 24h -dev -run @ -bench . 2>&1 | tee -a log-devbench
   158  	grep -n 'FAIL\|SKIP' log-devbench || true
   159  
   160  bench:
   161  	date 2>&1 | tee log-bench
   162  	go test -timeout 24h -v -run '^[^E]' -bench . 2>&1 | tee -a log-bench
   163  	grep -n 'FAIL\|SKIP' log-bench || true
   164  
   165  clean:
   166  	go clean
   167  	rm -f *~ *.test *.out
   168  
   169  cover:
   170  	t=$(shell mktemp) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t
   171  
   172  cpu: clean
   173  	go test -run @ -bench . -cpuprofile cpu.out
   174  	go tool pprof -lines *.test cpu.out
   175  
   176  edit:
   177  	@touch log
   178  	@if [ -f "Session.vim" ]; then gvim -S & else gvim -p Makefile *.go & fi
   179  
   180  editor:
   181  	gofmt -l -s -w *.go
   182  	nilness .
   183  	GO111MODULE=off go install -v 2>&1 | tee log-install
   184  
   185  later:
   186  	@grep -n $(grep) LATER * || true
   187  	@grep -n $(grep) MAYBE * || true
   188  
   189  mem: clean
   190  	go test -run @ -dev -bench . -memprofile mem.out -timeout 24h
   191  	go tool pprof -lines -web -alloc_space *.test mem.out
   192  
   193  nuke: clean
   194  	go clean -i
   195  
   196  todo:
   197  	@grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * | grep -v $(ngrep) || true
   198  	@grep -nrw $(grep) 'TODO\|panic' * | grep -v $(ngrep) || true
   199  	@grep -nr $(grep) BUG * | grep -v $(ngrep) || true
   200  	@grep -nr $(grep) [^[:alpha:]]println * | grep -v $(ngrep) || true
   201  	@grep -nir $(grep) 'work.*progress' || true