Skip to content

Commit b6a140b

Browse files
authored
Fix Rust target-dir with spaces (#173)
* Enquote all Cargo proj path * Add a test case * enquoted => backslashed * symlink simple cargo with space
1 parent 174637b commit b6a140b

File tree

8 files changed

+14
-1
lines changed

8 files changed

+14
-1
lines changed

plugin/src/main/scala/com/github/sbt/jni/build/Cargo.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Cargo(protected val configuration: Seq[String]) extends BuildTool {
3232
def clean(): Unit = Process("cargo clean", baseDirectory) ! log
3333

3434
def library(targetDirectory: File): List[File] = {
35-
val configurationString = (configuration ++ Seq("--target-dir", targetDirectory.getAbsolutePath)).mkString(" ").trim
35+
val configurationString = (configuration ++ Seq("--target-dir", targetDirectory.getAbsolutePath.backslashed)).mkString(" ").trim
3636
val ev =
3737
Process(
3838
s"cargo build $configurationString",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.github.sbt.jni
2+
3+
package object build {
4+
implicit class StringOps(val self: String) extends AnyVal {
5+
def backslashed: String = self.replaceAll(" ", "\\ ");
6+
}
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../simple-cargo/README.md
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../simple-cargo/build.sbt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../simple-cargo/core
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../simple-cargo/native
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../simple-cargo/project
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../simple-cargo/test

0 commit comments

Comments
 (0)