Skip to content

Commit

Permalink
build: simplify build process (#732)
Browse files Browse the repository at this point in the history
* build: bls doesn't need python bindings nor tests

* build: build inprovements

* chore: build improvements

* doc: installation update

* chore: remove CMAKE_INSTALL_PREFIX

* chore: fix CMAKE INSTALL

* chore: fix destdir
  • Loading branch information
lklimek authored Feb 1, 2024
1 parent 9fc725f commit 78b3c1f
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 39 deletions.
5 changes: 2 additions & 3 deletions DOCKER/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ FROM golang:${GOLANG_VERSION}-alpine${ALIPNE_VERSION} AS base

RUN apk update && \
apk upgrade && \
apk --no-cache add bash git gmp-dev sudo cmake build-base python3-dev libpcap-dev leveldb-dev && \
apk --no-cache add bash git gmp-dev sudo cmake build-base libpcap-dev leveldb-dev && \
rm -rf /var/cache/apk/*

WORKDIR /src/bls

# Install BLS library
COPY third_party ./third_party
RUN ./third_party/bls-signatures/build.sh && \
./third_party/bls-signatures/install.sh
RUN ./third_party/bls-signatures/build.sh

#####################################
# STAGE 2: install golang libraries #
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ endif
# allow users to pass additional flags via the conventional LDFLAGS variable
LD_FLAGS += $(LDFLAGS)

all: build install
all: build
build: build-bls build-binary
.PHONY: build

install: install-bls

.PHONY: all
Expand All @@ -113,7 +114,7 @@ build-bls:
.PHONY: build-bls

install-bls: build-bls
@sudo third_party/bls-signatures/install.sh
@third_party/bls-signatures/install.sh
.PHONY: install-bls

###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ to notify you of vulnerabilities and fixes in Tendermint Core. You can subscribe

| Requirement | Notes |
|-------------|------------------|
| Go version | Go1.17 or higher |
| Go version | Go1.21 or higher |

### Install

Expand Down
65 changes: 41 additions & 24 deletions docs/introduction/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,62 @@ order: 3

# Install Tenderdash

## Using Dashmate (Recommended Method)

Dashmate is a part of the Dash Platform and provides a comprehensive solution for installing the entire platform. We highly recommend using Dashmate for a seamless and straightforward installation process.

For detailed instructions on how to set up a node using Dashmate, please refer to the official Dash documentation: [Set Up a Node](https://docs.dash.org/projects/platform/en/stable/docs/tutorials/setup-a-node.html).

## From Binary

To download pre-built binaries, see the [releases page](https://github.com/dashevo/tenderdash/releases).

## From Source

You'll need `go` [installed](https://golang.org/doc/install) and the required
environment variables set, which can be done with the following commands:
Install official go into the standard location with standard PATH updates:

```sh
echo export GOPATH=\"\$HOME/go\" >> ~/.bash_profile
echo export PATH=\"\$PATH:\$GOPATH/bin\" >> ~/.bash_profile
```
```bash
curl https://webinstall.dev/go | sh
source ~/.config/envman/PATH.env
```

Get the source code:
Install git, cmake, and build-essential (apt) or build-base (apk) and other libs.

```sh
git clone https://github.com/dashevo/tenderdash.git
cd tenderdash
```
For Debian-based (eg. Ubuntu):

```bash
sudo apt update
sudo apt install -y git build-essential cmake libgmp-dev
```

Then run:
For Alpine Linux:

```sh
make install
```
```bash
apk add --no-cache git build-base cmake gmp-dev
```

to put the binary in `$GOPATH/bin` or use:
Get the source code:

```sh
make build
```
```bash
git clone https://github.com/dashpay/tenderdash.git
pushd ./tenderdash/
git submodule init
git submodule update
```

Build:

to put the binary in `$GOPATH/bin`:

```sh
make install
```

to put the binary in `./build`.
to put the binary in `./build`:

_DISCLAIMER_ The binary of Tenderdash is build/installed without the DWARF
symbol table. If you would like to build/install Tenderdash with the DWARF
symbol and debug information, remove `-s -w` from `BUILD_FLAGS` in the make
file.
```sh
make build
```

The latest Tenderdash is now installed. You can verify the installation by
running:
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ FROM golang:${GOLANG_VERSION}-alpine${ALIPNE_VERSION} AS base

RUN apk update && \
apk upgrade && \
apk --no-cache add bash git gmp-dev sudo cmake build-base python3-dev libpcap-dev leveldb-dev && \
apk --no-cache add bash git gmp-dev sudo cmake build-base libpcap-dev leveldb-dev && \
rm -rf /var/cache/apk/*

WORKDIR /src/bls
Expand Down
19 changes: 14 additions & 5 deletions third_party/bls-signatures/build.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
#!/bin/bash

SCRIPT_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
SCRIPT_PATH="$(realpath "$(dirname "$0")")"

SRC_PATH="${SCRIPT_PATH}/src"
BUILD_PATH="${SCRIPT_PATH}/build"
BLS_SM_PATH="third_party/bls-signatures/src"
BLS_SM_PATH="${SRC_PATH}"
BLS_GIT_REPO="https://github.com/dashpay/bls-signatures.git"
BLS_GIT_BRANCH=${BLS_GIT_BRANCH:-"1.2.6"}

set -e

if ! git submodule update --init "${BLS_SM_PATH}" ; then
pushd "${SCRIPT_PATH}"

if ! git submodule update --init "${BLS_SM_PATH}"; then
echo "It looks like this source code is not tracked by git."
echo "As a fallback scenario we will fetch \"${BLS_GIT_BRANCH}\" branch \"${BLS_GIT_REPO}\" library."
echo "We would recommend to clone of this project rather than using a release archive."
rm -r "${BLS_SM_PATH}" || true
rm -r "${BLS_SM_PATH}" || true
git clone --single-branch --branch "${BLS_GIT_BRANCH}" "${BLS_GIT_REPO}" "${BLS_SM_PATH}"
fi

# Create folders for source and build data
mkdir -p "${BUILD_PATH}"

# Configurate the library build
cmake -B "${BUILD_PATH}" -S "${SRC_PATH}"
cmake \
-D BUILD_BLS_PYTHON_BINDINGS=OFF \
-D BUILD_BLS_TESTS=OFF \
-D BUILD_BLS_BENCHMARKS=OFF \
-B "${BUILD_PATH}" -S "${SRC_PATH}"

# Build the library
cmake --build "${BUILD_PATH}" -- -j 6

mkdir -p "${BUILD_PATH}/src/bls-dash"
cp -r ${SRC_PATH}/src/* "${BUILD_PATH}/src/bls-dash"

popd

exit 0
16 changes: 13 additions & 3 deletions third_party/bls-signatures/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@

set -e

SCRIPT_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
SCRIPT_PATH="$(realpath "$(dirname "$0")")"
BUILD_PATH="$SCRIPT_PATH/build"

if [ ! -d $BUILD_PATH ]; then
if [ "$UID" -eq "0" ]; then
DESTDIR=${DESTDIR:-"/usr/local"}
else
DESTDIR=${DESTDIR:-"${HOME}/.local"}
fi

if [ ! -d "$BUILD_PATH" ]; then
echo "$BUILD_PATH doesn't exist. Run \"make build-bls\" first." >/dev/stderr
exit 1
fi

pushd "${SCRIPT_PATH}"

# Install the library
cmake -P $BUILD_PATH/cmake_install.cmake
cmake -D CMAKE_INSTALL_PREFIX="${DESTDIR}" -P "$BUILD_PATH/cmake_install.cmake"

popd

exit 0

0 comments on commit 78b3c1f

Please sign in to comment.