-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge: master to jdk12 branch (#428)
* * simlauncher stopped working with ios13. switching to apple's simctl instead. (#402) * * xcode11 fix. swift libraries not in /swift/ directory anymore but in swift-5.0. it is not a perfect fix but dirty workaround but it allows to use swift based frameworks with xcode11 (#405) * Ios13 switch to simctl -- starting simulator (#410) * * simlauncher stopped working with ios13. switching to apple's simctl instead. * * added 'open Simulator' as simctl boot doesn't show the simulator and it has to be opened either using spotlight or open cmd * #414 fix (libimobiledevice affected) (#416) * updated to recent master of libimobiledevice which should fix the issue: - removed libxml as it not required anymore by libplist v2.0.0 - libusbmuxd is picked from master, as version 1.1.0 is not available in releases - added openssl as dependency as it is not part of MacOSX anymore (probably LibreSSL might be used) * * fixed libmobiledevice to allow bypass ssl termination when required * * libimobiledevice: bindings re-generated to recent version with ssl passthrough and debug server * * libimobiledevice: added handling of introduced time-out * * libimobiledevice: added patch to provide timeout error through debugserver client * * libimobiledevice: added patch to provide timeout error through debugserver client * * libimobiledevice: removed unused debugserver api, fixed unix permissions for all other files * * libimobiledevice: switched to use DebugServerClient to interact with GDB server, cleaned up some if lint warnings in AppLauncher and fixed to dev image lookup to allow using older one available (for example to use 13.0 with 13.1 device) * * libimobiledevice: reverted back companion to byte[] parameter `count` argument. As usually byte array buffer contains less useful bytes than its length (this broke upload of app) * update libimobiledevice lib * * fixed broken reg-exp for version matching (development image lookup), added testcases for new code (#427) * * fixed #408 by adding @MarshalsValue to toNative methods. Otherwise compiler was not able to resolve to native marshaller for enum and went to parent class where it picked up default marshaller from ValuedEnum. This results in type difference in case type of enum data is not int and caused following exception: (#409) > java.lang.IllegalArgumentException: Duplicate @StructMember(1) in @PACKED structs (union in packed structs is not supported * Add bool declarations for non Darwin systems (#425)
- Loading branch information
Showing
84 changed files
with
2,738 additions
and
833 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
194 changes: 194 additions & 0 deletions
194
compiler/compiler/src/main/java/org/robovm/compiler/target/ios/SimLauncherProcess.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
/* | ||
* Copyright (C) 2013 RoboVM AB | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl-2.0.html>. | ||
*/ | ||
package org.robovm.compiler.target.ios; | ||
|
||
import org.apache.commons.exec.ExecuteException; | ||
import org.apache.commons.io.output.NullOutputStream; | ||
import org.robovm.compiler.log.ErrorOutputStream; | ||
import org.robovm.compiler.log.Logger; | ||
import org.robovm.compiler.target.Launcher; | ||
import org.robovm.compiler.util.Executor; | ||
import org.robovm.compiler.util.io.OpenOnWriteFileOutputStream; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InterruptedIOException; | ||
import java.io.OutputStream; | ||
import java.io.PrintStream; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
/** | ||
* {@link Process} implementation which runs an app on a simulator using an | ||
* simctl | ||
*/ | ||
public class SimLauncherProcess extends Process implements Launcher { | ||
private final CountDownLatch countDownLatch = new CountDownLatch(1); | ||
private final AtomicInteger threadCounter = new AtomicInteger(); | ||
private final Logger log; | ||
private final DeviceType deviceType; | ||
private final File wd; | ||
private final String bundleId; | ||
private final File appDir; | ||
private final List<String> arguments; | ||
private HashMap<String, String> env; | ||
private Thread launcherThread; | ||
private volatile boolean finished = false; | ||
private volatile int exitCode = -1; | ||
private OutputStream errStream; | ||
private OutputStream outStream; | ||
|
||
public SimLauncherProcess(Logger log, File appDir, String bundleId, IOSSimulatorLaunchParameters launchParameters) { | ||
this.log = log; | ||
deviceType = launchParameters.getDeviceType(); | ||
wd = launchParameters.getWorkingDirectory(); | ||
this.appDir = appDir; | ||
this.bundleId = bundleId; | ||
this.arguments = new ArrayList<>(launchParameters.getArguments()); | ||
if (launchParameters.getEnvironment() != null) { | ||
this.env = new HashMap<>(); | ||
for (Map.Entry<String, String> entry : launchParameters.getEnvironment().entrySet()) { | ||
env.put("SIMCTL_CHILD_" + entry.getKey(), entry.getValue()); | ||
} | ||
} | ||
|
||
outStream = System.out; | ||
errStream = System.err; | ||
if (launchParameters.getStdoutFifo() != null) { | ||
outStream = new OpenOnWriteFileOutputStream(launchParameters.getStdoutFifo()); | ||
} | ||
if (launchParameters.getStderrFifo() != null) { | ||
errStream = new OpenOnWriteFileOutputStream(launchParameters.getStderrFifo()); | ||
} | ||
} | ||
|
||
@Override | ||
public Process execAsync() throws IOException { | ||
this.launcherThread = new Thread("SimLauncherThread-" + threadCounter.getAndIncrement()) { | ||
@Override | ||
public void run() { | ||
try { | ||
Executor executor; | ||
|
||
if ("shutdown".equals(deviceType.getState(true).toLowerCase())) { | ||
log.info("Booting simulator %s", deviceType.getUdid()); | ||
executor = new Executor(log, "xcrun"); | ||
executor.args("simctl", "boot", deviceType.getUdid()); | ||
executor.exec(); | ||
} | ||
|
||
// bringing simulator to front (and showing it if it was just booted) | ||
log.info("Showing simulator %s", deviceType.getUdid()); | ||
executor = new Executor(log, "open"); | ||
executor.args("-a", "Simulator", "--args", "-CurrentDeviceUDID", deviceType.getUdid()); | ||
executor.exec(); | ||
|
||
log.info("Deploying app %s to simulator %s", appDir.getAbsolutePath(), | ||
deviceType.getUdid()); | ||
executor = new Executor(log, "xcrun"); | ||
executor.args("simctl", "install", deviceType.getUdid(), appDir.getAbsolutePath()); | ||
executor.exec(); | ||
|
||
log.info("Launching app %s on simulator %s", appDir.getAbsolutePath(), | ||
deviceType.getUdid()); | ||
executor = new Executor(log, "xcrun"); | ||
List<Object> args = new ArrayList<>(); | ||
args.add("simctl"); | ||
args.add("launch"); | ||
args.add("--console"); | ||
args.add(deviceType.getUdid()); | ||
args.add(bundleId); | ||
args.addAll(arguments); | ||
executor.args(args); | ||
|
||
if (env != null) { | ||
executor.env(env); | ||
} | ||
|
||
executor.wd(wd).out(outStream).err(errStream).closeOutputStreams(true).inheritEnv(false); | ||
executor.exec(); | ||
exitCode = 0; | ||
} catch (ExecuteException e) { | ||
exitCode = e.getExitValue(); | ||
} catch (Throwable t) { | ||
log.error("AppLauncher failed with an exception:", t.getMessage()); | ||
t.printStackTrace(new PrintStream(new ErrorOutputStream(log), true)); | ||
} finally { | ||
finished = true; | ||
countDownLatch.countDown(); | ||
} | ||
} | ||
}; | ||
this.launcherThread.start(); | ||
return this; | ||
} | ||
|
||
@Override | ||
public OutputStream getOutputStream() { | ||
return new NullOutputStream(); | ||
} | ||
|
||
@Override | ||
public InputStream getInputStream() { | ||
return waitInputStream; | ||
} | ||
|
||
@Override | ||
public InputStream getErrorStream() { | ||
return waitInputStream; | ||
} | ||
|
||
@Override | ||
public int waitFor() throws InterruptedException { | ||
countDownLatch.await(); | ||
return exitCode; | ||
} | ||
|
||
@Override | ||
public int exitValue() { | ||
if (!finished) { | ||
throw new IllegalThreadStateException("Not terminated"); | ||
} | ||
return exitCode; | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
try { | ||
this.launcherThread.interrupt(); | ||
this.launcherThread.join(); | ||
} catch (InterruptedException ignored) { | ||
} | ||
} | ||
|
||
final InputStream waitInputStream = new InputStream() { | ||
@Override | ||
public int read() throws IOException { | ||
try { | ||
countDownLatch.await(); | ||
} catch (InterruptedException e) { | ||
throw new InterruptedIOException(); | ||
} | ||
return -1; | ||
} | ||
}; | ||
} |
Oops, something went wrong.