@@ -37,21 +37,29 @@ open class CargoBuildTask : DefaultTask() {
37
37
// We also allow this to be specified in `local.properties`, not because this is
38
38
// something you should ever need to do currently, but we don't want it to ruin anyone's
39
39
// day if it turns out we're wrong about that.
40
- val targetDirectory =
40
+ val target =
41
41
getProperty(" rust.cargoTargetDir" , " CARGO_TARGET_DIR" )
42
42
? : targetDirectory
43
43
? : " ${module!! } /target"
44
44
45
45
val defaultTargetTriple = getDefaultTargetTriple(project, rustcCommand)
46
46
47
- val cargoOutputDir = if (toolchain.target == defaultTargetTriple) {
48
- " ${targetDirectory } /${profile} "
47
+ var cargoOutputDir = File ( if (toolchain.target == defaultTargetTriple) {
48
+ " ${target } /${profile} "
49
49
} else {
50
- " ${targetDirectory} /${toolchain.target} /${profile} "
50
+ " ${target} /${toolchain.target} /${profile} "
51
+ })
52
+ if (! cargoOutputDir.isAbsolute) {
53
+ cargoOutputDir = File (project.project.projectDir, cargoOutputDir.path)
51
54
}
55
+ cargoOutputDir = cargoOutputDir.canonicalFile
56
+
57
+ val intoDir = File (buildDir, " rustJniLibs/${toolchain.folder} " )
58
+ intoDir.mkdirs()
59
+
52
60
copy { spec ->
53
- spec.from(File (project.projectDir, cargoOutputDir) )
54
- spec.into(File (buildDir, " rustJniLibs/ ${toolchain.folder} " ) )
61
+ spec.from(cargoOutputDir)
62
+ spec.into(intoDir )
55
63
56
64
// Need to capture the value to dereference smoothly.
57
65
val targetIncludes = targetIncludes
@@ -76,7 +84,13 @@ open class CargoBuildTask : DefaultTask() {
76
84
project.exec { spec ->
77
85
with (spec) {
78
86
standardOutput = System .out
79
- workingDir = File (project.project.projectDir, cargoExtension.module!! )
87
+ val module = File (cargoExtension.module!! )
88
+ if (module.isAbsolute) {
89
+ workingDir = module
90
+ } else {
91
+ workingDir = File (project.project.projectDir, module.path)
92
+ }
93
+ workingDir = workingDir.canonicalFile
80
94
81
95
val theCommandLine = mutableListOf (cargoExtension.cargoCommand)
82
96
0 commit comments