Search in sources :

Example 1 with Executor

use of org.robovm.compiler.util.Executor in project robovm by robovm.

the class IOSTarget method createIOSSimLauncher.

private Launcher createIOSSimLauncher(LaunchParameters launchParameters) throws IOException {
    File dir = getAppDir();
    String iosSimPath = new File(config.getHome().getBinDir(), "ios-sim").getAbsolutePath();
    List<Object> args = new ArrayList<Object>();
    args.add("launch");
    args.add(dir);
    args.add("--timeout");
    args.add("90");
    args.add("--unbuffered");
    if (((IOSSimulatorLaunchParameters) launchParameters).getDeviceType() != null) {
        DeviceType deviceType = ((IOSSimulatorLaunchParameters) launchParameters).getDeviceType();
        args.add("--devicetypeid");
        args.add(deviceType.getDeviceTypeId());
    }
    if (launchParameters.getStdoutFifo() != null) {
        args.add("--stdout");
        args.add(launchParameters.getStdoutFifo());
    }
    if (launchParameters.getStderrFifo() != null) {
        args.add("--stderr");
        args.add(launchParameters.getStderrFifo());
    }
    if (launchParameters.getEnvironment() != null) {
        for (Entry<String, String> entry : launchParameters.getEnvironment().entrySet()) {
            args.add("--setenv");
            args.add(entry.getKey() + "=" + entry.getValue());
        }
    }
    if (!launchParameters.getArguments().isEmpty()) {
        args.add("--args");
        args.addAll(launchParameters.getArguments());
    }
    File xcodePath = new File(ToolchainUtil.findXcodePath());
    Map<String, String> env = Collections.singletonMap("DEVELOPER_DIR", xcodePath.getAbsolutePath());
    // See issue https://github.com/robovm/robovm/issues/1150, we need
    // to swallow the error message by ios-sim on Xcode 7. We need
    // to remove this
    Logger proxyLogger = new Logger() {

        boolean skipWarningsAndErrors = false;

        @Override
        public void debug(String format, Object... args) {
            config.getLogger().debug(format, args);
        }

        @Override
        public void info(String format, Object... args) {
            config.getLogger().info(format, args);
        }

        @Override
        public void warn(String format, Object... args) {
            // we get another warning.
            if (format.toString().contains("DVTPlugInManager.m:257")) {
                config.getLogger().info(format, args);
                return;
            }
            // logging of warnings and errors again
            if (skipWarningsAndErrors) {
                skipWarningsAndErrors = false;
                config.getLogger().info(format, args);
            } else {
                config.getLogger().warn(format, args);
            }
        }

        @Override
        public void error(String format, Object... args) {
            if (format.contains("Requested but did not find extension point with identifier Xcode.DVTFoundation.DevicePlatformMapping")) {
                skipWarningsAndErrors = true;
            }
            if (skipWarningsAndErrors) {
                config.getLogger().info(format, args);
            } else {
                config.getLogger().error(format, args);
            }
        }
    };
    return new Executor(proxyLogger, iosSimPath).args(args).wd(launchParameters.getWorkingDirectory()).inheritEnv(false).env(env);
}
Also used : Executor(org.robovm.compiler.util.Executor) ArrayList(java.util.ArrayList) NSObject(com.dd.plist.NSObject) NSString(com.dd.plist.NSString) Logger(org.robovm.compiler.log.Logger) File(java.io.File)

Example 2 with Executor

use of org.robovm.compiler.util.Executor in project robovm by robovm.

the class IOSTarget method ldid.

private void ldid(File entitlementsPList, File appDir) throws IOException {
    File executableFile = new File(appDir, getExecutable());
    config.getLogger().info("Pseudo-signing %s", executableFile.getAbsolutePath());
    List<Object> args = new ArrayList<Object>();
    if (entitlementsPList != null) {
        args.add("-S" + entitlementsPList.getAbsolutePath());
    } else {
        args.add("-S");
    }
    args.add(executableFile);
    new Executor(config.getLogger(), new File(config.getHome().getBinDir(), "ldid")).args(args).exec();
}
Also used : Executor(org.robovm.compiler.util.Executor) ArrayList(java.util.ArrayList) NSObject(com.dd.plist.NSObject) File(java.io.File)

Example 3 with Executor

use of org.robovm.compiler.util.Executor in project robovm by robovm.

the class IOSTarget method codesign.

