Skip to content

Commit

Permalink
Makefile: simplify and clean-up (cosmos#7453)
Browse files Browse the repository at this point in the history
The simd target is removed in favor of build/install targets:

- build runs go build ./... with all appropriate flags and args.
- install runs go install ./... with all approriate flags and args.

localnet-start now depends on build-linux [1].

[1] This should hopefully put a smile on @alexanderbez's face!

Remove unused install scripts and snapcraft build files.
  • Loading branch information
Alessio Treglia authored Oct 5, 2020
1 parent cdf9bd2 commit 6c1c2cc
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 238 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ WORKDIR /go/src/github.com/cosmos/cosmos-sdk
COPY . .

# install simapp, remove packages
RUN make simd-linux
RUN make build-linux


# Final image
Expand Down
42 changes: 16 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,17 @@ include contrib/devtools/Makefile
### Build ###
###############################################################################

build: go.sum
go build -mod=readonly ./...
BUILD_TARGETS := build install

simd:
mkdir -p $(BUILDDIR)
go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR) ./simapp/simd
build: BUILD_ARGS=-o $(BUILDDIR)/
build-linux:
GOOS=linux GOARCH=amd64 LEDGER_ENABLED=false $(MAKE) build

simd-linux: go.sum
$(MAKE) simd GOOS=linux GOARCH=amd64 LEDGER_ENABLED=false
$(BUILD_TARGETS): go.sum $(BUILDDIR)/
go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./...

$(BUILDDIR)/:
mkdir -p $(BUILDDIR)/

build-simd-all: go.sum
$(if $(shell docker inspect -f '{{ .Id }}' cosmossdk/rbuilder 2>/dev/null),$(info found image cosmossdk/rbuilder),docker pull cosmossdk/rbuilder:latest)
Expand All @@ -119,7 +121,7 @@ build-simd-all: go.sum
--name latest-build cosmossdk/rbuilder:latest
docker cp -a latest-build:/home/builder/artifacts/ $(CURDIR)/

build-simd-linux: go.sum
build-simd-linux: go.sum $(BUILDDIR)/
$(if $(shell docker inspect -f '{{ .Id }}' cosmossdk/rbuilder 2>/dev/null),$(info found image cosmossdk/rbuilder),docker pull cosmossdk/rbuilder:latest)
docker rm latest-build || true
docker run --volume=$(CURDIR):/sources:ro \
Expand All @@ -130,13 +132,12 @@ build-simd-linux: go.sum
--env LEDGER_ENABLED=false \
--name latest-build cosmossdk/rbuilder:latest
docker cp -a latest-build:/home/builder/artifacts/ $(CURDIR)/
mkdir -p $(BUILDDIR)
cp artifacts/simd-*-linux-amd64 $(BUILDDIR)/simd

cosmovisor:
$(MAKE) -C cosmovisor cosmovisor

.PHONY: build simd simd-linux build-simd-all build-simd-linux cosmovisor
.PHONY: build build-linux build-simd-all build-simd-linux cosmovisor

mocks: $(MOCKS_DIR)
mockgen -source=client/account_retriever.go -package mocks -destination tests/mocks/account_retriever.go
Expand All @@ -152,13 +153,7 @@ mocks: $(MOCKS_DIR)
$(MOCKS_DIR):
mkdir -p $(MOCKS_DIR)

distclean: clean
rm -rf \
gitian-build-darwin/ \
gitian-build-linux/ \
gitian-build-windows/ \
.gitian-builder-cache/

distclean: clean tools-clean
clean:
rm -rf \
$(BUILDDIR)/ \
Expand All @@ -171,15 +166,10 @@ clean:
### Tools & Dependencies ###
###############################################################################

go-mod-cache: go.sum
@echo "--> Download go modules to local cache"
@go mod download
.PHONY: go-mod-cache

go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
@go mod verify
@go mod tidy
echo "Ensure dependencies have not been modified ..." >&2
go mod verify
go mod tidy

###############################################################################
### Documentation ###
Expand Down Expand Up @@ -459,7 +449,7 @@ proto-update-deps:
###############################################################################

# Run a 4-node testnet locally
localnet-start: $(BUILDDIR)/simd localnet-stop
localnet-start: build-linux localnet-stop
$(if $(shell docker inspect -f '{{ .Id }}' cosmossdk/simd-env 2>/dev/null),$(info found image cosmossdk/simd-env),$(MAKE) -C contrib/images simd-env)
if ! [ -f build/node0/simd/config/genesis.json ]; then docker run --rm \
--user $(shell id -u):$(shell id -g) \
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ for os in ${TARGET_OS} ; do
for arch in ${archs} ; do
make clean
GOOS="${os}" GOARCH="${arch}" GOROOT_FINAL="$(go env GOROOT)" \
make ${APP} \
make build \
LDFLAGS=-buildid=${VERSION} \
VERSION=${VERSION} \
COMMIT=${COMMIT} \
Expand Down
37 changes: 0 additions & 37 deletions scripts/install/install_sdk_arm.sh

This file was deleted.

52 changes: 0 additions & 52 deletions scripts/install/install_sdk_bsd.sh

This file was deleted.

40 changes: 0 additions & 40 deletions scripts/install/install_sdk_ubuntu.sh

This file was deleted.

46 changes: 0 additions & 46 deletions snapcraft.yaml

This file was deleted.

35 changes: 0 additions & 35 deletions snapcraft.yaml.in

This file was deleted.

0 comments on commit 6c1c2cc

Please sign in to comment.