Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.xml.template
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<remoteRepository refid="remote.repository" />
<dependency groupId="org.renjin" artifactId="renjin-script-engine" version="${renjin-version}" />
<dependency groupId="org.renjin" artifactId="renjin-cli" version="${renjin-version}" />
<dependency groupId="commons-cli" artifactId="commons-cli" version="1.4" />
</artifact:dependencies>
<copy todir="${mode-lib}">
<fileset refid="dependency.fileset" />
Expand Down Expand Up @@ -120,6 +121,7 @@
<manifest>
<attribute name="Main-Class" value="rprocessing.Runner" />
</manifest>
<zipfileset src="${processing.classes.pde}"/>
<zipgroupfileset dir="${processing.classes.core}" includes="*.jar" />
<zipgroupfileset dir="${mode-lib}" includes="**/*.jar" />
</jar>
Expand Down
Binary file added lib/mode/commons-cli.jar
Binary file not shown.
60 changes: 22 additions & 38 deletions src/rprocessing/lancher/StandaloneSketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import processing.app.Platform;
import processing.core.PApplet;
import rprocessing.RunnableSketch;
import rprocessing.Runner;
Expand Down Expand Up @@ -103,44 +105,26 @@ public StandaloneSketch(final String[] args) throws Exception {
this.code = RScriptReader.readText(sketchPath.toPath());

// TODO: Support library in standalone sketch.
this.libraryDirs = null;
// {
// log("Populate library directories.");
// this.libraryDirs = new ArrayList<>();
// final String buildProperties = "build.properties";
// final String propsResource;
// try {
// propsResource =
// URLDecoder.decode(Runner.class.getResource(buildProperties).toString(), "UTF-8");
// log(propsResource);
// } catch (final UnsupportedEncodingException e) {
// throw new RuntimeException("Impossible: " + e);
// }
//
// if (propsResource == null) {
// log("Could not get build.properties from Runner.");
// libraryDirs.add(new File("libraries"));
// return;
// }
//
// final Pattern jarResource = Pattern
// .compile("jar:file:(.+?)/RLangMode\\.jar!/rprocessing/" + Pattern.quote(buildProperties));
// final Pattern fileResource =
// Pattern.compile("file:(.+?)/bin/rprocessing/" + Pattern.quote(buildProperties));
//
// final Matcher jarMatcher = jarResource.matcher(propsResource);
// final Matcher fileMatcher = fileResource.matcher(propsResource);
// if (jarMatcher.matches()) {
// log("We're running from a JAR file.");
// libraryDirs.add(new File(jarMatcher.group(1), "libraries"));
// } else if (fileMatcher.matches()) {
// log("We're running from class files.");
// libraryDirs.add(new File(fileMatcher.group(1), "libraries"));
// } else {
// log("WARNING: I can't find my libraries directory!");
// libraryDirs.add(new File("libraries"));
// }
// }
final List<File> libraryDirs = new ArrayList<>();
libraryDirs.add(getLibraryDir());
log(getLibraryDir());
libraryDirs.add(sketchPath);
this.libraryDirs = libraryDirs;
}

private File getLibraryDir() {
if (Platform.isMacOS()) {
String home = System.getProperty("user.home");
return new File(home + "/Documents/Processing/libraries");
} else if (Platform.isLinux()) {
String home = System.getProperty("user.home");
return new File(home + "/sketchbook/libraries");
} else if (Platform.isWindows()) {
String home = System.getProperty("user.home");
return new File(home + "\\Documents\\Processing\\modes");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modes? Shouldn't this be libraries?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a typo. Thanks for your review 🤔

}
log("Operating System is not supported now.");
return null;
}

@Override
Expand Down