Stephan Herrmann | 7b7062f | 2010-04-01 19:56:59 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | ############################################################################################################################################################ |
| 3 | # This file is part of "Object Teams Development Tooling"-Software |
| 4 | # |
| 5 | # Copyright 2003, 2006 Fraunhofer Gesellschaft, Munich, Germany, |
| 6 | # for its Fraunhofer Institute and Computer Architecture and Software |
| 7 | # Technology (FIRST), Berlin, Germany and Technical University Berlin, |
| 8 | # Germany. |
| 9 | # |
Stephan Herrmann | 3570538 | 2020-03-03 21:42:19 +0100 | [diff] [blame] | 10 | # This program and the accompanying materials |
| 11 | # are made available under the terms of the Eclipse Public License 2.0 |
Stephan Herrmann | 7b7062f | 2010-04-01 19:56:59 +0000 | [diff] [blame] | 12 | # which accompanies this distribution, and is available at |
Stephan Herrmann | 3570538 | 2020-03-03 21:42:19 +0100 | [diff] [blame] | 13 | # https://www.eclipse.org/legal/epl-2.0/ |
| 14 | # |
| 15 | # SPDX-License-Identifier: EPL-2.0 |
Stephan Herrmann | 7b7062f | 2010-04-01 19:56:59 +0000 | [diff] [blame] | 16 | # |
| 17 | # |
| 18 | # Contributors: |
| 19 | # Fraunhofer FIRST - Initial API and implementation |
| 20 | # Technical University Berlin - Initial API and implementation |
| 21 | # |
| 22 | # Dieses Script erzeugt aus der java.g Datei alle automatisch generierbaren Dateien |
| 23 | # und kopiert diese an die richtigen Stellen innerhalb der aktuellen Sourcen |
| 24 | # Das Script benötigt den Ordner "OTDTCore" |
| 25 | # Das Script benötigt die Datei "objectteams.g" welche aus dem Eclipse Quellcode extrahiert werden kann. |
| 26 | # Zu Beginn des Vorganges wird eine Kopie aller Dateien die in den Sourcen verändert werden erstellt |
| 27 | |
| 28 | ############################################################################################################################################################ |
| 29 | |
| 30 | JIKESPG_HOME=${JIKESPG_HOME:-/usr/bin} |
| 31 | export JIKESPG_HOME |
| 32 | |
Stephan Herrmann | 0b739cd | 2017-11-01 23:54:40 +0100 | [diff] [blame] | 33 | JAVAC=${JAVAC:-java} |
| 34 | |
Stephan Herrmann | 7b7062f | 2010-04-01 19:56:59 +0000 | [diff] [blame] | 35 | if test $# -ne 2 |
| 36 | then |
| 37 | echo "Achtung: JIKESPG_HOME muss KORREKT gesetzt sein!" |
| 38 | echo "Aufruf: generateOTParser.sh <grammatik> <eclipse-projekt-OTDTCore-verzeichnis>" |
| 39 | echo "Bsp: generateOTParser.sh objectteams.g OTDTCore" |
| 40 | echo "(im Verzeichnis des Skripts aufzurufen)." |
| 41 | exit |
| 42 | fi |
| 43 | |
| 44 | GRAMMAR=`readlink -f "$1"` |
| 45 | SOURCE=`readlink -f "$2"` |
| 46 | |
| 47 | if test -f $JIKESPG_HOME/jikespg |
| 48 | then |
| 49 | echo "jikespg wurde gefunden" |
| 50 | else |
| 51 | echo "JIKESPG_HOME/jikespg konnte nicht gefunden werden" |
| 52 | exit |
| 53 | fi |
| 54 | |
| 55 | if test -f $GRAMMAR |
| 56 | then |
| 57 | echo "Verwende Grammatik:" $GRAMMAR |
| 58 | else |
| 59 | echo "Fehler: Grammatik" $GRAMMAR "konnte nicht gefunden werden!" |
| 60 | echo "Aufruf: generateOTParser.sh <grammatik> <eclipse-projekt-OTDTCore-verzeichnis>" |
| 61 | exit |
| 62 | fi |
| 63 | |
| 64 | if test -d $SOURCE |
| 65 | then |
| 66 | echo "Verwende Eclipse-Sourcen:" $SOURCE |
| 67 | else |
| 68 | echo "Fehler: Eclipse-Sourcen" $SOURCE "konnten nicht gefunden werden!" |
| 69 | echo "Aufruf: generateOTParser.sh <grammatik> <eclipse-projekt-OTDTCore-verzeichnis>" |
| 70 | exit |
| 71 | fi |
| 72 | |
Stephan Herrmann | 4f3f3d1 | 2012-04-28 23:46:59 +0200 | [diff] [blame] | 73 | scriptDir=`dirname "$0"` |
| 74 | pluginDir=`readlink -f ${scriptDir}/..` |
| 75 | |
Stephan Herrmann | 7b7062f | 2010-04-01 19:56:59 +0000 | [diff] [blame] | 76 | echo "Initiales Aufräumen" |
| 77 | if test -d output |
| 78 | then |
| 79 | rm -r output |
| 80 | fi |
| 81 | |
| 82 | if test -d backup |
| 83 | then |
| 84 | rm -r backup |
| 85 | fi |
| 86 | |
| 87 | echo "Leere Verzeichnisse erzeugen" |
| 88 | mkdir output |
| 89 | mkdir backup |
| 90 | |
| 91 | echo "Original Dateien vor der Anpassung aus Sourcen holen" |
| 92 | |
| 93 | if test -f $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java |
| 94 | then |
| 95 | cp $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java output |
| 96 | else |
| 97 | exit |
| 98 | fi |
| 99 | |
| 100 | if test -f $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java |
| 101 | then |
| 102 | cp $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java output |
| 103 | else |
| 104 | exit |
| 105 | fi |
| 106 | |
| 107 | if test -f $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java |
| 108 | then |
| 109 | cp $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java output |
| 110 | else |
| 111 | exit |
| 112 | fi |
| 113 | |
| 114 | echo "Eine Kopie der Originaldateien die verändert werden im Ordner backup erzeugen" |
| 115 | cp $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java backup |
| 116 | cp $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java backup |
| 117 | cp $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java backup |
| 118 | cp $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser/parser?.rsc backup |
Stephan Herrmann | 12a2074 | 2013-04-25 20:12:57 +0200 | [diff] [blame] | 119 | cp $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser/readableNames.props backup |
Stephan Herrmann | 7b7062f | 2010-04-01 19:56:59 +0000 | [diff] [blame] | 120 | |
| 121 | cp $GRAMMAR output |
| 122 | |
| 123 | ############################################################################################################################################################ |
| 124 | cd output |
| 125 | echo "Parsergenerator starten" |
| 126 | islalr=`$JIKESPG_HOME/jikespg $GRAMMAR | tee /tmp/jikes.log | grep grammar` |
| 127 | |
| 128 | if [ "$islalr" = "This grammar is LALR(1)." ] |
| 129 | then |
| 130 | echo "Grammatik ist LALR(1)." |
| 131 | else |
| 132 | echo "Grammatik ist nicht korrekt!" |
| 133 | exit |
| 134 | fi |
| 135 | |
| 136 | chmod 644 * |
| 137 | |
| 138 | #echo "Konstanten von javasym.java umbenennen" |
| 139 | cat javasym.java | sed -e s/TokenName\$eof/TokenNameEOF/g -e s/TokenName\$error/TokenNameERROR/g > javasym_tmp.java |
| 140 | rm javasym.java |
| 141 | mv javasym_tmp.java javasym.java |
| 142 | cd .. |
| 143 | ############################################################################################################################################################ |
| 144 | cd output |
| 145 | echo "Alles unnötige wegschneiden: javadef.java" |
| 146 | cat javadef.java | awk '{ |
| 147 | if($0 ~ /^[ \t]*{[ \t]*$/ ){ |
| 148 | while((getline nextline) == 1 && nextline !~ /^[ \t]*}.*$/){ |
| 149 | print nextline ; |
| 150 | } |
| 151 | print "}" ; |
| 152 | } |
| 153 | } |
| 154 | ' > javadef_tmp.java |
| 155 | |
| 156 | echo "Alles unnötige wegschneiden: ParserBasicInformation.java" |
| 157 | cat ParserBasicInformation.java | awk '{ |
| 158 | if($0 ~ /^.*{[ \t]*$/ ){ |
| 159 | print $0; |
| 160 | while((getline nextline) == 1 && nextline !~ /^[ \t]*}[ \t]*$/){ |
| 161 | nextline="" ; |
| 162 | } |
| 163 | while((getline nextline) == 1 ){ |
| 164 | print nextline ; |
| 165 | } |
| 166 | } else { |
| 167 | print $0 |
| 168 | } |
| 169 | } |
| 170 | ' > ParserBasicInformation_tmp.java |
| 171 | |
| 172 | echo "Kopiere den Inhalt von javadef.java nach ParserBasicInformation.java" |
| 173 | cat ParserBasicInformation_tmp.java javadef_tmp.java > ParserBasicInformation.java |
| 174 | cd .. |
| 175 | ############################################################################################################################################################ |
| 176 | cd output |
| 177 | echo "Alles unnötige wegschneiden: JavaAction.java" |
| 178 | cat JavaAction.java | awk '{\ |
| 179 | if($0 !~ /^[ \t]*\/\/ This method is part of an automatic generation : do NOT edit-modify[ \t]*$/ ){\ |
| 180 | print $0\ |
| 181 | }\ |
| 182 | }\ |
| 183 | ' > JavaAction_tmp.java |
| 184 | |
| 185 | echo "Ersetze die Methode consumeRule gegen das Token TMP_CUT_OUT" |
| 186 | cat Parser.java | awk '{ |
| 187 | if($0 ~ /^[ \t]*protected void consumeRule\(int act\) \{[ \t]*$/ ){ |
| 188 | while((getline nextline) == 1 && nextline !~ /^[ \t]*}[ \t]*$/){ |
| 189 | nextline="" ; |
| 190 | } |
| 191 | while((getline nextline) == 1 && nextline !~ /^[ \t]*}[ \t]*$/){ |
| 192 | nextline="" ; |
| 193 | } |
| 194 | print "TMP_CUT_OUT"; |
| 195 | while((getline nextline) == 1 ){ |
| 196 | print nextline ; |
| 197 | } |
| 198 | } else { |
| 199 | print $0 |
| 200 | } |
| 201 | } |
| 202 | ' > Parser_tmp.java |
| 203 | |
| 204 | cat Parser_tmp.java | awk '{ |
| 205 | if($0 ~ /^TMP_CUT_OUT$/ ){ |
| 206 | while((getline nextline) == 1){ |
| 207 | nextline="" ; |
| 208 | } |
| 209 | } else { |
| 210 | print $0 |
| 211 | } |
| 212 | } |
| 213 | ' > Parser_1_tmp.java |
| 214 | |
| 215 | cat Parser_tmp.java | awk '{ |
| 216 | if($0 ~ /^TMP_CUT_OUT$/ ){ |
| 217 | while((getline nextline) == 1){ |
| 218 | print nextline; |
| 219 | } |
| 220 | } |
| 221 | } |
| 222 | ' > Parser_2_tmp.java |
| 223 | |
| 224 | echo "Kopiere den Inhalt von JavaAction.java nach Parser.java" |
| 225 | cat Parser_1_tmp.java JavaAction_tmp.java Parser_2_tmp.java > Parser.java |
| 226 | cd .. |
| 227 | ############################################################################################################################################################ |
| 228 | cd output |
| 229 | echo "Alles unnötige wegschneiden: TerminalTokens.java" |
| 230 | cat TerminalTokens.java | awk '{ |
| 231 | if($0 ~ /^[ \t]*public interface TerminalTokens \{[ \t]*$/ ){ |
| 232 | print $0 |
| 233 | while((getline nextline) == 1 && nextline !~ /^[ \t]*int[ \t]*$/){ |
| 234 | print nextline ; |
| 235 | } |
| 236 | print nextline ; |
| 237 | while((getline nextline) == 1 && nextline !~ /^[ \t]*int[ \t]*$/){ |
| 238 | print nextline ; |
| 239 | } |
| 240 | print nextline ; |
Stephan Herrmann | 7b7062f | 2010-04-01 19:56:59 +0000 | [diff] [blame] | 241 | while((getline nextline) == 1 ){ |
| 242 | nextline =""; |
| 243 | } |
Stephan Herrmann | 7b7062f | 2010-04-01 19:56:59 +0000 | [diff] [blame] | 244 | } else { |
| 245 | print $0 |
| 246 | } |
| 247 | } |
| 248 | ' > TerminalTokens_tmp.java |
| 249 | |
| 250 | echo "Alles unnötige wegschneiden: javasym.java" |
| 251 | cat javasym.java | awk '{ |
| 252 | if($0 ~ /^[ \t]*public final static int[ \t]*$/ ){ |
Stephan Herrmann | 5fa7f31 | 2012-07-13 01:52:51 +0200 | [diff] [blame] | 253 | while((getline nextline) == 1 && nextline !~ /^\}$/){ |
Stephan Herrmann | 7b7062f | 2010-04-01 19:56:59 +0000 | [diff] [blame] | 254 | print nextline ; |
| 255 | } |
Stephan Herrmann | 5fa7f31 | 2012-07-13 01:52:51 +0200 | [diff] [blame] | 256 | print "\n\n\t// This alias is statically inserted by generateOTParser.sh:" |
| 257 | print "\tint TokenNameBINDOUT = TokenNameARROW;\n}\n" ; |
Stephan Herrmann | 7b7062f | 2010-04-01 19:56:59 +0000 | [diff] [blame] | 258 | } |
| 259 | } |
| 260 | ' > javasym_tmp.java |
| 261 | |
| 262 | |
| 263 | echo "Kopiere den Inhalt von javasym.java nach TerminalTokens.java" |
| 264 | cat TerminalTokens_tmp.java javasym_tmp.java > TerminalTokens.java |
| 265 | cd .. |
| 266 | ############################################################################################################################################################ |
| 267 | cd output |
| 268 | |
| 269 | cp ../UpdateParserFiles.java . |
Stephan Herrmann | 5fa7f31 | 2012-07-13 01:52:51 +0200 | [diff] [blame] | 270 | |
Stephan Herrmann | 7b7062f | 2010-04-01 19:56:59 +0000 | [diff] [blame] | 271 | echo "UpdateParserFiles kompilieren" |
Stephan Herrmann | 0b739cd | 2017-11-01 23:54:40 +0100 | [diff] [blame] | 272 | $JAVAC -classpath ${pluginDir}/bin UpdateParserFiles.java |
Stephan Herrmann | 7b7062f | 2010-04-01 19:56:59 +0000 | [diff] [blame] | 273 | echo "Ressourcendateien erzeugen (*.rsc)" |
Stephan Herrmann | 4f3f3d1 | 2012-04-28 23:46:59 +0200 | [diff] [blame] | 274 | java -classpath ${pluginDir}/bin:. UpdateParserFiles javadcl.java javahdr.java |
Stephan Herrmann | 7b7062f | 2010-04-01 19:56:59 +0000 | [diff] [blame] | 275 | |
| 276 | cd .. |
| 277 | |
| 278 | ############################################################################################################################################################ |
| 279 | echo "Alle zu aktualisierenden Classfiles entfernen (Parser/TerminalTokens/ParserBasicInformation)" |
| 280 | if test -f $SOURCE/bin/org/eclipse/jdt/internal/compiler/parser/Parser.class |
| 281 | then |
| 282 | rm $SOURCE/bin/org/eclipse/jdt/internal/compiler/parser/Parser.class |
| 283 | fi |
| 284 | |
| 285 | if test -f $SOURCE/bin/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.class |
| 286 | then |
| 287 | rm $SOURCE/bin/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.class |
| 288 | fi |
| 289 | |
| 290 | if test -f $SOURCE/bin/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.class |
| 291 | then |
| 292 | rm $SOURCE/bin/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.class |
| 293 | fi |
| 294 | |
| 295 | ################################################################################################################# |
| 296 | echo "Die originalen Dateien werden in den Sourcen durch die neu generierten ersetzt" |
| 297 | cp output/Parser.java $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser |
| 298 | cp output/TerminalTokens.java $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser |
| 299 | cp output/ParserBasicInformation.java $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser |
| 300 | cp output/parser*.rsc $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser |
| 301 | cp output/parser*.rsc $SOURCE/bin/org/eclipse/jdt/internal/compiler/parser |
Stephan Herrmann | 4f3f3d1 | 2012-04-28 23:46:59 +0200 | [diff] [blame] | 302 | cp output/readableNames.props $SOURCE/compiler/org/eclipse/jdt/internal/compiler/parser |
| 303 | cp output/readableNames.props $SOURCE/bin/org/eclipse/jdt/internal/compiler/parser |
Stephan Herrmann | 7b7062f | 2010-04-01 19:56:59 +0000 | [diff] [blame] | 304 | ############################################################################################################################################################ |
| 305 | #echo "Eclipse Build ausfhren mit Optionen build -os linux -ws motif" |
| 306 | #cd $SOURCE |
| 307 | #build -os linux -ws motif |
| 308 | #cd .. |
| 309 | ############################################################################################################################################################ |
| 310 | #echo "Alle nicht mehr benötigten bzw temporären Dateien entfernen" |
| 311 | #rm -rf output |
| 312 | ############################################################################################################################################################ |
| 313 | #echo "Eclipse starten" |
| 314 | #cd $SOURCE |
| 315 | #eclipse |
| 316 | ############################################################################################################################################################ |
| 317 | echo "Fertig" |
| 318 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
| 319 | echo "Bitte fhren sie ein 'Refresh' im Eclipse Package Explorer aus" |
| 320 | echo "Da Eclipse die Abhängigkeiten zu den geänderten Interfaces sonst nicht aktualisiert" |