Skip to content

Commit 5d17f8a

Browse files
committed
More path fixes
1 parent 82ac651 commit 5d17f8a

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

bench/src/main/scala/Benchmarks.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ object Bench {
3030
val iterations = if (intArgs.length > 1) intArgs(1).toInt else 20
3131
val forks = if (intArgs.length > 2) intArgs(2).toInt else 1
3232

33+
34+
import File.{ separator => sep }
35+
3336
val args2 = args1.map { arg =>
34-
if ((arg.endsWith(".scala") || arg.endsWith(".java")) && arg.head != '/') "../" + arg
37+
if ((arg.endsWith(".scala") || arg.endsWith(".java")) && !(new File(arg)).isAbsolute) ".." + sep + arg
3538
else arg
3639
}
3740
storeCompileOptions(args2)
@@ -61,9 +64,10 @@ object Bench {
6164
val libs = if (args.contains("-with-compiler")) compiler_libs else standard_libs
6265
var argsNorm = args.filter(_ != "-with-compiler")
6366

67+
import File.{ pathSeparator => sep }
6468
var cpIndex = argsNorm.indexOf("-classpath")
6569
if (cpIndex == -1) cpIndex = argsNorm.indexOf("-cp")
66-
if (cpIndex != -1) argsNorm(cpIndex + 1) = argsNorm(cpIndex + 1) + java.io.File.pathSeparator + libs
70+
if (cpIndex != -1) argsNorm(cpIndex + 1) = argsNorm(cpIndex + 1) + sep + libs
6771
else argsNorm = argsNorm :+ "-classpath" :+ libs
6872

6973
val file = new File(COMPILE_OPTS_FILE)

compiler/src/dotty/tools/dotc/consumetasty/ConsumeTasty.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object ConsumeTasty {
1717
}
1818

1919
val currentClasspath = QuoteDriver.currentClasspath
20-
val sep = java.io.File.pathSeparator
20+
import java.io.File.{ pathSeparator => sep }
2121
val args = "-from-tasty" +: "-classpath" +: s"$classpath$sep$currentClasspath" +: classes
2222
(new Consume).process(args.toArray)
2323
}

doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import java.io.{ File => JFile, OutputStreamWriter, BufferedWriter, ByteArrayInp
88
import java.util.{ List => JList, Arrays }
99
import java.nio.file.Path
1010
import java.nio.charset.StandardCharsets
11+
import java.io.File.{ separator => sep }
1112

1213
import com.vladsch.flexmark.parser.ParserEmulationProfile
1314
import com.vladsch.flexmark.parser.Parser
@@ -164,8 +165,8 @@ case class Site(
164165
private def defaultParams(pageLocation: JFile, additionalDepth: Int = 0): DefaultParams = {
165166
val pathFromRoot = stripRoot(pageLocation)
166167
val baseUrl: String = {
167-
val rootLen = root.getAbsolutePath.split('/').length
168-
val assetLen = pageLocation.getAbsolutePath.split('/').length
168+
val rootLen = root.getAbsolutePath.split(sep).length
169+
val assetLen = pageLocation.getAbsolutePath.split(sep).length
169170
"../" * (assetLen - rootLen - 1 + additionalDepth) + "."
170171
}
171172

@@ -195,12 +196,12 @@ case class Site(
195196
// Suffix is index.html for packages and therefore the additional depth
196197
// is increased by 1
197198
val (suffix, offset) =
198-
if (e.kind == "package") ("/index.html", -1)
199+
if (e.kind == "package") (sep + "index.html", -1)
199200
else (".html", 0)
200201

201-
val target = mkdirs(fs.getPath(outDir.getAbsolutePath + "/api/" + e.path.mkString("/") + suffix))
202+
val target = mkdirs(fs.getPath(outDir.getAbsolutePath + sep + "api" + sep + e.path.mkString(sep) + suffix))
202203
val params = defaultParams(target.toFile, -1).withPosts(blogInfo).withEntity(Some(e)).toMap
203-
val page = new HtmlPage("_layouts/api-page.html", layouts("api-page").content, params, includes)
204+
val page = new HtmlPage("_layouts" + sep + "api-page.html", layouts("api-page").content, params, includes)
204205

205206
render(page).foreach { rendered =>
206207
val source = new ByteArrayInputStream(rendered.getBytes(StandardCharsets.UTF_8))
@@ -217,9 +218,9 @@ case class Site(
217218
}
218219

219220
// generate search page:
220-
val target = mkdirs(fs.getPath(outDir.getAbsolutePath + "/api/search.html"))
221+
val target = mkdirs(fs.getPath(outDir.getAbsolutePath + sep + "api" + sep + "search.html"))
221222
val searchPageParams = defaultParams(target.toFile, -1).withPosts(blogInfo).toMap
222-
val searchPage = new HtmlPage("_layouts/search.html", layouts("search").content, searchPageParams, includes)
223+
val searchPage = new HtmlPage("_layouts" + sep + "search.html", layouts("search").content, searchPageParams, includes)
223224
render(searchPage).foreach { rendered =>
224225
Files.copy(
225226
new ByteArrayInputStream(rendered.getBytes(StandardCharsets.UTF_8)),
@@ -230,7 +231,7 @@ case class Site(
230231
}
231232

232233
/** Generate HTML files from markdown and .html sources */
233-
def generateHtmlFiles(outDir: JFile = new JFile(root.getAbsolutePath + "/_site"))(implicit ctx: Context): this.type =
234+
def generateHtmlFiles(outDir: JFile = new JFile(root.getAbsolutePath + sep + "_site"))(implicit ctx: Context): this.type =
234235
createOutput(outDir) {
235236
compilableFiles.foreach { asset =>
236237
val pathFromRoot = stripRoot(asset)
@@ -250,7 +251,7 @@ case class Site(
250251
}
251252

252253
/** Generate blog from files in `blog/_posts` and output in `outDir` */
253-
def generateBlog(outDir: JFile = new JFile(root.getAbsolutePath + "/_site"))(implicit ctx: Context): this.type =
254+
def generateBlog(outDir: JFile = new JFile(root.getAbsolutePath + sep + "_site"))(implicit ctx: Context): this.type =
254255
createOutput(outDir) {
255256
blogposts.foreach { file =>
256257
val BlogPost.extract(year, month, day, name, ext) = file.getName

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ object Build {
623623
val args: List[String] = spaceDelimited("<arg>").parsed.toList
624624
val attList = (dependencyClasspath in Runtime).value
625625
val jars = packageAll.value
626-
val sep = File.pathSeparator
626+
import File.{ pathSeparator => sep }
627627

628628
val scalaLib = findLib(attList, "scala-library")
629629
val dottyLib = jars("dotty-library")

0 commit comments

Comments
 (0)