Skip to content

Commit 0c88214

Browse files
authored
Merge pull request #5085 from martijnhoekstra/winbuild
use cross platform path separatator in build
2 parents f5a6b74 + 0b0c763 commit 0c88214

File tree

7 files changed

+21
-18
lines changed

7 files changed

+21
-18
lines changed

bench/src/main/scala/Benchmarks.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ object Bench {
6363

6464
var cpIndex = argsNorm.indexOf("-classpath")
6565
if (cpIndex == -1) cpIndex = argsNorm.indexOf("-cp")
66-
if (cpIndex != -1) argsNorm(cpIndex + 1) = argsNorm(cpIndex + 1) + ":" + libs
66+
if (cpIndex != -1) argsNorm(cpIndex + 1) = argsNorm(cpIndex + 1) + java.io.File.pathSeparator + libs
6767
else argsNorm = argsNorm :+ "-classpath" :+ libs
6868

6969
val file = new File(COMPILE_OPTS_FILE)

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ class ClassfileParser(
763763

764764
if (allowed != "always") {
765765
failUnless(allowed != "never")
766-
val allowedList = allowed.split(":").toList
766+
val allowedList = allowed.split(java.io.File.pathSeparator).toList
767767
val file = classRoot.symbol.associatedFile
768768
// Using `.toString.contains` isn't great, but it's good enough for a debug flag.
769769
failUnless(file == null || allowedList.exists(path => file.toString.contains(path)))

compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class QuoteDriver extends Driver {
8181
// Loads the classes loaded by this class loader
8282
// When executing `run` or `test` in sbt the classpath is not in the property java.class.path
8383
val newClasspath = cl.getURLs.map(_.getFile())
84-
classpath = newClasspath.mkString("", ":", if (classpath == "") "" else ":" + classpath)
84+
classpath = newClasspath.mkString("", java.io.File.pathSeparator, if (classpath == "") "" else java.io.File.pathSeparator + classpath)
8585
case _ =>
8686
}
8787
ictx.settings.classpath.update(classpath)(ictx)

compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class ReifyQuotes extends MacroTransformWithImplicits {
6666
private[this] var myMacroClassLoader: java.lang.ClassLoader = _
6767
private def macroClassLoader(implicit ctx: Context): ClassLoader = {
6868
if (myMacroClassLoader == null) {
69-
val urls = ctx.settings.classpath.value.split(':').map(cp => java.nio.file.Paths.get(cp).toUri.toURL)
69+
val urls = ctx.settings.classpath.value.split(java.io.File.pathSeparatorChar).map(cp => java.nio.file.Paths.get(cp).toUri.toURL)
7070
myMacroClassLoader = new java.net.URLClassLoader(urls, getClass.getClassLoader)
7171
}
7272
myMacroClassLoader

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,16 @@ class CompilationTests extends ParallelTesting {
200200
// Make sure that the directory is clean
201201
dotty.tools.io.Directory(defaultOutputDir + "tastyBootstrap").deleteRecursively()
202202

203+
val sep = java.io.File.pathSeparator
204+
203205
val opt = TestFlags(
204206
// compile with bootstrapped library on cp:
205-
defaultOutputDir + libGroup + "/src/:" +
207+
defaultOutputDir + libGroup + "/src/" + sep +
206208
// as well as bootstrapped compiler:
207-
defaultOutputDir + dotty1Group + "/dotty/:" +
209+
defaultOutputDir + dotty1Group + "/dotty/" + sep +
208210
// and the other compiler dependenies:
209-
Properties.compilerInterface + ":" + Properties.scalaLibrary + ":" + Properties.scalaAsm + ":" +
210-
Properties.dottyInterfaces + ":" + Properties.jlineTerminal + ":" + Properties.jlineReader,
211+
Properties.compilerInterface + sep + Properties.scalaLibrary + sep + Properties.scalaAsm + sep +
212+
Properties.dottyInterfaces + sep + Properties.jlineTerminal + sep + Properties.jlineReader,
211213
Array("-Ycheck-reentrant", "-Yemit-tasty-in-class")
212214
)
213215

compiler/test/dotty/tools/vulpix/ChildJVMMain.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ public class ChildJVMMain {
1414

1515
private static void runMain(String dir) throws Exception {
1616
String jcp = System.getProperty("java.class.path");
17-
System.setProperty("java.class.path", jcp == null ? dir : dir + ":" + jcp);
17+
String sep = File.pathSeparator;
18+
System.setProperty("java.class.path", jcp == null ? dir : dir + sep + jcp);
1819

1920
ArrayList<URL> cp = new ArrayList<>();
20-
for (String path : dir.split(":"))
21+
for (String path : dir.split(sep))
2122
cp.add(new File(path).toURI().toURL());
2223

2324
URLClassLoader ucl = new URLClassLoader(cp.toArray(new URL[cp.size()]));

project/Build.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ object Build {
318318
lazy val commonBenchmarkSettings = Seq(
319319
outputStrategy := Some(StdoutOutput),
320320
mainClass in (Jmh, run) := Some("dotty.tools.benchmarks.Bench"), // custom main for jmh:run
321-
javaOptions += "-DBENCH_COMPILER_CLASS_PATH=" + Attributed.data((fullClasspath in (`dotty-bootstrapped`, Compile)).value).mkString("", ":", ""),
322-
javaOptions += "-DBENCH_CLASS_PATH=" + Attributed.data((fullClasspath in (`dotty-library-bootstrapped`, Compile)).value).mkString("", ":", "")
321+
javaOptions += "-DBENCH_COMPILER_CLASS_PATH=" + Attributed.data((fullClasspath in (`dotty-bootstrapped`, Compile)).value).mkString("", File.pathSeparator, ""),
322+
javaOptions += "-DBENCH_CLASS_PATH=" + Attributed.data((fullClasspath in (`dotty-library-bootstrapped`, Compile)).value).mkString("", File.pathSeparator, "")
323323
)
324324

325325
// sbt >= 0.13.12 will automatically rewrite transitive dependencies on
@@ -453,7 +453,7 @@ object Build {
453453
def findLib(attList: Seq[Attributed[File]], name: String) = attList
454454
.map(_.data.getAbsolutePath)
455455
.find(_.contains(name))
456-
.toList.mkString(":")
456+
.toList.mkString(File.pathSeparator)
457457

458458
// Settings shared between dotty-compiler and dotty-compiler-bootstrapped
459459
lazy val commonDottyCompilerSettings = Seq(
@@ -682,13 +682,13 @@ object Build {
682682
else if (debugFromTasty) "dotty.tools.dotc.fromtasty.Debug"
683683
else "dotty.tools.dotc.Main"
684684

685-
var extraClasspath = s"$scalaLib:$dottyLib"
686-
if ((decompile || printTasty) && !args.contains("-classpath")) extraClasspath += ":."
685+
var extraClasspath = s"$scalaLib${File.pathSeparator}$dottyLib"
686+
if ((decompile || printTasty) && !args.contains("-classpath")) extraClasspath += s"${File.pathSeparator}."
687687
if (args0.contains("-with-compiler")) {
688688
if (!isDotty.value) {
689689
throw new MessageOnlyException("-with-compiler can only be used with a bootstrapped compiler")
690690
}
691-
extraClasspath += s":$dottyCompiler"
691+
extraClasspath += s"${File.pathSeparator}$dottyCompiler"
692692
}
693693

694694
val fullArgs = main :: insertClasspathInArgs(args, extraClasspath)
@@ -698,7 +698,7 @@ object Build {
698698

699699
def insertClasspathInArgs(args: List[String], cp: String): List[String] = {
700700
val (beforeCp, fromCp) = args.span(_ != "-classpath")
701-
val classpath = fromCp.drop(1).headOption.fold(cp)(_ + ":" + cp)
701+
val classpath = fromCp.drop(1).headOption.fold(cp)(_ + File.pathSeparator + cp)
702702
"-classpath" :: classpath :: beforeCp ::: fromCp.drop(2)
703703
}
704704

@@ -1112,7 +1112,7 @@ object Build {
11121112
// Discover classpaths
11131113

11141114
def cpToString(cp: Seq[File]) =
1115-
cp.map(_.getAbsolutePath).mkString(java.io.File.pathSeparator)
1115+
cp.map(_.getAbsolutePath).mkString(File.pathSeparator)
11161116

11171117
val compilerCp = Attributed.data((fullClasspath in (`dotty-compiler`, Compile)).value)
11181118
val cpStr = cpToString(classpath ++ compilerCp)

0 commit comments

Comments
 (0)