mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[platform] using new restarter on macOS (IDEA-327235 prerequisite)
GitOrigin-RevId: 1c669198cd2d7a95358de8b79c7fb4256f2b8d1c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ccd4bbb462
commit
d9dc08c673
Binary file not shown.
@@ -5,4 +5,5 @@ gradleApiVersion=8.2
|
||||
jdkBuild=17.0.8.1b1063.1
|
||||
launcherBuild=233.7666
|
||||
nsisBuild=1
|
||||
restarterBuild=233.8717
|
||||
runtimeBuild=17.0.8.1b1063.1
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@file:Suppress("ReplaceJavaStaticMethodWithKotlinAnalog")
|
||||
|
||||
// Copyright 2000-2023 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 com.intellij.util.system.CpuArch
|
||||
|
||||
@Suppress("EnumEntryName")
|
||||
enum class JvmArchitecture(@JvmField val fileSuffix: String, @JvmField val dirName: String) {
|
||||
x64("64", "amd64"), aarch64("aarch64", "aarch64");
|
||||
enum class JvmArchitecture(@JvmField val archName: String, @JvmField val fileSuffix: String, @JvmField val dirName: String) {
|
||||
x64("X86_64", "64", "amd64"), aarch64("AArch64", "aarch64", "aarch64");
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val ALL: List<JvmArchitecture> = java.util.List.of(*values())
|
||||
val ALL: List<JvmArchitecture> = entries.toList()
|
||||
|
||||
@JvmField
|
||||
val currentJvmArch: JvmArchitecture = when {
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright 2000-2023 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 kotlin.io.path.isDirectory
|
||||
import kotlin.io.path.isRegularFile
|
||||
|
||||
object NativeBinaryDownloader {
|
||||
private const val GROUP_ID = "org.jetbrains.intellij.deps"
|
||||
private const val RESTARTER_ID = "restarter"
|
||||
private const val PACKAGING = "tar.gz"
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
val version = context.dependenciesProperties.property("restarterBuild")
|
||||
val uri = BuildDependenciesDownloader.getUriForMavenArtifact(INTELLIJ_DEPENDENCIES_URL, GROUP_ID, RESTARTER_ID, version, PACKAGING)
|
||||
val archiveFile = downloadFileToCacheLocation(uri.toString(), communityRoot)
|
||||
val unpackedDir = BuildDependenciesDownloader.extractFileToCacheLocation(communityRoot, archiveFile)
|
||||
|
||||
val platformDirName = "${os.osName}-${arch.archName}"
|
||||
val platformDir = unpackedDir.resolve(platformDirName)
|
||||
check(platformDir.isDirectory()) { "'${platformDir}' not found in '${archiveFile.fileName}'" }
|
||||
|
||||
val executableName = if (os == OsFamily.WINDOWS) "restarter.exe" else "restarter"
|
||||
val executableFile = platformDir.resolve(executableName)
|
||||
check(executableFile.isRegularFile()) { "Executable '${executableName}' not found in '${platformDir}'" }
|
||||
|
||||
return executableFile
|
||||
}
|
||||
}
|
||||
@@ -16,10 +16,7 @@ import org.jetbrains.intellij.build.*
|
||||
import org.jetbrains.intellij.build.TraceManager.spanBuilder
|
||||
import org.jetbrains.intellij.build.impl.OsSpecificDistributionBuilder.Companion.suffix
|
||||
import org.jetbrains.intellij.build.impl.productInfo.*
|
||||
import org.jetbrains.intellij.build.io.copyDir
|
||||
import org.jetbrains.intellij.build.io.copyFile
|
||||
import org.jetbrains.intellij.build.io.substituteTemplatePlaceholders
|
||||
import org.jetbrains.intellij.build.io.writeNewFile
|
||||
import org.jetbrains.intellij.build.io.*
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
@@ -217,6 +214,7 @@ class MacDistributionBuilder(override val context: BuildContext,
|
||||
arch: JvmArchitecture) {
|
||||
val macCustomizer = customizer
|
||||
copyDirWithFileFilter(context.paths.communityHomeDir.resolve("bin/mac"), macDistDir.resolve("bin"), customizer.binFilesFilter)
|
||||
copyFileToDir(NativeBinaryDownloader.downloadRestarter(context, OsFamily.MACOS, arch), macDistDir.resolve("bin"))
|
||||
copyDir(context.paths.communityHomeDir.resolve("platform/build-scripts/resources/mac/Contents"), macDistDir)
|
||||
|
||||
val executable = context.productProperties.baseFileName
|
||||
|
||||
@@ -122,6 +122,7 @@ public final class Restarter {
|
||||
return restarter != null && Files.isExecutable(restarter) ? null : "not an executable file: " + restarter;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void scheduleRestart(boolean elevate, String @NotNull ... beforeRestart) throws IOException {
|
||||
var exitCodeVariable = EnvironmentUtil.getValue(SPECIAL_EXIT_CODE_FOR_RESTART_ENV_VAR);
|
||||
if (exitCodeVariable != null) {
|
||||
@@ -158,13 +159,7 @@ public final class Restarter {
|
||||
if (starter == null) throw new IOException("Starter executable not found in " + PathManager.getBinPath());
|
||||
var restarter = PathManager.findBinFileWithException("restarter.exe");
|
||||
|
||||
var command = new ArrayList<String>();
|
||||
command.add(copyWhenNeeded(restarter, beforeRestart).toString());
|
||||
command.add(String.valueOf(ProcessHandle.current().pid()));
|
||||
if (beforeRestart.length > 0) {
|
||||
command.add(String.valueOf(beforeRestart.length));
|
||||
Collections.addAll(command, beforeRestart);
|
||||
}
|
||||
var command = prepareCommand(restarter, beforeRestart);
|
||||
if (elevate) {
|
||||
command.add("2");
|
||||
command.add(PathManager.findBinFileWithException("launcher.exe").toString());
|
||||
@@ -181,10 +176,10 @@ public final class Restarter {
|
||||
if (appDir == null) throw new IOException("Application bundle not found: " + PathManager.getHomePath());
|
||||
var restarter = Path.of(PathManager.getBinPath(), "restarter");
|
||||
|
||||
var command = new ArrayList<String>();
|
||||
command.add(copyWhenNeeded(restarter, beforeRestart).toString());
|
||||
var command = prepareCommand(restarter, beforeRestart);
|
||||
command.add("2");
|
||||
command.add("/usr/bin/open");
|
||||
command.add(appDir.toString());
|
||||
Collections.addAll(command, beforeRestart);
|
||||
runRestarter(command);
|
||||
}
|
||||
|
||||
@@ -210,6 +205,17 @@ public final class Restarter {
|
||||
System.setProperty(DO_NOT_LOCK_INSTALL_FOLDER_PROPERTY, "true");
|
||||
}
|
||||
|
||||
private static List<String> prepareCommand(Path restarter, String[] beforeRestart) throws IOException {
|
||||
var command = new ArrayList<String>();
|
||||
command.add(copyWhenNeeded(restarter, beforeRestart).toString());
|
||||
command.add(String.valueOf(ProcessHandle.current().pid()));
|
||||
if (beforeRestart.length > 0) {
|
||||
command.add(String.valueOf(beforeRestart.length));
|
||||
Collections.addAll(command, beforeRestart);
|
||||
}
|
||||
return command;
|
||||
}
|
||||
|
||||
private static Path copyWhenNeeded(Path binFile, String[] args) throws IOException {
|
||||
if (SystemProperties.getBooleanProperty(DO_NOT_LOCK_INSTALL_FOLDER_PROPERTY, false) || ArrayUtil.contains(UpdateInstaller.UPDATER_MAIN_CLASS, args)) {
|
||||
var tempDir = Files.createDirectories(PathManager.getSystemDir().resolve("restart"));
|
||||
@@ -223,8 +229,9 @@ public final class Restarter {
|
||||
private static void runRestarter(List<String> command) throws IOException {
|
||||
Logger.getInstance(Restarter.class).info("run restarter: " + command);
|
||||
|
||||
var processBuilder = new ProcessBuilder(command)
|
||||
.directory(Path.of(SystemProperties.getUserHome()).toFile());
|
||||
var processBuilder = new ProcessBuilder(command);
|
||||
processBuilder.directory(Path.of(SystemProperties.getUserHome()).toFile());
|
||||
processBuilder.environment().put("IJ_RESTARTER_LOG", PathManager.getLogDir().resolve("restarter.log").toString());
|
||||
|
||||
if (SystemInfo.isXWindow) setDesktopStartupId(processBuilder);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user