diff --git a/project/RustPlugin.scala b/project/RustPlugin.scala index c2f160484..2ffc5ab63 100644 --- a/project/RustPlugin.scala +++ b/project/RustPlugin.scala @@ -119,16 +119,18 @@ object RustPlugin extends AutoPlugin { // For each architecture find artifacts for (archTarget <- rustArchitectures.value) { + val normalizedArch = normalizeRustTarget(archTarget) + // Special case - host - val archFolder = if (archTarget == "host") { + val archFolder = if (normalizedArch == "host") { targetFolder / releaseDir } else { // General case - targetFolder / archTarget / releaseDir + targetFolder / normalizedArch / releaseDir } // get os arch / kernel, build path - val resourceArchTarget = mapRustTargetToJVMTarget(archTarget) + val resourceArchTarget = mapRustTargetToJVMTarget(normalizedArch) // Find library files in folder // We place every produced library in a resource path like @@ -207,6 +209,23 @@ object RustPlugin extends AutoPlugin { } } + // Normalize a target string by stripping excess info, like GLIBC version + private def normalizeRustTarget(target: String): String = { + // Handle strings like x86_64-unknown-linux-gnu.2.17, + // which contain a GLIBC version suffix + // + // We want to drop the suffix to get x86_64-unknown-linux-gnu + val RustPattern = "([^-]+)-([^-]+)-([^.]+).*".r + + target match { + // Valid inputs + case "host" => target + case RustPattern(arch, vendor, kernel) => s"$arch-$vendor-$kernel" + // Not matched + case x => sys.error(s"Unsupported target $x") + } + } + // Get normalized host kernel name private def getHostKernel: String = { if (SystemUtils.IS_OS_LINUX) {