Skip to content

Commit d835482

Browse files
Copy GraalVM install under shorter path on Windows
Makes it less likely for GraalVM to refer to header files whose path has more than 256 characters, which seems to be a problem sometimes when passed to cl.exe by native-image.
1 parent 6207a21 commit d835482

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

.github/scripts/generate-native-image.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ COMMAND="cli.base-image.writeNativeImageScript"
66
# Using 'mill -i' so that the Mill process doesn't outlive this invocation
77

88
if [[ "$OSTYPE" == "msys" ]]; then
9+
./mill.bat -i ci.copyJvm --dest jvm
10+
export JAVA_HOME="$(pwd -W | sed 's,/,\\,g')\\jvm"
11+
export GRAALVM_HOME="$JAVA_HOME"
12+
export PATH="$(pwd)/bin:$PATH"
13+
echo "PATH=$PATH"
914
./mill.bat -i "$COMMAND" generate-native-image.bat
1015
# Ideally, the generated script should create that directory itself
1116
mkdir -p out/cli/base-image/nativeImage/dest

build.sc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,4 +1069,23 @@ object ci extends Module {
10691069
def setShouldPublish() = T.command {
10701070
publish.setShouldPublish()
10711071
}
1072+
1073+
def copyJvm(jvm: String = deps.graalVmJvmId, dest: String = "jvm") = T.command {
1074+
import sys.process._
1075+
val command = Seq(
1076+
settings.cs(),
1077+
"java-home",
1078+
"--jvm",
1079+
jvm,
1080+
"--update",
1081+
"--ttl",
1082+
"0"
1083+
)
1084+
val baseJavaHome = os.Path(command.!!.trim, os.pwd)
1085+
System.err.println(s"Initial Java home $baseJavaHome")
1086+
val destJavaHome = os.Path(dest, os.pwd)
1087+
os.copy(baseJavaHome, destJavaHome, createFolders = true)
1088+
System.err.println(s"New Java home $destJavaHome")
1089+
destJavaHome
1090+
}
10721091
}

0 commit comments

Comments
 (0)