src/Tools/jEdit/lib/Tools/jedit
author wenzelm
Sat, 17 Nov 2012 21:01:11 +0100
changeset 50114 d203e98ef5c9
parent 49953 fc2e3b9d4852
child 50120 245f5947233c
permissions -rwxr-xr-x
prefer absolute default $USER_HOME/Scratch.thy;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
     1
#!/usr/bin/env bash
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
     2
#
34664
8f5fbe4a80ff Isabelle component;
wenzelm
parents: 34663
diff changeset
     3
# Author: Makarius
8f5fbe4a80ff Isabelle component;
wenzelm
parents: 34663
diff changeset
     4
#
8f5fbe4a80ff Isabelle component;
wenzelm
parents: 34663
diff changeset
     5
# DESCRIPTION: Isabelle/jEdit interface wrapper
8f5fbe4a80ff Isabelle component;
wenzelm
parents: 34663
diff changeset
     6
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
     7
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
     8
## sources
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
     9
43320
wenzelm
parents: 43287
diff changeset
    10
declare -a SOURCES=(
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    11
  "src/dockable.scala"
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    12
  "src/document_model.scala"
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    13
  "src/document_view.scala"
49570
2265456f6131 more uniform graphview terminology;
wenzelm
parents: 49566
diff changeset
    14
  "src/graphview_dockable.scala"
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    15
  "src/html_panel.scala"
48921
5d8d409b897e support for direct hyperlinks, without the Hyperlinks plugin;
wenzelm
parents: 48791
diff changeset
    16
  "src/hyperlink.scala"
49726
2074197dc274 detach tooltip as dockable window;
wenzelm
parents: 49702
diff changeset
    17
  "src/info_dockable.scala"
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    18
  "src/isabelle_encoding.scala"
49246
248e66e8321f more systematic JEdit_Options.make_component;
wenzelm
parents: 49245
diff changeset
    19
  "src/isabelle_logic.scala"
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    20
  "src/isabelle_options.scala"
45665
129db1416717 renamed Isabelle_Markup to Isabelle_Rendering to emphasize its meaning and make room for Pure Isabelle_Markup module;
wenzelm
parents: 45158
diff changeset
    21
  "src/isabelle_rendering.scala"
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    22
  "src/isabelle_sidekick.scala"
49406
38db4832b210 somewhat more general JEdit_Lib;
wenzelm
parents: 49398
diff changeset
    23
  "src/jedit_lib.scala"
49600
2b114b9d9d34 some support for jEdit warmstart;
wenzelm
parents: 49570
diff changeset
    24
  "src/jedit_main.scala"
44577
96b6388d06c4 separate module for jEdit primitives for loading theory files;
wenzelm
parents: 44565
diff changeset
    25
  "src/jedit_thy_load.scala"
49245
cb70157293c0 manage Isabelle/jEdit options as Isabelle/Scala options (with persistent preferences);
wenzelm
parents: 48921
diff changeset
    26
  "src/jedit_options.scala"
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    27
  "src/output_dockable.scala"
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    28
  "src/plugin.scala"
49398
0fa4389c04f9 alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents: 49246
diff changeset
    29
  "src/pretty_text_area.scala"
49702
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents: 49611
diff changeset
    30
  "src/pretty_tooltip.scala"
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    31
  "src/protocol_dockable.scala"
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    32
  "src/raw_output_dockable.scala"
48014
63021e59cbf0 separate README dockable, which allows to make it more prominent first and remove it later;
wenzelm
parents: 47995
diff changeset
    33
  "src/readme_dockable.scala"
49411
1da54e9bda68 renamed Text_Area_Painter to Rich_Text_Area;
wenzelm
parents: 49406
diff changeset
    34
  "src/rich_text_area.scala"
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    35
  "src/scala_console.scala"
49492
2e3e7ea5ce8e some support for hovering and sendback area;
wenzelm
parents: 49411
diff changeset
    36
  "src/sendback.scala"
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    37
  "src/session_dockable.scala"
48021
d899be1cfe6d separate syslog dockable -- discontinued tendency of sub-window management via tabs;
wenzelm
parents: 48014
diff changeset
    38
  "src/syslog_dockable.scala"
46572
3074685ab7ed separate module for text status overview;
wenzelm
parents: 46502
diff changeset
    39
  "src/text_overview.scala"
43414
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43413
diff changeset
    40
  "src/token_markup.scala"
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    41
)
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    42
43320
wenzelm
parents: 43287
diff changeset
    43
