Introduce universal build script
This commit is contained in:
parent
6280a95b27
commit
2a84f83f66
3 changed files with 91 additions and 3 deletions
8
.github/workflows/unit_tests.yml
vendored
8
.github/workflows/unit_tests.yml
vendored
|
@ -40,7 +40,7 @@ jobs:
|
|||
run: ci/prepare/macos/prepare.sh
|
||||
|
||||
- name: Build Tests
|
||||
run: ci/build-ci.sh "/tmp/qt/lib/cmake/Qt5";
|
||||
run: ci/build.sh
|
||||
|
||||
- name: Save Build Cache
|
||||
# Only save build cache from develop to avoid polluting it by other branches / PRs
|
||||
|
@ -100,7 +100,7 @@ jobs:
|
|||
run: sudo -E ci/prepare/linux/prepare.sh
|
||||
|
||||
- name: Build Tests
|
||||
run: docker run -e TEST_USE_ROCKSDB -e RELEASE -v ${PWD}:/workspace nanocurrency/nano-env:${{ matrix.COMPILER }} /bin/bash -c "cd /workspace && ./ci/build-ci.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5"
|
||||
run: ci/build.sh
|
||||
|
||||
- name: Save Build Cache
|
||||
# Only save build cache from develop to avoid polluting it by other branches / PRs
|
||||
|
@ -160,7 +160,9 @@ jobs:
|
|||
run: ci/prepare/windows/prepare.ps1
|
||||
|
||||
- name: Build Tests
|
||||
run: ci/actions/windows/build.ps1
|
||||
id: build
|
||||
run: ci/build.sh
|
||||
shell: bash
|
||||
|
||||
- name: Save Build Cache
|
||||
# only save build cache from develop to avoid polluting it by other branches / PRs
|
||||
|
|
|
@ -67,6 +67,8 @@ endif()
|
|||
|
||||
# Create all libraries and executables in the root binary dir
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
|
||||
|
||||
set(NANO_GUI
|
||||
OFF
|
||||
|
|
84
ci/build.sh
Executable file
84
ci/build.sh
Executable file
|
@ -0,0 +1,84 @@
|
|||
#!/bin/bash
|
||||
set -euox pipefail
|
||||
|
||||
NODE_SRC=${1:-${PWD}}
|
||||
|
||||
OS=$(uname)
|
||||
BUILD_TYPE=${NANO_BUILD_TYPE:-Debug}
|
||||
BUILD_TARGET=build_tests
|
||||
|
||||
if [[ "${RELEASE:-false}" == "true" ]]; then
|
||||
BUILD_TYPE="RelWithDebInfo"
|
||||
fi
|
||||
|
||||
if [[ ${NANO_ASAN_INT:-0} -eq 1 ]]; then
|
||||
SANITIZERS="-DNANO_ASAN_INT=ON"
|
||||
fi
|
||||
if [[ ${NANO_ASAN:-0} -eq 1 ]]; then
|
||||
SANITIZERS="-DNANO_ASAN=ON"
|
||||
fi
|
||||
if [[ ${NANO_TSAN:-0} -eq 1 ]]; then
|
||||
SANITIZERS="-DNANO_TSAN=ON"
|
||||
fi
|
||||
if [[ ${NANO_COVERAGE:-0} -eq 1 ]]; then
|
||||
SANITIZERS="-DCOVERAGE=ON"
|
||||
fi
|
||||
|
||||
if [[ "$OS" == 'Linux' ]]; then
|
||||
BACKTRACE="-DNANO_STACKTRACE_BACKTRACE=ON"
|
||||
|
||||
if [[ "$COMPILER" == 'clang' ]]; then
|
||||
BACKTRACE="${BACKTRACE} -DNANO_BACKTRACE_INCLUDE=</tmp/backtrace.h>"
|
||||
fi
|
||||
else
|
||||
BACKTRACE=""
|
||||
fi
|
||||
|
||||
mkdir -p build
|
||||
pushd build
|
||||
|
||||
cmake \
|
||||
-DACTIVE_NETWORK=nano_dev_network \
|
||||
-DNANO_TEST=ON \
|
||||
-DNANO_GUI=ON \
|
||||
-DPORTABLE=ON \
|
||||
-DNANO_WARN_TO_ERR=ON \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCI_TEST=ON \
|
||||
-DQt5_DIR=${NANO_QT_DIR:-} \
|
||||
${BACKTRACE:-} \
|
||||
${SANITIZERS:-} \
|
||||
${NODE_SRC}
|
||||
|
||||
number_of_processors() {
|
||||
case "$(uname -s)" in
|
||||
Linux*)
|
||||
nproc
|
||||
;;
|
||||
Darwin*)
|
||||
sysctl -n hw.ncpu
|
||||
;;
|
||||
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
||||
echo "${NUMBER_OF_PROCESSORS}"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown OS"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
parallel_build_flag() {
|
||||
case "$(uname -s)" in
|
||||
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
||||
echo "-- -m"
|
||||
;;
|
||||
*)
|
||||
echo "--parallel $(number_of_processors)"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
cmake --build ${PWD} --target ${BUILD_TARGET} $(parallel_build_flag)
|
||||
|
||||
popd
|
Loading…
Add table
Add a link
Reference in a new issue