mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
Merge pull request #148 from pranavjainjs/build
Added success/error statements in build.sh
This commit is contained in:
commit
b42ee1b363
44
build.sh
44
build.sh
@ -1,7 +1,33 @@
|
|||||||
python3 prebuild.py
|
#!/bin/bash
|
||||||
SRC=$(find src/ -name "*.cpp")
|
|
||||||
FLAGS="-std=c++17 -O2 -stdlib=libc++ -Wfatal-errors -Iinclude"
|
|
||||||
|
|
||||||
|
# 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 -n "Finding source files... "
|
||||||
|
SRC=$(find src/ -name "*.cpp")
|
||||||
|
# echo "Done"
|
||||||
|
|
||||||
|
echo "> Compiling and linking source files... "
|
||||||
|
|
||||||
|
FLAGS="-std=c++17 -O2 -stdlib=libc++ -Wfatal-errors -Iinclude"
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
LIB_EXTENSION=".dylib"
|
LIB_EXTENSION=".dylib"
|
||||||
FLAGS="$FLAGS -undefined dynamic_lookup"
|
FLAGS="$FLAGS -undefined dynamic_lookup"
|
||||||
@ -10,7 +36,17 @@ else
|
|||||||
LIB_EXTENSION=".so"
|
LIB_EXTENSION=".so"
|
||||||
LINK_FLAGS="-Wl,-rpath=."
|
LINK_FLAGS="-Wl,-rpath=."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
clang++ $FLAGS -o libpocketpy$LIB_EXTENSION $SRC -fPIC -shared -ldl
|
clang++ $FLAGS -o libpocketpy$LIB_EXTENSION $SRC -fPIC -shared -ldl
|
||||||
|
|
||||||
# compile main.cpp and link to libpocketpy.so
|
# compile main.cpp and link to libpocketpy.so
|
||||||
clang++ $FLAGS -o main src2/main.cpp -L. -lpocketpy $LINK_FLAGS
|
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. Type \"./main\" to enter REPL."
|
||||||
|
else
|
||||||
|
echo "Build failed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user