From eaed0bb2633ebf56486f749e2313691b108da0e4 Mon Sep 17 00:00:00 2001 From: benfry Date: Tue, 30 Jul 2002 05:37:08 +0000 Subject: [PATCH] working on osx distribution --- app/PdeBase.java | 37 +++++++++++++--- app/PdeEditor.java | 42 ++++++++++++------ build/macosx/dist.sh | 43 ++++++++++++------- .../macosx/dist/{Proce55ing => Proce55ing.sh} | 0 4 files changed, 90 insertions(+), 32 deletions(-) rename build/macosx/dist/{Proce55ing => Proce55ing.sh} (100%) diff --git a/app/PdeBase.java b/app/PdeBase.java index 5053c79fb..5a3442b79 100644 --- a/app/PdeBase.java +++ b/app/PdeBase.java @@ -68,7 +68,7 @@ public class PdeBase implements ActionListener { static public void main(String args[]) { //System.getProperties().list(System.out); - System.out.println(System.getProperty("java.class.path")); + //System.out.println(System.getProperty("java.class.path")); PdeBase app = new PdeBase(); } @@ -86,9 +86,27 @@ public class PdeBase implements ActionListener { properties = new Properties(); try { //properties.load(new FileInputStream("lib/pde.properties")); - properties.load(getClass().getResource("pde.properties").openStream()); - String platformProps = "pde.properties_" + platforms[platform]; - properties.load(getClass().getResource(platformProps).openStream()); + //#URL where = getClass().getResource("PdeBase.class"); + //System.err.println(where); + //System.getProperties().list(System.err); + //System.err.println("userdir = " + System.getProperty("user.dir")); + + if (PdeBase.platform == PdeBase.MACOSX) { + String pkg = "Proce55ing.app/Contents/Resources/Java/"; + properties.load(new FileInputStream(pkg + "pde.properties")); + properties.load(new FileInputStream(pkg + "pde.properties_macosx")); + + } else if (PdeBase.platform == PdeBase.MACOS9) { + properties.load(new FileInputStream("lib/pde.properties")); + properties.load(new FileInputStream("lib/pde.properties_macos9")); + + } else { + // under win95, current dir not set properly + // so using a relative url like "lib/" won't work + properties.load(getClass().getResource("pde.properties").openStream()); + String platformProps = "pde.properties_" + platforms[platform]; + properties.load(getClass().getResource(platformProps).openStream()); + } //properties.list(System.out); } catch (Exception e) { @@ -615,7 +633,16 @@ public class PdeBase implements ActionListener { //image = applet.getImage(applet.getCodeBase(), name); //} else { Toolkit tk = Toolkit.getDefaultToolkit(); - image = tk.getImage(who.getClass().getResource(name)); + + if (PdeBase.platform == PdeBase.MACOSX) { + String pkg = "Proce55ing.app/Contents/Resources/Java/"; + image = tk.getImage(pkg + name); + } else if (PdeBase.platform == PdeBase.MACOS9) { + image = tk.getImage("lib/" + name); + } else { + image = tk.getImage(who.getClass().getResource(name)); + } + //image = tk.getImage("lib/" + name); //URL url = PdeApplet.class.getResource(name); //image = tk.getImage(url); diff --git a/app/PdeEditor.java b/app/PdeEditor.java index a2267724b..ed6089651 100644 --- a/app/PdeEditor.java +++ b/app/PdeEditor.java @@ -137,7 +137,16 @@ public class PdeEditor extends Panel { Properties skprops = new Properties(); try { - skprops.load(getClass().getResource("sketch.properties").openStream()); + if (PdeBase.platform == PdeBase.MACOSX) { + String pkg = "Proce55ing.app/Contents/Resources/Java/"; + skprops.load(new FileInputStream(pkg + "sketch.properties")); + + } else if (PdeBase.platform == PdeBase.MACOS9) { + skprops.load(new FileInputStream("lib/pde.properties")); + + } else { + skprops.load(getClass().getResource("sketch.properties").openStream()); + } int windowX = Integer.parseInt(skprops.getProperty("window.x", "-1")); int windowY = Integer.parseInt(skprops.getProperty("window.y", "-1")); @@ -343,6 +352,11 @@ public class PdeEditor extends Panel { //if (program.length() != 0) { String buildPath = "lib" + File.separator + "build"; // TEMPORARY + if (PdeBase.platform == PdeBase.MACOSX) { + String pkg = "Proce55ing.app/Contents/Resources/Java/"; + buildPath = pkg + "build"; + } + File buildDir = new File(buildPath); if (!buildDir.exists()) buildDir.mkdirs(); @@ -1229,18 +1243,22 @@ public class PdeEditor extends Panel { // write sketch.properties try { - URL url = getClass().getResource("buttons.gif"); - //String urlstr = url.toString(); - //System.out.println(url.getFile()); - //urlstr = urlstr.substring(6, urlstr.lastIndexOf("/") + 1) + - //"sketch.properties"; - String urlstr = url.getFile(); - urlstr = urlstr.substring(0, urlstr.lastIndexOf("/") + 1) + - "sketch.properties"; + FileOutputStream output = null; - //System.out.println(urlstr); - //System.exit(0); - FileOutputStream output = new FileOutputStream(urlstr); + if (PdeBase.platform == PdeBase.MACOSX) { + String pkg = "Proce55ing.app/Contents/Resources/Java/"; + output = new FileOutputStream(pkg + "sketch.properties"); + + } else if (PdeBase.platform == PdeBase.MACOS9) { + output = new FileOutputStream("lib/pde.properties"); + + } else { // win95/98/ME doesn't set cwd properly + URL url = getClass().getResource("buttons.gif"); + String urlstr = url.getFile(); + urlstr = urlstr.substring(0, urlstr.lastIndexOf("/") + 1) + + "sketch.properties"; + output = new FileOutputStream(urlstr); + } //url = new URL(urlstr + "sketch.properties"); diff --git a/build/macosx/dist.sh b/build/macosx/dist.sh index a2849e235..4f8356ae8 100755 --- a/build/macosx/dist.sh +++ b/build/macosx/dist.sh @@ -1,6 +1,8 @@ #!/bin/sh -REVISION=`head -c 4 ../../../todo.txt` +#REVISION=`head -c 4 ../../../todo.txt` +# 'head' for osx doesn't support -c.. what a pisser +REVISION=0000 ./make.sh @@ -11,34 +13,44 @@ rm -rf processing rm -f processing-*.hqx # use 'shared' files as starting point -cp -r ../shared processing -# something like the following might be better: -# find / -name "*.mp3" -exec rm -f {}\; -# and same for cvsignore +cp -r ../shared/fonts processing/ +cp -r ../shared/reference processing/ +cp -r ../shared/sketchbook processing/ + rm -rf processing/CVS -rm -rf processing/lib/CVS +#rm -rf processing/lib/CVS rm -rf processing/fonts/CVS rm -rf processing/reference/CVS rm -rf processing/reference/images/CVS rm -rf processing/sketchbook/CVS rm -rf processing/sketchbook/default/CVS rm -f processing/sketchbook/default/.cvsignore -# will need to add a zillion of these for the reference.. -# add java (jre) files -#unzip -q -d processing jre.zip +# get package from the dist dir +cp -r dist/Proce55ing.app processing/ +rm -rf processing/Proce55ing.app/CVS +rm -rf processing/Proce55ing.app/Contents/CVS +rm -rf processing/Proce55ing.app/Contents/MacOS/CVS +rm -rf processing/Proce55ing.app/Contents/Resources/CVS +rm -rf processing/Proce55ing.app/Contents/Resources/Java/CVS + +RES=processing/Proce55ing.app/Contents/Resources/Java/ +cp ../shared/dist/lib/*.jar $RES/ +cp ../shared/dist/lib/pde.properties $RES/ +cp ../shared/dist/lib/buttons.gif $RES/ +cp comm.jar $RES/ # directories used by the app -mkdir processing/lib/build +#mkdir processing/lib/build # grab pde.jar and export from the working dir -cp work/lib/pde.jar processing/lib/ -cp -r work/lib/export processing/lib/ -rm -rf processing/lib/export/CVS +cp work/lib/pde.jar $RES/ +cp -r work/lib/export $RES/ +rm -rf $RES/export/CVS # get platform-specific goodies from the dist dir -cp dist/Proce55ing processing/ -cp dist/lib/pde.properties_macosx processing/lib/ +#cp dist/Proce55ing processing/ +#cp dist/lib/pde.properties_macosx processing/lib/ # convert notes.txt to windows LFs # the 2> is because the app is a little chatty @@ -53,5 +65,6 @@ mv processing $P5-macosx #zip -rq $P5.zip $P5 # nah, keep the new directory around #rm -rf $P5 +# if there is a command line tool to make a dmg from this dir.. hmm echo Done. \ No newline at end of file diff --git a/build/macosx/dist/Proce55ing b/build/macosx/dist/Proce55ing.sh similarity index 100% rename from build/macosx/dist/Proce55ing rename to build/macosx/dist/Proce55ing.sh