mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-218101 IJ-MR-181153 cleanup
GitOrigin-RevId: ecea0e4ccc20751a70c91aab8e61c665c65f42f8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2ec0ddfda6
commit
e9d7c8fac2
@@ -43,7 +43,6 @@ import org.jetbrains.intellij.build.classPath.generatePluginClassPathFromPrebuil
|
||||
import org.jetbrains.intellij.build.classPath.writePluginClassPathHeader
|
||||
import org.jetbrains.intellij.build.getDevModeOrTestBuildDateInSeconds
|
||||
import org.jetbrains.intellij.build.impl.BuildContextImpl
|
||||
import org.jetbrains.intellij.build.impl.CompilationContextImpl
|
||||
import org.jetbrains.intellij.build.impl.ModuleOutputPatcher
|
||||
import org.jetbrains.intellij.build.impl.PLUGIN_CLASSPATH
|
||||
import org.jetbrains.intellij.build.impl.PlatformLayout
|
||||
@@ -51,6 +50,7 @@ import org.jetbrains.intellij.build.impl.asArchived
|
||||
import org.jetbrains.intellij.build.impl.asArchivedIfNeeded
|
||||
import org.jetbrains.intellij.build.impl.asBazelIfNeeded
|
||||
import org.jetbrains.intellij.build.impl.copyDistFiles
|
||||
import org.jetbrains.intellij.build.impl.createCompilationContext
|
||||
import org.jetbrains.intellij.build.impl.createIdeaPropertyFile
|
||||
import org.jetbrains.intellij.build.impl.createPlatformLayout
|
||||
import org.jetbrains.intellij.build.impl.generateRuntimeModuleRepositoryForDevBuild
|
||||
@@ -458,7 +458,7 @@ private suspend fun createBuildContext(
|
||||
result.distAllDir = runDir
|
||||
Files.createDirectories(tempDir)
|
||||
|
||||
CompilationContextImpl.createCompilationContext(
|
||||
createCompilationContext(
|
||||
projectHome = request.projectDir,
|
||||
buildOutputRootEvaluator = { _ -> runDir },
|
||||
setupTracer = false,
|
||||
|
||||
@@ -75,11 +75,11 @@ suspend fun createBuildContext(
|
||||
proprietaryBuildTools: ProprietaryBuildTools = ProprietaryBuildTools.DUMMY,
|
||||
options: BuildOptions = BuildOptions(),
|
||||
): BuildContext {
|
||||
val compilationContext = CompilationContextImpl.createCompilationContext(
|
||||
val compilationContext = createCompilationContext(
|
||||
projectHome = projectHome,
|
||||
buildOutputRootEvaluator = createBuildOutputRootEvaluator(projectHome, productProperties, options),
|
||||
options = options,
|
||||
setupTracer = setupTracer
|
||||
setupTracer = setupTracer,
|
||||
).asBazelIfNeeded
|
||||
return createBuildContext(
|
||||
compilationContext = compilationContext,
|
||||
|
||||
+78
-89
@@ -15,10 +15,8 @@ import io.opentelemetry.api.trace.Span
|
||||
import kotlinx.coroutines.CoroutineName
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
import org.jetbrains.annotations.ApiStatus.Obsolete
|
||||
import org.jetbrains.intellij.build.BuildMessages
|
||||
import org.jetbrains.intellij.build.BuildOptions
|
||||
import org.jetbrains.intellij.build.BuildPaths
|
||||
@@ -66,15 +64,6 @@ import java.util.stream.Stream
|
||||
import kotlin.io.path.invariantSeparatorsPathString
|
||||
import kotlin.io.path.relativeToOrNull
|
||||
|
||||
@Obsolete
|
||||
fun createCompilationContextBlocking(
|
||||
projectHome: Path,
|
||||
defaultOutputRoot: Path,
|
||||
options: BuildOptions = BuildOptions(),
|
||||
): CompilationContext = runBlocking(Dispatchers.Default) {
|
||||
createCompilationContext(projectHome, defaultOutputRoot, options)
|
||||
}
|
||||
|
||||
suspend fun createCompilationContext(
|
||||
projectHome: Path,
|
||||
defaultOutputRoot: Path,
|
||||
@@ -82,7 +71,7 @@ suspend fun createCompilationContext(
|
||||
): CompilationContext {
|
||||
val logDir = options.logDir ?: (options.outRootDir ?: defaultOutputRoot).resolve("log")
|
||||
JaegerJsonSpanExporterManager.setOutput(logDir.toAbsolutePath().normalize().resolve("trace.json"))
|
||||
return CompilationContextImpl.createCompilationContext(
|
||||
return createCompilationContext(
|
||||
projectHome = projectHome,
|
||||
buildOutputRootEvaluator = { defaultOutputRoot },
|
||||
options = options,
|
||||
@@ -104,8 +93,75 @@ internal fun computeBuildPaths(options: BuildOptions, buildOut: Path, projectHom
|
||||
return result
|
||||
}
|
||||
|
||||
suspend fun createCompilationContext(
|
||||
projectHome: Path,
|
||||
buildOutputRootEvaluator: (JpsProject) -> Path,
|
||||
options: BuildOptions,
|
||||
setupTracer: Boolean,
|
||||
enableCoroutinesDump: Boolean = true,
|
||||
customBuildPaths: BuildPaths? = null,
|
||||
): CompilationContextImpl {
|
||||
if (!options.useCompiledClassesFromProjectOutput) {
|
||||
// disable compression - otherwise, our zstd/zip cannot compress efficiently
|
||||
System.setProperty("jps.storage.do.compression", "false")
|
||||
System.setProperty("jps.new.storage.cache.size.mb", "96")
|
||||
}
|
||||
|
||||
check(sequenceOf("platform/build-scripts", "bin/idea.properties", "build.txt").all {
|
||||
Files.exists(COMMUNITY_ROOT.communityRoot.resolve(it))
|
||||
}) {
|
||||
"communityHome ($COMMUNITY_ROOT) doesn't point to a directory containing IntelliJ Community sources"
|
||||
}
|
||||
|
||||
val messages = BuildMessagesImpl.create()
|
||||
if (options.printEnvironmentInfo) {
|
||||
Span.current().addEvent("environment info", Attributes.of(
|
||||
AttributeKey.stringKey("community home"), COMMUNITY_ROOT.communityRoot.toString(),
|
||||
AttributeKey.stringKey("project home"), projectHome.toString(),
|
||||
))
|
||||
printEnvironmentDebugInfo()
|
||||
}
|
||||
|
||||
if (options.printFreeSpace) {
|
||||
logFreeDiskSpace(dir = projectHome, phase = "before downloading dependencies")
|
||||
}
|
||||
|
||||
val model = loadProject(projectHome = projectHome, kotlinBinaries = KotlinBinaries(COMMUNITY_ROOT), isCompilationRequired = isCompilationRequired(options))
|
||||
|
||||
val buildPaths = customBuildPaths ?: computeBuildPaths(options, options.outRootDir ?: buildOutputRootEvaluator(model.project), projectHome)
|
||||
|
||||
// not as part of prepareForBuild because prepareForBuild may be called several times per each product or another flavor
|
||||
// (see createCopyForProduct)
|
||||
if (setupTracer) {
|
||||
JaegerJsonSpanExporterManager.setOutput(buildPaths.logDir.resolve("trace.json"))
|
||||
}
|
||||
|
||||
val context = CompilationContextImpl(model = model, messages = messages, paths = buildPaths, options = options)
|
||||
/**
|
||||
* [defineJavaSdk] may be skipped using [isCompilationRequired]
|
||||
* after removing workaround from [JpsCompilationRunner.compileMissingArtifactsModules].
|
||||
*/
|
||||
spanBuilder("define JDK").use {
|
||||
defineJavaSdk(context)
|
||||
}
|
||||
if (enableCoroutinesDump) {
|
||||
spanBuilder("enable coroutines dump").use {
|
||||
enableCoroutinesDump(it)
|
||||
}
|
||||
}
|
||||
|
||||
spanBuilder("prepare for build").use {
|
||||
context.prepareForBuild()
|
||||
}
|
||||
|
||||
messages.setDebugLogPath(context.paths.logDir.resolve("debug.log"))
|
||||
// this is not a proper place to initialize logging, but this is the only place called in most build scripts
|
||||
BuildMessagesHandler.initLogging(messages)
|
||||
return context
|
||||
}
|
||||
|
||||
@Internal
|
||||
class CompilationContextImpl private constructor(
|
||||
class CompilationContextImpl internal constructor(
|
||||
private val model: JpsModel,
|
||||
override val messages: BuildMessages,
|
||||
override val paths: BuildPaths,
|
||||
@@ -156,73 +212,6 @@ class CompilationContextImpl private constructor(
|
||||
System.setProperty("io.netty.tryReflectionSetAccessible", "true")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun createCompilationContext(
|
||||
projectHome: Path,
|
||||
buildOutputRootEvaluator: (JpsProject) -> Path,
|
||||
options: BuildOptions,
|
||||
setupTracer: Boolean,
|
||||
enableCoroutinesDump: Boolean = true,
|
||||
customBuildPaths: BuildPaths? = null,
|
||||
): CompilationContextImpl {
|
||||
if (!options.useCompiledClassesFromProjectOutput) {
|
||||
// disable compression - otherwise, our zstd/zip cannot compress efficiently
|
||||
System.setProperty("jps.storage.do.compression", "false")
|
||||
System.setProperty("jps.new.storage.cache.size.mb", "96")
|
||||
}
|
||||
|
||||
check(sequenceOf("platform/build-scripts", "bin/idea.properties", "build.txt").all {
|
||||
Files.exists(COMMUNITY_ROOT.communityRoot.resolve(it))
|
||||
}) {
|
||||
"communityHome ($COMMUNITY_ROOT) doesn't point to a directory containing IntelliJ Community sources"
|
||||
}
|
||||
|
||||
val messages = BuildMessagesImpl.create()
|
||||
if (options.printEnvironmentInfo) {
|
||||
Span.current().addEvent("environment info", Attributes.of(
|
||||
AttributeKey.stringKey("community home"), COMMUNITY_ROOT.communityRoot.toString(),
|
||||
AttributeKey.stringKey("project home"), projectHome.toString(),
|
||||
))
|
||||
printEnvironmentDebugInfo()
|
||||
}
|
||||
|
||||
if (options.printFreeSpace) {
|
||||
logFreeDiskSpace(dir = projectHome, phase = "before downloading dependencies")
|
||||
}
|
||||
|
||||
val model = loadProject(projectHome, KotlinBinaries(COMMUNITY_ROOT), isCompilationRequired(options))
|
||||
|
||||
val buildPaths = customBuildPaths ?: computeBuildPaths(options, options.outRootDir ?: buildOutputRootEvaluator(model.project), projectHome)
|
||||
|
||||
// not as part of prepareForBuild because prepareForBuild may be called several times per each product or another flavor
|
||||
// (see createCopyForProduct)
|
||||
if (setupTracer) {
|
||||
JaegerJsonSpanExporterManager.setOutput(buildPaths.logDir.resolve("trace.json"))
|
||||
}
|
||||
|
||||
val context = CompilationContextImpl(model = model, messages = messages, paths = buildPaths, options = options)
|
||||
/**
|
||||
* [defineJavaSdk] may be skipped using [isCompilationRequired]
|
||||
* after removing workaround from [JpsCompilationRunner.compileMissingArtifactsModules].
|
||||
*/
|
||||
spanBuilder("define JDK").use {
|
||||
defineJavaSdk(context)
|
||||
}
|
||||
if (enableCoroutinesDump) {
|
||||
spanBuilder("enable coroutines dump").use {
|
||||
context.enableCoroutinesDump(it)
|
||||
}
|
||||
}
|
||||
|
||||
spanBuilder("prepare for build").use {
|
||||
context.prepareForBuild()
|
||||
}
|
||||
|
||||
messages.setDebugLogPath(context.paths.logDir.resolve("debug.log"))
|
||||
// this is not a proper place to initialize logging, but this is the only place called in most build scripts
|
||||
BuildMessagesHandler.initLogging(messages)
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getStableJdkHome(): Path {
|
||||
@@ -241,7 +230,7 @@ class CompilationContextImpl private constructor(
|
||||
override suspend fun getOriginalModuleRepository(): OriginalModuleRepository = originalModuleRepository.await()
|
||||
|
||||
override fun createCopy(messages: BuildMessages, options: BuildOptions, paths: BuildPaths): CompilationContext {
|
||||
val copy = CompilationContextImpl(projectModel, messages, paths, options)
|
||||
val copy = CompilationContextImpl(model = projectModel, messages = messages, paths = paths, options = options)
|
||||
copy.compilationData = compilationData
|
||||
return copy
|
||||
}
|
||||
@@ -348,20 +337,20 @@ class CompilationContextImpl private constructor(
|
||||
}
|
||||
messages.artifactBuilt(pathToReport)
|
||||
}
|
||||
}
|
||||
|
||||
private fun enableCoroutinesDump(span: Span) {
|
||||
try {
|
||||
enableCoroutineDump()
|
||||
JBR.getJstack()?.includeInfoFrom { """
|
||||
private fun enableCoroutinesDump(span: Span) {
|
||||
try {
|
||||
enableCoroutineDump()
|
||||
JBR.getJstack()?.includeInfoFrom { """
|
||||
$COROUTINE_DUMP_HEADER
|
||||
${dumpCoroutines()}
|
||||
""" // dumpCoroutines is multiline, trimIndent won't work
|
||||
}
|
||||
}
|
||||
catch (e: NoClassDefFoundError) {
|
||||
span.addEvent("Cannot enable coroutines dump, JetBrains Runtime is required: ${e.message}")
|
||||
}
|
||||
}
|
||||
catch (e: NoClassDefFoundError) {
|
||||
span.addEvent("Cannot enable coroutines dump, JetBrains Runtime is required: ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun loadProject(projectHome: Path, kotlinBinaries: KotlinBinaries, isCompilationRequired: Boolean): JpsModel {
|
||||
|
||||
+13
-5
@@ -5,8 +5,14 @@ import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.util.io.NioFiles
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.jetbrains.intellij.build.*
|
||||
import org.jetbrains.intellij.build.BuildPaths.Companion.COMMUNITY_ROOT
|
||||
import org.jetbrains.intellij.build.CompilationContext
|
||||
import org.jetbrains.intellij.build.JetBrainsRuntimeDistribution
|
||||
import org.jetbrains.intellij.build.JvmArchitecture
|
||||
import org.jetbrains.intellij.build.LinuxLibcImpl
|
||||
import org.jetbrains.intellij.build.MacLibcImpl
|
||||
import org.jetbrains.intellij.build.OsFamily
|
||||
import org.jetbrains.intellij.build.WindowsLibcImpl
|
||||
import org.jetbrains.intellij.build.dependencies.JdkDownloader
|
||||
import org.junit.Test
|
||||
import java.nio.file.Files
|
||||
@@ -75,10 +81,12 @@ class BundledRuntimeTest {
|
||||
private inline fun withCompilationContext(block: (CompilationContext) -> Unit) {
|
||||
val tempDir = Files.createTempDirectory("compilation-context-")
|
||||
try {
|
||||
val context = createCompilationContextBlocking(
|
||||
projectHome = COMMUNITY_ROOT.communityRoot,
|
||||
defaultOutputRoot = tempDir,
|
||||
)
|
||||
val context = runBlocking(Dispatchers.Default) {
|
||||
createCompilationContext(
|
||||
projectHome = COMMUNITY_ROOT.communityRoot,
|
||||
defaultOutputRoot = tempDir
|
||||
)
|
||||
}
|
||||
block(context)
|
||||
}
|
||||
finally {
|
||||
|
||||
+12
-10
@@ -8,8 +8,8 @@ import org.jetbrains.intellij.build.BuildPaths.Companion.ULTIMATE_HOME
|
||||
import org.jetbrains.intellij.build.CompilationContext
|
||||
import org.jetbrains.intellij.build.TestingOptions
|
||||
import org.jetbrains.intellij.build.TestingTasks
|
||||
import org.jetbrains.intellij.build.impl.CompilationContextImpl
|
||||
import org.jetbrains.intellij.build.impl.asBazelIfNeeded
|
||||
import org.jetbrains.intellij.build.impl.createCompilationContext
|
||||
import org.jsoup.Jsoup
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.io.TempDir
|
||||
@@ -33,15 +33,17 @@ class CoverageTest {
|
||||
mainModule = "intellij.platform.buildScripts.tests"
|
||||
}
|
||||
|
||||
private suspend fun context(): CompilationContext = CompilationContextImpl.createCompilationContext(
|
||||
projectHome = ULTIMATE_HOME,
|
||||
buildOutputRootEvaluator = { tempDir },
|
||||
setupTracer = false,
|
||||
enableCoroutinesDump = false,
|
||||
options = BuildOptions().apply {
|
||||
useCompiledClassesFromProjectOutput = true
|
||||
}
|
||||
).asBazelIfNeeded
|
||||
private suspend fun context(): CompilationContext {
|
||||
return createCompilationContext(
|
||||
projectHome = ULTIMATE_HOME,
|
||||
buildOutputRootEvaluator = { tempDir },
|
||||
setupTracer = false,
|
||||
enableCoroutinesDump = false,
|
||||
options = BuildOptions().apply {
|
||||
useCompiledClassesFromProjectOutput = true
|
||||
}
|
||||
).asBazelIfNeeded
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test() {
|
||||
|
||||
Reference in New Issue
Block a user