mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
[IJI-2418] support running on musl containers
GitOrigin-RevId: 0669afc79deece53695293644fbe3ae1cd123b31
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8df735e9e5
commit
0bfe48648b
@@ -23,7 +23,8 @@ object JdkDownloader {
|
||||
val os = OS.current
|
||||
val arch = Arch.current
|
||||
val isMusl = LinuxLibcImpl.isLinuxMusl
|
||||
return getJdkHome(communityRoot = communityRoot, os = os, arch = arch, isMusl = isMusl, infoLog = infoLog, jdkBuildNumber = jdkBuildNumber, variation = variation)
|
||||
val effectiveVariation = if (isMusl) null else variation
|
||||
return getJdkHome(communityRoot = communityRoot, os = os, arch = arch, isMusl = isMusl, infoLog = infoLog, jdkBuildNumber = jdkBuildNumber, variation = effectiveVariation)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@@ -57,7 +58,8 @@ object JdkDownloader {
|
||||
variation: String? = null,
|
||||
infoLog: (String) -> Unit,
|
||||
): Path {
|
||||
val jdkUrl = getUrl(communityRoot = communityRoot, os = os, arch = arch, isMusl = isMusl, jdkBuildNumber = jdkBuildNumber, variation = variation)
|
||||
val effectiveVariation = if (isMusl) null else variation
|
||||
val jdkUrl = getUrl(communityRoot = communityRoot, os = os, arch = arch, isMusl = isMusl, jdkBuildNumber = jdkBuildNumber, variation = effectiveVariation)
|
||||
val jdkArchive = downloadFileToCacheLocation(url = jdkUrl.toString(), communityRoot = communityRoot)
|
||||
val jdkExtracted = BuildDependenciesDownloader.extractFileToCacheLocation(communityRoot = communityRoot,
|
||||
archiveFile = jdkArchive,
|
||||
|
||||
@@ -43,6 +43,7 @@ class BundledRuntimeImpl(
|
||||
get() {
|
||||
val bundledRuntimePrefix = options.bundledRuntimePrefix
|
||||
return when {
|
||||
LinuxLibcImpl.isLinuxMusl -> "jbrsdk-"
|
||||
// required as a runtime for debugger tests
|
||||
System.getProperty("intellij.build.jbr.setupSdk", "false").toBoolean() -> "jbrsdk-"
|
||||
bundledRuntimePrefix != null -> bundledRuntimePrefix
|
||||
@@ -125,7 +126,8 @@ class BundledRuntimeImpl(
|
||||
val version = if (forceVersionWithUnderscores) split[0].replace(".", "_") else split[0]
|
||||
val buildNumber = "b${split[1]}"
|
||||
val archSuffix = getArchSuffix(arch)
|
||||
return "${prefix}${version}-${os.jbrArchiveSuffix}-${archSuffix}-${runtimeBuildPrefix()}${buildNumber}.tar.gz"
|
||||
val muslSuffix = if (LinuxLibcImpl.isLinuxMusl) "-musl" else ""
|
||||
return "${prefix}${version}-${os.jbrArchiveSuffix}${muslSuffix}-${archSuffix}-${runtimeBuildPrefix()}${buildNumber}.tar.gz"
|
||||
}
|
||||
|
||||
private fun runtimeBuildPrefix(): String {
|
||||
|
||||
@@ -12,10 +12,13 @@ import com.intellij.openapi.util.io.FileUtilRt
|
||||
import com.intellij.openapi.util.io.NioFiles
|
||||
import com.intellij.openapi.util.text.StringUtilRt
|
||||
import com.intellij.util.lang.UrlClassLoader
|
||||
import com.jetbrains.plugin.structure.base.utils.isFile
|
||||
import io.opentelemetry.api.common.AttributeKey
|
||||
import kotlinx.coroutines.*
|
||||
import org.jetbrains.intellij.build.*
|
||||
import org.jetbrains.intellij.build.BuildPaths.Companion.ULTIMATE_HOME
|
||||
import org.jetbrains.intellij.build.causal.CausalProfilingOptions
|
||||
import org.jetbrains.intellij.build.dependencies.LinuxLibcImpl
|
||||
import org.jetbrains.intellij.build.dependencies.TeamCityHelper
|
||||
import org.jetbrains.intellij.build.io.readZipFile
|
||||
import org.jetbrains.intellij.build.io.runProcess
|
||||
@@ -38,6 +41,7 @@ import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.util.regex.Pattern
|
||||
import kotlin.io.path.*
|
||||
import kotlin.random.Random
|
||||
|
||||
private const val NO_TESTS_ERROR = 42
|
||||
|
||||
@@ -1053,6 +1057,36 @@ internal class TestingTasksImpl(context: CompilationContext, private val options
|
||||
|
||||
private class NoTestsFound : Exception()
|
||||
|
||||
/**
|
||||
* we need to gather all the jars from original classpath entries into one directory
|
||||
* to be able to pass them as a classpath argument using asterisk mask.
|
||||
* otherwise classpath may be too long and contradict with maximal allowed parameter size (see ARG_MAX)
|
||||
*/
|
||||
@OptIn(ExperimentalPathApi::class)
|
||||
private fun prepareMuslClassPath(classpath: ArrayList<String>) : ArrayList<String> {
|
||||
val muslClasspathEntries = ArrayList<String>()
|
||||
|
||||
val muslClassPath = ULTIMATE_HOME.resolve("musl_classpath_${Random.nextInt(Int.MAX_VALUE)}").let {
|
||||
if (it.exists()) {
|
||||
it.deleteRecursively()
|
||||
}
|
||||
Files.createDirectory(it)
|
||||
}
|
||||
|
||||
muslClasspathEntries.add("${muslClassPath.absolutePathString()}/*")
|
||||
|
||||
classpath.forEach { classPathFile ->
|
||||
val cpf = Path.of(classPathFile)
|
||||
if (cpf.isFile) {
|
||||
//copy the original classpath entry to the directory, which is already included in the resulting classpath above
|
||||
cpf.copyTo(muslClassPath.resolve(cpf.fileName.toString()), overwrite = true)
|
||||
} else {
|
||||
muslClasspathEntries.add(classPathFile)
|
||||
}
|
||||
}
|
||||
return muslClasspathEntries
|
||||
}
|
||||
|
||||
private fun runJUnit5Engine(systemProperties: Map<String, String?>,
|
||||
jvmArgs: List<String>,
|
||||
envVariables: Map<String, String>,
|
||||
@@ -1073,7 +1107,13 @@ internal class TestingTasksImpl(context: CompilationContext, private val options
|
||||
classpath += testClasspath
|
||||
}
|
||||
args += "-classpath"
|
||||
args += classpath.joinToString(separator = File.pathSeparator)
|
||||
|
||||
val classpathForTests = if (LinuxLibcImpl.isLinuxMusl) {
|
||||
prepareMuslClassPath(classpath)
|
||||
} else {
|
||||
classpath
|
||||
}
|
||||
args += classpathForTests.joinToString(separator = File.pathSeparator)
|
||||
|
||||
if (modulePath != null) {
|
||||
args += "--module-path"
|
||||
|
||||
Reference in New Issue
Block a user