diff --git a/.gitignore b/.gitignore index 36a9d28..5a85d4d 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ CMakeLists.txt.user nohup.out *.tmp err.txt +/build/b3view diff --git a/build.sh b/build.sh index 25060fc..3ef34cb 100755 --- a/build.sh +++ b/build.sh @@ -2,6 +2,15 @@ if [ -z "$PREFIX" ]; then PREFIX="/usr" fi +if [ -z "$DEBUG" ]; then + DEBUG=false +fi +OPTION1="-O2" +OPTION2="" +if [ "@$DEBUG" = "@true" ]; then + OPTION1="-g" + #OPTION2="-DQT_QML_DEBUG" +fi #IRR_INCDIR= #IRR_LIBDIR= FT2_INCDIR=$PREFIX/include/freetype2 @@ -25,28 +34,17 @@ fi #^ can't find a pc file # gcc -o build/b3view main.cpp Debug.cpp Engine.cpp EventHandler.cpp settings.cpp UserInterface.cpp Utility.cpp View.cpp -I$FT2_INCDIR -# Qmake does the following: -#g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/main.o ../b3view/main.cpp -#g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/Engine.o ../b3view/Engine.cpp -#g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/EventHandler.o ../b3view/EventHandler.cpp -#g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/UserInterface.o ../b3view/UserInterface.cpp -#g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/Debug.o ../b3view/Debug.cpp -#g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/View.o ../b3view/View.cpp -#g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/CGUITTFont.o ../b3view/extlib/CGUITTFont.cpp -#g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/Utility.o ../b3view/Utility.cpp -#g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/settings.o ../b3view/settings.cpp -#g++ -o build/b3view tmp/main.o tmp/Engine.o tmp/EventHandler.o tmp/UserInterface.o tmp/Debug.o tmp/View.o tmp/CGUITTFont.o tmp/Utility.o tmp/settings.o -lIrrlicht -lX11 -lGL -lXxf86vm -lXcursor -lstdc++fs -lfreetype - -# based on the above (some options are unclear): -g++ -c -pipe -g -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/main.o ../b3view/main.cpp -g++ -c -pipe -g -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/Engine.o ../b3view/Engine.cpp -g++ -c -pipe -g -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/EventHandler.o ../b3view/EventHandler.cpp -g++ -c -pipe -g -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/UserInterface.o ../b3view/UserInterface.cpp -g++ -c -pipe -g -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/View.o ../b3view/View.cpp -g++ -c -pipe -g -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/Debug.o ../b3view/Debug.cpp -g++ -c -pipe -g -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/CGUITTFont.o ../b3view/extlib/CGUITTFont.cpp -g++ -c -pipe -g -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/Utility.o ../b3view/Utility.cpp -g++ -c -pipe -g -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/settings.o ../b3view/settings.cpp +# based on qtcreator's build after clean (see contributing.md; some options are unclear): +eche +g++ -c -pipe $OPTION1 -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/main.o ../b3view/main.cpp +g++ -c -pipe $OPTION1 -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/Engine.o ../b3view/Engine.cpp +g++ -c -pipe $OPTION1 -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/EventHandler.o ../b3view/EventHandler.cpp +g++ -c -pipe $OPTION1 -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/UserInterface.o ../b3view/UserInterface.cpp +g++ -c -pipe $OPTION1 -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/View.o ../b3view/View.cpp +g++ -c -pipe $OPTION1 -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/Debug.o ../b3view/Debug.cpp +g++ -c -pipe $OPTION1 -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/CGUITTFont.o ../b3view/extlib/CGUITTFont.cpp +g++ -c -pipe $OPTION1 -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/Utility.o ../b3view/Utility.cpp +g++ -c -pipe $OPTION1 -fPIC -I../b3view -I$FT2_INCDIR -o $OBJDIR/settings.o ../b3view/settings.cpp #-w: suppress warning # -I.: include the current directory (suppresses errors when using include < instead of include " #-pipe: "Use pipes rather than intermediate files." @@ -69,6 +67,15 @@ fi INSTALLED_BIN="$HOME/.local/bin/b3view" if [ -f "$INSTALLED_BIN" ]; then echo "* updating $INSTALLED_BIN..." - rm "$INSTALLED_BIN" - cp -f "$OUT_BIN" "$INSTALLED_BIN" + ./$OUT_BIN + if [ $? -eq 0 ]; then + # if no errors occur, install it + rm "$INSTALLED_BIN" + cp -f "$OUT_BIN" "$INSTALLED_BIN" + if [ $? -eq 0 ]; then + echo "* installed $INSTALLED_BIN successfully." + else + echo "* FAILED to install $INSTALLED_BIN." + fi + fi fi diff --git a/contributing.md b/contributing.md new file mode 100644 index 0000000..7599d31 --- /dev/null +++ b/contributing.md @@ -0,0 +1,50 @@ +# Contributing + + +## Regression Tests + +### Manipulating mesh on failed load +- steps to reproduce + - File, Open, choose a mesh file such as animal_bat.b3d + - File, Open, choose a texture (purposely incorrect input) +- incorrect behaviors: + - manipulating the loaded scene, such as calling remove() + - SEGFAULT +- correct behaviors: + - Do nothing to the current scene. + - Show a message saying that the format is incorrect. + + +## What Qt Creator does +When building after clean, you can see the g++ commands in the "Compiler Output" bottom tab. See Debug and Release sections below. + +### Debug +``` +g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/main.o ../b3view/main.cpp +g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/Engine.o ../b3view/Engine.cpp +g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/EventHandler.o ../b3view/EventHandler.cpp +g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/UserInterface.o ../b3view/UserInterface.cpp +g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/Debug.o ../b3view/Debug.cpp +g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/View.o ../b3view/View.cpp +g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/CGUITTFont.o ../b3view/extlib/CGUITTFont.cpp +g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/Utility.o ../b3view/Utility.cpp +g++ -c -pipe -g -w -fPIC -DQT_QML_DEBUG -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/settings.o ../b3view/settings.cpp +g++ -o build/b3view tmp/main.o tmp/Engine.o tmp/EventHandler.o tmp/UserInterface.o tmp/Debug.o tmp/View.o tmp/CGUITTFont.o tmp/Utility.o tmp/settings.o -lIrrlicht -lX11 -lGL -lXxf86vm -lXcursor -lstdc++fs -lfreetype +``` + +### Release +``` +g++ -c -pipe -O2 -w -fPIC -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/main.o ../b3view/main.cpp +g++ -c -pipe -O2 -w -fPIC -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/Engine.o ../b3view/Engine.cpp +g++ -c -pipe -O2 -w -fPIC -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/EventHandler.o ../b3view/EventHandler.cpp +g++ -c -pipe -O2 -w -fPIC -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/UserInterface.o ../b3view/UserInterface.cpp +g++ -c -pipe -O2 -w -fPIC -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/Debug.o ../b3view/Debug.cpp +g++ -c -pipe -O2 -w -fPIC -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/View.o ../b3view/View.cpp +g++ -c -pipe -O2 -w -fPIC -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/CGUITTFont.o ../b3view/extlib/CGUITTFont.cpp +g++ -c -pipe -O2 -w -fPIC -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/Utility.o ../b3view/Utility.cpp +g++ -c -pipe -O2 -w -fPIC -I../b3view -I. -I/usr/include/freetype2 -I/../lib64/qt5/mkspecs/linux-g++ -o tmp/settings.o ../b3view/settings.cpp +g++ -Wl,-O1 -o build/b3view tmp/main.o tmp/Engine.o tmp/EventHandler.o tmp/UserInterface.o tmp/Debug.o tmp/View.o tmp/CGUITTFont.o tmp/Utility.o tmp/settings.o -lIrrlicht -lX11 -lGL -lXxf86vm -lXcursor -lstdc++fs -lfreetype +``` + + + diff --git a/install.sh b/install.sh index f1cdecf..0b1feb2 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/bin/sh -customDie() { +customExit() { echo echo "ERROR:" echo "$1" @@ -9,10 +9,10 @@ customDie() { exit 1 } -echo "Use the install.sh in build instead. Switching to build/install.sh..." -DIST_DIR=dist +DIST_DIR="`realpath dist`" +BUILD_DIR="build" if [ ! -d "$DIST_DIR" ]; then - customDie "ERROR: There is no $DIST_DIR directory in `pwd`" + customExit "ERROR: There is no $DIST_DIR directory in `pwd`" fi # chmod +x install.sh echo @@ -23,63 +23,70 @@ dest_share_dir="$PREFIX/share" project_unix_name=b3view dest_name=$project_unix_name src_name="$project_unix_name" -src_path="$src_name" -try_dest_bin="$dest_bin_dir/$dest_name" +src_path="$src_name" # detected later (dependent on how built) +dest_bin="$dest_bin_dir/$dest_name" icon_name="b3view.png" -icon_src_path="icons/$icon_name" +icon_src_path="$DIST_DIR/icons/$icon_name" shortcut_name="org.poikilos.b3view.desktop" -shortcut_src_path="applications/$shortcut_name" +shortcut_src_path="$DIST_DIR/applications/$shortcut_name" icons_root=$PREFIX/share/pixmaps applications_path=$PREFIX/share/applications -mimes_path="share/mime/packages" +mimes_path="$DIST_DIR/share/mime/packages" USER_MIMETYPES_DB_PATH=$HOME/.local/share/mime #USER_MIMETYPES_PATH="$USER_MIMETYPES_DB_PATH/packages" SYSTEM_MIMETYPES_DB_PATH=/usr/share/mime #SYSTEM_MIMETYPES_PATH=$SYSTEM_MIMETYPES_DB_PATH/packages MIMETYPES_DB_PATH=$SYSTEM_MIMETYPES_DB_PATH -try_build_path="../../build-$project_unix_name-Desktop-Release/build/" -try_src_path="$try_build_path/$src_name" -if [ ! -f $src_path ]; then - echo "Checking for $src_path...NOT FOUND" - if [ -f "$try_src_path" ]; then - echo "Checking for $src_name in $try_build_path...FOUND" - src_path="$try_src_path" - else - echo "Checking for $src_name in $try_build_path...NOT FOUND" +for try_build_path in "$BUILD_DIR" "../build" "../../build-$project_unix_name-Desktop-Release/build/" +do + try_src_path="$try_build_path/$src_name" + if [ ! -f $src_path ]; then + echo "Checking for $src_path...NOT FOUND" + if [ -f "$try_src_path" ]; then + echo "* Checking for $src_name in $try_build_path...FOUND" + src_path="$try_src_path" + break + else + echo "* Checking for $src_name in $try_build_path...NOT FOUND" + fi fi -fi +done if [ ! -f "$src_path" ]; then - customDie "(Nothing done) missing $src_name (You must build first, such as using Qt Creator)." + customExit "(Nothing done) missing $src_name (You must build first, such as using build.sh or Qt Creator (Release))." else echo "Checking for $src_path...FOUND" echo "* current directory: `pwd`" fi -if [ -d "$try_dest_bin" ]; then - customDie "(Nothing done) '$try_dest_bin' is a directory (should be deleted or a binary file of old version)" +if [ -d "$dest_bin" ]; then + customExit "(Nothing done) '$dest_bin' is a directory (should be deleted or a binary file of old version)" fi PROFILE_ENABLE=false -if [ -f "$try_dest_bin" ]; then - rm -f "$try_dest_bin" - if [ -f "$try_dest_bin" ]; then - echo "WARNING: can't remove old $try_dest_bin, so" +if [ -f "$dest_bin" ]; then + rm -f "$dest_bin" + if [ -f "$dest_bin" ]; then + echo "WARNING: can't remove old $dest_bin, so" PROFILE_ENABLE=true fi fi # echo "* using '$src_path'..." -cp -f "$src_path" "$try_dest_bin" +if [ ! -f "$src_path" ]; then + customExit "* Error: missing $src_path in `pwd`" +fi +cp -f "$src_path" "$dest_bin" -if [ ! -f "$try_dest_bin" ]; then +if [ ! -f "$dest_bin" ]; then PROFILE_ENABLE=true prev_dir="$dest_bin_dir" echo "WARNING: can't write to $prev_dir, so" fi if [ "@$PROFILE_ENABLE" = "@true" ]; then dest_bin_dir="$HOME/.local/bin" - echo "installing to '$dest_bin_dir'." + dest_bin="$dest_bin_dir/$src_name" + echo "installing as '$dest_bin'." echo "Press Ctrl C to cancel..." #sleep 1 #echo "3..." @@ -89,11 +96,20 @@ if [ "@$PROFILE_ENABLE" = "@true" ]; then #echo "1..." #sleep 1 else - echo "Successfully installed as '$try_dest_bin'" + echo "Successfully installed as '$dest_bin'" fi + if [ "@$PROFILE_ENABLE" = "@true" ]; then if [ ! -d "$dest_bin_dir" ]; then mkdir "$dest_bin_dir"; fi - cp -f $src_path "$dest_bin_dir/" + if [ -L "$dest_bin" ]; then + realpath="`readlink "$dest_bin"`" + echo "* \"$dest_bin\" was a symlink to \"$realpath\"" + if [ ! -f "$realpath" ]; then + echo " * removing dangling symlink..." + rm "$dest_bin" + fi + fi + cp -f $src_path "$dest_bin" || customExit "* copying to $dest_bin_dir/ FAILED" icons_root="$HOME/.local/share/icons" applications_path="$HOME/.local/share/applications" MIMETYPES_DB_PATH="$USER_MIMETYPES_DB_PATH" @@ -102,10 +118,11 @@ if [ ! -d "$icons_root" ]; then mkdir -p "$icons_root" fi cp -f "$icon_src_path" "$icons_root/" -if [ -f "$icons_root/$icon_name" ]; then +if [ $? -eq 0 ]; then echo "Successfully copied '$icons_root/$icon_name'" else - echo "FAILED to install '$icons_root/$icon_name'" + echo "FAILED to install '$icons_root/$icon_name' from `pwd`" + exit 1 fi if [ ! -d "$applications_path" ]; then diff --git a/readme.md b/readme.md index c50aa27..bdbad0f 100644 --- a/readme.md +++ b/readme.md @@ -224,16 +224,4 @@ only applies to Visual Studio users.) ## Developer Notes - -### Regression Tests - -#### Manipulating mesh on failed load -- steps to reproduce - - File, Open, choose a mesh file such as animal_bat.b3d - - File, Open, choose a texture (purposely incorrect input) -- incorrect behaviors: - - manipulating the loaded scene, such as calling remove() - - SEGFAULT -- correct behaviors: - - Do nothing to the current scene. - - Show a message saying that the format is incorrect. +See contributing.md