Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update #232 #249

Merged
merged 3 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ charts/
# Prevent copying scripts that are unused in docker
scripts/
!scripts/test.sh
!scripts/configure.sh
!scripts/install-build-tools.sh
!scripts/setup-dependencies.sh
!scripts/test-transaction.sh
!scripts/wait-for-it.sh

Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Configure
run: sudo ./scripts/configure.sh
- name: Setup Build Env
run: sudo ./scripts/install-build-tools.sh
- name: Setup Local Dependencies
run: ./scripts/setup-dependencies.sh
- name: Build
run: scripts/build.sh
lint:
Expand All @@ -36,8 +38,10 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Configure
run: sudo ./scripts/configure.sh
- name: Setup Build Env
run: sudo ./scripts/install-build-tools.sh
- name: Setup Local Dependencies
run: ./scripts/setup-dependencies.sh
- name: Build
run: scripts/build.sh
- name: Lint
Expand All @@ -50,8 +54,10 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Configure
run: sudo ./scripts/configure.sh
- name: Setup Build Env
run: sudo ./scripts/install-build-tools.sh
- name: Setup Local Dependencies
run: ./scripts/setup-dependencies.sh
- name: Build
run: scripts/build.sh
- name: Run Unit Tests
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ doxygen_generated
# Default build folder
build/

# Default dependency installation folder
prefix/

# 3rd party generated files
3rdparty/secp256k1_genctx
3rdparty/src/ecmult_static_context.h
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")

include_directories(3rdparty 3rdparty/secp256k1/include /usr/lib /usr/local/lib /usr/local/include /opt/homebrew/include)

if(DEFINED CMAKE_PREFIX_PATH)
include_directories(SYSTEM "${CMAKE_PREFIX_PATH}/include")
endif()

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-fprofile-arcs -ftest-coverage)
endif()
Expand Down
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ ENV BUILD_RELEASE 1

RUN mkdir -p /opt/tx-processor/scripts

COPY scripts/configure.sh /opt/tx-processor/scripts/configure.sh
COPY scripts/install-build-tools.sh /opt/tx-processor/scripts/install-build-tools.sh
COPY scripts/setup-dependencies.sh /opt/tx-processor/scripts/setup-dependencies.sh

# Set working directory
WORKDIR /opt/tx-processor

RUN scripts/configure.sh
RUN scripts/install-build-tools.sh
RUN scripts/setup-dependencies.sh

# Create Build Image
FROM $BASE_IMAGE AS builder
Expand All @@ -30,7 +32,7 @@ COPY . .
# Build binaries
RUN mkdir build && \
cd build && \
cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} .. && \
cmake -DCMAKE_PREFIX_PATH="prefix" -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} .. && \
make -j$(nproc)

# Create 2PC Deployment Image
Expand Down
31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,33 @@ If you want to dive straight in, take a look at our issue tracker's list of [goo
1. Clone the repository (including submodules)
- `git clone --recurse-submodules https://github.com/mit-dci/opencbdc-tx`

# Build
# Setup the build envirnoment

Use these directions if you want to build the source on your machine.
If you just want to run the system, see "Run the Code" below.

1. Install the necessary libraries and resources
```terminal
# ./scripts/configure.sh
```
1. Setup the build-environment.
Note that this script is just a convenience to install system-wide dependencies we expect.
As a result, it uses the system package manager, requires `sudo`, and should only be run **once**.
```console
# ./scripts/install-build-tools.sh
```
1. Setup project dependencies
This script builds and installs a local copy of several build-dependencies which are not widely packaged.
Because it installs to a local, configurable prefix (defaulting to `./prefix`), it does not need root permissions to run.
Furthermore, it should always be safe to delete `prefix` and rerun this script.
```console
$ ./scripts/setup-dependencies.sh
```
1. Run the build
```terminal
# ./scripts/build.sh
```
```console
$ ./scripts/build.sh
```

## macOS
Note that if you have not already installed the xcode cli tools you will need to:

