Skip to content

Commit

Permalink
fix-apple-m1-support
Browse files Browse the repository at this point in the history
  • Loading branch information
awesome-doge committed May 28, 2022
1 parent 31e2836 commit a0db419
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ mydir=$(pwd)
# На OSX нет такой директории по-умолчанию, поэтому создаем...
SOURCES_DIR=/usr/src
BIN_DIR=/usr/bin
if [ "$OSTYPE" == "darwin"* ]; then
if [[ "$OSTYPE" =~ darwin.* ]]; then
SOURCES_DIR=/usr/local/src
BIN_DIR=/usr/local/bin
mkdir -p ${SOURCES_DIR}
Expand Down
32 changes: 23 additions & 9 deletions scripts/toninstaller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ENDC='\033[0m'
# На OSX нет такой директории по-умолчанию, поэтому создаем...
SOURCES_DIR=/usr/src
BIN_DIR=/usr/bin
if [ "$OSTYPE" == "darwin"* ]; then
if [[ "$OSTYPE" =~ darwin.* ]]; then
SOURCES_DIR=/usr/local/src
BIN_DIR=/usr/local/bin
mkdir -p $SOURCES_DIR
Expand Down Expand Up @@ -56,7 +56,7 @@ if [ "$OSTYPE" == "linux-gnu" ]; then
echo "Please refer to https://github.com/ton-blockchain/mytonctrl for setup information."
exit 1
fi
elif [ "$OSTYPE" == "darwin"* ]; then
elif [[ "$OSTYPE" =~ darwin.* ]]; then
echo "Mac OS (Darwin) detected."
if [ ! which brew >/dev/null 2>&1 ]; then
$BIN_DIR/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Expand Down Expand Up @@ -98,7 +98,7 @@ mkdir $BIN_DIR/ton
cd $BIN_DIR/ton

# Подготовиться к компиляции
if [ "$OSTYPE" == "darwin"* ]; then
if [[ "$OSTYPE" =~ darwin.* ]]; then
export CMAKE_C_COMPILER=$(which clang)
export CMAKE_CXX_COMPILER=$(which clang++)
export CCACHE_DISABLE=1
Expand All @@ -109,16 +109,30 @@ else
fi

# Подготовиться к компиляции
cmake -DCMAKE_BUILD_TYPE=Release $SOURCES_DIR/ton
if [[ "$OSTYPE" =~ darwin.* ]]; then
if [[ $(uname -p) == 'arm' ]]; then
echo M1
CC="clang -mcpu=apple-a14" CXX="clang++ -mcpu=apple-a14" cmake $SOURCES_DIR/ton -DCMAKE_BUILD_TYPE=Release -DTON_ARCH= -Wno-dev
else
cmake -DCMAKE_BUILD_TYPE=Release $SOURCES_DIR/ton
fi
else
cmake -DCMAKE_BUILD_TYPE=Release $SOURCES_DIR/ton
fi

# Компилируем из исходников
echo -e "${COLOR}[4/6]${ENDC} Source Compilation"
memory=$(cat /proc/meminfo | grep MemAvailable | awk '{print $2}')
let "cpuNumber = memory / 2100000"
if [ ${cpuNumber} == 0 ]; then
echo "Warning! insufficient RAM"
cpuNumber=1
if [[ "$OSTYPE" =~ darwin.* ]]; then
cpuNumber=$(sysctl -n hw.logicalcpu)
else
memory=$(cat /proc/meminfo | grep MemAvailable | awk '{print $2}')
let "cpuNumber = memory / 2100000"
if [ ${cpuNumber} == 0 ]; then
echo "Warning! insufficient RAM"
cpuNumber=1
fi
fi

echo "use ${cpuNumber} cpus"
make -j ${cpuNumber} fift validator-engine lite-client pow-miner validator-engine-console generate-random-id dht-server

Expand Down

0 comments on commit a0db419

Please sign in to comment.