declare -a RESOURCES=(
43286
a319da4fbfb0 simplified directory structure;
wenzelm
parents: 43285
diff changeset
    44
  "src/actions.xml"
a319da4fbfb0 simplified directory structure;
wenzelm
parents: 43285
diff changeset
    45
  "src/dockables.xml"
a319da4fbfb0 simplified directory structure;
wenzelm
parents: 43285
diff changeset
    46
  "src/Isabelle.props"
a319da4fbfb0 simplified directory structure;
wenzelm
parents: 43285
diff changeset
    47
  "src/services.xml"
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    48
)
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    49
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    50
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    51
## diagnostics
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    52
34664
8f5fbe4a80ff Isabelle component;
wenzelm
parents: 34663
diff changeset
    53
PRG="$(basename "$0")"
8f5fbe4a80ff Isabelle component;
wenzelm
parents: 34663
diff changeset
    54
43284
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
    55
function usage()
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    56
{
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    57
  echo
34664
8f5fbe4a80ff Isabelle component;
wenzelm
parents: 34663
diff changeset
    58
  echo "Usage: isabelle $PRG [OPTIONS] [FILES ...]"
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    59
  echo
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    60
  echo "  Options are:"
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    61
  echo "    -J OPTION    add JVM runtime option"
34409
e61e2ab1f6f7 proper spelling of JEDIT_JAVA_OPTIONS;
wenzelm
parents: 34339
diff changeset
    62
  echo "                 (default JEDIT_JAVA_OPTIONS=$JEDIT_JAVA_OPTIONS)"
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    63
  echo "    -b           build only"
48791
9e8f30bfbdca added jedit option -d;
wenzelm
parents: 48603
diff changeset
    64
  echo "    -d DIR       include session directory"
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    65
  echo "    -f           fresh build"
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    66
  echo "    -j OPTION    add jEdit runtime option"
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    67
  echo "                 (default JEDIT_OPTIONS=$JEDIT_OPTIONS)"
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    68
  echo "    -l NAME      logic image name (default ISABELLE_LOGIC=$ISABELLE_LOGIC)"
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    69
  echo "    -m MODE      add print mode for output"
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    70
  echo
34664
8f5fbe4a80ff Isabelle component;
wenzelm
parents: 34663
diff changeset
    71
  echo "Start jEdit with Isabelle plugin setup and opens theory FILES"
50114
d203e98ef5c9 prefer absolute default $USER_HOME/Scratch.thy;
wenzelm
parents: 49953
diff changeset
    72
  echo "(default \"$USER_HOME/Scratch.thy\")."
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    73
  echo
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    74
  exit 1
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    75
}
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    76
43284
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
    77
function fail()
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    78
{
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    79
  echo "$1" >&2
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    80
  exit 2
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    81
}
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    82
43284
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
    83
function failed()
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
    84
{
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
    85
  fail "Failed!"
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
    86
}
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
    87
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    88
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    89
## process command line
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    90
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    91
# options
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    92
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    93
BUILD_ONLY=false
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
    94
BUILD_JARS="jars"
48791
9e8f30bfbdca added jedit option -d;
wenzelm
parents: 48603
diff changeset
    95
JEDIT_SESSION_DIRS=""
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    96
JEDIT_LOGIC="$ISABELLE_LOGIC"
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    97
JEDIT_PRINT_MODE=""
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
    98
43284
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
    99
function getoptions()
34780
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   100
{
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   101
  OPTIND=1
48791
9e8f30bfbdca added jedit option -d;
wenzelm
parents: 48603
diff changeset
   102
  while getopts "J:bd:fj:l:m:" OPT
34780
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   103
  do
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   104
    case "$OPT" in
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   105
      J)
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   106
        JAVA_ARGS["${#JAVA_ARGS[@]}"]="$OPTARG"
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   107
        ;;
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   108
      b)
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   109
        BUILD_ONLY=true
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   110
        ;;
48791
9e8f30bfbdca added jedit option -d;
wenzelm
parents: 48603
diff changeset
   111
      d)