```terminal
```console
# xcode-select --install
```
# Run the Code
Expand All @@ -100,11 +109,11 @@ See the [PArSEC User Guide](docs/parsec_user_guide.md)
Running Unit & Integration Tests

1. Build all docker images
```terminal
```console
$ ./scripts/build-docker.sh
```
1. Run Unit & Integration Tests
```terminal
```console
$ docker run -ti opencbdc-tx-builder ./scripts/test.sh
```

Expand Down
7 changes: 5 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@ set -e

echo "Building..."

# see PREFIX in ./scripts/configure.sh
PREFIX="$(cd "$(dirname "$0")"/.. && pwd)/prefix"

if [ -z ${BUILD_DIR+x} ]; then
export BUILD_DIR=build
fi

mkdir -p $BUILD_DIR
cd $BUILD_DIR

CMAKE_FLAGS=""
CMAKE_FLAGS=-DCMAKE_PREFIX_PATH="${PREFIX}"
CPUS=1
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
CPUS=$(grep -c ^processor /proc/cpuinfo)
elif [[ "$OSTYPE" == "darwin"* ]]; then
CPUS=$(sysctl -n hw.ncpu)
XCODE_CMDLINE_DIR=$(xcode-select -p)
CMAKE_FLAGS+="-DCMAKE_C_COMPILER=${XCODE_CMDLINE_DIR}/usr/bin/clang -DCMAKE_CXX_COMPILER=${XCODE_CMDLINE_DIR}/usr/bin/clang++ -DCMAKE_CXX_FLAGS=-isystem\ /usr/local/include -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
CMAKE_FLAGS+=" -DCMAKE_C_COMPILER=${XCODE_CMDLINE_DIR}/usr/bin/clang -DCMAKE_CXX_COMPILER=${XCODE_CMDLINE_DIR}/usr/bin/clang++ -DCMAKE_CXX_FLAGS=-isystem\ /usr/local/include -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
fi

CMAKE_BUILD_TYPE="Debug"
Expand Down
48 changes: 48 additions & 0 deletions scripts/install-build-tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

echo "Setting up build environment..."

green="\033[0;32m"
cyan="\033[0;36m"
end="\033[0m"

set -e

SUDO=''
if (( $EUID != 0 )); then
echo -e "non-root user, sudo required"
SUDO='sudo'
fi

if [[ "$OSTYPE" == "darwin"* ]]; then
CPUS=$(sysctl -n hw.ncpu)
# ensure development environment is set correctly for clang
$SUDO xcode-select -switch /Library/Developer/CommandLineTools
brew install llvm@14 googletest google-benchmark lcov make wget cmake curl
CLANG_TIDY=/usr/local/bin/clang-tidy
if [ ! -L "$CLANG_TIDY" ]; then
$SUDO ln -s $(brew --prefix)/opt/llvm@14/bin/clang-tidy /usr/local/bin/clang-tidy
fi
GMAKE=/usr/local/bin/gmake
if [ ! -L "$GMAKE" ]; then
$SUDO ln -s $(xcode-select -p)/usr/bin/gnumake /usr/local/bin/gmake
fi
fi

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
$SUDO apt update
$SUDO apt install -y build-essential wget cmake libgtest-dev libbenchmark-dev lcov git software-properties-common rsync unzip

wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | $SUDO apt-key add -
$SUDO add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main"
$SUDO apt install -y clang-format-14 clang-tidy-14
$SUDO ln -s -f $(which clang-format-14) /usr/local/bin/clang-format
$SUDO ln -s -f $(which clang-tidy-14) /usr/local/bin/clang-tidy
fi

PYTHON_TIDY=/usr/local/bin/run-clang-tidy.py
if [ ! -f "${PYTHON_TIDY}" ]; then
echo -e "${green}Copying run-clang-tidy to /usr/local/bin${end}"
wget https://raw.githubusercontent.com/llvm/llvm-project/e837ce2a32369b2e9e8e5d60270c072c7dd63827/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
$SUDO mv run-clang-tidy.py /usr/local/bin
fi
Loading
Loading