From d57ead75f690600f2351508e2bfe15a328760b99 Mon Sep 17 00:00:00 2001 From: Koki Shinjo Date: Fri, 13 Oct 2023 10:06:17 +0900 Subject: [PATCH] [cross] adaptive job number --- jsk_unitree_robot/cross/build_ros1.sh | 9 +++++++-- jsk_unitree_robot/cross/build_ros1_dependencies.sh | 11 +++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/jsk_unitree_robot/cross/build_ros1.sh b/jsk_unitree_robot/cross/build_ros1.sh index 27d52d2f32..4779c1ecf3 100755 --- a/jsk_unitree_robot/cross/build_ros1.sh +++ b/jsk_unitree_robot/cross/build_ros1.sh @@ -1,7 +1,12 @@ #!/bin/bash -# From https://qiita.com/ymdymd/items/312c9f554d4ffb1f8dc6 -JOBS=$(($(grep cpu.cores /proc/cpuinfo | sort -u | sed 's/[^0-9]//g') + 1)) +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + JOBS=$(cat /proc/cpuinfo | grep "processor" | wc -l) +elif [[ "$OSTYPE" == "darwin"* ]]; then + JOBS=$(sysctl -n hw.logicalcpu) +else + JOBS=8 +fi TARGET_MACHINE="${TARGET_MACHINE:-arm64v8}" HOST_INSTALL_ROOT="${BASE_ROOT:-${PWD}}/"${TARGET_MACHINE}_System diff --git a/jsk_unitree_robot/cross/build_ros1_dependencies.sh b/jsk_unitree_robot/cross/build_ros1_dependencies.sh index f250b7c824..097fbe89d4 100755 --- a/jsk_unitree_robot/cross/build_ros1_dependencies.sh +++ b/jsk_unitree_robot/cross/build_ros1_dependencies.sh @@ -1,7 +1,14 @@ #!/bin/bash -# From https://qiita.com/ymdymd/items/312c9f554d4ffb1f8dc6 -JOBS=$(($(grep cpu.cores /proc/cpuinfo | sort -u | sed 's/[^0-9]//g') + 1)) +IMAGE_NAME="${IMAGE_NAME:-ros1-unitree}" + +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + JOBS=$(cat /proc/cpuinfo | grep "processor" | wc -l) +elif [[ "$OSTYPE" == "darwin"* ]]; then + JOBS=$(sysctl -n hw.logicalcpu) +else + JOBS=8 +fi TARGET_MACHINE="${TARGET_MACHINE:-arm64v8}" HOST_INSTALL_ROOT="${BASE_ROOT:-${PWD}}/"${TARGET_MACHINE}_System