From 964bac9e38460df4bd1ad9d25136d5e9743028dd Mon Sep 17 00:00:00 2001 From: Nikita Gubarkov Date: Fri, 28 May 2021 19:53:57 +0000 Subject: [PATCH] 8267706: bin/idea.sh tries to use cygpath on WSL Reviewed-by: erikj --- bin/idea.sh | 161 ++++---- make/ide/idea/jdk/build.xml | 42 -- make/ide/idea/jdk/idea.gmk | 11 +- make/ide/idea/jdk/template/ant.xml | 14 - make/ide/idea/jdk/template/compiler.xml | 8 +- make/ide/idea/jdk/template/jdk.iml | 7 +- make/ide/idea/jdk/template/misc.xml | 8 +- make/ide/idea/jdk/template/module.iml | 13 + make/ide/idea/jdk/template/modules.xml | 2 + .../template/src/idea/IdeaLoggerWrapper.java | 13 - .../template/src/idea/JdkIdeaAntLogger.java | 375 ------------------ make/ide/idea/jdk/template/test.iml | 10 + make/ide/idea/jdk/template/vcs.xml | 2 +- make/ide/idea/jdk/template/workspace.xml | 105 +++-- 14 files changed, 172 insertions(+), 599 deletions(-) delete mode 100644 make/ide/idea/jdk/build.xml delete mode 100644 make/ide/idea/jdk/template/ant.xml create mode 100644 make/ide/idea/jdk/template/module.iml delete mode 100644 make/ide/idea/jdk/template/src/idea/IdeaLoggerWrapper.java delete mode 100644 make/ide/idea/jdk/template/src/idea/JdkIdeaAntLogger.java create mode 100644 make/ide/idea/jdk/template/test.iml diff --git a/bin/idea.sh b/bin/idea.sh index 49c6ee45e3b..2a2378e6eb2 100644 --- a/bin/idea.sh +++ b/bin/idea.sh @@ -36,6 +36,7 @@ cd $SCRIPT_DIR; SCRIPT_DIR=`pwd` cd $TOP; IDEA_OUTPUT=$TOP/.idea +CUSTOM_IDEA_OUTPUT=false VERBOSE="false" while [ $# -gt 0 ] do @@ -50,6 +51,7 @@ do -o | --output ) IDEA_OUTPUT=$2/.idea + CUSTOM_IDEA_OUTPUT=true shift ;; @@ -77,7 +79,7 @@ MAKE_DIR="$SCRIPT_DIR/../make" IDEA_MAKE="$MAKE_DIR/ide/idea/jdk" IDEA_TEMPLATE="$IDEA_MAKE/template" -cp -r "$IDEA_TEMPLATE"/* "$IDEA_OUTPUT" +cp -rn "$IDEA_TEMPLATE"/* "$IDEA_OUTPUT" #override template if [ -d "$TEMPLATES_OVERRIDE" ] ; then @@ -96,9 +98,9 @@ cd $SCRIPT_DIR . $IDEA_OUTPUT/env.cfg -# Expect MODULE_ROOTS, MODULE_NAMES, BOOT_JDK & SPEC to be set -if [ "x$MODULE_ROOTS" = "x" ] ; then - echo "FATAL: MODULE_ROOTS is empty" >&2; exit 1 +# Expect MODULES, MODULE_NAMES, BOOT_JDK & SPEC to be set +if [ "xMODULES" = "x" ] ; then + echo "FATAL: MODULES is empty" >&2; exit 1 fi if [ "x$MODULE_NAMES" = "x" ] ; then @@ -147,102 +149,89 @@ add_replacement() { add_replacement "###MODULE_NAMES###" "$MODULE_NAMES" add_replacement "###VCS_TYPE###" "$VCS_TYPE" SPEC_DIR=`dirname $SPEC` -if [ "x$CYGPATH" != "x" ]; then - add_replacement "###BUILD_DIR###" "`cygpath -am $SPEC_DIR`" - add_replacement "###IMAGES_DIR###" "`cygpath -am $SPEC_DIR`/images/jdk" - add_replacement "###ROOT_DIR###" "`cygpath -am $TOPLEVEL_DIR`" - add_replacement "###IDEA_DIR###" "`cygpath -am $IDEA_OUTPUT`" +RELATIVE_SPEC_DIR="`realpath --relative-to=\"$TOPLEVEL_DIR\" \"$SPEC_DIR\"`" +add_replacement "###BUILD_DIR###" "$RELATIVE_SPEC_DIR" +add_replacement "###IMAGES_DIR###" "$RELATIVE_SPEC_DIR/images/jdk" +if [ "x$PATHTOOL" != "x" ]; then + if [ "$CUSTOM_IDEA_OUTPUT" = true ]; then + add_replacement "###BASH_RUNNER_PREFIX###" "`$PATHTOOL -am $IDEA_OUTPUT/.idea/bash.bat`" + else + add_replacement "###BASH_RUNNER_PREFIX###" ".idea\\\\bash.bat" + fi +else + add_replacement "###BASH_RUNNER_PREFIX###" "" +fi +if [ "x$PATHTOOL" != "x" ]; then if [ "x$JT_HOME" = "x" ]; then add_replacement "###JTREG_HOME###" "" else - add_replacement "###JTREG_HOME###" "`cygpath -am $JT_HOME`" - fi -elif [ "x$WSL_DISTRO_NAME" != "x" ]; then - add_replacement "###BUILD_DIR###" "`wslpath -am $SPEC_DIR`" - add_replacement "###IMAGES_DIR###" "`wslpath -am $SPEC_DIR`/images/jdk" - add_replacement "###ROOT_DIR###" "`wslpath -am $TOPLEVEL_DIR`" - add_replacement "###IDEA_DIR###" "`wslpath -am $IDEA_OUTPUT`" - if [ "x$JT_HOME" = "x" ]; then - add_replacement "###JTREG_HOME###" "" - else - add_replacement "###JTREG_HOME###" "`wslpath -am $JT_HOME`" + add_replacement "###JTREG_HOME###" "`$PATHTOOL -am $JT_HOME`" fi else - add_replacement "###BUILD_DIR###" "$SPEC_DIR" add_replacement "###JTREG_HOME###" "$JT_HOME" - add_replacement "###IMAGES_DIR###" "$SPEC_DIR/images/jdk" - add_replacement "###ROOT_DIR###" "$TOPLEVEL_DIR" - add_replacement "###IDEA_DIR###" "$IDEA_OUTPUT" fi -SOURCE_PREFIX="" - -for root in $MODULE_ROOTS; do - if [ "x$CYGPATH" != "x" ]; then - root=`cygpath -am $root` - elif [ "x$WSL_DISTRO_NAME" != "x" ]; then - root=`wslpath -am $root` - fi - - VM_CI="jdk.internal.vm.ci/share/classes" - VM_COMPILER="src/jdk.internal.vm.compiler/share/classes" - if test "${root#*$VM_CI}" != "$root" || test "${root#*$VM_COMPILER}" != "$root"; then - for subdir in "$root"/*; do - if [ -d "$subdir" ]; then - SOURCES=$SOURCES" $SOURCE_PREFIX""$subdir"/src"$SOURCE_POSTFIX" - fi - done - else - SOURCES=$SOURCES" $SOURCE_PREFIX""$root""$SOURCE_POSTFIX" - fi +MODULE_IMLS="" +TEST_MODULE_DEPENDENCIES="" +for module in $MODULE_NAMES; do + MODULE_IMLS="$MODULE_IMLS " + TEST_MODULE_DEPENDENCIES="$TEST_MODULE_DEPENDENCIES " done - -add_replacement "###SOURCE_ROOTS###" "$SOURCES" +add_replacement "###MODULE_IMLS###" "$MODULE_IMLS" +add_replacement "###TEST_MODULE_DEPENDENCIES###" "$TEST_MODULE_DEPENDENCIES" replace_template_dir "$IDEA_OUTPUT" -### Compile the custom Logger +### Generate module project files -CLASSES=$IDEA_OUTPUT/classes - -if [ "x$ANT_HOME" = "x" ] ; then - # try some common locations, before giving up - if [ -f "/usr/share/ant/lib/ant.jar" ] ; then - ANT_HOME="/usr/share/ant" - elif [ -f "/usr/local/Cellar/ant/1.9.4/libexec/lib/ant.jar" ] ; then - ANT_HOME="/usr/local/Cellar/ant/1.9.4/libexec" - else - echo "FATAL: cannot find ant. Try setting ANT_HOME." >&2; exit 1 - fi -fi -CP=$ANT_HOME/lib/ant.jar -rm -rf $CLASSES; mkdir $CLASSES - -if [ "x$CYGPATH" != "x" ] ; then ## CYGPATH may be set in env.cfg - JAVAC_SOURCE_FILE=`cygpath -am $IDEA_OUTPUT/src/idea/IdeaLoggerWrapper.java` - JAVAC_SOURCE_PATH=`cygpath -am $IDEA_OUTPUT/src` - JAVAC_CLASSES=`cygpath -am $CLASSES` - JAVAC_CP=`cygpath -am $CP` - JAVAC=javac -elif [ "x$WSL_DISTRO_NAME" != "x" ]; then - JAVAC_SOURCE_FILE=`realpath --relative-to=./ $IDEA_OUTPUT/src/idea/IdeaLoggerWrapper.java` - JAVAC_SOURCE_PATH=`realpath --relative-to=./ $IDEA_OUTPUT/src` - JAVAC_CLASSES=`realpath --relative-to=./ $CLASSES` - ANT_TEMP=`mktemp -d -p ./` - cp $ANT_HOME/lib/ant.jar $ANT_TEMP/ant.jar - JAVAC_CP=$ANT_TEMP/ant.jar - JAVAC=javac.exe +( +DEFAULT_IFS="$IFS" +IFS='#' +if [ "x$PATHTOOL" != "x" ]; then + TOPDIR_FOR_RELATIVITY_CHECKS="`echo \"$TOPLEVEL_DIR\" | tr '[:upper:]' '[:lower:]'`" else - JAVAC_SOURCE_FILE=$IDEA_OUTPUT/src/idea/IdeaLoggerWrapper.java - JAVAC_SOURCE_PATH=$IDEA_OUTPUT/src - JAVAC_CLASSES=$CLASSES - JAVAC_CP=$CP - JAVAC=javac + TOPDIR_FOR_RELATIVITY_CHECKS="$TOPLEVEL_DIR" fi +for value in $MODULES; do + ( + eval "$value" + if [ "$VERBOSE" = "true" ] ; then + echo "generating project module: $module" + fi + add_replacement "###MODULE_DIR###" "src/$module" + SOURCE_DIRS="" + IFS=' ' + for dir in $moduleSrcDirs; do + if [ "x$PATHTOOL" != "x" ]; then + dir="`echo \"$dir\" | tr '[:upper:]' '[:lower:]'`" + fi + dir="`realpath --relative-to=\"$TOPDIR_FOR_RELATIVITY_CHECKS\" \"$dir\"`" + case $dir in # Exclude generated sources to avoid module-info conflicts, see https://youtrack.jetbrains.com/issue/IDEA-185108 + "$SPEC_DIR"*) ;; + *) SOURCE_DIRS="$SOURCE_DIRS " + esac + done + add_replacement "###SOURCE_DIRS###" "$SOURCE_DIRS" + DEPENDENCIES="" + for dep in $moduleDependencies; do + DEPENDENCIES="$DEPENDENCIES " + done + add_replacement "###DEPENDENCIES###" "$DEPENDENCIES" + cp "$IDEA_OUTPUT/module.iml" "$IDEA_OUTPUT/$module.iml" + IFS="$DEFAULT_IFS" + replace_template_file "$IDEA_OUTPUT/$module.iml" + ) +done +) +rm "$IDEA_OUTPUT/module.iml" -$BOOT_JDK/bin/$JAVAC -d $JAVAC_CLASSES -sourcepath $JAVAC_SOURCE_PATH -cp $JAVAC_CP $JAVAC_SOURCE_FILE +### Create shell script runner for Windows -if [ "x$WSL_DISTRO_NAME" != "x" ]; then - rm -rf $ANT_TEMP -fi \ No newline at end of file +if [ "x$PATHTOOL" != "x" ]; then + echo "@echo off" > "$IDEA_OUTPUT/bash.bat" + if [ "x$WSL_DISTRO_NAME" != "x" ] ; then + echo "wsl -d $WSL_DISTRO_NAME --cd \"%cd%\" -e %*" >> "$IDEA_OUTPUT/bash.bat" + else + echo "$WINENV_ROOT\bin\bash.exe -l -c \"cd %CD:\=/%/ && %*\"" >> "$IDEA_OUTPUT/bash.bat" + fi +fi diff --git a/make/ide/idea/jdk/build.xml b/make/ide/idea/jdk/build.xml deleted file mode 100644 index 0292f0f5d35..00000000000 --- a/make/ide/idea/jdk/build.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/make/ide/idea/jdk/idea.gmk b/make/ide/idea/jdk/idea.gmk index 310b582591c..455ac182c62 100644 --- a/make/ide/idea/jdk/idea.gmk +++ b/make/ide/idea/jdk/idea.gmk @@ -46,13 +46,18 @@ else #with SPEC endif idea: - $(ECHO) "SUPPORT=$(SUPPORT_OUTPUTDIR)" >> $(OUT) - $(ECHO) "MODULE_ROOTS=\"$(foreach mod, $(SEL_MODULES), $(call FindModuleSrcDirs,$(mod)))\"" >> $(OUT) + $(ECHO) "SUPPORT=$(SUPPORT_OUTPUTDIR)" > $(OUT) + $(ECHO) "MODULES=\"$(foreach mod, $(SEL_MODULES), \ + module='$(mod)' \ + moduleSrcDirs='$(call FindModuleSrcDirs,$(mod))' \ + moduleDependencies='$(call FindTransitiveDepsForModule,$(mod))' \ + #)\"" >> $(OUT) $(ECHO) "MODULE_NAMES=\"$(strip $(foreach mod, $(SEL_MODULES), $(mod)))\"" >> $(OUT) $(ECHO) "SEL_MODULES=\"$(SEL_MODULES)\"" >> $(OUT) $(ECHO) "BOOT_JDK=\"$(BOOT_JDK)\"" >> $(OUT) - $(ECHO) "CYGPATH=\"$(PATHTOOL)\"" >> $(OUT) + $(ECHO) "PATHTOOL=\"$(PATHTOOL)\"" >> $(OUT) $(ECHO) "SPEC=\"$(SPEC)\"" >> $(OUT) $(ECHO) "JT_HOME=\"$(JT_HOME)\"" >> $(OUT) + $(ECHO) "WINENV_ROOT=\"$(WINENV_ROOT)\"" >> $(OUT) endif diff --git a/make/ide/idea/jdk/template/ant.xml b/make/ide/idea/jdk/template/ant.xml deleted file mode 100644 index 9cb90246ea0..00000000000 --- a/make/ide/idea/jdk/template/ant.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/make/ide/idea/jdk/template/compiler.xml b/make/ide/idea/jdk/template/compiler.xml index eef129e7b87..309f5608043 100644 --- a/make/ide/idea/jdk/template/compiler.xml +++ b/make/ide/idea/jdk/template/compiler.xml @@ -3,10 +3,10 @@