Commit f6ae5106 authored by hal's avatar hal

Merge pull request #46 from afmckinney/windows_build

Added changes to enable the building of app-inventor in windows
parents d0dba97b 45816d1d
...@@ -422,6 +422,9 @@ public class YABlockCompiler { ...@@ -422,6 +422,9 @@ public class YABlockCompiler {
*/ */
public static String packageNameFromPath(String path) { public static String packageNameFromPath(String path) {
path = path.replaceFirst(".*?/?src/", ""); path = path.replaceFirst(".*?/?src/", "");
if (System.getProperty("os.name").startsWith("Windows")){
path = path.replace("/","\\").replaceFirst(".*?/?src/", "");
}
int extensionIndex = path.lastIndexOf("."); int extensionIndex = path.lastIndexOf(".");
if (extensionIndex != -1) { if (extensionIndex != -1) {
return path.substring(0, extensionIndex).replaceAll("/", "."); return path.substring(0, extensionIndex).replaceAll("/", ".");
......
...@@ -72,6 +72,8 @@ public final class Compiler { ...@@ -72,6 +72,8 @@ public final class Compiler {
RUNTIME_FILES_DIR + "android.jar"; RUNTIME_FILES_DIR + "android.jar";
private static final String MAC_AAPT_TOOL = private static final String MAC_AAPT_TOOL =
"/tools/mac/aapt"; "/tools/mac/aapt";
private static final String WINDOWS_AAPT_TOOL =
"/tools/windows/aapt";
private static final String LINUX_AAPT_TOOL = private static final String LINUX_AAPT_TOOL =
"/tools/linux/aapt"; "/tools/linux/aapt";
private static final String KAWA_RUNTIME = private static final String KAWA_RUNTIME =
...@@ -415,6 +417,10 @@ public final class Compiler { ...@@ -415,6 +417,10 @@ public final class Compiler {
String sourceFileRelativePath = sourceFileName.substring(srcIndex + 8); String sourceFileRelativePath = sourceFileName.substring(srcIndex + 8);
String classFileName = (classesDir.getAbsolutePath() + "/" + sourceFileRelativePath) String classFileName = (classesDir.getAbsolutePath() + "/" + sourceFileRelativePath)
.replace(YoungAndroidConstants.YAIL_EXTENSION, ".class"); .replace(YoungAndroidConstants.YAIL_EXTENSION, ".class");
if (System.getProperty("os.name").startsWith("Windows")){
classFileName = classesDir.getAbsolutePath()
.replace(YoungAndroidConstants.YAIL_EXTENSION, ".class");
}
// Check whether user code exists by seeing if a left parenthesis exists at the beginning of // Check whether user code exists by seeing if a left parenthesis exists at the beginning of
// a line in the file // a line in the file
...@@ -516,6 +522,10 @@ public final class Compiler { ...@@ -516,6 +522,10 @@ public final class Compiler {
// This works when a JDK is installed with the JRE. // This works when a JDK is installed with the JRE.
jarsignerFile = new File(javaHome + File.separator + ".." + File.separator + "bin" + jarsignerFile = new File(javaHome + File.separator + ".." + File.separator + "bin" +
File.separator + "jarsigner"); File.separator + "jarsigner");
if (System.getProperty("os.name").startsWith("Windows")){
jarsignerFile = new File(javaHome + File.separator + ".." + File.separator + "bin" +
File.separator + "jarsigner.exe");
}
if (!jarsignerFile.exists()) { if (!jarsignerFile.exists()) {
LOG.warning("YAIL compiler - could not find jarsigner."); LOG.warning("YAIL compiler - could not find jarsigner.");
err.println("YAIL compiler - could not find jarsigner."); err.println("YAIL compiler - could not find jarsigner.");
...@@ -622,6 +632,8 @@ public final class Compiler { ...@@ -622,6 +632,8 @@ public final class Compiler {
aaptTool = MAC_AAPT_TOOL; aaptTool = MAC_AAPT_TOOL;
} else if (osName.equals("Linux")) { } else if (osName.equals("Linux")) {
aaptTool = LINUX_AAPT_TOOL; aaptTool = LINUX_AAPT_TOOL;
} else if (osName.startsWith("Windows")) {
aaptTool = WINDOWS_AAPT_TOOL;
} else { } else {
LOG.warning("YAIL compiler - cannot run AAPT on OS " + osName); LOG.warning("YAIL compiler - cannot run AAPT on OS " + osName);
err.println("YAIL compiler - cannot run AAPT on OS " + osName); err.println("YAIL compiler - cannot run AAPT on OS " + osName);
......
...@@ -98,7 +98,11 @@ public final class Execution { ...@@ -98,7 +98,11 @@ public final class Execution {
public static boolean execute(File workingDir, String[] command, PrintStream out, public static boolean execute(File workingDir, String[] command, PrintStream out,
PrintStream err) { PrintStream err) {
LOG.log(Level.INFO, "____Executing " + joiner.join(command)); LOG.log(Level.INFO, "____Executing " + joiner.join(command));
if (System.getProperty("os.name").startsWith("Windows")){
for(int i =0; i < command.length; i++){
command[i] = command[i].replace("\"", "\\\"");
}
}
try { try {
Process process = Runtime.getRuntime().exec(command, null, workingDir); Process process = Runtime.getRuntime().exec(command, null, workingDir);
new RedirectStreamHandler(new PrintWriter(out, true), process.getInputStream()); new RedirectStreamHandler(new PrintWriter(out, true), process.getInputStream());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment