fix a relative path for native file

GitOrigin-RevId: bad6f99c41c1fca7cd41fafc3c6993f5fe1f0238
This commit is contained in:
Vladimir Krivosheev
2024-02-08 17:50:24 +01:00
committed by intellij-monorepo-bot
parent e9b2a6f774
commit a611f5be16
3 changed files with 25 additions and 11 deletions

View File

@@ -145,7 +145,9 @@ class BuiltinModulesFileData(
@JvmField val fileExtensions: MutableList<String> = mutableListOf(),
)
data class DistFile(@JvmField val file: Path,
@JvmField val relativePath: String,
@JvmField val os: OsFamily? = null,
@JvmField val arch: JvmArchitecture? = null)
data class DistFile(
@JvmField val file: Path,
@JvmField val relativePath: String,
@JvmField val os: OsFamily? = null,
@JvmField val arch: JvmArchitecture? = null,
)

View File

@@ -201,7 +201,9 @@ class JarPackager private constructor(private val outDir: Path,
return coroutineScope {
if (nativeFiles.isNotEmpty()) {
launch {
packNativePresignedFiles(nativeFiles = nativeFiles, dryRun = dryRun, context = context, outDir = outputDir)
packNativePresignedFiles(nativeFiles = nativeFiles, dryRun = dryRun, context = context, toRelativePath = { libName, fileName ->
"lib/$libName/$fileName"
})
}
}

View File

@@ -82,19 +82,31 @@ internal suspend fun packNativePresignedFiles(
nativeFiles: Map<ZipSource, List<String>>,
dryRun: Boolean,
context: BuildContext,
outDir: Path,
toRelativePath: (String, String) -> String,
) {
coroutineScope {
for ((source, paths) in nativeFiles) {
val sourceFile = source.file
launch(Dispatchers.IO) {
unpackNativeLibraries(sourceFile = sourceFile, paths = paths, dryRun = dryRun, context = context, outDir = outDir)
unpackNativeLibraries(
sourceFile = sourceFile,
paths = paths,
dryRun = dryRun,
context = context,
toRelativePath = toRelativePath,
)
}
}
}
}
private suspend fun unpackNativeLibraries(sourceFile: Path, paths: List<String>, dryRun: Boolean, context: BuildContext, outDir: Path) {
private suspend fun unpackNativeLibraries(
sourceFile: Path,
paths: List<String>,
dryRun: Boolean,
context: BuildContext,
toRelativePath: (String, String) -> String,
) {
val libVersion = sourceFile.getName(sourceFile.nameCount - 2).toString()
val signTool = context.proprietaryBuildTools.signTool
val unsignedFiles = TreeMap<OsFamily, MutableList<Path>>()
@@ -145,11 +157,9 @@ private suspend fun unpackNativeLibraries(sourceFile: Path, paths: List<String>,
}
}
val relativePath = outDir.resolve(libName)
.resolve(getRelativePath(libName = libName, arch = arch, fileName = fileName, path = path))
context.addDistFile(DistFile(
file = file,
relativePath = context.paths.distAllDir.relativize(relativePath).toString(),
relativePath = toRelativePath(libName, getRelativePath(libName = libName, arch = arch, fileName = fileName, path = path)),
os = os.takeUnless { allPlatformsRequired },
arch = arch.takeUnless { allPlatformsRequired },
))