github.com/cznic/ql@v1.2.1-0.20181122101857-b60735abf8a0/Makefile (about)

     1  # Copyright (c) 2014 The ql 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 clean cover cpu editor internalError later mem nuke todo edit
     6  
     7  grep=--include=*.go --include=*.l --include=*.y --include=*.yy --exclude=ql.y
     8  ngrep='TODOOK\|parser\.go\|scanner\.go\|.*_string\.go'
     9  
    10  all: editor scanner.go parser.go
    11  	go vet 2>&1 | grep -v $(ngrep) || true
    12  	golint 2>&1 | grep -v $(ngrep) || true
    13  	make todo
    14  	unused . || true
    15  	misspell *.go
    16  	gosimple || true
    17  	unconvert -apply
    18  	go install ./...
    19  
    20  bench: all
    21  	go test -run NONE -bench .
    22  
    23  clean:
    24  	go clean
    25  	rm -f *~ y.go y.tab.c *.out *.test
    26  
    27  coerce.go: helper/helper.go
    28  	if [ -f coerce.go ] ; then rm coerce.go ; fi
    29  	go run helper/helper.go | gofmt > $@
    30  
    31  cover:
    32  	t=$(shell mktemp) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t
    33  
    34  cpu: clean
    35  	go test -run @ -bench BenchmarkInsertBoolFileNoX1e2 -cpuprofile cpu.out -benchmem -benchtime 4s
    36  	go tool pprof -lines *.test cpu.out
    37  
    38  edit:
    39  	@ 1>/dev/null 2>/dev/null gvim -p Makefile *.l *.y *.go testdata.ql testdata.log
    40  
    41  edit2:
    42  	touch log
    43  	@ 1>/dev/null 2>/dev/null gvim -p Makefile all_test.go log driver*.go encode2.go file*.go mem.go ql.go storage*.go testdata.ql testdata.log
    44  
    45  editor: ql.y scanner.go parser.go coerce.go
    46  	gofmt -s -l -w *.go
    47  	go test -i
    48  	go test 2>&1 | tee log
    49  
    50  internalError:
    51  	egrep -ho '"internal error.*"' *.go | sort | cat -n
    52  
    53  later:
    54  	@grep -n $(grep) LATER * || true
    55  	@grep -n $(grep) MAYBE * || true
    56  
    57  mem: clean
    58  	go test -run @ -bench BenchmarkInsertBoolFileNoX1e2 -memprofile mem.out -memprofilerate 1 -timeout 24h -benchmem -benchtime 4s
    59  	go tool pprof -lines -web -alloc_space *.test mem.out
    60  
    61  nuke: clean
    62  	go clean -i
    63  
    64  parser.go: parser.y
    65  	a=$(shell mktemp) ; \
    66  	  goyacc -o /dev/null -xegen $$a $< ; \
    67  	  goyacc -cr -o $@ -xe $$a $< ; \
    68  	  rm -f $$a
    69  	sed -i -e 's|//line.*||' -e 's/yyEofCode/yyEOFCode/' $@
    70  
    71  ql.y: doc.go
    72  	#TODO sed -n '1,/^package/ s/^\/\/  //p' < $< \
    73  	#TODO 	| ebnf2y -o $@ -oe $*.ebnf -start StatementList -pkg $* -p _
    74  	#TODO goyacc -cr -o /dev/null $@
    75  
    76  scanner.go: scanner.l parser.go
    77  	golex -o $@ $<
    78  
    79  todo:
    80  	@grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * || true
    81  	@grep -nr $(grep) TODO * || true
    82  	@grep -nr $(grep) BUG * || true
    83  	@grep -nr $(grep) [^[:alpha:]]println * || true