9e8f30bfbdca added jedit option -d;
wenzelm
parents: 48603
diff changeset
   112
        if [ -z "$JEDIT_SESSION_DIRS" ]; then
9e8f30bfbdca added jedit option -d;
wenzelm
parents: 48603
diff changeset
   113
          JEDIT_SESSION_DIRS="$OPTARG"
9e8f30bfbdca added jedit option -d;
wenzelm
parents: 48603
diff changeset
   114
        else
9e8f30bfbdca added jedit option -d;
wenzelm
parents: 48603
diff changeset
   115
          JEDIT_SESSION_DIRS="$JEDIT_SESSION_DIRS:$OPTARG"
9e8f30bfbdca added jedit option -d;
wenzelm
parents: 48603
diff changeset
   116
        fi
9e8f30bfbdca added jedit option -d;
wenzelm
parents: 48603
diff changeset
   117
        ;;
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   118
      f)
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   119
        BUILD_JARS="jars_fresh"
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   120
        ;;
34780
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   121
      j)
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   122
        ARGS["${#ARGS[@]}"]="$OPTARG"
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   123
        ;;
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   124
      l)
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   125
        JEDIT_LOGIC="$OPTARG"
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   126
        ;;
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   127
      m)
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   128
        if [ -z "$JEDIT_PRINT_MODE" ]; then
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   129
          JEDIT_PRINT_MODE="$OPTARG"
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   130
        else
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   131
          JEDIT_PRINT_MODE="$JEDIT_PRINT_MODE,$OPTARG"
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   132
        fi
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   133
        ;;
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   134
      \?)
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   135
        usage
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   136
        ;;
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   137
    esac
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   138
  done
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   139
}
34581
abab3a577e10 slightly more robust treatment of options via arrays;
wenzelm
parents: 34412
diff changeset
   140
38257
f0fd14a9c11f clarified JEDIT_JAVA_OPTIONS vs. JEDIT_SYSTEM_OPTIONS -- discontinued JEDIT_APPLE_PROPERTIES;
wenzelm
parents: 34881
diff changeset
   141
declare -a JAVA_ARGS; eval "JAVA_ARGS=($JEDIT_JAVA_OPTIONS $JEDIT_SYSTEM_OPTIONS)"
34843
eb8806a2e348 define scala.home, for more robust startup of Scala tools, notably the compiler;
wenzelm
parents: 34790
diff changeset
   142
[ -n "$SCALA_HOME" ] && JAVA_ARGS["${#JAVA_ARGS[@]}"]="-Dscala.home=$SCALA_HOME"
eb8806a2e348 define scala.home, for more robust startup of Scala tools, notably the compiler;
wenzelm
parents: 34790
diff changeset
   143
34780
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   144
declare -a ARGS; eval "ARGS=($JEDIT_OPTIONS)"
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   145
34780
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   146
declare -a OPTIONS; eval "OPTIONS=($ISABELLE_JEDIT_OPTIONS)"
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   147
getoptions "${OPTIONS[@]}"
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   148
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34691
diff changeset
   149
getoptions "$@"
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   150
shift $(($OPTIND - 1))
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   151
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   152
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   153
# args
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   154
44485
2f0a34fc4d2d back to tradition Scratch.thy default -- execution wrt. perspective overcomes the main problems of 226563829580;
wenzelm
parents: 43695
diff changeset
   155
if [ "$#" -eq 0 ]; then
50114
d203e98ef5c9 prefer absolute default $USER_HOME/Scratch.thy;
wenzelm
parents: 49953
diff changeset
   156
  ARGS["${#ARGS[@]}"]="$USER_HOME/Scratch.thy"
44485
2f0a34fc4d2d back to tradition Scratch.thy default -- execution wrt. perspective overcomes the main problems of 226563829580;
wenzelm
parents: 43695
diff changeset
   157
else
2f0a34fc4d2d back to tradition Scratch.thy default -- execution wrt. perspective overcomes the main problems of 226563829580;
wenzelm
parents: 43695
diff changeset
   158
  while [ "$#" -gt 0 ]; do
2f0a34fc4d2d back to tradition Scratch.thy default -- execution wrt. perspective overcomes the main problems of 226563829580;
wenzelm
parents: 43695
diff changeset
   159
    ARGS["${#ARGS[@]}"]="$(jvmpath "$1")"
