| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2401,12 +2401,26 @@ static public File getContentFile(String name) { | |||
| 2401 | 2401 | } | |
| 2402 | 2402 | ||
| 2403 | 2403 | ||
| 2404 | - // static public File getJavaHome() { | ||
| 2405 | - // } | ||
| 2404 | + static public File getJavaHome() { | ||
| 2405 | + if (isMacOS()) { | ||
| 2406 | + //return "Contents/PlugIns/jdk1.7.0_40.jdk/Contents/Home/jre/bin/java"; | ||
| 2407 | + File[] plugins = getContentFile("../PlugIns").listFiles(new FilenameFilter() { | ||
| 2408 | + public boolean accept(File dir, String name) { | ||
| 2409 | + return name.endsWith(".jdk") && dir.isDirectory(); | ||
| 2410 | + } | ||
| 2411 | + }); | ||
| 2412 | + return new File(plugins[0], "Contents/Home/jre"); | ||
| 2413 | + } | ||
| 2414 | + // On all other platforms, it's the 'java' folder adjacent to Processing | ||
| 2415 | + return getContentFile("java"); | ||
| 2416 | + } | ||
| 2406 | 2417 | ||
| 2407 | 2418 | ||
| 2408 | 2419 | /** Get the path to the embedded Java executable. */ | |
| 2409 | 2420 | static public String getJavaPath() { | |
| 2421 | + String javaPath = "bin/java" + (isWindows() ? ".exe" : ""); | ||
| 2422 | + return new File(getJavaHome(), javaPath).getAbsolutePath(); | ||
| 2423 | + /* | ||
| 2410 | 2424 | if (isMacOS()) { | |
| 2411 | 2425 | //return "Contents/PlugIns/jdk1.7.0_40.jdk/Contents/Home/jre/bin/java"; | |
| 2412 | 2426 | File[] plugins = getContentFile("../PlugIns").listFiles(new FilenameFilter() { | |
@@ -2429,6 +2443,7 @@ public boolean accept(File dir, String name) { | |||
| 2429 | 2443 | System.err.println("No appropriate platform found. " + | |
| 2430 | 2444 | "Hoping that Java is in the path."); | |
| 2431 | 2445 | return Base.isWindows() ? "java.exe" : "java"; | |
| 2446 | + */ | ||
| 2432 | 2447 | } | |
| 2433 | 2448 | ||
| 2434 | 2449 | ||
@@ -2569,6 +2584,7 @@ static public void copyFile(File sourceFile, | |||
| 2569 | 2584 | to = null; | |
| 2570 | 2585 | ||
| 2571 | 2586 | targetFile.setLastModified(sourceFile.lastModified()); | |
| 2587 | + targetFile.setExecutable(sourceFile.canExecute()); | ||
| 2572 | 2588 | } | |
| 2573 | 2589 | ||
| 2574 | 2590 | ||
@@ -2639,6 +2655,28 @@ static public void copyDir(File sourceDir, | |||
| 2639 | 2655 | } | |
| 2640 | 2656 | } | |
| 2641 | 2657 | } | |
| 2658 | + | ||
| 2659 | + | ||
| 2660 | + static public void copyDirNative(File sourceDir, | ||
| 2661 | + File targetDir) throws IOException { | ||
| 2662 | + Process process = null; | ||
| 2663 | + if (Base.isMacOS() || Base.isLinux()) { | ||
| 2664 | + process = Runtime.getRuntime().exec(new String[] { | ||
| 2665 | + "cp", "-a", sourceDir.getAbsolutePath(), targetDir.getAbsolutePath() | ||
| 2666 | + }); | ||
| 2667 | + } else { | ||
| 2668 | + // TODO implement version that uses XCOPY here on Windows | ||
| 2669 | + throw new RuntimeException("Not yet implemented on Windows"); | ||
| 2670 | + } | ||
| 2671 | + try { | ||
| 2672 | + int result = process.waitFor(); | ||
| 2673 | + if (result != 0) { | ||
| 2674 | + throw new IOException("Error while copying (result " + result + ")"); | ||
| 2675 | + } | ||
| 2676 | + } catch (InterruptedException e) { | ||
| 2677 | + e.printStackTrace(); | ||
| 2678 | + } | ||
| 2679 | + } | ||
| 2642 | 2680 | ||
| 2643 | 2681 | ||
| 2644 | 2682 | /** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1162,11 +1162,42 @@ protected boolean exportApplication(File destFolder, | |||
| 1162 | 1162 | File dotAppFolder = null; | |
| 1163 | 1163 | if (exportPlatform == PConstants.MACOSX) { | |
| 1164 | 1164 | dotAppFolder = new File(destFolder, sketch.getName() + ".app"); | |
| 1165 | - // String APP_SKELETON = "skeleton.app"; | ||
| 1166 | - //File dotAppSkeleton = new File(folder, APP_SKELETON); | ||
| 1167 | - File dotAppSkeleton = mode.getContentFile("application/template.app"); | ||
| 1168 | - Base.copyDir(dotAppSkeleton, dotAppFolder); | ||
| 1169 | 1165 | ||
| 1166 | + File contentsOrig = new File(Base.getJavaHome(), "../../../../.."); | ||
| 1167 | + | ||
| 1168 | + // File dotAppSkeleton = mode.getContentFile("application/template.app"); | ||
| 1169 | + // Base.copyDir(dotAppSkeleton, dotAppFolder); | ||
| 1170 | + File contentsFolder = new File(dotAppFolder, "Contents"); | ||
| 1171 | + contentsFolder.mkdirs(); | ||
| 1172 | + | ||
| 1173 | + // Info.plist will be written later | ||
| 1174 | + | ||
| 1175 | + // set the jar folder to a different location than windows/linux | ||
| 1176 | + //jarFolder = new File(dotAppFolder, "Contents/Resources/Java"); | ||
| 1177 | + jarFolder = new File(contentsFolder, "Java"); | ||
| 1178 | + | ||
| 1179 | + File macosFolder = new File(contentsFolder, "MacOS"); | ||
| 1180 | + macosFolder.mkdirs(); | ||
| 1181 | + Base.copyFile(new File(contentsOrig, "MacOS/Processing"), | ||
| 1182 | + new File(contentsFolder, "MacOS/" + sketch.getName())); | ||
| 1183 | + | ||
| 1184 | + File pkgInfo = new File(contentsFolder, "PkgInfo"); | ||
| 1185 | + PrintWriter writer = PApplet.createWriter(pkgInfo); | ||
| 1186 | + writer.println("APPL????"); | ||
| 1187 | + writer.flush(); | ||
| 1188 | + writer.close(); | ||
| 1189 | + | ||
| 1190 | + // Use faster(?) native copy here (also to do sym links) | ||
| 1191 | + Base.copyDirNative(new File(contentsOrig, "PlugIns"), | ||
| 1192 | + new File(contentsFolder, "PlugIns")); | ||
| 1193 | + | ||
| 1194 | + File resourcesFolder = new File(contentsFolder, "Resources"); | ||
| 1195 | + Base.copyDir(new File(contentsOrig, "Resources/en.lproj"), | ||
| 1196 | + new File(resourcesFolder, "en.lproj")); | ||
| 1197 | + Base.copyFile(mode.getContentFile("application/sketch.icns"), | ||
| 1198 | + new File(resourcesFolder, "sketch.icns")); | ||
| 1199 | + | ||
| 1200 | + /* | ||
| 1170 | 1201 | String stubName = "Contents/MacOS/JavaApplicationStub"; | |
| 1171 | 1202 | // need to set the stub to executable | |
| 1172 | 1203 | // will work on osx or *nix, but just dies on windows, oh well.. | |
@@ -1189,13 +1220,11 @@ protected boolean exportApplication(File destFolder, | |||
| 1189 | 1220 | String stubPath = stubFile.getAbsolutePath(); | |
| 1190 | 1221 | Runtime.getRuntime().exec(new String[] { "chmod", "+x", stubPath }); | |
| 1191 | 1222 | } | |
| 1192 | - | ||
| 1193 | - // set the jar folder to a different location than windows/linux | ||
| 1194 | - jarFolder = new File(dotAppFolder, "Contents/Resources/Java"); | ||
| 1223 | + */ | ||
| 1195 | 1224 | } | |
| 1196 | 1225 | ||
| 1197 | 1226 | ||
| 1198 | - /// make the jar folder (windows and linux) | ||
| 1227 | + /// make the jar folder (all platforms) | ||
| 1199 | 1228 | ||
| 1200 | 1229 | if (!jarFolder.exists()) jarFolder.mkdirs(); | |
| 1201 | 1230 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -542,11 +542,11 @@ | |||
| 542 | 542 | <option value="-Xmx256M" /> | |
| 543 | 543 | --> | |
| 544 | 544 | ||
| 545 | - <option value="-Dapple.laf.useScreenMenuBar=true"/> | ||
| 546 | - <option value="-Dcom.apple.macos.use-file-dialog-packages=true"/> | ||
| 547 | - <option value="-Dcom.apple.macos.useScreenMenuBar=true"/> | ||
| 548 | - <option value="-Dcom.apple.mrj.application.apple.menu.about.name=${bundle.name}"/> | ||
| 549 | - <option value="-Dcom.apple.smallTabs=true"/> | ||
| 545 | + <option value="-Dapple.laf.useScreenMenuBar=true" /> | ||
| 546 | + <option value="-Dcom.apple.macos.use-file-dialog-packages=true" /> | ||
| 547 | + <option value="-Dcom.apple.macos.useScreenMenuBar=true" /> | ||
| 548 | + <option value="-Dcom.apple.mrj.application.apple.menu.about.name=${bundle.name}" /> | ||
| 549 | + <option value="-Dcom.apple.smallTabs=true" /> | ||
| 550 | 550 | ||
| 551 | 551 | <!-- | |
| 552 | 552 | the old options; most of these are probably no longer useful | |
| Back | FazBrowse Home | New Git URL |
0 commit comments