worflow: nproc doesn't exist on mac

This commit is contained in:
2024-10-19 13:10:17 -04:00
parent 06f82b7328
commit 6c20c3ed39
2 changed files with 20 additions and 9 deletions

View File

@@ -34,13 +34,6 @@ jobs:
brew install bash brew install bash
echo "Bash version: $(bash --version)" echo "Bash version: $(bash --version)"
if command -v nproc &> /dev/null; then
echo "nproc is installed. Number of processors: $(nproc)"
else
echo "Error: nproc installation failed"
exit 1
fi
- name: Run build script - name: Run build script
run: | run: |
if [ -f "./scripts/build_sokol_demo.sh" ]; then if [ -f "./scripts/build_sokol_demo.sh" ]; then

View File

@@ -19,8 +19,26 @@ if [ -f "$path_system_details" ]; then
CoreCount_Physical=$(grep "PhysicalCores" "$path_system_details" | cut -d'=' -f2) CoreCount_Physical=$(grep "PhysicalCores" "$path_system_details" | cut -d'=' -f2)
CoreCount_Logical=$(grep "LogicalCores" "$path_system_details" | cut -d'=' -f2) CoreCount_Logical=$(grep "LogicalCores" "$path_system_details" | cut -d'=' -f2)
else else
CoreCount_Physical=$(nproc --all) # Detect the operating system
CoreCount_Logical=$(nproc) OS=$(uname -s)
case "$OS" in
Darwin*)
# macOS-specific commands
CoreCount_Physical=$(sysctl -n hw.physicalcpu)
CoreCount_Logical=$(sysctl -n hw.logicalcpu)
;;
Linux*)
# Linux-specific commands
CoreCount_Physical=$(nproc --all)
CoreCount_Logical=$(nproc)
;;
*)
echo "Unsupported operating system: $OS"
CoreCount_Physical=1
CoreCount_Logical=1
;;
esac
echo "[CPU]" > "$path_system_details" echo "[CPU]" > "$path_system_details"
echo "PhysicalCores=$CoreCount_Physical" >> "$path_system_details" echo "PhysicalCores=$CoreCount_Physical" >> "$path_system_details"