gitlab.com/SiaPrime/SiaPrime@v1.4.1/Makefile (about)

     1  # These variables get inserted into ./build/commit.go
     2  BUILD_TIME=$(shell date)
     3  GIT_REVISION=$(shell git rev-parse --short HEAD)
     4  GIT_DIRTY=$(shell git diff-index --quiet HEAD -- || echo "✗-")
     5  
     6  ldflags= -X gitlab.com/SiaPrime/SiaPrime/build.GitRevision=${GIT_DIRTY}${GIT_REVISION} \
     7  -X "gitlab.com/SiaPrime/SiaPrime/build.BuildTime=${BUILD_TIME}"
     8  
     9  # all will build and install release binaries
    10  all: release
    11  
    12  # pkgs changes which packages the makefile calls operate on. run changes which
    13  # tests are run during testing.
    14  run = .
    15  pkgs = ./build ./cmd/spc ./cmd/spd ./compatibility ./crypto ./encoding ./modules ./modules/consensus ./modules/explorer \
    16         ./modules/gateway ./modules/host ./modules/host/contractmanager ./modules/renter ./modules/renter/contractor       \
    17         ./modules/renter/hostdb ./modules/renter/hostdb/hosttree ./modules/renter/proto ./modules/renter/siadir            \
    18         ./modules/renter/siafile ./modules/miner ./modules/wallet ./modules/transactionpool ./modules/stratumminer ./node ./node/api ./persist    \
    19         ./siatest ./siatest/consensus ./siatest/gateway ./siatest/renter ./siatest/wallet ./node/api/server ./sync ./types
    20  
    21  # fmt calls go fmt on all packages.
    22  fmt:
    23  	gofmt -s -l -w $(pkgs)
    24  
    25  # vet calls go vet on all packages.
    26  # NOTE: go vet requires packages to be built in order to obtain type info.
    27  vet:
    28  	GO111MODULE=on go vet $(pkgs)
    29  
    30  lint:
    31  	go get golang.org/x/lint/golint
    32  	golint -min_confidence=1.0 -set_exit_status $(pkgs)
    33  
    34  # spellcheck checks for misspelled words in comments or strings.
    35  spellcheck:
    36  	misspell -error .
    37  
    38  # debug builds and installs debug binaries.
    39  debug:
    40  	GO111MODULE=on go install -tags='debug profile netgo' -ldflags='$(ldflags)' $(pkgs)
    41  debug-race:
    42  	GO111MODULE=on go install -race -tags='debug profile netgo' -ldflags='$(ldflags)' $(pkgs)
    43  
    44  # dev builds and installs developer binaries.
    45  dev:
    46  	GO111MODULE=on go install -tags='dev debug profile netgo' -ldflags='$(ldflags)' $(pkgs)
    47  dev-race:
    48  	GO111MODULE=on go install -race -tags='dev debug profile netgo' -ldflags='$(ldflags)' $(pkgs)
    49  
    50  # release builds and installs release binaries.
    51  release:
    52  	GO111MODULE=on go install -tags='netgo' -ldflags='-s -w $(ldflags)' $(pkgs)
    53  release-race:
    54  	GO111MODULE=on go install -race -tags='netgo' -ldflags='-s -w $(ldflags)' $(pkgs)
    55  
    56  # clean removes all directories that get automatically created during
    57  # development.
    58  clean:
    59  	rm -rf cover doc/whitepaper.aux doc/whitepaper.log doc/whitepaper.pdf release 
    60  
    61  test:
    62  	GO111MODULE=on go test -short -tags='debug testing netgo' -timeout=5s $(pkgs) -run=$(run)
    63  test-v:
    64  	GO111MODULE=on go test -race -v -short -tags='debug testing netgo' -timeout=15s $(pkgs) -run=$(run)
    65  test-long: clean fmt vet lint
    66  	@mkdir -p cover
    67  	GO111MODULE=on go test --coverprofile='./cover/cover.out' -v -race -failfast -tags='testing debug netgo' -timeout=1800s $(pkgs) -run=$(run)
    68  test-vlong: clean fmt vet lint
    69  	@mkdir -p cover
    70  	GO111MODULE=on go test --coverprofile='./cover/cover.out' -v -race -tags='testing debug vlong netgo' -timeout=20000s $(pkgs) -run=$(run)
    71  test-cpu:
    72  	GO111MODULE=on go test -v -tags='testing debug netgo' -timeout=500s -cpuprofile cpu.prof $(pkgs) -run=$(run)
    73  test-mem:
    74  	GO111MODULE=on go test -v -tags='testing debug netgo' -timeout=500s -memprofile mem.prof $(pkgs) -run=$(run)
    75  test-pool:
    76  	GO111MODULE=on go test -short -parallel=1 -tags='testing debug pool' -timeout=120s ./modules/miningpool -run=$(run)
    77  bench: clean fmt
    78  	GO111MODULE=on go test -tags='debug testing netgo' -timeout=500s -run=XXX -bench=$(run) $(pkgs)
    79  cover: clean
    80  	@mkdir -p cover
    81  	@for package in $(pkgs); do                                                                                                          \
    82  		mkdir -p `dirname cover/$$package`                                                                                        \
    83  		&& go test -tags='testing debug netgo' -timeout=500s -covermode=atomic -coverprofile=cover/$$package.out ./$$package -run=$(run) \
    84  		&& go tool cover -html=cover/$$package.out -o=cover/$$package.html                                                               \
    85  		&& rm cover/$$package.out ;                                                                                                      \
    86  	done
    87  
    88  # whitepaper builds the whitepaper from whitepaper.tex. pdflatex has to be
    89  # called twice because references will not update correctly the first time.
    90  whitepaper:
    91  	@pdflatex -output-directory=doc whitepaper.tex > /dev/null
    92  	pdflatex -output-directory=doc whitepaper.tex
    93  
    94  .PHONY: all fmt install release clean test test-v test-long cover whitepaper
    95