From d01b4e7bf4dc3c927ff056d93b4bf6a017eebef7 Mon Sep 17 00:00:00 2001 From: benfry Date: Tue, 1 Nov 2011 00:47:37 +0000 Subject: [PATCH] trying to sort out path and bits issues for 2.0a2 --- app/src/processing/mode/java/JavaBuild.java | 14 +++++++-- build/windows/export/launcher.cpp | 4 +-- core/src/processing/core/PApplet.java | 30 +++++++++++++++++-- core/todo.txt | 3 ++ .../video/src/processing/video/Capture.java | 10 +++---- todo.txt | 2 ++ 6 files changed, 52 insertions(+), 11 deletions(-) diff --git a/app/src/processing/mode/java/JavaBuild.java b/app/src/processing/mode/java/JavaBuild.java index 6ab9edd31..caae2b48c 100644 --- a/app/src/processing/mode/java/JavaBuild.java +++ b/app/src/processing/mode/java/JavaBuild.java @@ -1151,8 +1151,18 @@ public class JavaBuild { /// on windows, copy the exe file if (exportPlatform == PConstants.WINDOWS) { - Base.copyFile(mode.getContentFile("application/template.exe"), - new File(destFolder, sketch.getName() + ".exe")); + if (exportBits == 64) { + // We don't yet have a 64-bit launcher, so this is a workaround for now. + File batFile = new File(destFolder, sketch.getName() + ".bat"); + PrintWriter writer = PApplet.createWriter(batFile); + writer.println("@echo off"); + writer.println("java -Djava.ext.dirs=lib -Djava.library.path=lib " + sketch.getName()); + writer.flush(); + writer.close(); + } else { + Base.copyFile(mode.getContentFile("application/template.exe"), + new File(destFolder, sketch.getName() + ".exe")); + } } diff --git a/build/windows/export/launcher.cpp b/build/windows/export/launcher.cpp index 0be2be5ea..0dbdc8722 100644 --- a/build/windows/export/launcher.cpp +++ b/build/windows/export/launcher.cpp @@ -212,7 +212,6 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) #endif } - /* SHELLEXECUTEINFO ShExecInfo; #ifdef DEBUG @@ -261,8 +260,8 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) } return 0; - */ + /* PROCESS_INFORMATION pi; memset(&pi, 0, sizeof(pi)); STARTUPINFO si; @@ -298,6 +297,7 @@ WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) } } return dwExitCode; + */ } diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index ec02402f4..d13e103f7 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -6548,8 +6548,8 @@ public class PApplet extends Applet return sketchPath + File.separator + "data" + File.separator + where; } - - + + /** * Return a full path to an item in the data folder as a File object. * See the dataPath() method for more information. @@ -6559,6 +6559,32 @@ public class PApplet extends Applet } + /** + * On Windows and Linux, this is simply the data folder. On Mac OS X, this is + * the path to the data folder buried inside Contents/Resources/Java + */ + public File inputFile(String where) { + // isAbsolute() could throw an access exception, but so will writing + // to the local disk using the sketch path, so this is safe here. + File why = new File(where); + if (why.isAbsolute()) return why; + + String jarPath = getClass().getProtectionDomain().getCodeSource().getLocation().getPath(); + if (jarPath.contains("Contents/Resources/Java/")) { + File containingFolder = new File(jarPath).getParentFile(); + File dataFolder = new File(containingFolder, "data"); + return new File(dataFolder, where); + } + // Windows, Linux, or when not using a Mac OS X .app file + return new File(sketchPath + File.separator + "data" + File.separator + where); + } + + + public String inputPath(String where) { + return inputFile(where).getAbsolutePath(); + } + + /** * Takes a path and creates any in-between folders if they don't * already exist. Useful when trying to save to a subfolder that diff --git a/core/todo.txt b/core/todo.txt index e1e642fb4..779efe19f 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -4,6 +4,9 @@ X doing this via a tool instead X on resize, call redraw() when noLoop() is used o need to add this to the docs X was already in the documentation.. +X add inputPath() + +_ split dataPath() into inputPath() and outputPath() _ finish adding loadStrings(BufferedReader) _ decide if we want to keep this (and/or others?) diff --git a/java/libraries/video/src/processing/video/Capture.java b/java/libraries/video/src/processing/video/Capture.java index fc890f036..ea706ca79 100644 --- a/java/libraries/video/src/processing/video/Capture.java +++ b/java/libraries/video/src/processing/video/Capture.java @@ -438,7 +438,7 @@ public class Capture extends PImage implements PConstants { } res = new String[devices.size()]; for (int i = 0; i < res.length; i++) { - res[i] = (String)devices.get(i); + res[i] = devices.get(i); } } else { System.err.println("The capture plugin doesn't support device query!"); @@ -484,7 +484,7 @@ public class Capture extends PImage implements PConstants { int n = resolutions.size(); res = new Resolution[n]; for (int i = 0; i < n; i++) { - res[i] = new Resolution((Resolution)resolutions.get(i)); + res[i] = new Resolution(resolutions.get(i)); } } @@ -626,7 +626,7 @@ public class Capture extends PImage implements PConstants { if (properties != null) { Iterator it = properties.keySet().iterator(); while (it.hasNext()) { - String name = (String) it.next(); + String name = it.next(); Object value = properties.get(name); gsource.set(name, value); } @@ -716,7 +716,7 @@ public class Capture extends PImage implements PConstants { protected void checkResolutions() { boolean suppRes = false; for (int i = 0; i < resolutions.size(); i++) { - Resolution res = (Resolution) resolutions.get(i); + Resolution res = resolutions.get(i); if (reqWidth == res.width && reqHeight == res.height && fps.equals("") || fps.equals(res.fpsString)) { suppRes = true; @@ -732,7 +732,7 @@ public class Capture extends PImage implements PConstants { System.err.println("The requested resolution of " + reqWidth + "x" + reqHeight + fpsStr + " is not supported by selected the capture device."); System.err.println("Use one of the following resolutions instead:"); for (int i = 0; i < resolutions.size(); i++) { - Resolution res = (Resolution) resolutions.get(i); + Resolution res = resolutions.get(i); System.err.println(res.toString()); } } diff --git a/todo.txt b/todo.txt index c4af3f086..73d20cde6 100644 --- a/todo.txt +++ b/todo.txt @@ -11,6 +11,8 @@ X requires change to export/launcher.cpp to include the exe dir _ this will cause trouble with ... X change Linux script to handle the 'lib' dir as part of the lib path X changed Mac OS X launchers, also requiring Java 1.6. +X write .bat file for windows64 +_ document that this is temporary / file a bug // If no bits specified (libs are all universal, or no native libs) // then exportBits will be 0, and can be controlled via "Get Info".