Files
nixpkgs/pkgs/by-name/rs/rstudio/fix-darwin.patch
2026-01-08 15:50:28 +01:00

204 lines
7.6 KiB
Diff

diff --git a/cmake/globals.cmake b/cmake/globals.cmake
index 3601ee4..5090f32 100644
--- a/cmake/globals.cmake
+++ b/cmake/globals.cmake
@@ -340,6 +340,7 @@ if (APPLE)
set(RSTUDIO_INSTALL_SUPPORTING RStudio.app/Contents/Resources/app)
# handles Quarto share when not stored alongside bin
set(RSTUDIO_INSTALL_RESOURCES RStudio.app/Contents/Resources)
+ set(RSTUDIO_INSTALL_ELECTRON .)
else()
set(RSTUDIO_INSTALL_BIN RStudio.app/Contents/MacOS)
set(RSTUDIO_INSTALL_SUPPORTING RStudio.app/Contents/Resources)
@@ -470,44 +471,6 @@ macro(add_stripped_executable _target)
define_source_file_names("${_target}")
endmacro(add_stripped_executable)
-if(APPLE)
-
- # set Homebrew prefix directory
- if(NOT DEFINED HOMEBREW_PREFIX)
-
- if(UNAME_M STREQUAL arm64)
- set(HOMEBREW_PREFIX_FALLBACK /opt/homebrew)
- else()
- set(HOMEBREW_PREFIX_FALLBACK /usr/local)
- endif()
-
- find_path(HOMEBREW_PREFIX
- NAMES bin/brew
- HINTS
- "${HOMEBREW_PREFIX_FALLBACK}")
-
- message(STATUS "Using Homebrew: ${HOMEBREW_PREFIX}")
-
- endif()
-
- # help Boost find icu4c
- if(RSTUDIO_USE_SYSTEM_BOOST)
- link_directories(${HOMEBREW_PREFIX}/opt/icu4c/lib)
- endif()
-
- # set OPENSSL_ROOT_DIR if unset
- if(NOT DEFINED OPENSSL_ROOT_DIR)
-
- file(GLOB OPENSSL_ROOT_CANDIDATE "${HOMEBREW_PREFIX}/Cellar/openssl/*")
- if(EXISTS "${OPENSSL_ROOT_CANDIDATE}")
- set(OPENSSL_ROOT_DIR "${OPENSSL_ROOT_CANDIDATE}" CACHE INTERNAL "")
- elseif(EXISTS "${HOMEBREW_PREFIX}/opt/openssl")
- set(OPENSSL_ROOT_DIR "${HOMEBREW_PREFIX}/opt/openssl" CACHE INTERNAL "")
- endif()
-
- endif()
-
-endif()
# If enabled, use caching for the build
if(SCCACHE_ENABLED)
diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt
index 62688dd..f909f8d 100644
--- a/src/cpp/CMakeLists.txt
+++ b/src/cpp/CMakeLists.txt
@@ -167,7 +167,7 @@ endif()
# determine whether we should statically link boost. we always do this
# unless we are building a non-packaged build on linux (in which case
# boost dynamic libraries are presumed to be installed on the system ldpath)
-if(APPLE OR WIN32 OR RSTUDIO_PACKAGE_BUILD)
+if(WIN32 OR RSTUDIO_PACKAGE_BUILD)
set(Boost_USE_STATIC_LIBS ON)
endif()
@@ -304,7 +304,7 @@ endif()
# find SOCI libraries
if(UNIX)
- if(NOT APPLE AND RSTUDIO_USE_SYSTEM_SOCI)
+ if(RSTUDIO_USE_SYSTEM_SOCI)
find_library(SOCI_CORE_LIB NAMES "libsoci_core.a" "soci_core" REQUIRED)
find_library(SOCI_SQLITE_LIB NAMES "libsoci_sqlite3.a" "soci_sqlite3" REQUIRED)
if(RSTUDIO_PRO_BUILD)
diff --git a/src/cpp/session/postback/CMakeLists.txt b/src/cpp/session/postback/CMakeLists.txt
index 7bba997..4ef0abf 100644
--- a/src/cpp/session/postback/CMakeLists.txt
+++ b/src/cpp/session/postback/CMakeLists.txt
@@ -36,6 +36,7 @@ add_stripped_executable(rpostback ${POSTBACK_SOURCE_FILES} ${POSTBACK_HEADER_FIL
# set link dependencies
target_link_libraries(rpostback
rstudio-core
+ ${FOUNDATION_LIBRARY}
)
if (RSTUDIO_SERVER)
diff --git a/src/node/CMakeNodeTools.txt b/src/node/CMakeNodeTools.txt
index fb3f394..3595f87 100644
--- a/src/node/CMakeNodeTools.txt
+++ b/src/node/CMakeNodeTools.txt
@@ -27,17 +27,7 @@ endif()
# set cmake env vars for node (NODEJS) and node tools, like YARN, and NPM
-if(APPLE AND UNAME_M STREQUAL arm64)
-
- # make sure we're using arm64 binaries of node / npm for arm64 builds
- set(NODEJS
- "${CMAKE_CURRENT_LIST_DIR}/../../dependencies/common/node/${RSTUDIO_NODE_VERSION}-arm64/bin/node")
- set(NPM
- "${CMAKE_CURRENT_LIST_DIR}/../../dependencies/common/node/${RSTUDIO_NODE_VERSION}-arm64/bin/npm")
- set(NPX
- "${CMAKE_CURRENT_LIST_DIR}/../../dependencies/common/node/${RSTUDIO_NODE_VERSION}-arm64/bin/npx")
-
-else()
+if(true)
# Detect node.js, npm, and npx; use versions supplied by the dependency scripts
find_program(NODEJS
diff --git a/src/node/desktop/CMakeLists.txt b/src/node/desktop/CMakeLists.txt
index bccf5b3..0cc798a 100644
--- a/src/node/desktop/CMakeLists.txt
+++ b/src/node/desktop/CMakeLists.txt
@@ -236,16 +236,21 @@ if(WIN32)
install(FILES ${VCRUNTIME_X86_FILES} DESTINATION "${RSTUDIO_INSTALL_BIN}/x86")
install(FILES ${VCRUNTIME_X64_FILES} DESTINATION "${RSTUDIO_INSTALL_BIN}")
-elseif(LINUX)
+elseif(LINUX OR APPLE)
- if(UNAME_M STREQUAL aarch64)
+ if(UNAME_M STREQUAL aarch64 OR UNAME_M STREQUAL arm64)
set(ELECTRON_ARCH arm64)
else()
set(ELECTRON_ARCH x64)
endif()
+ if(APPLE)
+ set(ELECTRON_PLATFORM darwin)
+ else()
+ set(ELECTRON_PLATFORM linux)
+ endif()
install(
- DIRECTORY "${ELECTRON_BINARY_DIR}/out/RStudio-linux-${ELECTRON_ARCH}/"
+ DIRECTORY "${ELECTRON_BINARY_DIR}/out/RStudio-${ELECTRON_PLATFORM}-${ELECTRON_ARCH}/"
DIRECTORY_PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
diff --git a/src/node/desktop/src/main/session-launcher.ts b/src/node/desktop/src/main/session-launcher.ts
index d84de20..efef843 100644
--- a/src/node/desktop/src/main/session-launcher.ts
+++ b/src/node/desktop/src/main/session-launcher.ts
@@ -85,29 +85,9 @@ function launchProcess(absPath: FilePath, argList: string[]): ChildProcess {
// DYLD_INSERT_LIBRARIES to inject the library we wish to use
const rHome = new FilePath(getenv('R_HOME'));
const rLib = rHome.completePath('lib/libR.dylib');
- const dyldArgs = [
- '-e',
- `DYLD_INSERT_LIBRARIES=${rLib.getAbsolutePath()}`,
- '-e',
- `DYLD_FALLBACK_LIBRARY_PATH=${dyldFallbackLibraryPath}`,
- ];
-
- // launch via /usr/bin/arch, so we can control whether the OS requests
- // x86 or arm64 versions of the libraries in the launched rsession
- const path = absPath.getAbsolutePath();
- if (process.arch === 'arm64') {
- const fileInfo = execSync(`/usr/bin/file "${rLib}"`, { encoding: 'utf-8' });
- if (fileInfo.indexOf('arm64') === -1 && fileInfo.indexOf('x86_64') !== -1) {
- argList = ['-x86_64', ...dyldArgs, path, ...argList];
- absPath = new FilePath('/usr/bin/arch');
- } else {
- argList = ['-arm64', ...dyldArgs, path, ...argList];
- absPath = new FilePath('/usr/bin/arch');
- }
- } else {
- argList = ['-x86_64', ...dyldArgs, path, ...argList];
- absPath = new FilePath('/usr/bin/arch');
- }
+
+ env['DYLD_INSERT_LIBRARIES'] = rLib.getAbsolutePath();
+ env['DYLD_FALLBACK_LIBRARY_PATH'] = dyldFallbackLibraryPath;
}
const rsessionOptions = new LogOptions('rsession');
@@ -563,22 +543,6 @@ export class SessionLauncher {
}
}
- // on macOS, we need to look at R and figure out if we should be trying to run
- // with the arm64 session binary (rsession-arm64) or with the x64 session binary (rsession)
- if (app.isPackaged && process.platform === 'darwin' && process.arch === 'arm64') {
- const rHome = getenv('R_HOME');
- const rLibPath = `${rHome}/lib/libR.dylib`;
- logger().logDebug(`$ /usr/bin/file "${rLibPath}"`);
- const fileInfo = execSync(`/usr/bin/file "${rLibPath}"`, { encoding: 'utf-8' });
- logger().logDebug(fileInfo);
- if (fileInfo.indexOf('arm64') !== -1) {
- this.sessionPath = this.sessionPath.getParent().completeChildPath('rsession-arm64');
- logger().logDebug(`R is arm64; using ${this.sessionPath}`);
- } else {
- logger().logDebug(`R is x86_64; using ${this.sessionPath}`);
- }
- }
-
// if we're running automation tests, set that up now
if (app.commandLine.hasSwitch('run-automation')) {
argList.push('--run-automation');