2f0a34fc4d2d back to tradition Scratch.thy default -- execution wrt. perspective overcomes the main problems of 226563829580;
wenzelm
parents: 43695
diff changeset
   160
    shift
2f0a34fc4d2d back to tradition Scratch.thy default -- execution wrt. perspective overcomes the main problems of 226563829580;
wenzelm
parents: 43695
diff changeset
   161
  done
2f0a34fc4d2d back to tradition Scratch.thy default -- execution wrt. perspective overcomes the main problems of 226563829580;
wenzelm
parents: 43695
diff changeset
   162
fi
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   163
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   164
43284
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   165
## dependencies
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   166
49953
fc2e3b9d4852 avoid duplicate build of jars_fresh;
wenzelm
parents: 49726
diff changeset
   167
if [ -e "$ISABELLE_HOME/Admin/build" ]; then
fc2e3b9d4852 avoid duplicate build of jars_fresh;
wenzelm
parents: 49726
diff changeset
   168
  if [ "$BUILD_JARS" = jars_fresh ]; then
fc2e3b9d4852 avoid duplicate build of jars_fresh;
wenzelm
parents: 49726
diff changeset
   169
    "$ISABELLE_TOOL" graphview -b -f || exit $?
fc2e3b9d4852 avoid duplicate build of jars_fresh;
wenzelm
parents: 49726
diff changeset
   170
  else
49566
66cbf8bb4693 basic integration of graphview into document model;
wenzelm
parents: 49494
diff changeset
   171
    "$ISABELLE_HOME/Admin/build" "$BUILD_JARS" || exit $?
49953
fc2e3b9d4852 avoid duplicate build of jars_fresh;
wenzelm
parents: 49726
diff changeset
   172
    "$ISABELLE_TOOL" graphview -b || exit $?
fc2e3b9d4852 avoid duplicate build of jars_fresh;
wenzelm
parents: 49726
diff changeset
   173
  fi
fc2e3b9d4852 avoid duplicate build of jars_fresh;
wenzelm
parents: 49726
diff changeset
   174
fi
43413
7a7604573ecd explicit dependency on Pure.jar;
wenzelm
parents: 43405
diff changeset
   175
43523
5aaa0fe92672 simplified arrangement of jars;
wenzelm
parents: 43521
diff changeset
   176
PURE_JAR="$ISABELLE_HOME/lib/classes/ext/Pure.jar"
49566
66cbf8bb4693 basic integration of graphview into document model;
wenzelm
parents: 49494
diff changeset
   177
GRAPHVIEW_JAR="$ISABELLE_HOME/lib/classes/ext/Graphview.jar"
43413
7a7604573ecd explicit dependency on Pure.jar;
wenzelm
parents: 43405
diff changeset
   178
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   179
pushd "$JEDIT_HOME" >/dev/null || failed
43284
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   180
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   181
JEDIT_JAR="$ISABELLE_JEDIT_BUILD_HOME/contrib/$ISABELLE_JEDIT_BUILD_VERSION/jedit.jar"
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   182
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   183
JEDIT_JARS=(
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   184
  "$ISABELLE_JEDIT_BUILD_HOME/contrib/Console.jar"
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   185
  "$ISABELLE_JEDIT_BUILD_HOME/contrib/ErrorList.jar"
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   186
  "$ISABELLE_JEDIT_BUILD_HOME/contrib/SideKick.jar"
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   187
  "$ISABELLE_JEDIT_BUILD_HOME/contrib/cobra.jar"
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   188
  "$ISABELLE_JEDIT_BUILD_HOME/contrib/js.jar"
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   189
)
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   190
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   191
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   192
# target
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   193
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   194
TARGET="dist/jars/Isabelle-jEdit.jar"
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   195
43384
9c228b8953f2 more explicit check of dependencies;
wenzelm
parents: 43381
diff changeset
   196
declare -a UPDATED=()
9c228b8953f2 more explicit check of dependencies;
wenzelm
parents: 43381
diff changeset
   197
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   198
if [ "$BUILD_JARS" = jars_fresh ]; then
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   199
  OUTDATED=true
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   200
else
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   201
  OUTDATED=false
