Skip to content

Commit

Permalink
[all] Make the developer scripts compatible with MacOS.
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Feb 11, 2021
1 parent 69b0239 commit 820a4dc
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 18 deletions.
59 changes: 44 additions & 15 deletions sarlide
Expand Up @@ -2,31 +2,60 @@

CDIR=`dirname $0`

if [ -z "$DEVEL_SARL_LAUNCH_SCRIPT" ]
then
EXEC="$CDIR/products/updatesite/target/products/io.sarl.lang.product/linux/gtk/x86_64/eclipse-sarl-ubuntu.sh"
else
EXEC="$DEVEL_SARL_LAUNCH_SCRIPT"
fi

if [ -z "$DEVEL_SARL_WORKSPACE" ]
then
WORKSPACE="$HOME/Documents/Workspaces/runtime-io.sarl.lang.product"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux
if [ -z "$DEVEL_SARL_LAUNCH_SCRIPT" ]; then
EXEC="$CDIR/products/updatesite/target/products/io.sarl.lang.product/linux/gtk/x86_64/eclipse-sarl-ubuntu.sh"
else
EXEC="$DEVEL_SARL_LAUNCH_SCRIPT"
fi
if [ -z "$DEVEL_SARL_WORKSPACE" ]; then
WORKSPACE="$HOME/Documents/Workspaces/runtime-io.sarl.lang.product"
else
WORKSPACE="$DEVEL_SARL_WORKSPACE"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
if [ -z "$DEVEL_SARL_LAUNCH_SCRIPT" ]; then
EXEC="$CDIR/products/updatesite/target/products/io.sarl.lang.product/macosx/cocoa/x86_64/Eclipse.app/Content/Eclipse/eclipse-sarl-macos.sh"
else
EXEC="$DEVEL_SARL_LAUNCH_SCRIPT"
fi
if [ -z "$DEVEL_SARL_WORKSPACE" ]; then
WORKSPACE="$HOME/Documents/Workspaces/runtime-io.sarl.lang.product"
else
WORKSPACE="$DEVEL_SARL_WORKSPACE"
fi
elif [[ "$OSTYPE" == "cygwin" ]]; then
echo "Unsupported operating system: $OSTYPE" >&2
exit 255
elif [[ "$OSTYPE" == "msys" ]]; then
# MinGW
echo "Unsupported operating system: $OSTYPE" >&2
exit 255
elif [[ "$OSTYPE" == "win32" ]]; then
# Standard Windows
echo "Unsupported operating system: $OSTYPE" >&2
exit 255
elif [[ "$OSTYPE" == "freebsd"* ]]; then
# FreeBSD
echo "Unsupported operating system: $OSTYPE" >&2
exit 255
else
WORKSPACE="$DEVEL_SARL_WORKSPACE"
echo "Unknown operating system: $OSTYPE" >&2
exit 255
fi

echo "Running: $EXEC"

if [ -f "$EXEC" ]
then
if [ -d "$WORKSPACE" ]
then
if [ -f "$EXEC" ]; then
if [ -d "$WORKSPACE" ]; then
echo "Workspace: $WORKSPACE"
exec bash "$EXEC" -data "$WORKSPACE" "$@"
else
exec bash "$EXEC" "$@"
fi
exit 0
else
echo "Executable not found or not runnable. Please re-generate it with:" >&2
echo "mvn clean install -Dmaven.test.skip=true" >&2
Expand Down
17 changes: 14 additions & 3 deletions sarlide-setjava
Expand Up @@ -7,6 +7,17 @@ my $CDIR = dirname("$0");
my $INIFILE = $ENV['DEVEL_SARL_INI_FILE'] || "$CDIR/products/updatesite/target/products/io.sarl.lang.product/linux/gtk/x86_64/eclipse-sarl.ini";

my $JVM_ROOT = "/usr/lib/jvm";
my $JVM_BIN_PATH = "bin";
my $JVM_JAVACBIN_PATH = "$JVM_BIN_PATH/javac";
my $JVM_JAVABIN_PATH = "$JVM_BIN_PATH/java";

# Special case for MacOS
if (-d '/Library/Java/JavaVirtualMachines') {
$JVM_ROOT = "/Library/Java/JavaVirtualMachines";
$JVM_BIN_PATH = "Contents/Home/bin";
$JVM_JAVACBIN_PATH = "$JVM_BIN_PATH/javac";
$JVM_JAVABIN_PATH = "$JVM_BIN_PATH/java";
}

sub findJdks(;$) {
my $root = shift || '';
Expand All @@ -26,7 +37,7 @@ sub findJdks(;$) {
$version = "$1";
}
my $dir = "$root/$file";
my $bin = "$dir/bin/javac";
my $bin = "$dir/$JVM_JAVACBIN_PATH";
if (-x "$bin") {
$jdks{"$version"}{"$vendor"} = "$dir";
}
Expand Down Expand Up @@ -125,8 +136,8 @@ sub updateIniContent(@) {
my $jvm = shift || die("no JVM provided\n");
# Check the JVM path
my $jvmfolder = "$jvm";
if (-x "$jvm/bin/java") {
$jvmfolder = "$jvm/bin";
if (-x "$jvm/$JVM_JAVABIN_PATH") {
$jvmfolder = "$jvm/$JVM_BIN_PATH";
}
my $content = shift || die("no content\n");
if ($content =~ /^-vm$/m) {
Expand Down

0 comments on commit 820a4dc

Please sign in to comment.