Skip to content
Snippets Groups Projects
Commit 3a18dc6f authored by Danilo Ansaloni's avatar Danilo Ansaloni Committed by Gilles Duboscq
Browse files

Register FastR component.

parent 24da2526
No related branches found
No related tags found
No related merge requests found
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.truffle.r.launcher;
import java.lang.reflect.Method;
import java.util.Arrays;
import org.graalvm.polyglot.Engine;
public final class LegacyLauncher {
public static void main(String[] args) throws NoSuchMethodException, SecurityException {
String className = args[0];
Method loadClassMethod = Engine.class.getDeclaredMethod("loadLanguageClass", String.class);
try {
loadClassMethod.setAccessible(true);
Class<?> result = (Class<?>) loadClassMethod.invoke(null, className);
result.getMethod("main", String[].class).invoke(null, (Object) Arrays.copyOfRange(args, 1, args.length));
} catch (NoSuchMethodException | SecurityException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
}
#!/usr/bin/env bash
source="${BASH_SOURCE[0]}"
while [ -h "$source" ] ; do
prev_source="$source"
source="$(readlink "$source")";
if [[ "$source" != /* ]]; then
# if the link was relative, it was relative to where it came from
dir="$( cd -P "$( dirname "$prev_source" )" && pwd )"
source="$dir/$source"
fi
done
EXEC="$( cd -P "$( dirname "$source" )" && pwd )"
# This script is deployed as jre/languages/R/bin/exec/R
exec_location=jre/languages/R/bin/exec
slashes=${exec_location//[^\/]/}
dir_count=${#slashes}
JRE="$EXEC"
for i in $(seq 1 ${dir_count}); do
JRE="$( dirname "$JRE" )"
done
JAVA_ARGS=()
PROGRAM_ARGS=()
for opt in "${@:1}"
do
case $opt in
-J:*)
opt=${opt:3}
JAVA_ARGS+=("$opt") ;;
*)
PROGRAM_ARGS+=("$opt") ;;
esac
done
JAVA_HOME="$( dirname "$JRE" )"
GRAALVMCP=""
TMPCP="%%GRAALVMCP"
for cp in ${TMPCP//:/ }
do
GRAALVMCP="$GRAALVMCP$JAVA_HOME/$cp:"
done
# we can invoke FastR directly, but we do have to set R_HOME
export R_HOME="$JRE/languages/R"
exec "$JAVA_HOME/bin/java" -cp "$GRAALVMCP" -noverify -Dgraal.TruffleCompilationThreshold=10000 -Dgraal.TruffleCompilerThreads=2 -Xmx8g "${JAVA_ARGS[@]}" com.oracle.graalvm.launcher.LegacyLauncher com.oracle.truffle.r.launcher.RCommand "${PROGRAM_ARGS[@]}"
#!/usr/bin/env bash
source="${BASH_SOURCE[0]}"
while [ -h "$source" ] ; do
prev_source="$source"
source="$(readlink "$source")";
if [[ "$source" != /* ]]; then
# if the link was relative, it was relative to where it came from
dir="$( cd -P "$( dirname "$prev_source" )" && pwd )"
source="$dir/$source"
fi
done
BIN="$( cd -P "$( dirname "$source" )" && pwd )"
# This script is deployed as jre/languages/R/bin/Rscript
bin_location=jre/languages/R/bin
slashes=${bin_location//[^\/]/}
dir_count=${#slashes}
JRE="$BIN"
for i in $(seq 1 ${dir_count}); do
JRE="$( dirname "$JRE" )"
done
JAVA_ARGS=()
PROGRAM_ARGS=()
for opt in "${@:1}"
do
case $opt in
-J:*)
opt=${opt:3}
JAVA_ARGS+=("$opt") ;;
*)
PROGRAM_ARGS+=("$opt") ;;
esac
done
JAVA_HOME="$( dirname "$JRE" )"
GRAALVMCP=""
TMPCP="%%GRAALVMCP"
for cp in ${TMPCP//:/ }
do
GRAALVMCP="$GRAALVMCP$JAVA_HOME/$cp:"
done
# we can invoke FastR directly, but we do have to set R_HOME
export R_HOME="$JRE/languages/R"
exec "$JAVA_HOME/bin/java" -cp "$GRAALVMCP" -noverify -Dgraal.TruffleCompilationThreshold=10000 -Dgraal.TruffleCompilerThreads=2 -Xmx4g "${JAVA_ARGS[@]}" com.oracle.graalvm.launcher.LegacyLauncher com.oracle.truffle.r.launcher.RscriptCommand "${PROGRAM_ARGS[@]}"
......@@ -21,6 +21,7 @@
# questions.
#
import mx
import mx_sdk
import mx_fastr
import os, string, shutil
from os.path import join, basename, isfile
......@@ -208,3 +209,19 @@ def mx_post_parse_cmd_line(opts):
if isinstance(dist, mx.JARDistribution):
dist.set_archiveparticipant(FastRArchiveParticipant(dist))
mx_sdk.register_component(mx_sdk.GraalVmLanguage(
name='FastR',
id='R',
documentation_files=['extracted-dependency:fastr:FASTR_GRAALVM_SUPPORT<rffi>/README_FASTR'],
license_files=[
'link:<support>/COPYRIGHT_FASTR',
'link:<support>/LICENSE_FASTR',
],
third_party_license_files=[],
truffle_jars=['dependency:fastr:FASTR'],
support_distributions=['extracted-dependency:fastr:FASTR_GRAALVM_SUPPORT<rffi>'],
provided_executables=[
'link:<support>/bin/Rscript',
'link:<support>/bin/exec/R',
]
))
......@@ -449,20 +449,22 @@ suite = {
"layout" : {
"./" : [
{
"source_type": "extracted-dependency",
"dependency": "FASTR_RELEASE<rffi>",
"path": "*",
"exclude": [
"source_type" : "extracted-dependency",
"dependency" : "FASTR_RELEASE<rffi>",
"path" : "*",
"exclude" : [
"COPYRIGHT",
"LICENSE",
"README.md",
"bin/Rscript",
"bin/fastr_jars",
"bin/exec/R",
],
},
{
"source_type": "extracted-dependency",
"dependency": "FASTR_RELEASE<rffi>",
"path": "bin/fastr_jars/*",
"source_type" : "extracted-dependency",
"dependency" : "FASTR_RELEASE<rffi>",
"path" : "bin/fastr_jars/*",
"exclude" : [
"bin/fastr_jars/truffle*",
"bin/fastr_jars/graal-sdk*",
......@@ -473,6 +475,8 @@ suite = {
"COPYRIGHT_FASTR" : "extracted-dependency:fastr:FASTR_RELEASE<rffi>/COPYRIGHT",
"LICENSE_FASTR" : "extracted-dependency:fastr:FASTR_RELEASE<rffi>/LICENSE",
"README_FASTR" : "extracted-dependency:fastr:FASTR_RELEASE<rffi>/README.md",
"bin/Rscript" : "file:com.oracle.truffle.r.release/src/Rscript_legacy",
"bin/exec/R" : "file:com.oracle.truffle.r.release/src/R_legacy",
},
}
},
......
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