private void codesign(SigningIdentity identity, File entitlementsPList, boolean preserveMetadata, boolean verbose, boolean allocate, File target) throws IOException {
    List<Object> args = new ArrayList<Object>();
    args.add("-f");
    args.add("-s");
    args.add(identity.getFingerprint());
    if (entitlementsPList != null) {
        args.add("--entitlements");
        args.add(entitlementsPList);
    }
    if (preserveMetadata) {
        args.add("--preserve-metadata=identifier,entitlements,resource-rules");
    }
    if (verbose) {
        args.add("--verbose");
    }
    args.add(target);
    Executor executor = new Executor(config.getLogger(), "codesign");
    if (allocate) {
        executor.addEnv("CODESIGN_ALLOCATE", ToolchainUtil.findXcodeCommand("codesign_allocate", "iphoneos"));
    }
    executor.args(args);
    executor.exec();
}
Also used : Executor(org.robovm.compiler.util.Executor) ArrayList(java.util.ArrayList) NSObject(com.dd.plist.NSObject)

Example 4 with Executor

use of org.robovm.compiler.util.Executor in project robovm by robovm.

the class IOSTarget method packageApplication.

private void packageApplication(File appDir) throws IOException {
    File ipaFile = new File(config.getInstallDir(), getExecutable() + ".ipa");
    config.getLogger().info("Packaging IPA %s from %s", ipaFile.getName(), appDir.getName());
    File tmpDir = new File(config.getInstallDir(), "ipabuild");
    FileUtils.deleteDirectory(tmpDir);
    tmpDir.mkdirs();
    File payloadDir = new File(tmpDir, "Payload");
    payloadDir.mkdir();
    config.getLogger().info("Copying %s to %s", appDir.getName(), payloadDir);
    new Executor(config.getLogger(), "cp").args("-Rp", appDir, payloadDir).exec();
    File frameworksDir = new File(appDir, "Frameworks");
    if (frameworksDir.exists()) {
        String[] swiftLibs = frameworksDir.list(new AndFileFilter(new PrefixFileFilter("libswift"), new SuffixFileFilter(".dylib")));
        if (swiftLibs.length > 0) {
            File swiftSupportDir = new File(tmpDir, "SwiftSupport");
            swiftSupportDir.mkdir();
            copySwiftLibs(Arrays.asList(swiftLibs), swiftSupportDir);
        }
    }
    config.getLogger().info("Zipping %s to %s", tmpDir, ipaFile);
    new Executor(Logger.NULL_LOGGER, "zip").wd(tmpDir).args("--symlinks", "--recurse-paths", ipaFile, ".").exec();
    config.getLogger().info("Deleting temp dir %s", tmpDir);
    FileUtils.deleteDirectory(tmpDir);
}
Also used : Executor(org.robovm.compiler.util.Executor) AndFileFilter(org.apache.commons.io.filefilter.AndFileFilter) SuffixFileFilter(org.apache.commons.io.filefilter.SuffixFileFilter) NSString(com.dd.plist.NSString) File(java.io.File) PrefixFileFilter(org.apache.commons.io.filefilter.PrefixFileFilter)

Example 5 with Executor

use of org.robovm.compiler.util.Executor in project robovm by robovm.

the class IOSTarget method doLaunch.

@Override
protected Process doLaunch(LaunchParameters launchParameters) throws IOException {
    prepareLaunch(getAppDir());
    Process process = super.doLaunch(launchParameters);
    if (launchParameters instanceof IOSSimulatorLaunchParameters) {
        File script = File.createTempFile("BISTF", ".scpt");
        FileUtils.copyURLToFile(getClass().getResource("/BringIOSSimulatorToFront.scpt"), script);
        new Executor(config.getHome().isDev() ? config.getLogger() : Logger.NULL_LOGGER, "osascript").args(script).execAsync();
    }
    return process;
}
Also used : Executor(org.robovm.compiler.util.Executor) File(java.io.File)

Aggregations

Executor (org.robovm.compiler.util.Executor)7 File (java.io.File)6 NSObject (com.dd.plist.NSObject)5 NSString (com.dd.plist.NSString)3 ArrayList (java.util.ArrayList)3 Logger (org.robovm.compiler.log.Logger)2 NSDictionary (com.dd.plist.NSDictionary)1 NSNumber (com.dd.plist.NSNumber)1 FileStore (java.nio.file.FileStore)1 AndFileFilter (org.apache.commons.io.filefilter.AndFileFilter)1 PrefixFileFilter (org.apache.commons.io.filefilter.PrefixFileFilter)1 SuffixFileFilter (org.apache.commons.io.filefilter.SuffixFileFilter)1 LoggerProxy (org.robovm.compiler.log.LoggerProxy)1