@@ -34,7 +34,7 @@ object MsvcEnvironment {
3434 logger.debug(s " Using vcvars script $vcvars" )
3535
3636 val msvcEnv = captureVcvarsEnv(vcvars, workingDir)
37- val clDir = os.Path (msvcEnv(" VCTOOLSINSTALLDIR" )) / " bin" / " Hostx64" / " x64"
37+ val clDir = os.Path (msvcEnv(" VCTOOLSINSTALLDIR" )) / " bin" / " Hostx64" / " x64"
3838 logger.debug(s " clDir[ $clDir] " )
3939 if (! os.exists(clDir)) {
4040 logger.message(s " cl.exe directory missing: $clDir" )
@@ -44,34 +44,28 @@ object MsvcEnvironment {
4444 val msvcEnv : Map [String , String ] = captureVcvarsEnv(vcvars, workingDir)
4545 val clExe : os.Path = clDir / " cl.exe"
4646 if ! os.exists(clExe) then
47- logger.error (s " not found: $clExe" )
47+ logger.message (s " warning: file not found: $clExe" )
4848
4949 val msvcEntries : Seq [String ] = {
5050 val entries = msvcEnv.getOrElse(" PATH" , " " ).split(" ;" ).toSeq
5151 if entries.headOption == Some (clDir.toString) then entries
5252 else clDir.toString +: entries
5353 }
5454
55- def logMergedEntries (): Unit = {
56- logger.debug(s " msvc PATH entries: " )
57- msvcEntries.foreach { entry =>
58- logger.debug(s " $entry; " )
59- }
60- }
61-
6255 // show aliased drive map
6356 val substMap : Map [Char , String ] = aliasedDriveLetters
6457 substMap.foreach((k, v) => logger.message(s " substMap $k: -> $v" ))
6558
66- val mergedPath = msvcEntries.mkString(" ;" )
67- val mergedEnv =
68- minimalBaseEnv ++
69- msvcEnv +
70- (" PATH" -> mergedPath) +
59+ val finalPath = msvcEntries.mkString(" ;" )
60+ val finalEnv =
61+ msvcEnv +
62+ (" PATH" -> finalPath) +
7163 (" GRAALVM_ARGUMENT_VECTOR_PROGRAM_NAME" -> " native-image" )
7264
73- logger.debug(s " Launching native-image.exe with args: $command" )
74- logMergedEntries()
65+ logger.message(s " msvc PATH entries: " )
66+ msvcEntries.foreach { entry =>
67+ logger.message(s " $entry; " )
68+ }
7569
7670 // Replace native-image.cmd with native-image.exe, if applicable
7771 val updatedCommand : Seq [String ] =
@@ -89,11 +83,13 @@ object MsvcEnvironment {
8983 command
9084 }
9185
86+ logger.message(s " native-image w/args: $updatedCommand" )
87+
9288 val result =
9389 os.proc(updatedCommand)
9490 .call(
9591 cwd = workingDir,
96- env = mergedEnv ,
92+ env = finalEnv ,
9793 stdout = os.Inherit ,
9894 stderr = os.Inherit
9995 )
@@ -228,9 +224,6 @@ object MsvcEnvironment {
228224 candidates.find(os.exists)
229225 }
230226
231- private def minimalBaseEnv : Map [String , String ] =
232- sys.env.filter { case (k, _) => windowsCoreEnvKeys.contains(k) }
233-
234227 private def vcvarsOpt : Option [os.Path ] = {
235228 val candidates =
236229 vcVarsCandidates
@@ -247,33 +240,6 @@ object MsvcEnvironment {
247240 }
248241 }
249242
250- def isAbs (p : String ): Boolean =
251- try os.Path (p).root.nonEmpty
252- catch case _ : Throwable => false
253-
254- def canonicalKey (p : String , cwd : os.Path ): String =
255- try
256- val resolved = cwd.toNIO.resolve(p).normalize()
257- resolved.toRealPath().toString
258- .replace('\\ ' , '/' )
259- .stripSuffix(" /" )
260- .toLowerCase
261- catch
262- case _ : Throwable =>
263- p.replace('\\ ' , '/' ).stripSuffix(" /" ).toLowerCase
264-
265- def dedupePaths (entries : Seq [String ], cwd : os.Path ): Seq [String ] =
266- val seen = scala.collection.mutable.HashSet [String ]()
267- val out = scala.collection.mutable.ArrayBuffer [String ]()
268- for p <- entries.map(_.trim).filter(_.nonEmpty) do
269- val key = canonicalKey(p, cwd)
270- if ! seen.contains(key) then
271- seen += key
272- out += p // preserve original form
273- out.toSeq
274-
275-
276-
277243 // newest VS first, Enterprise > Community > BuildTools
278244 private def vcVersions = Seq (" 2022" , " 2019" , " 2017" )
279245 private def vcEditions = Seq (" Enterprise" , " Community" , " BuildTools" )
@@ -289,16 +255,6 @@ object MsvcEnvironment {
289255 }
290256 }
291257
292- private lazy val windowsCoreEnvKeys = Set (
293- " SystemRoot" ,
294- " ComSpec" ,
295- " PATHEXT" ,
296- " TEMP" ,
297- " TMP" ,
298- " NUMBER_OF_PROCESSORS" ,
299- " PROCESSOR_ARCHITECTURE"
300- )
301-
302258 lazy val mountedDrives : String = {
303259 val str = " HKEY_LOCAL_MACHINE/SYSTEM/MountedDevices" .replace('/' , '\\ ' )
304260 val queryDrives = s " reg query $str"
@@ -313,13 +269,4 @@ object MsvcEnvironment {
313269
314270 lazy val systemRoot : String = sys.env.getOrElse(" SystemRoot" , " C:\\ Windows" ).stripSuffix(" \\ " )
315271 lazy val cmdExe : String = s " $systemRoot\\ System32 \\ cmd.exe "
316-
317- lazy val windowsCorePathEntries : Seq [String ] =
318- Seq (
319- s " $systemRoot\\ System32 " ,
320- s " $systemRoot" ,
321- s " $systemRoot\\ System32 \\ Wbem " ,
322- s " $systemRoot\\ System32 \\ WindowsPowerShell \\ v1.0 " ,
323- s " $systemRoot\\ System32 \\ OpenSSH "
324- )
325272}
0 commit comments