[android] added module
This commit is contained in:
@@ -5,11 +5,13 @@ const fs = require('fs');
|
||||
const fse = require('fs-extra');
|
||||
const Haxe = require('./haxe');
|
||||
const FlashPlayer = require('./flashplayer');
|
||||
const Android = require('./android');
|
||||
const Neko = require('./neko');
|
||||
const debug = require('./debug');
|
||||
const webserver = require('gulp-webserver');
|
||||
const run = require('../run/index');
|
||||
const tail = require('./tail');
|
||||
const exec = require('./exec');
|
||||
const deb = require('gulp-debian');
|
||||
const {BuildSystem, Platform, Config} = require('./core');
|
||||
const vfs = require('vinyl-fs');
|
||||
@@ -36,6 +38,14 @@ class Target {
|
||||
this.target = 'target';
|
||||
}
|
||||
|
||||
prepare() {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
call() {
|
||||
throw 'Not Implemented';
|
||||
}
|
||||
|
||||
get targetPath() {
|
||||
return path.resolve(this.target, this.config.name, this.platform);
|
||||
}
|
||||
@@ -52,14 +62,6 @@ class Builder extends Target {
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
prepare() {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
call() {
|
||||
throw 'Not Implemented';
|
||||
}
|
||||
|
||||
static register(buildSystem, builder) {
|
||||
Builder.factory[buildSystem] = builder;
|
||||
}
|
||||
@@ -79,15 +81,26 @@ class HaxeBuilder extends Builder {
|
||||
constructor(config, platform, buildSystem, debug) {
|
||||
super(config, platform, buildSystem, debug);
|
||||
this.haxe = new Haxe();
|
||||
this.android = new Android();
|
||||
}
|
||||
|
||||
prepare() {
|
||||
let result = this.haxe.prepare().then(() => this.haxe.install(this.config.libs));
|
||||
/*if (this.buildSystem === BuildSystem.OPENFL) {
|
||||
if (this.buildSystem === BuildSystem.OPENFL) {
|
||||
if (this.platform === Platform.ANDROID) {
|
||||
result = result.then(() => this.android.prepare()).then(() => this.android.activate());
|
||||
}
|
||||
result = result.then(() => {
|
||||
return this.haxe.haxelib(['run', 'openfl', 'setup', this.platform]);
|
||||
return exec('.', [
|
||||
'echo',
|
||||
`"${this.android.path}"`,
|
||||
`"${this.android.path + '/ndk-bundle'}"`,
|
||||
'|',
|
||||
this.haxe.haxelibBin, 'run', 'openfl', 'setup', this.platform,
|
||||
].join(' '));
|
||||
//return this.haxe.haxelib(['echo'].concat(answers.map(item => `"${item}"`)).concat(['|', 'run', 'openfl', 'setup', this.platform]));
|
||||
});
|
||||
}*/
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -112,20 +125,17 @@ Builder.register(BuildSystem.OPENFL, HaxeBuilder);
|
||||
*/
|
||||
class Packer extends Target {
|
||||
|
||||
prepare() {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
call() {
|
||||
throw 'Not Implemented';
|
||||
}
|
||||
|
||||
static register(platform, packer) {
|
||||
Packer.factory[platform] = packer;
|
||||
static register(platform, name, packer) {
|
||||
if (!Packer.factory[platform]) Packer.factory[platform] = {};
|
||||
Packer.factory[platform][name] = packer;
|
||||
}
|
||||
|
||||
static new(config, platform) {
|
||||
return new Packer.factory[platform](config);
|
||||
static new(config, platform, name) {
|
||||
return new Packer.factory[platform][name](config);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +144,7 @@ Packer.factory = {};
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class FlashPacker extends Packer {
|
||||
class FlashHTMLPacker extends Packer {
|
||||
|
||||
constructor(config) {
|
||||
super(config, Platform.FLASH);
|
||||
@@ -150,12 +160,14 @@ class FlashPacker extends Packer {
|
||||
}
|
||||
}
|
||||
|
||||
Packer.register(Platform.FLASH, FlashPacker);
|
||||
FlashHTMLPacker.NAME = 'html';
|
||||
|
||||
Packer.register(Platform.FLASH, FlashHTMLPacker.NAME, FlashHTMLPacker);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class LinuxPacker extends Packer {
|
||||
class LinuxDEBPacker extends Packer {
|
||||
|
||||
constructor(config) {
|
||||
super(config, Platform.LINUX);
|
||||
@@ -192,7 +204,9 @@ class LinuxPacker extends Packer {
|
||||
}
|
||||
}
|
||||
|
||||
Packer.register(Platform.LINUX, LinuxPacker);
|
||||
LinuxDEBPacker.NAME = 'deb';
|
||||
|
||||
Packer.register(Platform.LINUX, LinuxDEBPacker.NAME, LinuxDEBPacker);
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -204,14 +218,6 @@ class Runner extends Target {
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
prepare() {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
call() {
|
||||
throw 'Not Implemented';
|
||||
}
|
||||
|
||||
log(stream) {
|
||||
return stream
|
||||
.pipe(tail(debug.log))
|
||||
@@ -319,6 +325,33 @@ class NekoRunner extends Runner {
|
||||
|
||||
Runner.register(Platform.NEKO, NekoRunner);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class AndroidRunner extends Runner {
|
||||
|
||||
constructor(config, debug) {
|
||||
super(config, Platform.ANDROID, debug);
|
||||
this.android = new Android();
|
||||
}
|
||||
|
||||
prepare() {
|
||||
return this.android.prepare();
|
||||
}
|
||||
|
||||
call() {
|
||||
const target = this.targetPath;
|
||||
const filename = path.resolve(target, this.config.meta.filename+'-debug.apk');
|
||||
console.log(filename);
|
||||
return gulp.src(filename)
|
||||
.pipe(this.android.apk())
|
||||
.pipe(this.android.install())
|
||||
.pipe(this.android.start());
|
||||
}
|
||||
}
|
||||
|
||||
Runner.register(Platform.ANDROID, AndroidRunner);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -340,16 +373,20 @@ class Project {
|
||||
return tasks;
|
||||
}
|
||||
|
||||
run(platform) {
|
||||
run(platform, debug) {
|
||||
const runner = Runner.new(this.config, platform, debug);
|
||||
return this.build(platform, debug).concat([
|
||||
return [
|
||||
runner.prepare.bind(runner),
|
||||
runner.call.bind(runner),
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
pack(platform) {
|
||||
const packer = Packer.new(this.config, platform);
|
||||
test(platform) {
|
||||
return this.build(platform, debug).concat(this.run(platform, debug));
|
||||
}
|
||||
|
||||
pack(platform, name) {
|
||||
const packer = Packer.new(this.config, platform, name);
|
||||
return [
|
||||
packer.prepare.bind(packer),
|
||||
packer.call.bind(packer),
|
||||
@@ -360,9 +397,14 @@ class Project {
|
||||
const _gulp = (external_gulp || gulp);
|
||||
for (const platform of this.platforms) {
|
||||
module.exports[`${this.config.name}:${platform}:build`] = _gulp.series(this.build(platform));
|
||||
module.exports[`${this.config.name}:${platform}:run`] = _gulp.series(this.run(platform));
|
||||
if (Runner.factory[platform]) {
|
||||
module.exports[`${this.config.name}:${platform}:run`] = _gulp.series(this.run(platform));
|
||||
module.exports[`${this.config.name}:${platform}:test`] = _gulp.series(this.test(platform));
|
||||
}
|
||||
if (Packer.factory[platform]) {
|
||||
module.exports[`${this.config.name}:${platform}:pack`] = _gulp.series(this.pack(platform));
|
||||
for (const name of Object.keys(Packer.factory[platform])) {
|
||||
module.exports[`${this.config.name}:${platform}:${name}`] = _gulp.series(this.pack(platform, name));
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user