diff --git a/haxetool/android.js b/haxetool/android.js
index f65d63a..8c3f3fa 100644
--- a/haxetool/android.js
+++ b/haxetool/android.js
@@ -1,7 +1,7 @@
const fs = require('fs');
const path = require('path');
const exec = require('./exec');
-const run = require('../run/index');
+const {StringWritable} = require('./tail');
const Command = require('../run/command');
const through = require('through2');
@@ -125,10 +125,35 @@ class Android extends Sdk {
});
}
+ _installApk(filename, pack) {
+ this.log.i('install *%s*', filename);
+ return this.adb(['install', '-r', '-d', filename])
+ .then(() => {
+ return false;
+ })
+ .catch(error => {
+ if (error.includes('INSTALL_FAILED_UPDATE_INCOMPATIBLE')) {
+ this.log.w('!INSTALL FAILED UPDATE INCOMPATIBLE!');
+ return true;
+ } else {
+ throw error;
+ }
+ })
+ .then(reinstall => {
+ if (reinstall) {
+ this.log.i('uninstall *%s*', pack);
+ return this.adb(['uninstall', pack]).then(() => {
+ this.log.i('install *%s*', filename);
+ return this.adb(['install', '-r', '-d', filename]);
+ });
+ }
+ });
+ }
+
install() {
const self = this;
return through.obj(function(file, enc, callback) {
- self.adb(['install', '-r', file.path]).then(() => {
+ self._installApk(file.path, file.package).then(() => {
this.push(file);
callback();
});
@@ -139,6 +164,7 @@ class Android extends Sdk {
const self = this;
return through.obj(function(file, enc, callback) {
const name = `${file.package}/${file.activity}`;
+ self.log.i('start *%s*', name);
self.adb(['shell', 'am', 'start', '-n', name]).then(() => {
setTimeout(() => {
self.adb(['shell', `"ps | grep ${file.package}"`]).then(result => {
@@ -155,7 +181,14 @@ class Android extends Sdk {
const self = this;
return through.obj(function(file, enc, callback) {
const cmd = `${self.adbBin} logcat --pid ${file.pid}`;
- this.push(new Command(cmd).exec());
+ const command = new Command(cmd).exec();
+ this.push(command);
+ command.contents.pipe(new StringWritable(line => {
+ if (line.includes('SDL') && (line.includes('onDestroy()') || line.includes('onStop()'))) {
+ callback();
+ throw 'Exit'; // ToDo:
+ }
+ }));
});
}
}
diff --git a/haxetool/core.js b/haxetool/core.js
index 5c25ae1..765f443 100644
--- a/haxetool/core.js
+++ b/haxetool/core.js
@@ -42,10 +42,13 @@ class Config {
company: null,
width: 800,
height: 600,
+ mobileWidth: null,
+ mobileHeight: null,
fps: 60,
};
if (params) {
this.update(params);
+ this.afterUpdate();
}
}
@@ -68,12 +71,18 @@ class Config {
if (this.meta.icon) this.icon = Config.absolutePath(this.meta.icon);
}
+ afterUpdate() {
+ if (this.meta.mobileWidth === null) this.meta.mobileWidth = this.meta.width;
+ if (this.meta.mobileHeight === null) this.meta.mobileHeight = Math.round(this.meta.mobileWidth / 1.777777778);
+ }
+
branch(params) {
const result = new Config();
for (const params of this._params) {
result.update(params);
}
result.update(params);
+ result.afterUpdate();
return result;
}
}
diff --git a/haxetool/project.js b/haxetool/project.js
index 587b260..e031e38 100644
--- a/haxetool/project.js
+++ b/haxetool/project.js
@@ -377,8 +377,7 @@ class AndroidRunner extends Runner {
call() {
const target = this.targetPath;
- const filename = path.resolve(target, this.config.meta.filename+'-debug.apk');
- return this.log(gulp.src(filename)
+ return this.log(gulp.src(`${target}/${this.config.meta.filename}_*.apk`)
.pipe(this.android.apk())
.pipe(this.android.install())
.pipe(this.android.start())
diff --git a/haxetool/tail.js b/haxetool/tail.js
index c048a18..5682053 100644
--- a/haxetool/tail.js
+++ b/haxetool/tail.js
@@ -67,3 +67,4 @@ module.exports = (handler) => {
};
module.exports.TailVinyl = TailVinyl;
+module.exports.StringWritable = StringWritable;
diff --git a/package.json b/package.json
index 624ba11..65d8263 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "gulp-haxetool",
- "version": "0.0.23",
+ "version": "0.0.24",
"description": "HaXe Tool for Gulp",
"main": "index.js",
"dependencies": {
diff --git a/template/project.xml b/template/project.xml
index 0c2a2f8..b1687d0 100644
--- a/template/project.xml
+++ b/template/project.xml
@@ -17,7 +17,8 @@
-
+