Skip to content
Snippets Groups Projects
Commit 7e76306a authored by Mick Jordan's avatar Mick Jordan
Browse files

rpath rceommended packages on Darwin

parent 6c2ef442
No related branches found
No related tags found
No related merge requests found
......@@ -27,9 +27,19 @@
# N.B. As this takes quite a while the building is conditional on the
# FASTR_RELEASE environment variable
FASTR_R_HOME := $(abspath $(CURDIR)/..)
NATIVE_PROJECT_DIR := $(FASTR_R_HOME)/com.oracle.truffle.r.native
ifneq (,$(wildcard $(NATIVE_PROJECT_DIR)/platform.mk))
include $(NATIVE_PROJECT_DIR)/platform.mk
else
ifneq ($(MAKECMDGOALS),clean)
$(error no platform.mk available)
endif
endif
.PHONY: all clean
FASTR_R_HOME := $(abspath $(CURDIR)/..)
NATIVE_PROJECT := $(subst native.recommended,native,$(CURDIR))
R_VERSION := $(notdir $(wildcard $(NATIVE_PROJECT)/gnur/R-*))
GNUR_HOME := $(NATIVE_PROJECT)/gnur/$(R_VERSION)
......@@ -45,6 +55,14 @@ install.recommended: $(GNUR_RECOMMENDED_TARS)
for pkgtar in $(GNUR_RECOMMENDED_TARS); do \
$(FASTR_R_HOME)/bin/R CMD INSTALL --library=$(FASTR_R_HOME)/library $$pkgtar; \
done
ifeq ($(OS_NAME),Darwin)
for pkgname in $(GNUR_RECOMMENDED_PKGNAMES); do \
if [ -e $(FASTR_R_HOME)/library/$$pkgname/libs/$$pkgname.so ] ; then \
install_name_tool -id @rpath/../library/$$pkgname/libs/$$pkgname.so $(FASTR_R_HOME)/library/$$pkgname/libs/$$pkgname.so; \
mx rupdatelib $(FASTR_R_HOME)/library/$$pkgname/libs; \
fi \
done
endif
touch install.recommended
else
install.recommended:
......
......@@ -25,6 +25,7 @@ import platform
import subprocess
import shutil
import mx
import mx_fastr
def _darwin_extract_realpath(lib, libpath):
'''
......@@ -126,31 +127,45 @@ def copylib(args):
def updatelib(args):
'''
If we captured a library then, on Darwin, we patch up the references
in the target library passed as argument to use @rpath.
On Darwin, if we captured a library, then we patch up the references
to it to use @rpath, for all the libs in the directory passed as argument .
args:
0 directory containing library
0 directory containing libs to patch (and may also contain the patchees)
'''
# These are not captured
ignore_list = ['R', 'Rblas', 'Rlapack', 'jniboot']
def ignorelib(name):
fastr_libdir = os.path.join(mx_fastr._fastr_suite.dir, 'lib')
def locally_built(name):
for ignore in ignore_list:
x = 'lib' + ignore + '.dylib'
if x == name:
return True
return False
def get_captured_libs():
cap_libs = []
for lib in os.listdir(fastr_libdir):
if not '.dylib' in lib:
# ignore non-libraries
continue
if locally_built(lib) or os.path.islink(os.path.join(fastr_libdir, lib)):
continue
cap_libs.append(lib)
return cap_libs
libdir = args[0]
cap_libs = []
cap_libs = get_captured_libs()
libs = []
for lib in os.listdir(libdir):
if not '.dylib' in lib:
if not ('.dylib' in lib or '.so' in lib):
# ignore non-libraries
continue
if not os.path.islink(os.path.join(libdir, lib)):
libs.append(lib)
if ignorelib(lib) or os.path.islink(os.path.join(libdir, lib)):
continue
cap_libs.append(lib)
# for each of the libs, check whether they depend
# on any of the captured libs, @rpath the dependency if so
for lib in libs:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment