diff --git a/run-android.sh b/run-android.sh index cb0c340382..feaf0d91d1 100755 --- a/run-android.sh +++ b/run-android.sh @@ -1,5 +1,5 @@ #!/bin/bash -source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/universal_sed.sh" +source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/functions.sh" # Get the current git branch get_current_branch() { if git rev-parse --git-dir > /dev/null 2>&1; then diff --git a/scripts/android/build_monero_all.sh b/scripts/android/build_monero_all.sh index b848e11066..1c28d1cd12 100755 --- a/scripts/android/build_monero_all.sh +++ b/scripts/android/build_monero_all.sh @@ -1,4 +1,5 @@ #!/bin/bash +source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/functions.sh" # Usage: env USE_DOCKER= ./build_all.sh @@ -6,8 +7,6 @@ set -x -e cd "$(dirname "$0")" -NPROC="-j$(nproc)" - ../prepare_moneroc.sh for COIN in monero wownero; @@ -19,7 +18,7 @@ do then echo "file exist, not building monero_c for ${COIN}/$target."; else - ./build_single.sh ${COIN} $target $NPROC + ./build_single.sh ${COIN} $target -j$MAKE_JOB_COUNT unxz -f ../monero_c/release/${COIN}/${target}_libwallet2_api_c.so.xz fi done diff --git a/scripts/android/inject_app_details.sh b/scripts/android/inject_app_details.sh index 7b0d747982..7f0858b18d 100755 --- a/scripts/android/inject_app_details.sh +++ b/scripts/android/inject_app_details.sh @@ -1,5 +1,5 @@ #!/bin/bash -source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/universal_sed.sh" +source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/functions.sh" if [ -z "$APP_ANDROID_TYPE" ]; then echo "Please set APP_ANDROID_TYPE" exit 1 diff --git a/scripts/functions.sh b/scripts/functions.sh new file mode 100644 index 0000000000..3b613da228 --- /dev/null +++ b/scripts/functions.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +detect_sed() { + if sed --version 2>/dev/null | grep -q "GNU"; then + SED_TYPE="GNU" + else + SED_TYPE="BSD" + fi +} + +universal_sed() { + local expression=$1 + local file=$2 + + if [[ "$SED_TYPE" == "GNU" ]]; then + sed -i "$expression" "$file" + else + sed -i '' "$expression" "$file" + fi +} + +detect_sed + +if [[ "$(uname)" == "Linux" ]]; +then + export MAKE_JOB_COUNT="$(expr $(printf '%s\n%s' $(( $(grep MemTotal: /proc/meminfo | cut -d: -f2 | cut -dk -f1) * 4 / (1048576 * 9) )) $(nproc) | sort -n | head -n1) '|' 1)" +elif [[ "$(uname)" == "Darwin" ]]; +then + export MAKE_JOB_COUNT="(expr $(printf '%s\n%s' $(( $(sysctl -n hw.memsize) * 4 / (1073741824 * 9) )) $(sysctl -n hw.logicalcpu) | sort -n | head -n1) '|' 1)" +else + # Assume windows eh? + export MAKE_JOB_COUNT="$(expr $(printf '%s\n%s' $(( $(grep MemTotal: /proc/meminfo | cut -d: -f2 | cut -dk -f1) * 4 / (1048576 * 9) )) $(nproc) | sort -n | head -n1) '|' 1)" +fi \ No newline at end of file diff --git a/scripts/ios/app_config.sh b/scripts/ios/app_config.sh index 4af57bbd56..35bbe7b74b 100755 --- a/scripts/ios/app_config.sh +++ b/scripts/ios/app_config.sh @@ -1,5 +1,5 @@ #!/bin/bash -source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/universal_sed.sh" +source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/functions.sh" set -x -e MONERO_COM="monero.com" CAKEWALLET="cakewallet" diff --git a/scripts/ios/build_monero_all.sh b/scripts/ios/build_monero_all.sh index e6c291898d..79a3c61f8e 100755 --- a/scripts/ios/build_monero_all.sh +++ b/scripts/ios/build_monero_all.sh @@ -1,4 +1,5 @@ #!/bin/sh +source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/functions.sh" . ./config.sh # ./install_missing_headers.sh @@ -12,15 +13,13 @@ set -x -e cd "$(dirname "$0")" -NPROC="-j$(sysctl -n hw.logicalcpu)" - ../prepare_moneroc.sh for COIN in monero wownero zano; do pushd ../monero_c rm -rf external/ios/build - ./build_single.sh ${COIN} aarch64-apple-ios $NPROC + ./build_single.sh ${COIN} aarch64-apple-ios -j$MAKE_JOB_COUNT popd done diff --git a/scripts/linux/app_config.sh b/scripts/linux/app_config.sh index 222808a08f..cbeb9d3462 100755 --- a/scripts/linux/app_config.sh +++ b/scripts/linux/app_config.sh @@ -1,5 +1,5 @@ #!/bin/bash -source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/universal_sed.sh" +source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/functions.sh" CAKEWALLET="cakewallet" DIR=`pwd` diff --git a/scripts/linux/build_monero_all.sh b/scripts/linux/build_monero_all.sh index a2a85000b8..25a6203383 100755 --- a/scripts/linux/build_monero_all.sh +++ b/scripts/linux/build_monero_all.sh @@ -1,11 +1,10 @@ #!/bin/bash +source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/functions.sh" set -x -e cd "$(dirname "$0")" -NPROC="-j$(nproc)" - ../prepare_moneroc.sh for COIN in monero wownero zano; @@ -17,7 +16,7 @@ do then echo "file exist, not building monero_c for ${COIN}/$target."; else - ./build_single.sh ${COIN} $target $NPROC + ./build_single.sh ${COIN} $target -j$MAKE_JOB_COUNT unxz -f ../monero_c/release/${COIN}/${target}_libwallet2_api_c.so.xz fi done diff --git a/scripts/macos/app_config.sh b/scripts/macos/app_config.sh index 5089fe2632..e909bb9a23 100755 --- a/scripts/macos/app_config.sh +++ b/scripts/macos/app_config.sh @@ -1,5 +1,5 @@ #!/bin/bash -source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/universal_sed.sh" +source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/functions.sh" MONERO_COM="monero.com" CAKEWALLET="cakewallet" diff --git a/scripts/macos/gen_common.sh b/scripts/macos/gen_common.sh index d1d40edc94..72ff638b6a 100755 --- a/scripts/macos/gen_common.sh +++ b/scripts/macos/gen_common.sh @@ -1,5 +1,5 @@ #!/bin/sh -source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/universal_sed.sh" +source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/functions.sh" gen_podspec() { ARCH=$1 CW_PLUGIN_DIR="`pwd`/../../cw_monero/macos" diff --git a/scripts/universal_sed.sh b/scripts/universal_sed.sh deleted file mode 100644 index d8a95684e6..0000000000 --- a/scripts/universal_sed.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -detect_sed() { - if sed --version 2>/dev/null | grep -q "GNU"; then - SED_TYPE="GNU" - else - SED_TYPE="BSD" - fi -} - -universal_sed() { - local expression=$1 - local file=$2 - - if [[ "$SED_TYPE" == "GNU" ]]; then - sed -i "$expression" "$file" - else - sed -i '' "$expression" "$file" - fi -} - -detect_sed diff --git a/scripts/windows/build_all.sh b/scripts/windows/build_all.sh index e77f6edb57..90a60dac71 100755 --- a/scripts/windows/build_all.sh +++ b/scripts/windows/build_all.sh @@ -1,4 +1,6 @@ +#!/bin/bash set -x -e +source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/functions.sh" cd "$(dirname "$0")" @@ -16,19 +18,18 @@ pushd ../monero_c set +e command -v sudo && export SUDO=sudo set -e - NPROC="-j$(nproc)" if [[ ! "x$USE_DOCKER" == "x" ]]; then for COIN in monero wownero; do - $SUDO docker run --platform linux/amd64 -v$HOME/.cache/ccache:/root/.ccache -v$PWD:$PWD -w $PWD --rm -it git.mrcyjanek.net/mrcyjanek/debian:buster bash -c "git config --global --add safe.directory '*'; apt update; apt install -y ccache gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 gperf libtinfo5; ./build_single.sh ${COIN} x86_64-w64-mingw32 $NPROC" - # $SUDO docker run --platform linux/amd64 -v$HOME/.cache/ccache:/root/.ccache -v$PWD:$PWD -w $PWD --rm -it git.mrcyjanek.net/mrcyjanek/debian:buster bash -c "git config --global --add safe.directory '*'; apt update; apt install -y ccache gcc-mingw-w64-i686 g++-mingw-w64-i686 gperf libtinfo5; ./build_single.sh ${COIN} i686-w64-mingw32 $NPROC" + $SUDO docker run --platform linux/amd64 -v$HOME/.cache/ccache:/root/.ccache -v$PWD:$PWD -w $PWD --rm -it git.mrcyjanek.net/mrcyjanek/debian:buster bash -c "git config --global --add safe.directory '*'; apt update; apt install -y ccache gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 gperf libtinfo5; ./build_single.sh ${COIN} x86_64-w64-mingw32 -j$MAKE_JOB_COUNT" + # $SUDO docker run --platform linux/amd64 -v$HOME/.cache/ccache:/root/.ccache -v$PWD:$PWD -w $PWD --rm -it git.mrcyjanek.net/mrcyjanek/debian:buster bash -c "git config --global --add safe.directory '*'; apt update; apt install -y ccache gcc-mingw-w64-i686 g++-mingw-w64-i686 gperf libtinfo5; ./build_single.sh ${COIN} i686-w64-mingw32 -j$MAKE_JOB_COUNT" done else for COIN in monero wownero; do - $SUDO ./build_single.sh ${COIN} x86_64-w64-mingw32 $NPROC - # $SUDO ./build_single.sh ${COIN} i686-w64-mingw32 $NPROC + $SUDO ./build_single.sh ${COIN} x86_64-w64-mingw32 -j$MAKE_JOB_COUNT + # $SUDO ./build_single.sh ${COIN} i686-w64-mingw32 -j$MAKE_JOB_COUNT done fi popd