Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detect CPU cores count and utilize while building project #88

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ display_help() {

#location of OS details for linux
OS_RELEASE_FILE="/etc/os-release"
CPU_CORE_COUNT=`grep -c ^processor /proc/cpuinfo`
RAM_SIZE=`free -g | grep "Mem:" | awk '{print $2}'`

if [[ $(($RAM_SIZE + 0)) -lt 4 ]]; then
CPU_CORE_COUNT=2
fi
if [[ $(($RAM_SIZE + 0)) -lt 2 ]]; then
CPU_CORE_COUNT=1
fi
echo "RAM size is ${RAM_SIZE} GB, Utilizing threads: ${CPU_CORE_COUNT}"

#check if Raspian is in the file, if not set the install Args to be false
if grep -q "Raspbian" ${OS_RELEASE_FILE}; then
Expand Down Expand Up @@ -185,7 +195,7 @@ else
cd build

#beginning cmake
cmake -DCMAKE_BUILD_TYPE=Release ../
cmake -DCMAKE_BUILD_TYPE=Release -- -j$CPU_CORE_COUNT ../
if [[ $? -eq 0 ]]; then
echo -e Aasdk CMake completed successfully'\n'
else
Expand All @@ -194,7 +204,7 @@ else
fi

#beginning make
make -j2
make -j$CPU_CORE_COUNT

if [[ $? -eq 0 ]]; then
echo -e Aasdk Make completed successfully '\n'
Expand Down Expand Up @@ -260,7 +270,7 @@ if [ $gstreamer = true ]; then

#run cmake
echo Beginning cmake
cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH) -DCMAKE_INSTALL_INCLUDEDIR=include -DQT_VERSION=5 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-std=c++11
cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH) -DCMAKE_INSTALL_INCLUDEDIR=include -DQT_VERSION=5 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-std=c++11 -- -j$CPU_CORE_COUNT

if [[ $? -eq 0 ]]; then
echo -e Make ok'\n'
Expand All @@ -270,7 +280,7 @@ if [ $gstreamer = true ]; then
fi

echo Making Gstreamer
make -j4
make -j$CPU_CORE_COUNT

if [[ $? -eq 0 ]]; then
echo -e Gstreamer make ok'\n'
Expand Down Expand Up @@ -337,7 +347,7 @@ else
cd build

echo Beginning openauto cmake
cmake ${installArgs} -DGST_BUILD=true ../
cmake ${installArgs} -DGST_BUILD=true -- -j$CPU_CORE_COUNT ../
if [[ $? -eq 0 ]]; then
echo -e Openauto CMake OK'\n'
else
Expand All @@ -346,7 +356,7 @@ else
fi

echo Beginning openauto make
make
make -j$CPU_CORE_COUNT
if [[ $? -eq 0 ]]; then
echo -e Openauto make OK'\n'
else
Expand Down Expand Up @@ -386,7 +396,7 @@ else

echo -e Installing dash'\n'
echo Running CMake for dash
cmake ${installArgs} -DGST_BUILD=TRUE ../
cmake ${installArgs} -DGST_BUILD=TRUE -- -j$CPU_CORE_COUNT ../
if [[ $? -eq 0 ]]; then
echo -e Dash CMake OK'\n'
else
Expand All @@ -395,7 +405,7 @@ else
fi

echo Running Dash make
make
make -j$CPU_CORE_COUNT
if [[ $? -eq 0 ]]; then
echo -e Dash make ok, executable can be found ../bin/dash
echo
Expand Down