43368
0dc67b3cf8a5 check source dependencies only if jedit_build component is available;
wenzelm
parents: 43320
diff changeset
   202
  if [ ! -e "$TARGET" ]; then
0dc67b3cf8a5 check source dependencies only if jedit_build component is available;
wenzelm
parents: 43320
diff changeset
   203
    OUTDATED=true
43384
9c228b8953f2 more explicit check of dependencies;
wenzelm
parents: 43381
diff changeset
   204
  else
9c228b8953f2 more explicit check of dependencies;
wenzelm
parents: 43381
diff changeset
   205
    if [ -n "$ISABELLE_JEDIT_BUILD_HOME" ]; then
49566
66cbf8bb4693 basic integration of graphview into document model;
wenzelm
parents: 49494
diff changeset
   206
      declare -a DEPS=(
66cbf8bb4693 basic integration of graphview into document model;
wenzelm
parents: 49494
diff changeset
   207
        "$JEDIT_JAR" "${JEDIT_JARS[@]}"
66cbf8bb4693 basic integration of graphview into document model;
wenzelm
parents: 49494
diff changeset
   208
        "$PURE_JAR" "$GRAPHVIEW_JAR" "${SOURCES[@]}" "${RESOURCES[@]}"
66cbf8bb4693 basic integration of graphview into document model;
wenzelm
parents: 49494
diff changeset
   209
      )
47666
cf5fe7eb6793 pretend jedit is up-to-date if this is not a repository -- avoid accidental build attempts after touching files etc.;
wenzelm
parents: 47115
diff changeset
   210
    elif [ -e "$ISABELLE_HOME/Admin/build" ]; then
49566
66cbf8bb4693 basic integration of graphview into document model;
wenzelm
parents: 49494
diff changeset
   211
      declare -a DEPS=("$PURE_JAR" "$GRAPHVIEW_JAR" "${SOURCES[@]}" "${RESOURCES[@]}")
43384
9c228b8953f2 more explicit check of dependencies;
wenzelm
parents: 43381
diff changeset
   212
    else
47666
cf5fe7eb6793 pretend jedit is up-to-date if this is not a repository -- avoid accidental build attempts after touching files etc.;
wenzelm
parents: 47115
diff changeset
   213
      declare -a DEPS=()
43384
9c228b8953f2 more explicit check of dependencies;
wenzelm
parents: 43381
diff changeset
   214
    fi
9c228b8953f2 more explicit check of dependencies;
wenzelm
parents: 43381
diff changeset
   215
    for DEP in "${DEPS[@]}"
43368
0dc67b3cf8a5 check source dependencies only if jedit_build component is available;
wenzelm
parents: 43320
diff changeset
   216
    do
43384
9c228b8953f2 more explicit check of dependencies;
wenzelm
parents: 43381
diff changeset
   217
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
9c228b8953f2 more explicit check of dependencies;
wenzelm
parents: 43381
diff changeset
   218
      [ "$DEP" -nt "$TARGET" ] && {
9c228b8953f2 more explicit check of dependencies;
wenzelm
parents: 43381
diff changeset
   219
        OUTDATED=true
9c228b8953f2 more explicit check of dependencies;
wenzelm
parents: 43381
diff changeset
   220
        UPDATED["${#UPDATED[@]}"]="$DEP"
9c228b8953f2 more explicit check of dependencies;
wenzelm
parents: 43381
diff changeset
   221
      }
43368
0dc67b3cf8a5 check source dependencies only if jedit_build component is available;
wenzelm
parents: 43320
diff changeset
   222
    done
0dc67b3cf8a5 check source dependencies only if jedit_build component is available;
wenzelm
parents: 43320
diff changeset
   223
  fi
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   224
fi
43284
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   225
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   226
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   227
# build
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   228
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   229
if [ "$OUTDATED" = true ]
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   230
then
43405
723a8af9d3f0 tuned messages;
wenzelm
parents: 43395
diff changeset
   231
  echo "### Building Isabelle/jEdit ..."
723a8af9d3f0 tuned messages;
wenzelm
parents: 43395
diff changeset
   232
