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