github.com/fozzysec/SiaPrime@v0.0.0-20190612043147-66c8e8d11fe3/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 SiaPrime/build.GitRevision=${GIT_DIRTY}${GIT_REVISION} \
     7  -X "SiaPrime/build.BuildTime=${BUILD_TIME}"
     8  
     9  # all will build and install release binaries
    10  all: release
    11  
    12  # dependencies installs all of the dependencies that are required for building
    13  # SiaPrime.
    14  dependencies:
    15  	#replace golang.org with github mirrors to solve connection problem in China
    16  	if [ -d ${GOPATH}/src/golang.org/x/crypto ];then \
    17  		rm -rf "${GOPATH}/src/golang.org/x/crypto"; \
    18  	fi
    19  	mkdir -p ${GOPATH}/src/golang.org/x/crypto
    20  	git clone https://github.com/golang/crypto.git ${GOPATH}/src/golang.org/x/crypto
    21  	if [ -d ${GOPATH}/src/golang.org/x/lint ];then \
    22  		rm -rf "${GOPATH}/src/golang.org/x/lint"; \
    23  	fi
    24  	mkdir -p ${GOPATH}/src/golang.org/x/lint
    25  	git clone https://github.com/golang/lint.git ${GOPATH}/src/golang.org/x/lint
    26  	if [ -d ${GOPATH}/src/golang.org/x/text ];then \
    27  		rm -rf "${GOPATH}/src/golang.org/x/text"; \
    28  	fi
    29  	mkdir -p ${GOPATH}/src/golang.org/x/text
    30  	git clone https://github.com/golang/text.git ${GOPATH}/src/golang.org/x/text
    31  	if [ -d ${GOPATH}/src/golang.org/x/net ];then \
    32  		rm -rf "${GOPATH}/src/golang.org/x/net"; \
    33  	fi
    34  	mkdir -p ${GOPATH}/src/golang.org/x/net
    35  	git clone https://github.com/golang/net.git ${GOPATH}/src/golang.org/x/net
    36  	# Consensus Dependencies
    37  	go get -u gitlab.com/NebulousLabs/demotemutex
    38  	go get -u gitlab.com/NebulousLabs/fastrand
    39  	go get -u gitlab.com/NebulousLabs/merkletree
    40  	go get -u gitlab.com/NebulousLabs/bolt
    41  	#go get -u golang.org/x/crypto/blake2b
    42  	#go get -u golang.org/x/crypto/ed25519
    43  	# Module + Daemon Dependencies
    44  	go get -u gitlab.com/NebulousLabs/entropy-mnemonics
    45  	go get -u gitlab.com/NebulousLabs/errors
    46  	go get -u gitlab.com/NebulousLabs/go-upnp
    47  	go get -u gitlab.com/NebulousLabs/ratelimit
    48  	go get -u gitlab.com/NebulousLabs/threadgroup
    49  	go get -u gitlab.com/NebulousLabs/writeaheadlog
    50  	go get -u github.com/klauspost/reedsolomon
    51  	go get -u github.com/julienschmidt/httprouter
    52  	go get -u github.com/inconshreveable/go-update
    53  	go get -u github.com/kardianos/osext
    54  	go get -u github.com/inconshreveable/mousetrap
    55  	go get -u github.com/go-sql-driver/mysql
    56  	go get -u github.com/lib/pq
    57  	go get github.com/sasha-s/go-deadlock/...
    58  	# Frontend Dependencies
    59  	#go get -u golang.org/x/crypto/ssh/terminal
    60  	go get -u github.com/spf13/cobra/...
    61  	go get -u github.com/spf13/viper
    62  	go get -u github.com/inconshreveable/mousetrap
    63  	# Developer Dependencies
    64  	#go install -race std
    65  	go get -u github.com/client9/misspell/cmd/misspell
    66  	#go get -u golang.org/x/lint/golint
    67  	go get -u gitlab.com/NebulousLabs/glyphcheck
    68  
    69  # pkgs changes which packages the makefile calls operate on. run changes which
    70  # tests are run during testing.
    71  run = .
    72  pkgs = ./build ./cmd/spc ./cmd/spd ./compatibility ./crypto ./encoding ./modules ./modules/consensus ./modules/explorer \
    73         ./modules/gateway ./modules/host ./modules/host/contractmanager ./modules/renter ./modules/renter/contractor       \
    74         ./modules/renter/hostdb ./modules/renter/hostdb/hosttree ./modules/renter/proto ./modules/miner ./modules/miningpool \
    75         ./modules/wallet ./modules/transactionpool ./modules/stratumminer ./node ./node/api ./persist ./siatest \
    76         ./siatest/consensus ./siatest/renter ./siatest/wallet ./node/api/server ./sync ./types
    77  
    78  # fmt calls go fmt on all packages.
    79  fmt:
    80  	gofmt -s -l -w $(pkgs)
    81  
    82  # vet calls go vet on all packages.
    83  # NOTE: go vet requires packages to be built in order to obtain type info.
    84  vet: release-std
    85  	go vet $(pkgs)
    86  
    87  lint:
    88  	golint -min_confidence=1.0 -set_exit_status $(pkgs)
    89  
    90  # spellcheck checks for misspelled words in comments or strings.
    91  spellcheck:
    92  	misspell -error .
    93  
    94  # debug builds and installs debug binaries.
    95  debug:
    96  	go install -tags='debug profile netgo' -ldflags='$(ldflags)' $(pkgs)
    97  debug-race:
    98  	go install -race -tags='debug profile netgo' -ldflags='$(ldflags)' $(pkgs)
    99  
   100  # dev builds and installs developer binaries.
   101  dev:
   102  	go install -tags='dev debug profile netgo' -ldflags='$(ldflags)' $(pkgs)
   103  dev-race:
   104  	go install -race -tags='dev debug profile netgo' -ldflags='$(ldflags)' $(pkgs)
   105  
   106  # release builds and installs release binaries.
   107  release:
   108  	go install -tags='netgo' -a -ldflags='-s -w $(ldflags)' $(pkgs)
   109  release-race:
   110  	go install -race -tags='netgo' -a -ldflags='-s -w $(ldflags)' $(pkgs)
   111  
   112  # clean removes all directories that get automatically created during
   113  # development.
   114  clean:
   115  	rm -rf cover doc/whitepaper.aux doc/whitepaper.log doc/whitepaper.pdf release
   116  
   117  test:
   118  	go test -short -tags='debug testing netgo' -timeout=5s $(pkgs) -run=$(run)
   119  test-v:
   120  	go test -race -v -short -tags='debug testing netgo' -timeout=15s $(pkgs) -run=$(run)
   121  test-long: clean fmt vet lint
   122  	@mkdir -p cover
   123  	go test --coverprofile='./cover/cover.out' -v -race -tags='testing debug netgo' -timeout=1800s $(pkgs) -run=$(run)
   124  test-vlong: clean fmt vet lint
   125  	@mkdir -p cover
   126  	go test --coverprofile='./cover/cover.out' -v -race -tags='testing debug vlong netgo' -timeout=20000s $(pkgs) -run=$(run)
   127  test-cpu:
   128  	go test -v -tags='testing debug netgo' -timeout=500s -cpuprofile cpu.prof $(pkgs) -run=$(run)
   129  test-mem:
   130  	go test -v -tags='testing debug netgo' -timeout=500s -memprofile mem.prof $(pkgs) -run=$(run)
   131  test-pool:
   132  	go test -short -parallel=1 -tags='testing debug pool' -timeout=120s ./modules/miningpool -run=$(run)
   133  bench: clean fmt
   134  	go test -tags='debug testing netgo' -timeout=500s -run=XXX -bench=$(run) $(pkgs)
   135  cover: clean
   136  	@mkdir -p cover
   137  	@for package in $(pkgs); do                                                                                                          \
   138  		mkdir -p `dirname cover/$$package`                                                                                        \
   139  		&& go test -tags='testing debug netgo' -timeout=500s -covermode=atomic -coverprofile=cover/$$package.out ./$$package -run=$(run) \
   140  		&& go tool cover -html=cover/$$package.out -o=cover/$$package.html                                                               \
   141  		&& rm cover/$$package.out ;                                                                                                      \
   142  	done
   143  
   144  # whitepaper builds the whitepaper from whitepaper.tex. pdflatex has to be
   145  # called twice because references will not update correctly the first time.
   146  whitepaper:
   147  	@pdflatex -output-directory=doc whitepaper.tex > /dev/null
   148  	pdflatex -output-directory=doc whitepaper.tex
   149  
   150  .PHONY: all dependencies fmt install release release-std xc clean test test-v test-long cover cover-integration cover-unit whitepaper
   151