43384
9c228b8953f2 more explicit check of dependencies;
wenzelm
parents: 43381
diff changeset
   233
  [ "${#UPDATED[@]}" -gt 0 ] && {
43405
723a8af9d3f0 tuned messages;
wenzelm
parents: 43395
diff changeset
   234
    echo "Changed files:"
43384
9c228b8953f2 more explicit check of dependencies;
wenzelm
parents: 43381
diff changeset
   235
    for FILE in "${UPDATED[@]}"
9c228b8953f2 more explicit check of dependencies;
wenzelm
parents: 43381
diff changeset
   236
    do
9c228b8953f2 more explicit check of dependencies;
wenzelm
parents: 43381
diff changeset
   237
      echo "  $FILE"
9c228b8953f2 more explicit check of dependencies;
wenzelm
parents: 43381
diff changeset
   238
    done
9c228b8953f2 more explicit check of dependencies;
wenzelm
parents: 43381
diff changeset
   239
  }
9c228b8953f2 more explicit check of dependencies;
wenzelm
parents: 43381
diff changeset
   240
43284
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   241
  [ -z "$ISABELLE_JEDIT_BUILD_HOME" ] && \
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   242
    fail "Unknown ISABELLE_JEDIT_BUILD_HOME -- missing auxiliary component"
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   243
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   244
  rm -rf dist || failed
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   245
  mkdir -p dist dist/classes || failed
43287
acc680ab6204 simplified directory structure;
wenzelm
parents: 43286
diff changeset
   246
46502
3d43d4d4d071 more uniform / portable representation of the idea of "copy_dir" (NB: cp -f dereferences symlinks on GNU/Linux, but does not on old-school Unixen including BSD/Mac OS X);
wenzelm
parents: 45665
diff changeset
   247
  cp -p -R -f "$ISABELLE_JEDIT_BUILD_HOME/contrib/$ISABELLE_JEDIT_BUILD_VERSION/." dist/.
3d43d4d4d071 more uniform / portable representation of the idea of "copy_dir" (NB: cp -f dereferences symlinks on GNU/Linux, but does not on old-school Unixen including BSD/Mac OS X);
wenzelm
parents: 45665
diff changeset
   248
  cp -p -R -f "${RESOURCES[@]}" dist/classes/.
43287
acc680ab6204 simplified directory structure;
wenzelm
parents: 43286
diff changeset
   249
  cp src/jEdit.props dist/properties/.
46502
3d43d4d4d071 more uniform / portable representation of the idea of "copy_dir" (NB: cp -f dereferences symlinks on GNU/Linux, but does not on old-school Unixen including BSD/Mac OS X);
wenzelm
parents: 45665
diff changeset
   250
  cp -p -R -f src/modes/. dist/modes/.
43284
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   251
43391
986860aa51ac include scala mode;
wenzelm
parents: 43384
diff changeset
   252
  perl -i -e 'while (<>) {
986860aa51ac include scala mode;
wenzelm
parents: 43384
diff changeset
   253
    if (m/NAME="javacc"/) {
986860aa51ac include scala mode;
wenzelm
parents: 43384
diff changeset
   254
      print qq,<MODE NAME="isabelle" FILE="isabelle.xml" FILE_NAME_GLOB="*.thy"/>\n\n,;
48366
7363de5c8a26 basic jEdit mode for Isabelle options;
wenzelm
parents: 48280
diff changeset
   255
      print qq,<MODE NAME="isabelle-options" FILE="isabelle-options.xml"/>\n\n,;
48575
920cf986e84f renamed isabelle-root minor mode;
wenzelm
parents: 48366
diff changeset
   256
      print qq,<MODE NAME="isabelle-root" FILE="isabelle-root.xml" FILE_NAME_GLOB="ROOT"/>\n\n,; }
43391
986860aa51ac include scala mode;
wenzelm
parents: 43384
diff changeset
   257
    elsif (m/NAME="scheme"/) {
986860aa51ac include scala mode;
wenzelm
parents: 43384
diff changeset
   258
      print qq,<MODE NAME="scala" FILE="scala.xml" FILE_NAME_GLOB="*.scala" />\n\n,; }
43284
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   259
    print; }' dist/modes/catalog
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   260
47995
72f52cd7c633 include scala-compiler.jar in basic Isabelle/Scala environment, to make Isabelle/jEdit console work with scala-2.10.0-M3;
wenzelm
parents: 47849
diff changeset
   261
  cp -p -R -f "${JEDIT_JARS[@]}" dist/jars/. || failed
