author | ysr |
Fri, 07 Apr 2017 10:45:26 +0200 | |
changeset 44522 | b10606c613ef |
parent 37976 | 9cc5debe0f47 |
permissions | -rw-r--r-- |
37861 | 1 |
#!/bin/sh |
2 |
# |
|
3 |
# Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. |
|
4 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
5 |
# |
|
6 |
# This code is free software; you can redistribute it and/or modify it |
|
7 |
# under the terms of the GNU General Public License version 2 only, as |
|
8 |
# published by the Free Software Foundation. |
|
9 |
# |
|
10 |
# This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 |
# version 2 for more details (a copy is included in the LICENSE file that |
|
14 |
# accompanied this code). |
|
15 |
# |
|
16 |
# You should have received a copy of the GNU General Public License version |
|
17 |
# 2 along with this work; if not, write to the Free Software Foundation, |
|
18 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 |
# |
|
20 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 |
# or visit www.oracle.com if you need additional information or have any |
|
22 |
# questions. |
|
23 |
# |
|
24 |
||
25 |
# Shell script for generating an IDEA project from a given list of modules |
|
26 |
||
27 |
usage() { |
|
28 |
echo "usage: $0 [-h|--help] [-v|--verbose] [-o|--output <path>] [modules]+" |
|
29 |
exit 1 |
|
30 |
} |
|
31 |
||
32 |
SCRIPT_DIR=`dirname $0` |
|
33 |
PWD=`pwd` |
|
34 |
cd $SCRIPT_DIR; SCRIPT_DIR=`pwd` |
|
35 |
cd ../../; TOP=`pwd`; cd $PWD |
|
36 |
||
37 |
IDEA_OUTPUT=$TOP/.idea |
|
38 |
VERBOSE="false" |
|
39 |
while [ $# -gt 0 ] |
|
40 |
do |
|
41 |
case $1 in |
|
42 |
-h | --help ) |
|
43 |
usage |
|
44 |
;; |
|
45 |
||
46 |
-v | --vebose ) |
|
47 |
VERBOSE="true" |
|
48 |
;; |
|
49 |
||
50 |
-o | --output ) |
|
51 |
IDEA_OUTPUT=$2 |
|
52 |
shift |
|
53 |
;; |
|
54 |
||
55 |
-*) # bad option |
|
56 |
usage |
|
57 |
;; |
|
58 |
||
59 |
* ) # non option |
|
60 |
break |
|
61 |
;; |
|
62 |
esac |
|
63 |
shift |
|
64 |
done |
|
65 |
||
66 |
mkdir $IDEA_OUTPUT || exit 1 |
|
67 |
cd $IDEA_OUTPUT; IDEA_OUTPUT=`pwd` |
|
68 |
||
69 |
IDEA_MAKE="$TOP/make/idea" |
|
70 |
IDEA_TEMPLATE="$IDEA_MAKE/template" |
|
71 |
IML_TEMPLATE="$IDEA_TEMPLATE/jdk.iml" |
|
72 |
ANT_TEMPLATE="$IDEA_TEMPLATE/ant.xml" |
|
73 |
IDEA_IML="$IDEA_OUTPUT/jdk.iml" |
|
74 |
IDEA_ANT="$IDEA_OUTPUT/ant.xml" |
|
75 |
||
76 |
if [ "$VERBOSE" = "true" ] ; then |
|
77 |
echo "output dir: $IDEA_OUTPUT" |
|
78 |
echo "idea template dir: $IDEA_TEMPLATE" |
|
79 |
fi |
|
80 |
||
81 |
if [ ! -f "$IML_TEMPLATE" ] ; then |
|
82 |
echo "FATAL: cannot find $IML_TEMPLATE" >&2; exit 1 |
|
83 |
fi |
|
84 |
||
85 |
if [ ! -f "$ANT_TEMPLATE" ] ; then |
|
86 |
echo "FATAL: cannot find $ANT_TEMPLATE" >&2; exit 1 |
|
87 |
fi |
|
88 |
||
89 |
cp -r "$IDEA_TEMPLATE"/* "$IDEA_OUTPUT" |
|
90 |
cd $TOP ; make -f "$IDEA_MAKE/idea.gmk" -I make/common idea MAKEOVERRIDES= OUT=$IDEA_OUTPUT/env.cfg MODULES="$*" || exit 1 |
|
91 |
cd $SCRIPT_DIR |
|
92 |
||
93 |
. $IDEA_OUTPUT/env.cfg |
|
94 |
||
95 |
# Expect MODULE_ROOTS, MODULE_NAMES, BOOT_JDK & SPEC to be set |
|
96 |
if [ "x$MODULE_ROOTS" = "x" ] ; then |
|
97 |
echo "FATAL: MODULE_ROOTS is empty" >&2; exit 1 |
|
98 |
fi |
|
99 |
||
100 |
if [ "x$MODULE_NAMES" = "x" ] ; then |
|
101 |
echo "FATAL: MODULE_NAMES is empty" >&2; exit 1 |
|
102 |
fi |
|
103 |
||
104 |
if [ "x$BOOT_JDK" = "x" ] ; then |
|
105 |
echo "FATAL: BOOT_JDK is empty" >&2; exit 1 |
|
106 |
fi |
|
107 |
||
108 |
if [ "x$SPEC" = "x" ] ; then |
|
109 |
echo "FATAL: SPEC is empty" >&2; exit 1 |
|
110 |
fi |
|
111 |
||
112 |
SOURCE_FOLDER=" <sourceFolder url=\"file://\$MODULE_DIR\$/####\" isTestSource=\"false\" />" |
|
113 |
SOURCE_FOLDERS_DONE="false" |
|
114 |
||
115 |
addSourceFolder() { |
|
116 |
root=$@ |
|
117 |
relativePath="`echo "$root" | sed -e s@"$TOP/\(.*$\)"@"\1"@`" |
|
118 |
folder="`echo "$SOURCE_FOLDER" | sed -e s@"\(.*/\)####\(.*\)"@"\1$relativePath\2"@`" |
|
119 |
printf "%s\n" "$folder" >> $IDEA_IML |
|
120 |
} |
|
121 |
||
122 |
### Generate project iml |
|
123 |
RELATIVE_BUILD_DIR="`dirname $SPEC | sed -e s@"$TOP/\(.*$\)"@"\1"@`" |
|
124 |
rm -f $IDEA_IML |
|
125 |
while IFS= read -r line |
|
126 |
do |
|
127 |
if echo "$line" | egrep "^ .* <sourceFolder.*####" > /dev/null ; then |
|
128 |
if [ "$SOURCE_FOLDERS_DONE" = "false" ] ; then |
|
129 |
SOURCE_FOLDERS_DONE="true" |
|
130 |
for root in $MODULE_ROOTS; do |
|
131 |
addSourceFolder $root |
|
132 |
done |
|
133 |
fi |
|
134 |
elif echo "$line" | egrep "^ .* <excludeFolder.*####" > /dev/null ; then |
|
135 |
ul="`echo "$line" | sed -e s@"\(.*/\)####\(.*\)"@"\1$RELATIVE_BUILD_DIR\2"@`" |
|
136 |
printf "%s\n" "$ul" >> $IDEA_IML |
|
137 |
else |
|
138 |
printf "%s\n" "$line" >> $IDEA_IML |
|
139 |
fi |
|
140 |
done < "$IML_TEMPLATE" |
|
141 |
||
142 |
||
143 |
MODULE_NAME=" <property name=\"module.name\" value=\"####\" />" |
|
144 |
||
145 |
addModuleName() { |
|
146 |
mn="`echo "$MODULE_NAME" | sed -e s@"\(.*\)####\(.*\)"@"\1$MODULE_NAMES\2"@`" |
|
147 |
printf "%s\n" "$mn" >> $IDEA_ANT |
|
148 |
} |
|
149 |
||
150 |
BUILD_DIR=" <property name=\"build.target.dir\" value=\"####\" />" |
|
151 |
||
152 |
addBuildDir() { |
|
153 |
DIR=`dirname $SPEC` |
|
154 |
mn="`echo "$BUILD_DIR" | sed -e s@"\(.*\)####\(.*\)"@"\1$DIR\2"@`" |
|
155 |
printf "%s\n" "$mn" >> $IDEA_ANT |
|
156 |
} |
|
157 |
||
37976
9cc5debe0f47
8157061: Add support for running jtreg tests from IntelliJ project
mcimadamore
parents:
37861
diff
changeset
|
158 |
JTREG_HOME=" <property name=\"jtreg.home\" value=\"####\" />" |
9cc5debe0f47
8157061: Add support for running jtreg tests from IntelliJ project
mcimadamore
parents:
37861
diff
changeset
|
159 |
|
9cc5debe0f47
8157061: Add support for running jtreg tests from IntelliJ project
mcimadamore
parents:
37861
diff
changeset
|
160 |
addJtregHome() { |
9cc5debe0f47
8157061: Add support for running jtreg tests from IntelliJ project
mcimadamore
parents:
37861
diff
changeset
|
161 |
DIR=`dirname $SPEC` |
9cc5debe0f47
8157061: Add support for running jtreg tests from IntelliJ project
mcimadamore
parents:
37861
diff
changeset
|
162 |
mn="`echo "$JTREG_HOME" | sed -e s@"\(.*\)####\(.*\)"@"\1$JT_HOME\2"@`" |
9cc5debe0f47
8157061: Add support for running jtreg tests from IntelliJ project
mcimadamore
parents:
37861
diff
changeset
|
163 |
printf "%s\n" "$mn" >> $IDEA_ANT |
9cc5debe0f47
8157061: Add support for running jtreg tests from IntelliJ project
mcimadamore
parents:
37861
diff
changeset
|
164 |
} |
9cc5debe0f47
8157061: Add support for running jtreg tests from IntelliJ project
mcimadamore
parents:
37861
diff
changeset
|
165 |
|
37861 | 166 |
### Generate ant.xml |
167 |
||
168 |
rm -f $IDEA_ANT |
|
169 |
while IFS= read -r line |
|
170 |
do |
|
171 |
if echo "$line" | egrep "^ .* <property name=\"module.name\"" > /dev/null ; then |
|
172 |
addModuleName |
|
37976
9cc5debe0f47
8157061: Add support for running jtreg tests from IntelliJ project
mcimadamore
parents:
37861
diff
changeset
|
173 |
elif echo "$line" | egrep "^ .* <property name=\"jtreg.home\"" > /dev/null ; then |
9cc5debe0f47
8157061: Add support for running jtreg tests from IntelliJ project
mcimadamore
parents:
37861
diff
changeset
|
174 |
addJtregHome |
37861 | 175 |
elif echo "$line" | egrep "^ .* <property name=\"build.target.dir\"" > /dev/null ; then |
176 |
addBuildDir |
|
177 |
else |
|
178 |
printf "%s\n" "$line" >> $IDEA_ANT |
|
179 |
fi |
|
180 |
done < "$ANT_TEMPLATE" |
|
181 |
||
182 |
### Compile the custom Logger |
|
183 |
||
184 |
CLASSES=$IDEA_OUTPUT/classes |
|
185 |
||
186 |
if [ "x$ANT_HOME" = "x" ] ; then |
|
187 |
# try some common locations, before giving up |
|
188 |
if [ -f "/usr/share/ant/lib/ant.jar" ] ; then |
|
189 |
ANT_HOME="/usr/share/ant" |
|
190 |
elif [ -f "/usr/local/Cellar/ant/1.9.4/libexec/lib/ant.jar" ] ; then |
|
191 |
ANT_HOME="/usr/local/Cellar/ant/1.9.4/libexec" |
|
192 |
else |
|
193 |
echo "FATAL: cannot find ant. Try setting ANT_HOME." >&2; exit 1 |
|
194 |
fi |
|
195 |
fi |
|
196 |
CP=$ANT_HOME/lib/ant.jar |
|
197 |
rm -rf $CLASSES; mkdir $CLASSES |
|
198 |
||
199 |
if [ "x$CYGPATH" = "x" ] ; then ## CYGPATH may be set in env.cfg |
|
200 |
JAVAC_SOURCE_FILE=$IDEA_OUTPUT/src/idea/JdkIdeaAntLogger.java |
|
201 |
JAVAC_CLASSES=$CLASSES |
|
202 |
JAVAC_CP=$CP |
|
203 |
else |
|
204 |
JAVAC_SOURCE_FILE=`cygpath -am $IDEA_OUTPUT/src/idea/JdkIdeaAntLogger.java` |
|
205 |
JAVAC_CLASSES=`cygpath -am $CLASSES` |
|
206 |
JAVAC_CP=`cygpath -am $CP` |
|
207 |
fi |
|
208 |
||
209 |
$BOOT_JDK/bin/javac -d $JAVAC_CLASSES -cp $JAVAC_CP $JAVAC_SOURCE_FILE |