File indexing completed on 2024-06-23 08:57:40

0001 #!/bin/sh
0002 set -e
0003 set -x
0004 
0005 # script for building ktechlab for development/testing
0006 # currently it (1) builds ktechlab with gcc-5 and (2) enables address sanitizer
0007 
0008 #SCRIPTDIR=$(dirname $(readlink -f "$0"))
0009 
0010 case "$(uname -s)" in
0011 
0012    Darwin)
0013      echo 'Mac OS X'
0014      readlinkf(){ perl -MCwd -e 'print Cwd::abs_path shift' "$1";}
0015      SCRIPTDIR=$(dirname $(readlinkf "$0"))
0016      ;;
0017 
0018    # taken from: https://en.wikipedia.org/wiki/Uname
0019    Linux|*BSD)
0020      echo 'Linux'
0021      SCRIPTDIR=$(dirname $(readlink -f "$0"))
0022      ;;
0023 
0024    CYGWIN*|MINGW32*|MSYS*)
0025      echo 'MS Windows'
0026      SCRIPTDIR=$(dirname $(readlink -f "$0")) # untested
0027      ;;
0028 
0029    # Add here more strings to compare
0030    #
0031 
0032    *)
0033      echo 'other OS, please notify the developers'
0034      SCRIPTDIR=$(dirname $(readlink -f "$0")) # untested
0035      ;;
0036 esac
0037 
0038 LOGFILE="$SCRIPTDIR/build-developer.log"
0039 
0040 log_cmd() {
0041     "$@" 2>&1  | tee -a "$LOGFILE"
0042 }
0043 
0044 log_cmd echo "== starting build at $( date ) == "
0045 
0046 (
0047     mkdir -p "$SCRIPTDIR/build-developer/"
0048     cd "$SCRIPTDIR/build-developer/"
0049 
0050     if [ -f "$SCRIPTDIR/build-developer/CMakeCache.txt" ] ; then
0051         echo "buildsystem generated, using it"
0052     else
0053         echo "buildsystem being generated"
0054 
0055         log_cmd cmake   -DCMAKE_INSTALL_PREFIX="$SCRIPTDIR/inst-developer/" \
0056                         -DKTECHLAB_DEVELOPER_BUILD=true \
0057             "$SCRIPTDIR"
0058 
0059         # -DCMAKE_C_COMPILER=gcc-5 -DCMAKE_CXX_COMPILER=g++-5 \ # 2017.09.18 - deprecated
0060 
0061     fi
0062 
0063 #     # bug in buildsystem: generated header files are not always built; work it around
0064 # 
0065 #     UI_HEADERS_TO_GENERATE="
0066 #         ./src/gui/ui_contexthelpwidget.h
0067 #         ./src/gui/ui_generaloptionswidget.h
0068 #         ./src/gui/ui_linkeroptionswidget.h
0069 #         ./src/gui/ui_processingoptionswidget.h
0070 #         ./src/gui/ui_programmerwidget.h
0071 #         ./src/gui/ui_gpasmsettingswidget.h
0072 #         ./src/gui/ui_newprojectwidget.h
0073 #         ./src/gui/ui_newfilewidget.h
0074 #         ./src/gui/ui_outputmethodwidget.h
0075 #         ./src/gui/ui_scopescreenwidget.h
0076 #         ./src/gui/ui_createsubprojectwidget.h
0077 #         ./src/gui/ui_asmformattingwidget.h
0078 #         ./src/gui/ui_oscilloscopewidget.h
0079 #         ./src/gui/ui_microsettingswidget.h
0080 #         ./src/gui/ui_newpinmappingwidget.h
0081 #         ./src/gui/ui_logicwidget.h
0082 #         ./src/gui/ui_sdccoptionswidget.h
0083 #         ./src/gui/ui_picprogrammerconfigwidget.h
0084 #         ./src/gui/ui_gplinksettingswidget.h
0085 #         "
0086 #     for HEADER in $UI_HEADERS_TO_GENERATE ; do
0087 #         make -f src/gui/CMakeFiles/gui.dir/build.make "$HEADER"
0088 #     done
0089 # 
0090 #     # work around the bug: core directory has to be built first
0091 #     # ./src/core/ktlconfig.h
0092 #     log_cmd make -C "$SCRIPTDIR/build-developer/src/core"
0093 
0094     log_cmd make install -j"$( nproc )"
0095 )