mirror of
https://github.com/darlinghq/darling-openjdk.git
synced 2024-11-26 22:00:25 +00:00
8210226: Add support for multiple project folders to idea.sh
Overhaul templating logic for idea.sh; add support for -o option Reviewed-by: erikj, ihse
This commit is contained in:
parent
3a37a5d219
commit
4871d9935e
130
bin/idea.sh
130
bin/idea.sh
@ -49,7 +49,7 @@ do
|
||||
;;
|
||||
|
||||
-o | --output )
|
||||
IDEA_OUTPUT=$2
|
||||
IDEA_OUTPUT=$2/.idea
|
||||
shift
|
||||
;;
|
||||
|
||||
@ -64,28 +64,25 @@ do
|
||||
shift
|
||||
done
|
||||
|
||||
mkdir $IDEA_OUTPUT || exit 1
|
||||
mkdir -p $IDEA_OUTPUT || exit 1
|
||||
cd $IDEA_OUTPUT; IDEA_OUTPUT=`pwd`
|
||||
|
||||
if [ "x$TOPLEVEL_DIR" = "x" ] ; then
|
||||
cd $SCRIPT_DIR/..
|
||||
TOPLEVEL_DIR=`pwd`
|
||||
cd $IDEA_OUTPUT
|
||||
fi
|
||||
|
||||
MAKE_DIR="$SCRIPT_DIR/../make"
|
||||
IDEA_MAKE="$MAKE_DIR/idea"
|
||||
IDEA_TEMPLATE="$IDEA_MAKE/template"
|
||||
|
||||
cp -r "$IDEA_TEMPLATE"/* "$IDEA_OUTPUT"
|
||||
|
||||
#init template variables
|
||||
for file in `ls -p $IDEA_TEMPLATE | grep -v /`; do
|
||||
VAR_SUFFIX=`echo $file | cut -d'.' -f1 | tr [:lower:] [:upper:]`
|
||||
eval "$VAR_SUFFIX"_TEMPLATE="$IDEA_TEMPLATE"/$file
|
||||
eval IDEA_"$VAR_SUFFIX"="$IDEA_OUTPUT"/$file
|
||||
done
|
||||
|
||||
#override template variables
|
||||
#override template
|
||||
if [ -d "$TEMPLATES_OVERRIDE" ] ; then
|
||||
for file in `ls -p "$TEMPLATES_OVERRIDE" | grep -v /`; do
|
||||
cp "$TEMPLATES_OVERRIDE"/$file "$IDEA_OUTPUT"/
|
||||
VAR_SUFFIX=`echo $file | cut -d'.' -f1 | tr [:lower:] [:upper:]`
|
||||
eval "$VAR_SUFFIX"_TEMPLATE="$TEMPLATES_OVERRIDE"/$file
|
||||
done
|
||||
fi
|
||||
|
||||
@ -94,14 +91,6 @@ if [ "$VERBOSE" = "true" ] ; then
|
||||
echo "idea template dir: $IDEA_TEMPLATE"
|
||||
fi
|
||||
|
||||
if [ ! -f "$JDK_TEMPLATE" ] ; then
|
||||
echo "FATAL: cannot find $JDK_TEMPLATE" >&2; exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$ANT_TEMPLATE" ] ; then
|
||||
echo "FATAL: cannot find $ANT_TEMPLATE" >&2; exit 1
|
||||
fi
|
||||
|
||||
cd $TOP ; make -f "$IDEA_MAKE/idea.gmk" -I $MAKE_DIR/.. idea MAKEOVERRIDES= OUT=$IDEA_OUTPUT/env.cfg MODULES="$*" || exit 1
|
||||
cd $SCRIPT_DIR
|
||||
|
||||
@ -124,8 +113,6 @@ if [ "x$SPEC" = "x" ] ; then
|
||||
echo "FATAL: SPEC is empty" >&2; exit 1
|
||||
fi
|
||||
|
||||
SOURCE_FOLDER=" <sourceFolder url=\"file://\$MODULE_DIR\$/####\" isTestSource=\"false\" />"
|
||||
SOURCE_FOLDERS_DONE="false"
|
||||
|
||||
addSourceFolder() {
|
||||
root=$@
|
||||
@ -134,84 +121,45 @@ addSourceFolder() {
|
||||
printf "%s\n" "$folder" >> $IDEA_JDK
|
||||
}
|
||||
|
||||
### Generate project iml
|
||||
### Replace template variables
|
||||
|
||||
rm -f $IDEA_JDK
|
||||
while IFS= read -r line
|
||||
do
|
||||
if echo "$line" | egrep "^ .* <sourceFolder.*####" > /dev/null ; then
|
||||
if [ "$SOURCE_FOLDERS_DONE" = "false" ] ; then
|
||||
SOURCE_FOLDERS_DONE="true"
|
||||
for root in $MODULE_ROOTS; do
|
||||
addSourceFolder $root
|
||||
done
|
||||
fi
|
||||
else
|
||||
printf "%s\n" "$line" >> $IDEA_JDK
|
||||
fi
|
||||
done < "$JDK_TEMPLATE"
|
||||
NUM_REPLACEMENTS=0
|
||||
|
||||
|
||||
MODULE_NAME=" <property name=\"module.name\" value=\"####\" />"
|
||||
|
||||
addModuleName() {
|
||||
mn="`echo "$MODULE_NAME" | sed -e s@"\(.*\)####\(.*\)"@"\1$MODULE_NAMES\2"@`"
|
||||
printf "%s\n" "$mn" >> $IDEA_ANT
|
||||
replace_template_file() {
|
||||
for i in $(seq 1 $NUM_REPLACEMENTS); do
|
||||
eval "sed -i \"s|\${FROM${i}}|\${TO${i}}|g\" $1"
|
||||
done
|
||||
}
|
||||
|
||||
BUILD_DIR=" <property name=\"build.target.dir\" value=\"####\" />"
|
||||
|
||||
addBuildDir() {
|
||||
DIR=`dirname $SPEC`
|
||||
mn="`echo "$BUILD_DIR" | sed -e s@"\(.*\)####\(.*\)"@"\1$DIR\2"@`"
|
||||
printf "%s\n" "$mn" >> $IDEA_ANT
|
||||
replace_template_dir() {
|
||||
for f in `find $1 -type f` ; do
|
||||
replace_template_file $f
|
||||
done
|
||||
}
|
||||
|
||||
### Generate ant.xml
|
||||
|
||||
rm -f $IDEA_ANT
|
||||
while IFS= read -r line
|
||||
do
|
||||
if echo "$line" | egrep "^ .* <property name=\"module.name\"" > /dev/null ; then
|
||||
addModuleName
|
||||
elif echo "$line" | egrep "^ .* <property name=\"build.target.dir\"" > /dev/null ; then
|
||||
addBuildDir
|
||||
else
|
||||
printf "%s\n" "$line" >> $IDEA_ANT
|
||||
fi
|
||||
done < "$ANT_TEMPLATE"
|
||||
|
||||
### Generate misc.xml
|
||||
|
||||
rm -f $IDEA_MISC
|
||||
|
||||
JTREG_HOME=" <path>####</path>"
|
||||
|
||||
IMAGES_DIR=" <jre alt=\"true\" value=\"####\" />"
|
||||
|
||||
addImagesDir() {
|
||||
DIR=`dirname $SPEC`/images/jdk
|
||||
mn="`echo "$IMAGES_DIR" | sed -e s@"\(.*\)####\(.*\)"@"\1$DIR\2"@`"
|
||||
printf "%s\n" "$mn" >> $IDEA_MISC
|
||||
add_replacement() {
|
||||
NUM_REPLACEMENTS=`expr $NUM_REPLACEMENTS + 1`
|
||||
eval FROM$NUM_REPLACEMENTS='$1'
|
||||
eval TO$NUM_REPLACEMENTS='$2'
|
||||
}
|
||||
|
||||
addJtregHome() {
|
||||
DIR=`dirname $SPEC`
|
||||
mn="`echo "$JTREG_HOME" | sed -e s@"\(.*\)####\(.*\)"@"\1$JT_HOME\2"@`"
|
||||
printf "%s\n" "$mn" >> $IDEA_MISC
|
||||
}
|
||||
add_replacement "###BUILD_DIR###" "`dirname $SPEC`"
|
||||
add_replacement "###MODULE_NAMES###" "$MODULE_NAMES"
|
||||
add_replacement "###JTREG_HOME###" "$JT_HOME"
|
||||
add_replacement "###IMAGES_DIR###" "`dirname $SPEC`/images/jdk"
|
||||
add_replacement "###ROOT_DIR###" "$TOPLEVEL_DIR"
|
||||
add_replacement "###IDEA_DIR###" "$IDEA_OUTPUT"
|
||||
|
||||
rm -f $MISC_ANT
|
||||
while IFS= read -r line
|
||||
do
|
||||
if echo "$line" | egrep "^ .*<path>jtreg_home</path>" > /dev/null ; then
|
||||
addJtregHome
|
||||
elif echo "$line" | egrep "^ .*<jre alt=\"true\" value=\"images_jdk\"" > /dev/null ; then
|
||||
addImagesDir
|
||||
else
|
||||
printf "%s\n" "$line" >> $IDEA_MISC
|
||||
fi
|
||||
done < "$MISC_TEMPLATE"
|
||||
SOURCE_PREFIX="<sourceFolder url=\"file://"
|
||||
SOURCE_POSTFIX="\" isTestSource=\"false\" />"
|
||||
|
||||
for root in $MODULE_ROOTS; do
|
||||
SOURCES=$SOURCES"\n$SOURCE_PREFIX""$root""$SOURCE_POSTFIX"
|
||||
done
|
||||
|
||||
add_replacement "###SOURCE_ROOTS###" "$SOURCES"
|
||||
|
||||
replace_template_dir "$IDEA_OUTPUT"
|
||||
|
||||
### Compile the custom Logger
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AntConfiguration">
|
||||
<buildFile url="file://$PROJECT_DIR$/make/idea/build.xml">
|
||||
<buildFile url="file://###ROOT_DIR###/make/idea/build.xml">
|
||||
<properties>
|
||||
<property name="intellij.ismake" value="$IsMake$" />
|
||||
<property name="build.target.dir" value="specDir" /> <!-- this will be replaced -->
|
||||
<property name="module.name" value="java.base" /> <!-- this will be replaced -->
|
||||
<property name="idea.dir" value="$ModuleFileDir$" />
|
||||
<property name="build.target.dir" value="###BUILD_DIR###" />
|
||||
<property name="module.name" value="###MODULE_NAMES###" />
|
||||
<property name="idea.dir" value="###IDEA_DIR###" />
|
||||
</properties>
|
||||
<executeOn event="afterCompilation" target="post-make" />
|
||||
</buildFile>
|
||||
|
@ -3,10 +3,10 @@
|
||||
<component name="CompilerConfiguration">
|
||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||
<excludeFromCompile>
|
||||
<directory url="file://$PROJECT_DIR$/src" includeSubdirectories="true" />
|
||||
<directory url="file://$PROJECT_DIR$/build" includeSubdirectories="true" />
|
||||
<directory url="file://$PROJECT_DIR$/make" includeSubdirectories="true" />
|
||||
<directory url="file://$PROJECT_DIR$/test" includeSubdirectories="true" />
|
||||
<directory url="file://###ROOT_DIR###/src" includeSubdirectories="true" />
|
||||
<directory url="file://###ROOT_DIR###/build" includeSubdirectories="true" />
|
||||
<directory url="file://###ROOT_DIR###/make" includeSubdirectories="true" />
|
||||
<directory url="file://###ROOT_DIR###/test" includeSubdirectories="true" />
|
||||
</excludeFromCompile>
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
@ -25,4 +25,5 @@
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
||||
</project>
|
||||
|
||||
|
@ -2,10 +2,10 @@
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/####" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/make" />
|
||||
<content url="file://###ROOT_DIR###">
|
||||
###SOURCE_ROOTS###
|
||||
<excludeFolder url="file://###ROOT_DIR###/build" />
|
||||
<excludeFolder url="file://###ROOT_DIR###/make" />
|
||||
</content>
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
|
@ -4,15 +4,15 @@
|
||||
<entry_points version="2.0" />
|
||||
</component>
|
||||
<component name="JTRegService">
|
||||
<path>jtreg_home</path> <!-- this will be replaced -->
|
||||
<workDir>build</workDir>
|
||||
<jre alt="true" value="images_jdk" /> <!-- this will be replaced -->
|
||||
<path>###JTREG_HOME###</path>
|
||||
<workDir>###BUILD_DIR###</workDir>
|
||||
<jre alt="true" value="###IMAGES_DIR###" />
|
||||
<options></options>
|
||||
<ant>
|
||||
<target file="file://$PROJECT_DIR$/make/idea/build.xml" name="images" />
|
||||
<target file="file://###ROOT_DIR###/make/idea/build.xml" name="images" />
|
||||
</ant>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_9" assert-keyword="true" jdk-15="true">
|
||||
<output url="file://$PROJECT_DIR$/build/out" />
|
||||
<output url="file://###BUILD_DIR###" />
|
||||
</component>
|
||||
</project>
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="hg4idea" />
|
||||
<mapping directory="###ROOT_DIR###" vcs="hg4idea" />
|
||||
</component>
|
||||
</project>
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<ignored path="jdk.iws" />
|
||||
<ignored path="$PROJECT_DIR$/build/idea/out/" />
|
||||
<ignored path="###ROOT_DIR###/build/idea/out/" />
|
||||
<ignored path=".idea/" />
|
||||
</component>
|
||||
<component name="StructureViewFactory">
|
||||
@ -11,7 +11,7 @@
|
||||
<component name="antWorkspaceConfiguration">
|
||||
<option name="IS_AUTOSCROLL_TO_SOURCE" value="false" />
|
||||
<option name="FILTER_TARGETS" value="false" />
|
||||
<buildFile url="file://$PROJECT_DIR$/make/idea/build.xml">
|
||||
<buildFile url="file://###ROOT_DIR###/make/idea/build.xml">
|
||||
<runInBackground value="false" />
|
||||
<targetFilters>
|
||||
<filter targetName="clean" isVisible="true" />
|
||||
|
@ -1,7 +1,7 @@
|
||||
<!-- importing.xml -->
|
||||
<project name="langtools" basedir = "../../..">
|
||||
|
||||
<script language="javascript" classpath="${idea.dir}/classes">
|
||||
<script language="javascript" classpath=".idea/classes">
|
||||
var LangtoolsLogger = Java.type("idea.LangtoolsIdeaAntLogger");
|
||||
new LangtoolsLogger(project)
|
||||
</script>
|
||||
|
@ -5,7 +5,6 @@
|
||||
<properties>
|
||||
<property name="langtools.jdk.home" value="@IDEA_TARGET_JDK@" />
|
||||
<property name="intellij.ismake" value="$IsMake$" />
|
||||
<property name="idea.dir" value="$ModuleFileDir$" />
|
||||
</properties>
|
||||
<executeOn event="afterCompilation" target="post-make" />
|
||||
</buildFile>
|
||||
|
@ -13,6 +13,6 @@
|
||||
</ant>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/.idea-support/out" />
|
||||
<output url="file://$PROJECT_DIR$/build" />
|
||||
</component>
|
||||
</project>
|
||||
|
Loading…
Reference in New Issue
Block a user