mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
[build scripts] merging native downloaders; using common launcher 3rd-party licenses report
GitOrigin-RevId: 91e1ebbc22b8f024ea8c8b2afc0f546dec1f46f4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c4b9eebe22
commit
4c65fd84e0
@@ -3,7 +3,7 @@ bundledMavenVersion=3.9.6
|
||||
debuggerAgent=1.2
|
||||
gradleApiVersion=8.7
|
||||
jdkBuild=17.0.11b1286.1
|
||||
launcherBuild=242.10578
|
||||
launcherBuild=242.10629
|
||||
nsisBuild=1
|
||||
restarterBuild=242.9890
|
||||
runtimeBuild=21.0.3b446.1
|
||||
|
||||
@@ -1,34 +1,82 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.intellij.build
|
||||
|
||||
import org.jetbrains.intellij.build.dependencies.BuildDependenciesConstants.INTELLIJ_DEPENDENCIES_URL
|
||||
import org.jetbrains.intellij.build.dependencies.BuildDependenciesDownloader
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.StandardOpenOption
|
||||
import kotlin.io.path.exists
|
||||
import kotlin.io.path.isDirectory
|
||||
import kotlin.io.path.isRegularFile
|
||||
import kotlin.io.path.writeText
|
||||
|
||||
object NativeBinaryDownloader {
|
||||
private const val GROUP_ID = "org.jetbrains.intellij.deps"
|
||||
private const val LAUNCHER_ID = "launcher"
|
||||
private const val RESTARTER_ID = "restarter"
|
||||
private const val PACKAGING = "tar.gz"
|
||||
private const val LICENSE_FILE_NAME = "xplat-launcher-third-party-licenses.html"
|
||||
|
||||
/**
|
||||
* Attempts to locate a local debug build of cross-platform launcher when in the development mode
|
||||
* and [org.jetbrains.intellij.build.BuildOptions.useLocalLauncher] is set to `true`.
|
||||
*
|
||||
* Otherwise, Downloads and unpacks the launcher tarball.
|
||||
*
|
||||
* Returns a pair of paths `(executable, license)` for the given platform.
|
||||
*/
|
||||
suspend fun getLauncher(context: BuildContext, os: OsFamily, arch: JvmArchitecture): Pair<Path, Path> {
|
||||
if (context.options.isInDevelopmentMode && context.options.useLocalLauncher) {
|
||||
val localLauncher = findLocalLauncher(context, os)
|
||||
if (localLauncher != null) return localLauncher
|
||||
}
|
||||
|
||||
val (archiveFile, unpackedDir) = downloadAndUnpack(context, "launcherBuild", LAUNCHER_ID)
|
||||
val executableFile = findExecutable(archiveFile, unpackedDir, os, arch, "xplat-launcher")
|
||||
val licenseFile = findFile(archiveFile, unpackedDir, "license/${LICENSE_FILE_NAME}")
|
||||
return executableFile to licenseFile
|
||||
}
|
||||
|
||||
private fun findLocalLauncher(context: BuildContext, os: OsFamily): Pair<Path, Path>? {
|
||||
val targetDir = context.paths.communityHomeDirRoot.communityRoot.resolve("native/XPlatLauncher/target/debug")
|
||||
if (targetDir.isDirectory()) {
|
||||
val executableName = "xplat-launcher${if (os == OsFamily.WINDOWS) ".exe" else ""}"
|
||||
val executableFile = targetDir.resolve(executableName)
|
||||
if (executableFile.isRegularFile()) {
|
||||
val licenseFile = targetDir.resolve(LICENSE_FILE_NAME)
|
||||
if (!licenseFile.exists()) {
|
||||
licenseFile.writeText("(cross-platform launcher license file stub)", options = arrayOf(StandardOpenOption.CREATE_NEW))
|
||||
}
|
||||
return executableFile to licenseFile
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and unpacks the restarter tarball and returns a path to an executable for the given platform.
|
||||
*/
|
||||
suspend fun downloadRestarter(context: BuildContext, os: OsFamily, arch: JvmArchitecture): Path {
|
||||
val communityRoot = context.paths.communityHomeDirRoot
|
||||
suspend fun getRestarter(context: BuildContext, os: OsFamily, arch: JvmArchitecture): Path {
|
||||
val (archiveFile, unpackedDir) = downloadAndUnpack(context, "restarterBuild", RESTARTER_ID)
|
||||
return findExecutable(archiveFile, unpackedDir, os, arch, "restarter")
|
||||
}
|
||||
|
||||
val version = context.dependenciesProperties.property("restarterBuild")
|
||||
val uri = BuildDependenciesDownloader.getUriForMavenArtifact(INTELLIJ_DEPENDENCIES_URL, GROUP_ID, RESTARTER_ID, version, PACKAGING)
|
||||
private suspend fun downloadAndUnpack(context: BuildContext, propertyName: String, artifactId: String): Pair<Path, Path> {
|
||||
val communityRoot = context.paths.communityHomeDirRoot
|
||||
val version = context.dependenciesProperties.property(propertyName)
|
||||
val uri = BuildDependenciesDownloader.getUriForMavenArtifact(INTELLIJ_DEPENDENCIES_URL, GROUP_ID, artifactId, version, PACKAGING)
|
||||
val archiveFile = downloadFileToCacheLocation(uri.toString(), communityRoot)
|
||||
val unpackedDir = BuildDependenciesDownloader.extractFileToCacheLocation(communityRoot, archiveFile)
|
||||
return archiveFile to unpackedDir
|
||||
}
|
||||
|
||||
val platformDir = unpackedDir.resolve("${os.osName}-${arch.archName}")
|
||||
check(platformDir.isDirectory()) { "'${platformDir.fileName}' not found in '${archiveFile.fileName}'" }
|
||||
private fun findExecutable(archiveFile: Path, unpackedDir: Path, os: OsFamily, arch: JvmArchitecture, baseName: String): Path =
|
||||
findFile(archiveFile, unpackedDir, "${os.osName}-${arch.archName}/${baseName}${if (os == OsFamily.WINDOWS) ".exe" else ""}")
|
||||
|
||||
val executableFile = platformDir.resolve(if (os == OsFamily.WINDOWS) "restarter.exe" else "restarter")
|
||||
check(executableFile.isRegularFile()) { "Executable '${executableFile.fileName}' not found in '${platformDir}'" }
|
||||
|
||||
return executableFile
|
||||
private fun findFile(archiveFile: Path, unpackedDir: Path, relativePath: String): Path {
|
||||
val file = unpackedDir.resolve(relativePath)
|
||||
check(file.isRegularFile()) { "Executable '${relativePath}' not found in '${archiveFile.fileName}'" }
|
||||
return file
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.intellij.build
|
||||
|
||||
import org.jetbrains.intellij.build.dependencies.BuildDependenciesDownloader
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.StandardOpenOption
|
||||
import org.jetbrains.intellij.build.dependencies.BuildDependenciesConstants.INTELLIJ_DEPENDENCIES_URL as REPOSITORY_URL
|
||||
|
||||
object NativeLauncherDownloader {
|
||||
/**
|
||||
* Attempts to locate a local debug build of cross-platform launcher when in the development mode
|
||||
* and [org.jetbrains.intellij.build.BuildOptions.useLocalLauncher] is set to `true`.
|
||||
*
|
||||
* Otherwise, Downloads and unpacks the launcher tarball.
|
||||
*
|
||||
* Returns a pair of paths `(executable, license)` for the given platform.
|
||||
*/
|
||||
suspend fun findLocalOrDownload(context: BuildContext, os: OsFamily, arch: JvmArchitecture): Pair<Path, Path> {
|
||||
if (context.options.isInDevelopmentMode && context.options.useLocalLauncher) {
|
||||
val localLauncher = findLocalLauncher(context, os, arch)
|
||||
if (localLauncher != null) return localLauncher
|
||||
}
|
||||
|
||||
return downloadLauncher(context, os, arch)
|
||||
}
|
||||
|
||||
private suspend fun downloadLauncher(context: BuildContext, os: OsFamily, arch: JvmArchitecture): Pair<Path, Path> {
|
||||
val communityRoot = context.paths.communityHomeDirRoot
|
||||
|
||||
val version = context.dependenciesProperties.property("launcherBuild")
|
||||
val uri = BuildDependenciesDownloader.getUriForMavenArtifact(REPOSITORY_URL, GROUP_ID, ARTIFACT_ID, version, PACKAGING)
|
||||
val archiveFile = downloadFileToCacheLocation(uri.toString(), communityRoot)
|
||||
val unpackedDir = BuildDependenciesDownloader.extractFileToCacheLocation(communityRoot, archiveFile)
|
||||
|
||||
val platformDirName = PLATFORMS[os to arch] ?: throw IllegalArgumentException("Unknown platform: ${os} / ${arch}")
|
||||
val platformDir = unpackedDir.resolve(platformDirName)
|
||||
check(Files.isDirectory(platformDir)) { "'${platformDir}' not found in '${archiveFile.fileName}'" }
|
||||
|
||||
val executableName = executableName(os)
|
||||
val executableFile = platformDir.resolve(executableName)
|
||||
check(Files.isRegularFile(executableFile)) { "Executable '${executableName}' not found in '${platformDir}'" }
|
||||
|
||||
val licenseFile = platformDir.resolve(LICENSE_FILE_NAME)
|
||||
check(Files.isRegularFile(licenseFile)) { "Third-party licenses file ${LICENSE_FILE_NAME} not found in '${platformDir}'" }
|
||||
|
||||
return executableFile to licenseFile
|
||||
}
|
||||
|
||||
private fun findLocalLauncher(context: BuildContext, os: OsFamily, arch: JvmArchitecture): Pair<Path, Path>? {
|
||||
check(os to arch in PLATFORMS) { "Unknown platform: ${os} / ${arch}" }
|
||||
|
||||
val targetDir = context.paths.communityHomeDirRoot.communityRoot.resolve("native/XPlatLauncher/target/debug")
|
||||
if (Files.isDirectory(targetDir)) {
|
||||
val executableName = executableName(os)
|
||||
val executableFile = targetDir.resolve(executableName)
|
||||
if (Files.isRegularFile(executableFile)) {
|
||||
val licenseFile = targetDir.resolve(LICENSE_FILE_NAME)
|
||||
if (!Files.exists(licenseFile)) {
|
||||
Files.writeString(licenseFile, "(cross-platform launcher license file stub)", StandardOpenOption.CREATE_NEW)
|
||||
}
|
||||
return executableFile to licenseFile
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
private const val GROUP_ID = "org.jetbrains.intellij.deps"
|
||||
private const val ARTIFACT_ID = "launcher"
|
||||
private const val PACKAGING = "tar.gz"
|
||||
|
||||
private val PLATFORMS = mapOf(
|
||||
(OsFamily.WINDOWS to JvmArchitecture.x64) to "x86_64-pc-windows-msvc",
|
||||
(OsFamily.WINDOWS to JvmArchitecture.aarch64) to "aarch64-pc-windows-msvc",
|
||||
(OsFamily.MACOS to JvmArchitecture.x64) to "x86_64-apple-darwin",
|
||||
(OsFamily.MACOS to JvmArchitecture.aarch64) to "aarch64-apple-darwin",
|
||||
(OsFamily.LINUX to JvmArchitecture.x64) to "x86_64-unknown-linux-gnu",
|
||||
(OsFamily.LINUX to JvmArchitecture.aarch64) to "aarch64-unknown-linux-gnu"
|
||||
)
|
||||
|
||||
private fun executableName(osFamily: OsFamily) = when(osFamily) {
|
||||
OsFamily.WINDOWS -> "xplat-launcher.exe"
|
||||
OsFamily.MACOS, OsFamily.LINUX -> "xplat-launcher"
|
||||
}
|
||||
|
||||
private const val LICENSE_FILE_NAME = "xplat-launcher-third-party-licenses.html"
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.jetbrains.intellij.build.*
|
||||
import org.jetbrains.intellij.build.NativeBinaryDownloader
|
||||
import org.jetbrains.intellij.build.TraceManager.spanBuilder
|
||||
import org.jetbrains.intellij.build.impl.OsSpecificDistributionBuilder.Companion.suffix
|
||||
import org.jetbrains.intellij.build.impl.client.ADDITIONAL_EMBEDDED_CLIENT_VM_OPTIONS
|
||||
@@ -50,7 +51,7 @@ class LinuxDistributionBuilder(
|
||||
val distBinDir = targetPath.resolve("bin")
|
||||
val sourceBinDir = context.paths.communityHomeDir.resolve("bin/linux")
|
||||
addNativeLauncher(distBinDir, targetPath, arch)
|
||||
copyFileToDir(NativeBinaryDownloader.downloadRestarter(context, OsFamily.LINUX, arch), distBinDir)
|
||||
copyFileToDir(NativeBinaryDownloader.getRestarter(context, OsFamily.LINUX, arch), distBinDir)
|
||||
copyFileToDir(sourceBinDir.resolve("${arch.dirName}/fsnotifier"), distBinDir)
|
||||
copyFileToDir(sourceBinDir.resolve("${arch.dirName}/libdbm.so"), distBinDir)
|
||||
generateBuildTxt(context, targetPath)
|
||||
@@ -379,7 +380,7 @@ class LinuxDistributionBuilder(
|
||||
|
||||
private suspend fun addNativeLauncher(distBinDir: Path, targetPath: Path, arch: JvmArchitecture) {
|
||||
if (customizer.useXPlatLauncher) {
|
||||
val (execPath, licensePath) = NativeLauncherDownloader.findLocalOrDownload(context, OsFamily.LINUX, arch)
|
||||
val (execPath, licensePath) = NativeBinaryDownloader.getLauncher(context, OsFamily.LINUX, arch)
|
||||
copyFile(execPath, distBinDir.resolve(context.productProperties.baseFileName))
|
||||
copyFile(licensePath, targetPath.resolve("license/launcher-third-party-libraries.html"))
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import kotlinx.coroutines.withContext
|
||||
import org.apache.commons.compress.archivers.zip.Zip64Mode
|
||||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry
|
||||
import org.jetbrains.intellij.build.*
|
||||
import org.jetbrains.intellij.build.NativeBinaryDownloader
|
||||
import org.jetbrains.intellij.build.TraceManager.spanBuilder
|
||||
import org.jetbrains.intellij.build.impl.OsSpecificDistributionBuilder.Companion.suffix
|
||||
import org.jetbrains.intellij.build.impl.client.createJetBrainsClientContextForLaunchers
|
||||
@@ -192,11 +193,11 @@ class MacDistributionBuilder(
|
||||
) {
|
||||
val macBinDir = macDistDir.resolve("bin")
|
||||
copyDirWithFileFilter(context.paths.communityHomeDir.resolve("bin/mac"), macBinDir, customizer.binFilesFilter)
|
||||
copyFileToDir(NativeBinaryDownloader.downloadRestarter(context, OsFamily.MACOS, arch), macBinDir)
|
||||
copyFileToDir(NativeBinaryDownloader.getRestarter(context, OsFamily.MACOS, arch), macBinDir)
|
||||
copyDir(context.paths.communityHomeDir.resolve("platform/build-scripts/resources/mac/Contents"), macDistDir)
|
||||
|
||||
val executable = context.productProperties.baseFileName
|
||||
val (execPath, licensePath) = NativeLauncherDownloader.findLocalOrDownload(context, OsFamily.MACOS, arch)
|
||||
val (execPath, licensePath) = NativeBinaryDownloader.getLauncher(context, OsFamily.MACOS, arch)
|
||||
copyFile(execPath, macDistDir.resolve("MacOS/${executable}"))
|
||||
copyFile(licensePath, macDistDir.resolve("license/launcher-third-party-libraries.html"))
|
||||
|
||||
@@ -221,7 +222,8 @@ class MacDistributionBuilder(
|
||||
|
||||
Files.writeString(
|
||||
macBinDir.resolve(PROPERTIES_FILE_NAME),
|
||||
(ideaPropertyContent.lineSequence() + platformProperties).joinToString(separator = "\n"))
|
||||
(ideaPropertyContent.lineSequence() + platformProperties).joinToString(separator = "\n")
|
||||
)
|
||||
|
||||
writeVmOptions(macBinDir)
|
||||
createJetBrainsClientContextForLaunchers(context)?.let { clientContext ->
|
||||
|
||||
@@ -10,6 +10,7 @@ import io.opentelemetry.api.common.AttributeKey
|
||||
import io.opentelemetry.api.trace.Span
|
||||
import kotlinx.coroutines.*
|
||||
import org.jetbrains.intellij.build.*
|
||||
import org.jetbrains.intellij.build.NativeBinaryDownloader
|
||||
import org.jetbrains.intellij.build.TraceManager.spanBuilder
|
||||
import org.jetbrains.intellij.build.impl.OsSpecificDistributionBuilder.Companion.suffix
|
||||
import org.jetbrains.intellij.build.impl.client.ADDITIONAL_EMBEDDED_CLIENT_VM_OPTIONS
|
||||
@@ -45,7 +46,7 @@ internal class WindowsDistributionBuilder(
|
||||
context.includeBreakGenLibraries() || !file.name.startsWith("breakgen")
|
||||
})
|
||||
|
||||
copyFileToDir(NativeBinaryDownloader.downloadRestarter(context, OsFamily.WINDOWS, arch), distBinDir)
|
||||
copyFileToDir(NativeBinaryDownloader.getRestarter(context, OsFamily.WINDOWS, arch), distBinDir)
|
||||
|
||||
generateBuildTxt(context, targetPath)
|
||||
generateLanguagePluginsXml(context, targetPath)
|
||||
@@ -342,7 +343,7 @@ internal class WindowsDistributionBuilder(
|
||||
Files.writeString(launcherPropertiesPath, launcherProperties.joinToString(separator = System.lineSeparator()) { (k, v) -> "${k}=${v}" })
|
||||
|
||||
val inputPath = if (customizer.useXPlatLauncher) {
|
||||
val (execPath, licensePath) = NativeLauncherDownloader.findLocalOrDownload(context, OsFamily.WINDOWS, arch)
|
||||
val (execPath, licensePath) = NativeBinaryDownloader.getLauncher(context, OsFamily.WINDOWS, arch)
|
||||
if (copyLicense) {
|
||||
copyFile(licensePath, winDistPath.resolve("license/launcher-third-party-libraries.html"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user