瀏覽代碼

added python3 and clang++ checks in build.sh

Pranav 2 年之前
父節點
當前提交
642810d3b5
共有 1 個文件被更改,包括 26 次插入14 次删除
  1. 26 14
      build.sh

+ 26 - 14
build.sh

@@ -1,14 +1,32 @@
 #!/bin/bash
 
-echo -n "Running prebuild.py... "
+# Check if python3 is installed
+if ! type -P python3 >/dev/null 2>&1; then
+    echo "python3 is required and not installed. Kindly install it."
+    echo "Run: sudo apt install python3"
+    exit 1
+fi
+
+# Check if clang++ is installed
+if ! type -P clang++ >/dev/null 2>&1; then
+    echo "clang++ is required and not installed. Kindly install it."
+    echo "Run: sudo apt-get install libc++-dev libc++abi-dev clang++"
+    exit 1
+fi
+
+echo "Requirements satisfied: python3 and clang++ are installed."
+echo "It takes a moment to finish building."
+echo ""
+echo "> Running prebuild.py... "
+
 python3 prebuild.py
-echo "Done"
 
-echo -n "Finding source files... "
+# echo -n "Finding source files... "
 SRC=$(find src/ -name "*.cpp")
-echo "Done"
+# echo "Done"
+
+echo "> Compiling and linking source files... "
 
-echo -n "Compiling and linking source files... "
 FLAGS="-std=c++17 -O2 -stdlib=libc++ -Wfatal-errors -Iinclude"
 if [[ "$OSTYPE" == "darwin"* ]]; then
     LIB_EXTENSION=".dylib"
@@ -21,19 +39,13 @@ fi
 
 clang++ $FLAGS -o libpocketpy$LIB_EXTENSION $SRC -fPIC -shared -ldl
 
-if [ $? -eq 0 ]; then
-    echo "Library build successful: libpocketpy$LIB_EXTENSION"
-else
-    echo "Library build failed."
-    exit 1
-fi
-
 # compile main.cpp and link to libpocketpy.so
-echo "Compiling main.cpp and linking to libpocketpy$LIB_EXTENSION..."
+echo "> Compiling main.cpp and linking to libpocketpy$LIB_EXTENSION..."
+
 clang++ $FLAGS -o main src2/main.cpp -L. -lpocketpy $LINK_FLAGS
 
 if [ $? -eq 0 ]; then
-    echo "Build completed successfully."
+    echo "Build completed successfully. To use pocketpy, run : ./main"
 else
     echo "Build failed."
     exit 1