github.com/igggame/nebulas-go@v2.1.0+incompatible/nbre/build.sh (about) 1 # Copyright (C) 2019 go-nebulas authors 2 # 3 # This file is part of the go-nebulas library. 4 # 5 # the go-nebulas library is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation, either version 3 of the License, or 8 # (at your option) any later version. 9 10 # the go-nebulas library is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with the go-nebulas library. If not, see <http://www.gnu.org/licenses/>. 17 18 #!/bin/bash 19 20 CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" 21 OS="$(uname -s)" 22 23 if [ "$OS" = "Darwin" ]; then 24 LOGICAL_CPU=$(sysctl -n hw.ncpu) 25 else 26 LOGICAL_CPU=$(cat /proc/cpuinfo |grep "processor"|wc -l) 27 fi 28 PARALLEL=$LOGICAL_CPU 29 30 build_with_cmake() { 31 source $CUR_DIR/env.set.sh 32 mkdir -p $CUR_DIR/build 33 pushd $CUR_DIR/build 34 if [ "$1" = "debug" ]; then 35 cmake .. 36 else 37 cmake -DRelease=1 .. 38 fi 39 make -j$PARALLEL && make install 40 popd 41 } 42 43 clean() { 44 rm -rf $CUR_DIR/build 45 } 46 47 48 if [ "$1" = "debug" ]; then 49 build_with_cmake debug 50 elif [ "$1" = "clear" ]; then 51 clean 52 build_with_cmake 53 else 54 build_with_cmake 55 fi