43284
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   262
  (
49566
66cbf8bb4693 basic integration of graphview into document model;
wenzelm
parents: 49494
diff changeset
   263
    for JAR in "$JEDIT_JAR" "${JEDIT_JARS[@]}" "$PURE_JAR" "$GRAPHVIEW_JAR" \
66cbf8bb4693 basic integration of graphview into document model;
wenzelm
parents: 49494
diff changeset
   264
      "$SCALA_HOME/lib/scala-compiler.jar"
43284
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   265
    do
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   266
      CLASSPATH="$CLASSPATH:$JAR"
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   267
    done
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   268
    CLASSPATH="$(jvmpath "$CLASSPATH")"
47009
97b68d61de2e less noisy Isabelle/Scala build process;
wenzelm
parents: 46996
diff changeset
   269
    exec "$SCALA_HOME/bin/scalac" $ISABELLE_SCALA_BUILD_OPTIONS -d dist/classes "${SOURCES[@]}"
43284
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   270
  ) || fail "Failed to compile sources"
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   271
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   272
  cd dist/classes
47115
1a05adae1cc9 more robust command invocation via ISABELLE_JDK_HOME or SCALA_HOME (NB: bash exec requires genuine executable, not function);
wenzelm
parents: 47113
diff changeset
   273
  isabelle_jdk jar cf "../jars/Isabelle-jEdit.jar" * || failed
43284
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   274
  cd ../..
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   275
  rm -rf dist/classes
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   276
fi
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   277
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   278
popd >/dev/null
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   279
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   280
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   281
## main
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   282
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   283
# perspective
34880
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   284
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   285
mkdir -p "$JEDIT_SETTINGS/DockableWindowManager"
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   286
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   287
if [ ! -e "$JEDIT_SETTINGS/perspective.xml" ]; then
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   288
  cat > "$JEDIT_SETTINGS/DockableWindowManager/perspective-view0.xml" <<EOF
48014
63021e59cbf0 separate README dockable, which allows to make it more prominent first and remove it later;
wenzelm
parents: 47995
diff changeset
   289
<DOCKING LEFT="" TOP="" RIGHT="" BOTTOM="isabelle-readme" LEFT_POS="0" TOP_POS="0" RIGHT_POS="250" BOTTOM_POS="250" />
34880
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   290
EOF
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   291
  cat > "$JEDIT_SETTINGS/perspective.xml" <<EOF
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   292
<?xml version="1.0" encoding="UTF-8" ?>
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   293
<!DOCTYPE PERSPECTIVE SYSTEM "perspective.dtd">
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   294
<PERSPECTIVE>
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   295
<VIEW PLAIN="FALSE">
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   296
<GEOMETRY X="0" Y="35" WIDTH="1072" HEIGHT="787" EXT_STATE="0" />
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   297
</VIEW>
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   298
</PERSPECTIVE>
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   299
EOF
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   300
fi
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   301
f88fc4fcab86 provide JEDIT_SETTINGS via settings;
wenzelm
parents: 34843
diff changeset
   302
43284
04d473e883df build jedit as part of regular startup script (in that case depending on jedit_build component);
wenzelm
parents: 41380
diff changeset
   303
# run
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   304
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   305
[ "$BUILD_ONLY" = true ] || {
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   306
  case "$JEDIT_LOGIC" in
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   307
    /*)
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   308
      ;;
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   309
    */*)
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   310
      JEDIT_LOGIC="$(pwd -P)/$JEDIT_LOGIC"
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   311
      ;;
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   312
  esac
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   313
48791
9e8f30bfbdca added jedit option -d;
wenzelm
parents: 48603
diff changeset
   314
  export JEDIT_SESSION_DIRS JEDIT_LOGIC JEDIT_PRINT_MODE
34333
b353b4cd9bd4 Isabelle/jEdit interface wrapper.
wenzelm
parents:
diff changeset
   315
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   316
  exec "$ISABELLE_TOOL" java "${JAVA_ARGS[@]}" \
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   317
    -jar "$(jvmpath "$JEDIT_HOME/dist/jedit.jar")" \
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   318
    "-settings=$(jvmpath "$JEDIT_SETTINGS")" "${ARGS[@]}"
966f359dc724 further jedit build option;
wenzelm
parents: 43284
diff changeset
   319
}