author | rkennke |
Mon, 24 Sep 2018 18:44:39 +0200 | |
changeset 51865 | eb954a4b6083 |
parent 51657 | 0fd48caf8243 |
child 52517 | 59065e5d56ec |
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() { |
|
47217 | 28 |
echo "usage: $0 [-h|--help] [-v|--verbose] [-o|--output <path>] [modules]+" |
37861 | 29 |
exit 1 |
30 |
} |
|
31 |
||
32 |
SCRIPT_DIR=`dirname $0` |
|
48667
f2344724a475
8196081: Add support for customized intellij project templates
mcimadamore
parents:
47217
diff
changeset
|
33 |
#assume TOP is the dir from which the script has been called |
f2344724a475
8196081: Add support for customized intellij project templates
mcimadamore
parents:
47217
diff
changeset
|
34 |
TOP=`pwd` |
37861 | 35 |
cd $SCRIPT_DIR; SCRIPT_DIR=`pwd` |
48667
f2344724a475
8196081: Add support for customized intellij project templates
mcimadamore
parents:
47217
diff
changeset
|
36 |
cd $TOP; |
37861 | 37 |
|
38 |
IDEA_OUTPUT=$TOP/.idea |
|
39 |
VERBOSE="false" |
|
40 |
while [ $# -gt 0 ] |
|
41 |
do |
|
42 |
case $1 in |
|
43 |
-h | --help ) |
|
44 |
usage |
|
45 |
;; |
|
46 |
||
47 |
-v | --vebose ) |
|
48 |
VERBOSE="true" |
|
49 |
;; |
|
50 |
||
51 |
-o | --output ) |
|
51612
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
52 |
IDEA_OUTPUT=$2/.idea |
37861 | 53 |
shift |
54 |
;; |
|
55 |
||
56 |
-*) # bad option |
|
57 |
usage |
|
58 |
;; |
|
59 |
||
60 |
* ) # non option |
|
61 |
break |
|
62 |
;; |
|
63 |
esac |
|
64 |
shift |
|
65 |
done |
|
66 |
||
51612
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
67 |
mkdir -p $IDEA_OUTPUT || exit 1 |
37861 | 68 |
cd $IDEA_OUTPUT; IDEA_OUTPUT=`pwd` |
69 |
||
51612
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
70 |
if [ "x$TOPLEVEL_DIR" = "x" ] ; then |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
71 |
cd $SCRIPT_DIR/.. |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
72 |
TOPLEVEL_DIR=`pwd` |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
73 |
cd $IDEA_OUTPUT |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
74 |
fi |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
75 |
|
48667
f2344724a475
8196081: Add support for customized intellij project templates
mcimadamore
parents:
47217
diff
changeset
|
76 |
MAKE_DIR="$SCRIPT_DIR/../make" |
f2344724a475
8196081: Add support for customized intellij project templates
mcimadamore
parents:
47217
diff
changeset
|
77 |
IDEA_MAKE="$MAKE_DIR/idea" |
37861 | 78 |
IDEA_TEMPLATE="$IDEA_MAKE/template" |
48667
f2344724a475
8196081: Add support for customized intellij project templates
mcimadamore
parents:
47217
diff
changeset
|
79 |
|
f2344724a475
8196081: Add support for customized intellij project templates
mcimadamore
parents:
47217
diff
changeset
|
80 |
cp -r "$IDEA_TEMPLATE"/* "$IDEA_OUTPUT" |
f2344724a475
8196081: Add support for customized intellij project templates
mcimadamore
parents:
47217
diff
changeset
|
81 |
|
51612
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
82 |
#override template |
48667
f2344724a475
8196081: Add support for customized intellij project templates
mcimadamore
parents:
47217
diff
changeset
|
83 |
if [ -d "$TEMPLATES_OVERRIDE" ] ; then |
f2344724a475
8196081: Add support for customized intellij project templates
mcimadamore
parents:
47217
diff
changeset
|
84 |
for file in `ls -p "$TEMPLATES_OVERRIDE" | grep -v /`; do |
f2344724a475
8196081: Add support for customized intellij project templates
mcimadamore
parents:
47217
diff
changeset
|
85 |
cp "$TEMPLATES_OVERRIDE"/$file "$IDEA_OUTPUT"/ |
f2344724a475
8196081: Add support for customized intellij project templates
mcimadamore
parents:
47217
diff
changeset
|
86 |
done |
f2344724a475
8196081: Add support for customized intellij project templates
mcimadamore
parents:
47217
diff
changeset
|
87 |
fi |
37861 | 88 |
|
89 |
if [ "$VERBOSE" = "true" ] ; then |
|
90 |
echo "output dir: $IDEA_OUTPUT" |
|
91 |
echo "idea template dir: $IDEA_TEMPLATE" |
|
92 |
fi |
|
93 |
||
48667
f2344724a475
8196081: Add support for customized intellij project templates
mcimadamore
parents:
47217
diff
changeset
|
94 |
cd $TOP ; make -f "$IDEA_MAKE/idea.gmk" -I $MAKE_DIR/.. idea MAKEOVERRIDES= OUT=$IDEA_OUTPUT/env.cfg MODULES="$*" || exit 1 |
37861 | 95 |
cd $SCRIPT_DIR |
96 |
||
97 |
. $IDEA_OUTPUT/env.cfg |
|
98 |
||
99 |
# Expect MODULE_ROOTS, MODULE_NAMES, BOOT_JDK & SPEC to be set |
|
100 |
if [ "x$MODULE_ROOTS" = "x" ] ; then |
|
101 |
echo "FATAL: MODULE_ROOTS is empty" >&2; exit 1 |
|
102 |
fi |
|
103 |
||
104 |
if [ "x$MODULE_NAMES" = "x" ] ; then |
|
105 |
echo "FATAL: MODULE_NAMES is empty" >&2; exit 1 |
|
106 |
fi |
|
107 |
||
108 |
if [ "x$BOOT_JDK" = "x" ] ; then |
|
109 |
echo "FATAL: BOOT_JDK is empty" >&2; exit 1 |
|
110 |
fi |
|
111 |
||
112 |
if [ "x$SPEC" = "x" ] ; then |
|
113 |
echo "FATAL: SPEC is empty" >&2; exit 1 |
|
114 |
fi |
|
115 |
||
51612
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
116 |
### Replace template variables |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
117 |
|
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
118 |
NUM_REPLACEMENTS=0 |
48667
f2344724a475
8196081: Add support for customized intellij project templates
mcimadamore
parents:
47217
diff
changeset
|
119 |
|
51612
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
120 |
replace_template_file() { |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
121 |
for i in $(seq 1 $NUM_REPLACEMENTS); do |
51657 | 122 |
eval "sed \"s|\${FROM${i}}|\${TO${i}}|g\" $1 > $1.tmp" |
123 |
mv $1.tmp $1 |
|
51612
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
124 |
done |
37861 | 125 |
} |
126 |
||
51612
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
127 |
replace_template_dir() { |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
128 |
for f in `find $1 -type f` ; do |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
129 |
replace_template_file $f |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
130 |
done |
37861 | 131 |
} |
132 |
||
51612
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
133 |
add_replacement() { |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
134 |
NUM_REPLACEMENTS=`expr $NUM_REPLACEMENTS + 1` |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
135 |
eval FROM$NUM_REPLACEMENTS='$1' |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
136 |
eval TO$NUM_REPLACEMENTS='$2' |
47217 | 137 |
} |
138 |
||
51612
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
139 |
add_replacement "###BUILD_DIR###" "`dirname $SPEC`" |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
140 |
add_replacement "###MODULE_NAMES###" "$MODULE_NAMES" |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
141 |
add_replacement "###JTREG_HOME###" "$JT_HOME" |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
142 |
add_replacement "###IMAGES_DIR###" "`dirname $SPEC`/images/jdk" |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
143 |
add_replacement "###ROOT_DIR###" "$TOPLEVEL_DIR" |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
144 |
add_replacement "###IDEA_DIR###" "$IDEA_OUTPUT" |
47217 | 145 |
|
51612
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
146 |
SOURCE_PREFIX="<sourceFolder url=\"file://" |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
147 |
SOURCE_POSTFIX="\" isTestSource=\"false\" />" |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
148 |
|
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
149 |
for root in $MODULE_ROOTS; do |
51657 | 150 |
SOURCES=$SOURCES" $SOURCE_PREFIX""$root""$SOURCE_POSTFIX" |
51612
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
151 |
done |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
152 |
|
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
153 |
add_replacement "###SOURCE_ROOTS###" "$SOURCES" |
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
154 |
|
bdac20c6c8dd
8210226: Add support for multiple project folders to idea.sh
mcimadamore
parents:
51565
diff
changeset
|
155 |
replace_template_dir "$IDEA_OUTPUT" |
47217 | 156 |
|
37861 | 157 |
### Compile the custom Logger |
158 |
||
159 |
CLASSES=$IDEA_OUTPUT/classes |
|
160 |
||
161 |
if [ "x$ANT_HOME" = "x" ] ; then |
|
162 |
# try some common locations, before giving up |
|
163 |
if [ -f "/usr/share/ant/lib/ant.jar" ] ; then |
|
164 |
ANT_HOME="/usr/share/ant" |
|
165 |
elif [ -f "/usr/local/Cellar/ant/1.9.4/libexec/lib/ant.jar" ] ; then |
|
166 |
ANT_HOME="/usr/local/Cellar/ant/1.9.4/libexec" |
|
167 |
else |
|
168 |
echo "FATAL: cannot find ant. Try setting ANT_HOME." >&2; exit 1 |
|
169 |
fi |
|
170 |
fi |
|
171 |
CP=$ANT_HOME/lib/ant.jar |
|
172 |
rm -rf $CLASSES; mkdir $CLASSES |
|
173 |
||
174 |
if [ "x$CYGPATH" = "x" ] ; then ## CYGPATH may be set in env.cfg |
|
175 |
JAVAC_SOURCE_FILE=$IDEA_OUTPUT/src/idea/JdkIdeaAntLogger.java |
|
176 |
JAVAC_CLASSES=$CLASSES |
|
177 |
JAVAC_CP=$CP |
|
178 |
else |
|
179 |
JAVAC_SOURCE_FILE=`cygpath -am $IDEA_OUTPUT/src/idea/JdkIdeaAntLogger.java` |
|
180 |
JAVAC_CLASSES=`cygpath -am $CLASSES` |
|
181 |
JAVAC_CP=`cygpath -am $CP` |
|
182 |
fi |
|
183 |
||
184 |
$BOOT_JDK/bin/javac -d $JAVAC_CLASSES -cp $JAVAC_CP $JAVAC_SOURCE_FILE |