Index: mttroot/mtt/bin/mtt ================================================================== --- mttroot/mtt/bin/mtt +++ mttroot/mtt/bin/mtt @@ -12,10 +12,13 @@ ############################################################### ## Version control history ############################################################### ## $Header$ ## $Log$ +## Revision 1.116 1998/02/04 11:00:04 peterg +## Added view of subsystems. +## ## Revision 1.115 1998/01/29 19:37:31 peterg ## Fixed spurious call to X server bug ## ## Revision 1.114 1998/01/23 13:38:07 peterg ## VERSION 2.7 @@ -416,13 +419,17 @@ # By default, don't look for BG switches switches=0 #By default, don't print the environment variables print=''; + +# By default, make it untidy +tidy=untidy; #Initialise list mtt_switches=''; + #Look for a command line argument while [ -n "`echo $1 | grep '^-'`" ]; do case $1 in -q ) @@ -439,13 +446,22 @@ dae_is_ode=1 ;; -s ) mtt_switches="$mtt_switches $1"; switches=1 ;; -d ) + mtt_switches="$mtt_switches $1"; directory=$2; cd $directory; shift ;; -D ) + mtt_switches="$mtt_switches $1"; debug=debug ;; + -t ) + tidy=tidy ;; + -T ) + tidy=tidy; + verytidy=verytidy ;; + -u ) + tidy=untidy ;; -l ) mtt_switches="$mtt_switches $1"; level=$2; shift ;; *) echo "$1 is an invalid argument - ignoring" ;; @@ -458,25 +474,42 @@ echo echo 'MTT (Model Transformation Tools) version 2.7++ ($Date$)' echo 'This is free software with ABSOLUTELY NO WARRANTY.' echo 'Type `mtt warranty'\' 'for details.' echo -fi - -# Print current directory if in -d mode -if [ -n "$directory" ]; then - echo Using directory $directory - echo + # Print current directory if in -d mode + if [ -n "$directory" ]; then + echo Using directory $directory + echo + fi fi #Check the principle paths mtt_check_vars $print # Exit if just printing paths if [ "$print" != "" ]; then exit fi + +# Tidy mode - operate in the directory MTT-work +if [ "$tidy" = "tidy" ]; then + mkdir -p MTT_work + cp -u *_*.* MTT_work + cd MTT_work + mtt -u -q $mtt_switches $1 $2 $3 $4 + if [ "$3" != "view" ]; then + cp -f MTT_work/$1_$2.$3 . + fi + + # Remove the MTT_work directory if very tidy + if [ "$verytidy" = "verytidy" ]; then + echo Removing all working files + rm -rf ../MTT_work + fi +exit +fi if [ -z "$1" ]; then if [ -z "$print" ]; then echo 'Usage: mtt help -- mtt on-line help' echo ' mtt info -- info-based manual' @@ -571,11 +604,11 @@ rm -f *_odeso.dat *_odeso.gdat *_odeso.sdat *_odeso.m *_odeso.ps rm -f *_*.doc *_*.idx *_*.ind *_*.ilg *_*.dvi *_*.aux *_*.lof *_*.toc rm -f *_rep.tex rm -f *_unique_raw_list *_raw_list rm -f mtt_error.txt mtt_info.txt a.out - rm -fR *_rep + rm -fR *_rep MTT_work exit fi # Clean up named system if [ "$2" = "clean" ] && [ "$3" = "" ]; then @@ -595,11 +628,11 @@ rm -f $1_odeso.dat $1_odeso.gdat $1_odeso.m $1_odeso.ps rm -f $1_*.doc $1_*.idx $1_*.ind $1_*.ilg $1_*.dvi $1_*.aux $1_*.lof $1_*.toc rm -f $1_rep.tex rm -f $1_unique_raw_list $1_raw_list rm -f mtt_error.txt mtt_info.txt a.out - rm -fR $1_rep + rm -fR $1_rep MTT_work exit fi #SUMMARY abg acausal bond graph (fig) #SUMMARY abg acausal bond graph (ps) @@ -618,42 +651,70 @@ exit fi # Copy systems from the example library if [ "$1" = "copy" ]; then - # check that its not here already - file_exists=`ls $2 2> /dev/null` + #set up source and destination dirs + source=$3 + if [ -z "$source" ]; then + source=$MTTPATH/lib/examples + fi + destination=$4 + if [ -z "$destination" ]; then + destination=$2 + fi +# check that its not here already + file_exists=`ls $destination/$2_abg.fig 2> /dev/null` if [ -n "$file_exists" ]; then if [ "$quiet" != "quiet" ]; then - echo Directory $2 exists already - no action taken + echo System $2 exists already - no action taken fi else - path_name=$3 - if [ -z "$path_name" ]; then - path_name=$MTTPATH/lib/examples + source=$3 + if [ -z "$source" ]; then + source=$MTTPATH/lib/examples fi - echo Copying system $2 to here from $path_name into directory $2 - find $path_name -name "$2" -exec cp -r {} . \; + destination=$4 + if [ -z "$destination" ]; then + destination=$2 + fi +echo Copying system $2 from $source into directory $destination + find $source -name "$2" -exec cp -rf {} . \; fi exit fi # Copy components from the library if [ "$1" = "compcopy" ]; then + #set up source and destination dirs + source=$3 + if [ -z "$source" ]; then + source=$MTTPATH/lib/comp/compound + fi + destination=$4 + if [ -z "$destination" ]; then + destination='.' + fi + # check that its not here already - file_exists=`ls $2_abg.fig 2> /dev/null` + file_exists=`ls $destination/$2_abg.fig 2> /dev/null` if [ -n "$file_exists" ]; then if [ "$quiet" != "quiet" ]; then - echo $2_abg.fig exists already - no action taken + echo $destination/$2_abg.fig exists already - no action taken fi else - path_name=$3 - if [ -z "$path_name" ]; then - path_name=$MTTPATH/lib/comp/compound + if [ -z "$source" ]; then + source=$MTTPATH/lib/comp/compound + fi + if [ "$quiet" != "quiet" ]; then + echo Copying component $2 from $source to $destination fi - echo Copying component $2 from $path_name - find $path_name -name "$2_*.*" -exec cp {} . \; + if [ $source = "." ]; then + cp -u *_*.* $destination + else + find $source -name "$2_*.*" -exec cp {} $destination \; + fi fi exit fi # Copy CRs from the library @@ -1570,7 +1631,10 @@ # Remove logs if not debugging if [ "$debug" != "debug" ]; then rm -f *.log else - echo Debugging - log files retained + echo Debugging - log files retained in $directory/LOGFILES + mkdir -p LOGFILES + mv -f *.log LOGFILES fi +