smalltalk
branchjv
changeset 1625 2425cb5d073e
parent 1587 7fcb40139a7c
child 1626 62ac134d4f7f
equal deleted inserted replaced
1608:efa48d08c563 1625:2425cb5d073e
    46     STX_EXE="$STX_TOPDIR/bin/stx-bin"
    46     STX_EXE="$STX_TOPDIR/bin/stx-bin"
    47     export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$STX_LIBDIR/lib"
    47     export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$STX_LIBDIR/lib"
    48 else
    48 else
    49     # Running from build tree
    49     # Running from build tree
    50     STX_LIBDIR="$STX_BIN_DIR"
    50     STX_LIBDIR="$STX_BIN_DIR"
       
    51     if [ -x "$STX_BIN_DIR/../../../../config.guess" ]; then
       
    52 	native_target=$($STX_BIN_DIR/../../../../config.guess)
       
    53         STX_EXE="$STX_BIN_DIR/build/${native_target}/stx"
       
    54         if [ ! -x "$STX_EXE" ]; then
       
    55 	    # Sigh, special hack for i386. I know, I know, this is kind of 
       
    56 	    # dated, but still, I'd like to keep it alive as this is
       
    57             # - as of today - the only working 32bit architecture. 
       
    58 	    if [ "${native_target}" == "x86_64-pc-linux-gnu" ]; then
       
    59 		# Try i386...
       
    60 		STX_EXE="$STX_BIN_DIR/build/i686-pc-linux-gnu/stx"
       
    61 		if [ ! -x "$STX_EXE" ]; then
       
    62                     STX_EXE=stx
       
    63                     export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$(dirname $STX_EXE)"
       
    64                 fi
       
    65 	    else
       
    66                 STX_EXE=stx
       
    67                 export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$(dirname $STX_EXE)"
       
    68             fi
       
    69         fi
       
    70     fi
    51 fi
    71 fi
    52 
    72 
    53 if [ "$STX_LIBDIR" != "" ]
    73 if [ "$STX_LIBDIR" != "" ]
    54 then
    74 then
    55     if [ ! -f $STX_LIBDIR/smalltalk.rc ]
    75     if [ ! -f $STX_LIBDIR/smalltalk.rc ]
    63 # notice: STXLIBDIR is filled in here by install-sh script
    83 # notice: STXLIBDIR is filled in here by install-sh script
    64 if test -z "$STX_LIBDIR"
    84 if test -z "$STX_LIBDIR"
    65 then
    85 then
    66     bindir=`dirname $0`
    86     bindir=`dirname $0`
    67     case "$bindir" in
    87     case "$bindir" in
    68         /* )
    88     /* )
    69         ;;
    89     ;;
    70         .* )
    90     .* )
    71         bindir=`( cd $bindir; pwd ) 2> /dev/null`
    91     bindir=`( cd $bindir; pwd ) 2> /dev/null`
    72         ;;
    92     ;;
    73     esac
    93     esac
    74     if [ -d ${bindir}/../lib ]
    94     if [ -d ${bindir}/../lib ]
    75     then
    95     then
    76         STX_LIBDIR=`cd ${bindir}/../lib ; pwd`
    96     STX_LIBDIR=`cd ${bindir}/../lib ; pwd`
    77     fi
    97     fi
    78 fi
    98 fi
    79 
    99 
    80 if [ -z "$STX_LIBDIR" ]
   100 if [ -z "$STX_LIBDIR" ]
    81 then
   101 then
    82     if [ -d ../lib ]
   102     if [ -d ../lib ]
    83     then
   103     then
    84         STX_LIBDIR=`cd ../lib ; pwd`
   104     STX_LIBDIR=`cd ../lib ; pwd`
    85     fi
   105     fi
    86 fi
   106 fi
    87 if [ ! -d "$STX_LIBDIR" ]
   107 if [ ! -d "$STX_LIBDIR" ]
    88 then
   108 then
    89     if [ -d ../lib ]
   109     if [ -d ../lib ]
    90     then
   110     then
    91         STX_LIBDIR=`cd ../lib ; pwd`
   111     STX_LIBDIR=`cd ../lib ; pwd`
    92     fi
   112     fi
    93 fi
   113 fi
    94 
   114 
    95 if test -z "$STX_TOPDIR"
   115 if test -z "$STX_TOPDIR"
    96 then
   116 then
    97     if [ -f ../lib/smalltalk.rc ]
   117     if [ -f ../lib/smalltalk.rc ]
    98     then
   118     then
    99         STX_TOPDIR=`cd .. ; pwd`
   119     STX_TOPDIR=`cd .. ; pwd`
   100     else
   120     else
   101        if [ -f $STX_LIBDIR/../lib/smalltalk.rc ]
   121        if [ -f $STX_LIBDIR/../lib/smalltalk.rc ]
   102        then
   122        then
   103            STX_TOPDIR=`cd $STX_LIBDIR/.. ; pwd`
   123        STX_TOPDIR=`cd $STX_LIBDIR/.. ; pwd`
   104        else
   124        else
   105            if [ -f $STX_BIN_DIR/smalltalk.rc ]
   125        if [ -f $STX_BIN_DIR/smalltalk.rc ]
   106            then
   126        then
   107               STX_TOPDIR=`cd $STX_BIN_DIR/../.. ; pwd`
   127           STX_TOPDIR=`cd $STX_BIN_DIR/../.. ; pwd`
   108            fi
   128        fi
   109        fi
   129        fi
   110     fi
   130     fi
   111 fi
   131 fi
   112 
   132 
   113 # echo STX_LIBDIR is $STX_LIBDIR
   133 # echo STX_LIBDIR is $STX_LIBDIR
   116 export STX_LIBDIR STX_TOPDIR
   136 export STX_LIBDIR STX_TOPDIR
   117 
   137 
   118 # echo STX is $STX_EXE
   138 # echo STX is $STX_EXE
   119 
   139 
   120 function error() {
   140 function error() {
   121 	echo "$0: $1"	
   141     echo "$0: $1"   
   122 	exit 1
   142     exit 1
   123 }
   143 }
   124 
   144 
   125 function usage() {
   145 function usage() {
   126 cat <<USAGE_END
   146 cat <<USAGE_END
   127 usage: $(basename $0) <args to launcher script> <args to VM> <args to startup classes>
   147 usage: $(basename $0) <args to launcher script> <args to VM> <args to startup classes>
   132    --ldd .................. show which shared libraries are used
   152    --ldd .................. show which shared libraries are used
   133    --vdb .................. run with Visual / VM Debugger
   153    --vdb .................. run with Visual / VM Debugger
   134    --gdb .................. run with gdb (type r in debugger to start)   
   154    --gdb .................. run with gdb (type r in debugger to start)   
   135    --cgdb ................. run with cgdb (type r in debugger to start)                            
   155    --cgdb ................. run with cgdb (type r in debugger to start)                            
   136    --callgrind ............ run under callgrind profiler tool with profiling 
   156    --callgrind ............ run under callgrind profiler tool with profiling 
   137                             off. Use this to profile some benchmark.
   157                 off. Use this to profile some benchmark.
   138    --callgrind-startup .... run under callgrind profiler tool with profiling 
   158    --callgrind-startup .... run under callgrind profiler tool with profiling 
   139                             on. Use this to profile VM startup.
   159                 on. Use this to profile VM startup.
   140    --stap SCRIPT .......... run given systemtap script, passing stx command as
   160    --stap SCRIPT .......... run given systemtap script, passing stx command as
   141                             stap -c 'stx ...' Systemtap may not be compiled in.
   161                 stap -c 'stx ...' Systemtap may not be compiled in.
   142    --record ............... record execution using rr. 
   162    --record ............... record execution using rr. 
   143    --replay ............... replay last recorded execution using rr. Must be used
   163    --replay ............... replay last recorded execution using rr. Must be used
   144                             in combination with --vdb.
   164                 in combination with --vdb.
   145 USAGE_END
   165 USAGE_END
   146   $STX_BIN_DIR/$STX_EXE --help
   166   $STX_BIN_DIR/$STX_EXE --help
   147   exit 0
   167   exit 0
   148 }
   168 }
   149 
   169 
   150 
   170 
   151 while [ $# -gt 0 ]
   171 while [ $# -gt 0 ]
   152 do
   172 do
   153     case $1 in
   173     case $1 in
   154         --help)
   174     --help)
   155             usage
   175         usage
   156             ;;
   176         ;;
   157         -x)
   177     -x)
   158             STX_EXE=$2
   178         STX_EXE=$2
   159             shift 2
   179         shift 2
   160             ;;
   180         ;;
   161         -X)            
   181     -X)            
   162             STX_EXE=$2/stx
   182         STX_EXE=$2/stx
   163             shift 2
   183         shift 2
   164             ;; 
   184         ;; 
   165         --ldd)            
   185     --ldd)            
   166             DEBUGLIB=yes
   186         DEBUGLIB=yes
       
   187         shift
       
   188         ;;
       
   189     --gdb|--cgdb|--vdb|--callgrind|--callgrind-startup|--stap)
       
   190             if [ ! -z "$SUPERVISOR" ]; then
       
   191                 error "$1 cannot be used together with $SUPERVISOR."
       
   192             fi          
       
   193             if [ "x$RECORD" == "xyes" ]; then
       
   194                 error "$1 cannot be used together with --record"
       
   195             fi
       
   196             if [ "x$REPLAY" == "xyes" ]; then
       
   197                 if [ "$1" != "--vdb" ]; then
       
   198                     error "$1 cannot be used together with --replay"
       
   199                 fi
       
   200             fi
       
   201         SUPERVISOR=$1            
       
   202         if [ $SUPERVISOR == "--stap" ]; then
       
   203         if [ -z "$2" ]; then
       
   204             error "--stap requires systemtap script to run"
       
   205         fi
       
   206         if [ ! -r "$2" ]; then
       
   207             error "$2: no such file or not readable"
       
   208         fi
       
   209         STAPSCRIPT=$2
       
   210         shift
       
   211         fi
       
   212         shift
       
   213         ;;     
       
   214     --record)
       
   215             if [ ! -z "$SUPERVISOR" ]; then
       
   216                 error "$1 cannot be used together with $SUPERVISOR."                
       
   217             fi
       
   218             if [ "x$REPLAY" == "xyes" ]; then
       
   219                 error "$1 cannot be used together with --replay"
       
   220             fi
       
   221             RECORD=yes
   167             shift
   222             shift
   168             ;;
   223         ;;        
   169         --gdb|--cgdb|--vdb|--callgrind|--callgrind-startup|--stap)
   224     --replay)
   170 			if [ ! -z "$SUPERVISOR" ]; then
   225             if [ ! -z "$SUPERVISOR" ]; then
   171 				error "$1 cannot be used together with $SUPERVISOR."
   226                 if [ "$SUPERVISOR" != "--vgb" ]; then
   172 			fi			
   227                     error "$1 cannot be used together with $SUPERVISOR."
   173 			if [ "x$RECORD" == "xyes" ]; then
       
   174 				error "$1 cannot be used together with --record"
       
   175 			fi
       
   176 			if [ "x$REPLAY" == "xyes" ]; then
       
   177 				if [ "$1" != "--vdb" ]; then
       
   178 					error "$1 cannot be used together with --replay"
       
   179 				fi
       
   180 			fi
       
   181             SUPERVISOR=$1            
       
   182             if [ $SUPERVISOR == "--stap" ]; then
       
   183             	if [ -z "$2" ]; then
       
   184                 	error "--stap requires systemtap script to run"
       
   185                 fi
   228                 fi
   186                 if [ ! -r "$2" ]; then
   229             fi
   187                 	error "$2: no such file or not readable"
   230             if [ "x$RECORD" == "xyes" ]; then
   188                 fi
   231                 error "$1 cannot be used together with --record"
   189                 STAPSCRIPT=$2
   232             fi
   190                 shift
   233         REPLAY=yes
   191             fi
   234         shift
   192             shift
   235         ;;   
   193             ;;     
   236     *)
   194         --record)
   237         break
   195 			if [ ! -z "$SUPERVISOR" ]; then
   238         ;;
   196 				error "$1 cannot be used together with $SUPERVISOR."				
       
   197 			fi
       
   198 			if [ "x$REPLAY" == "xyes" ]; then
       
   199 				error "$1 cannot be used together with --replay"
       
   200 			fi
       
   201 			RECORD=yes
       
   202 			shift
       
   203         	;;        
       
   204         --replay)
       
   205 			if [ ! -z "$SUPERVISOR" ]; then
       
   206 				if [ "$SUPERVISOR" != "--vgb" ]; then
       
   207 					error "$1 cannot be used together with $SUPERVISOR."
       
   208 				fi
       
   209 			fi
       
   210 			if [ "x$RECORD" == "xyes" ]; then
       
   211 				error "$1 cannot be used together with --record"
       
   212 			fi
       
   213         	REPLAY=yes
       
   214         	shift
       
   215         	;;   
       
   216         *)
       
   217             break
       
   218             ;;
       
   219     esac
   239     esac
   220 done 
   240 done 
   221 
   241 
   222 #
   242 #
   223 #
   243 #
   319 # echo PATH is $PATH
   339 # echo PATH is $PATH
   320 # echo DISPLAY is $DISPLAY
   340 # echo DISPLAY is $DISPLAY
   321 
   341 
   322 
   342 
   323 #
   343 #
   324 # When running on modern DE (such as GNOME or KDE), install 
   344 # When running on modern DE (such as GNOME or KDE), install
   325 # .desktop and .svg so to get nice(r) icon and - more importantly - 
   345 # .desktop and .svg so to get nice(r) icon and - more importantly -
   326 # proper window grouping in task list. 
   346 # proper window grouping in task list.
   327 #
   347 #
   328 # See issue #66: https://swing.fit.cvut.cz/projects/stx-jv/ticket/66
   348 # See issue #66: https://swing.fit.cvut.cz/projects/stx-jv/ticket/66
   329 #           
   349 #
   330 if [ ! -z "$XDG_CURRENT_DESKTOP" ]; then
   350 if [ ! -z "$XDG_CURRENT_DESKTOP" ]; then
   331     icon_dir=~/.local/share/icons/hicolor/scalable/apps
   351     icon_dir=~/.local/share/icons/hicolor/scalable/apps
   332     dskp_dir=~/.local/share/applications
   352     dskp_dir=~/.local/share/applications
   333     if [ ! -f "$icon_dir/smalltalkx.svg" ]; then
   353     if [ ! -f "$icon_dir/smalltalkx.svg" ]; then
   334         mkdir -p "$icon_dir" || true
   354     mkdir -p "$icon_dir" || true
   335         cp "$STX_LIBDIR/smalltalkx.svg" "$icon_dir" || true
   355     cp "$STX_LIBDIR/smalltalkx.svg" "$icon_dir" || true
   336     fi
   356     fi
   337     if [ ! -f "$dskp_dir/smalltalkx.desktop" ]; then
   357     if [ ! -f "$dskp_dir/smalltalkx.desktop" ]; then
   338         mkdir -p "$dskp_dir" || true
   358     mkdir -p "$dskp_dir" || true
   339         cp "$STX_LIBDIR/smalltalkx.desktop" "$dskp_dir" || true
   359     cp "$STX_LIBDIR/smalltalkx.desktop" "$dskp_dir" || true
   340     fi
   360     fi
   341 fi
   361 fi
   342 
   362 
   343 
   363 
   344 if [ ! -z "$STAPSCRIPT" ]; then
   364 if [ ! -z "$STAPSCRIPT" ]; then
   347     echo "$CMD"
   367     echo "$CMD"
   348     exec stap --unprivileged $STAPSCRIPT -I "$STX_TOPDIR/hacking/tapset" -c "$CMD"
   368     exec stap --unprivileged $STAPSCRIPT -I "$STX_TOPDIR/hacking/tapset" -c "$CMD"
   349 fi
   369 fi
   350 
   370 
   351 if [ "x$RECORD" == "xyes" ]; then
   371 if [ "x$RECORD" == "xyes" ]; then
   352 	exec rr $STX_EXE ${1+"$@"}
   372     exec rr $STX_EXE ${1+"$@"}
       
   373 elif [ "x$REPLAY" == "xyes" ]; then
       
   374     if [ -z "$SUPERVISOR" ]; then
       
   375         error "--replay can only be used together with --vdb"
       
   376     elif [ "$SUPERVISOR" != "--vdb" ]; then
       
   377         error "--replay can only be used together with --vdb"
       
   378     else
       
   379         exec vdb --replay $STX_EXE ${1+"$@"}
       
   380     fi
   353 elif [ ! -z "$SUPERVISOR" ]; then
   381 elif [ ! -z "$SUPERVISOR" ]; then
   354 	case "$SUPERVISOR" in
   382     case "$SUPERVISOR" in
   355 		--gdb)
   383     --gdb)
   356 			exec gdb --tui --args $STX_EXE ${1+"$@"}
   384         exec gdb --tui --args $STX_EXE ${1+"$@"}
   357 			;;
   385         ;;
   358 		--cgdb)
   386     --cgdb)
   359 			exec cgdb --args $STX_EXE ${1+"$@"}
   387         exec cgdb --args $STX_EXE ${1+"$@"}
   360 			;;
   388         ;;
   361 		--vdb)
   389     --vdb)
   362 			if which "vdb"; then
   390         if which "vdb"; then
   363                 vdb=vdb
   391             vdb=vdb
   364             elif [ -x "$STX_BIN_DIR/../../../jv/vdb/application/vdb" ]; then
   392         elif [ -x "$STX_BIN_DIR/../../../jv/vdb/application/vdb" ]; then
   365                 vdb="$STX_BIN_DIR/../../../jv/vdb/application/vdb"
   393             vdb="$STX_BIN_DIR/../../../jv/vdb/application/vdb"
   366             else
   394         else
   367                 error "could not find Visual / VM Debugger (vdb)"                
   395             error "could not find Visual / VM Debugger (vdb)"
   368             fi   
   396         fi
   369             if [ "x$REPLAY" == "xyes" ]; then
   397         exec vdb $STX_EXE ${1+"$@"}
   370             	exec vdb --replay $STX_EXE ${1+"$@"}
   398         ;;
   371             else
   399     --callgrind)
   372             	exec vdb $STX_EXE ${1+"$@"}
   400         exec valgrind --tool=callgrind --instr-atstart=no $STX_EXE ${1+"$@"}
   373             fi
   401         ;;
   374             ;;
   402     --callgrind-startup)
   375 		--callgrind)
   403         exec valgrind --tool=callgrind $STX_EXE ${1+"$@"}
   376     		exec valgrind --tool=callgrind --instr-atstart=no $STX_EXE ${1+"$@"}
   404         ;;
   377     		;;
   405     --stap)
   378     	--callgrind-startup)
   406         exec stap --unprivileged $STAPSCRIPT -I "$STX_TOPDIR/librun" -c "$STX_EXE $@"
   379 			exec valgrind --tool=callgrind $STX_EXE ${1+"$@"}
   407         ;;
   380     		;;
   408     *)
   381     	--stap)			
   409         error "Unknown supervisor option: $SUPERVISOR"
   382     		exec stap --unprivileged $STAPSCRIPT -I "$STX_TOPDIR/librun" -c "$STX_EXE $@"
   410         ;;
   383     		;;
   411     esac
   384     	*)
       
   385 			error "Unknown supervisor option: $SUPERVISOR"
       
   386 			;;
       
   387 	esac
       
   388 else
   412 else
   389 	exec $STX_EXE ${1+"$@"}
   413     exec $STX_EXE ${1+"$@"}
   390 fi
   414 fi
   391 
   415 
   392 
   416 
   393 
   417