[all] fixes for windows

This commit is contained in:
2019-09-03 20:56:23 +03:00
parent 414099bd67
commit 7fa0174a7b
11 changed files with 117 additions and 69 deletions

57
README.md Normal file → Executable file
View File

@@ -8,6 +8,7 @@
* Universal project config for simple HaXe build and OpenFL build. * Universal project config for simple HaXe build and OpenFL build.
* Branch project config for many build presets (many OpenFL apps in one project). * Branch project config for many build presets (many OpenFL apps in one project).
* Packaging linux output in DEB. * Packaging linux output in DEB.
* Packaging windows output in exe install with InnoSetup.
* Create html wrapper for flash output. * Create html wrapper for flash output.
### Flaws ### Flaws
@@ -15,9 +16,7 @@
* Hardcode build output in {projectDir}/target (need param in Project.Config). * Hardcode build output in {projectDir}/target (need param in Project.Config).
* HTML5 run output not caught. * HTML5 run output not caught.
* Adobe AIR Build System in progress. * Adobe AIR Build System in progress.
* Packaging Windows application in progress (with [Inno Setup](http://www.jrsoftware.org/isinfo.php)) * Windows target depends Visual Studio 2017 build tools
* OpenFL android build failed due to problems with Android NDK
## API ## API
@@ -60,10 +59,15 @@ create gulp tasks in module:
<config.name>:<platform>:test <config.name>:<platform>:test
<config.name>:flash:html <config.name>:flash:html
<config.name>:linux:archive
<config.name>:linux:deb <config.name>:linux:deb
<config.name>:windows:archive
<config.name>:windows:installer
``` ```
eg: ```gulp app:flash:build``` eg: ```gulp app:flash:test```
## Example ## Example
@@ -75,12 +79,12 @@ eg: ```gulp app:flash:build```
"devDependencies": { "devDependencies": {
"gulp": "^4.0.0", "gulp": "^4.0.0",
"gulp-clean": "^0.4.0", "gulp-clean": "^0.4.0",
"gulp-haxetool": "^0.0.21" "gulp-haxetool": "^0.1.0"
}, },
"haxeDependencies": { "haxeDependencies": {
"lime": "6.0.1", "lime": "7.6.0",
"openfl": "7.0.0", "openfl": "8.9.2",
"hxcpp": "3.4.188" "hxcpp": "4.0.19"
} }
} }
``` ```
@@ -108,7 +112,7 @@ class Main {
const gulp = require('gulp'); const gulp = require('gulp');
const gulpClean = require('gulp-clean'); const gulpClean = require('gulp-clean');
const packageInfo = require('./package.json'); const packageInfo = require('./package.json');
const {Sdk, Haxe, Project} = require('gulp-haxetool'); const {System, Sdk, Haxe, Project} = require('gulp-haxetool');
//Sdk.dir = '/opt/sdk'; //Sdk.dir = '/opt/sdk';
@@ -144,19 +148,38 @@ const project = new Project(
Project.Platform.FLASH, Project.Platform.FLASH,
Project.Platform.HTML5, Project.Platform.HTML5,
Project.Platform.LINUX, Project.Platform.LINUX,
Project.Platform.WINDOWS,
], ],
config config
).bind(module); ).bind(module);
module.exports.default = gulp.series(
const defaultSeries = [
exports.clean, exports.clean,
exports.install,
module.exports['app:flash:build'], module.exports['app:flash:build'],
module.exports['app:html5:build'],
module.exports['app:linux:build'],
module.exports['app:flash:html'], module.exports['app:flash:html'],
module.exports['app:html5:build'],
];
if (System.isLinux) {
defaultSeries.push(
module.exports['app:linux:build'],
module.exports['app:linux:archive'],
module.exports['app:linux:deb'], module.exports['app:linux:deb'],
);
module.exports['app:android:build'],
);
}
if (System.isWindows) {
defaultSeries.push(
module.exports['app:windows:build'],
module.exports['app:windows:archive'],
module.exports['app:windows:installer'],
);
}
module.exports.default = gulp.series(defaultSeries);
``` ```
Build for all platforms: `gulp default` Build for all platforms: `gulp default`
@@ -165,6 +188,10 @@ Build app for specific platform: `gulp app:flash:build`
Build and run flash app in flashplayer: `gulp app:flash:test` Build and run flash app in flashplayer: `gulp app:flash:test`
Build and run html5 app in brpwser: `gulp app:html5:test` Build and run html5 app in browser: `gulp app:html5:test`
Build and run linux app native: `gulp app:linux:test` Build and run linux app native: `gulp app:linux:test`
Build and run windows app native: `gulp app:windows:test`
Build and run android app: `gulp app:android:test`

33
example/gulpfile.js Normal file → Executable file
View File

@@ -1,7 +1,7 @@
const gulp = require('gulp'); const gulp = require('gulp');
const gulpClean = require('gulp-clean'); const gulpClean = require('gulp-clean');
const packageInfo = require('./package.json'); const packageInfo = require('./package.json');
const {Sdk, Haxe, Project} = require('gulp-haxetool'); const {System, Sdk, Haxe, Project} = require('gulp-haxetool');
//Sdk.dir = '/opt/sdk'; //Sdk.dir = '/opt/sdk';
@@ -37,16 +37,35 @@ const project = new Project(
Project.Platform.FLASH, Project.Platform.FLASH,
Project.Platform.HTML5, Project.Platform.HTML5,
Project.Platform.LINUX, Project.Platform.LINUX,
Project.Platform.WINDOWS,
], ],
config config
).bind(module, gulp); ).bind(module);
module.exports.default = gulp.series(
const defaultSeries = [
exports.clean, exports.clean,
exports.install,
module.exports['app:flash:build'], module.exports['app:flash:build'],
module.exports['app:html5:build'],
module.exports['app:linux:build'],
module.exports['app:flash:html'], module.exports['app:flash:html'],
module.exports['app:html5:build'],
];
if (System.isLinux) {
defaultSeries.push(
module.exports['app:linux:build'],
module.exports['app:linux:archive'],
module.exports['app:linux:deb'], module.exports['app:linux:deb'],
);
module.exports['app:android:build'],
);
}
if (System.isWindows) {
defaultSeries.push(
module.exports['app:windows:build'],
module.exports['app:windows:archive'],
module.exports['app:windows:installer'],
);
}
module.exports.default = gulp.series(defaultSeries);

8
example/package.json Normal file → Executable file
View File

@@ -4,11 +4,11 @@
"devDependencies": { "devDependencies": {
"gulp": "^4.0.0", "gulp": "^4.0.0",
"gulp-clean": "^0.4.0", "gulp-clean": "^0.4.0",
"gulp-haxetool": "^0.0.21" "gulp-haxetool": "^0.1.0"
}, },
"haxeDependencies": { "haxeDependencies": {
"lime": "6.0.1", "lime": "7.6.0",
"openfl": "7.0.0", "openfl": "8.9.2",
"hxcpp": "3.4.188" "hxcpp": "4.0.19"
} }
} }

4
haxetool/android.js Normal file → Executable file
View File

@@ -2,8 +2,8 @@ const fs = require('fs');
const path = require('path'); const path = require('path');
const exec = require('./exec'); const exec = require('./exec');
const {StringWritable} = require('./tail'); const {StringWritable} = require('./tail');
const System = require('./system');
const Command = require('../run/command'); const Command = require('../run/command');
const through = require('through2'); const through = require('through2');
const Sdk = require('./sdk'); const Sdk = require('./sdk');
const Env = require('./env'); const Env = require('./env');
@@ -25,7 +25,7 @@ class Android extends Sdk {
} }
get link() { get link() {
const system = Sdk.System.isWindows ? 'windows' : Sdk.System.isLinux ? 'linux' : null; const system = System.isWindows ? 'windows' : System.isLinux ? 'linux' : null;
if (!system) throw 'Unsupported system'; if (!system) throw 'Unsupported system';
if (this.version.indexOf('.') > -1) { if (this.version.indexOf('.') > -1) {
return `https://dl.google.com/android/repository/tools_r${this.version}-${system}.zip`; return `https://dl.google.com/android/repository/tools_r${this.version}-${system}.zip`;

View File

@@ -4,6 +4,7 @@ const fse = require('fs-extra');
const os = require('os'); const os = require('os');
const through = require('through2'); const through = require('through2');
const Sdk = require('./sdk'); const Sdk = require('./sdk');
const System = require('./system');
const run = require('../run/index'); const run = require('../run/index');
const {TailVinyl} = require('./tail'); const {TailVinyl} = require('./tail');
@@ -29,9 +30,9 @@ class FlashPlayer extends Sdk {
get link() { get link() {
const baseUrl = `https://fpdownload.macromedia.com/pub/flashplayer/updaters/${this.version}/`; const baseUrl = `https://fpdownload.macromedia.com/pub/flashplayer/updaters/${this.version}/`;
if (Sdk.System.isWindows) { if (System.isWindows) {
return baseUrl + `flashplayer_${this.version}_sa${this.debug ? '_debug' : ''}.exe`; return baseUrl + `flashplayer_${this.version}_sa${this.debug ? '_debug' : ''}.exe`;
} else if (Sdk.System.isLinux) { } else if (System.isLinux) {
return baseUrl + `flash_player_sa_linux${this.debug ? '_debug' : ''}.x86_64.tar.gz`; return baseUrl + `flash_player_sa_linux${this.debug ? '_debug' : ''}.x86_64.tar.gz`;
} else { } else {
throw `Unsupported os '${os.type()}'`; throw `Unsupported os '${os.type()}'`;

View File

@@ -4,6 +4,7 @@ const fse = require('fs-extra');
const path = require('path'); const path = require('path');
const exec = require('./exec'); const exec = require('./exec');
const Sdk = require('./sdk'); const Sdk = require('./sdk');
const System = require('./system');
const Env = require('./env'); const Env = require('./env');
const Neko = require('./neko'); const Neko = require('./neko');
const vfs = require('vinyl-fs'); const vfs = require('vinyl-fs');
@@ -13,9 +14,9 @@ const rename = require('gulp-rename');
class Haxe extends Sdk { class Haxe extends Sdk {
getBin(name) { getBin(name) {
if (Sdk.System.isWindows) { if (System.isWindows) {
return path.join(this.path, name + '.exe'); return path.join(this.path, name + '.exe');
} else if (Sdk.System.isLinux) { } else if (System.isLinux) {
const binPath = path.join(this.path, name); const binPath = path.join(this.path, name);
if (fs.existsSync(binPath)) { if (fs.existsSync(binPath)) {
fs.chmodSync(binPath, 0o755); fs.chmodSync(binPath, 0o755);
@@ -62,10 +63,10 @@ class Haxe extends Sdk {
} }
get link() { get link() {
if (Sdk.System.isWindows) { if (System.isWindows) {
return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-win.zip`; return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-win.zip`;
} else if (Sdk.System.isLinux) { } else if (System.isLinux) {
let arch = Sdk.System.archInt; let arch = System.archInt;
return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-linux${arch}.tar.gz`; return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-linux${arch}.tar.gz`;
} }
} }
@@ -140,7 +141,7 @@ class Haxe extends Sdk {
const target = path.resolve(buildDir, platform, 'bin'); const target = path.resolve(buildDir, platform, 'bin');
fse.emptyDirSync(target); fse.emptyDirSync(target);
for (const asset of config.assets) { for (const asset of config.assets) {
fse.copySync(asset, path.join(target, asset.split(path.sep).pop())); fse.copySync(asset, path.join(target, asset.split("/").pop()));
} }
return this.haxe(args).then(() => vfs.src(`${target}/**/*`)); return this.haxe(args).then(() => vfs.src(`${target}/**/*`));
} }

View File

@@ -4,7 +4,6 @@ const os = require('os');
const path = require('path'); const path = require('path');
const Sdk = require('./sdk'); const Sdk = require('./sdk');
const exec = require('./exec'); const exec = require('./exec');
const Env = require('./env');
const template = require('lodash.template'); const template = require('lodash.template');
class InnoSetup extends Sdk { class InnoSetup extends Sdk {
@@ -21,14 +20,14 @@ class InnoSetup extends Sdk {
let result = super.prepare(strip); let result = super.prepare(strip);
if (!this.prepared) { if (!this.prepared) {
result = result.then(() => { result = result.then(() => {
return exec(this.path, 'is.exe /VERYSILENT /SUPPRESSMSGBOXES'); return exec(this.path, `is.exe /VERYSILENT /SUPPRESSMSGBOXES /DIR=${this.path}`);
}); });
} }
return result; return result;
} }
get isccBin() { get isccBin() {
return path.join(Env.get('ProgramFiles(x86)'), `Inno Setup ${this.version}`, 'ISCC.exe') return path.join(this.path, 'ISCC.exe')
} }
get prepared() { get prepared() {

View File

@@ -9,32 +9,6 @@ const progress = require('cli-progress');
const fse = require('fs-extra'); const fse = require('fs-extra');
const Log = require('./log'); const Log = require('./log');
class System {
static get isWindows() {
return os.type() === 'Windows_NT';
}
static get isLinux() {
return os.type() === 'Linux';
}
static get archInt() {
if (os.arch() === 'ia32') return 32;
if (os.arch() === 'x64') return 64;
}
static get isArch32() {
return this.archInt === 32;
}
static get isArch64() {
return this.archInt === 64;
}
}
class Downloader { class Downloader {
static createProgressBar() { static createProgressBar() {
@@ -151,6 +125,5 @@ class Sdk {
} }
Sdk.Downloader = Downloader; Sdk.Downloader = Downloader;
Sdk.System = System;
module.exports = Sdk; module.exports = Sdk;

27
haxetool/system.js Executable file
View File

@@ -0,0 +1,27 @@
const os = require('os');
class System {
static get isWindows() {
return os.type() === 'Windows_NT';
}
static get isLinux() {
return os.type() === 'Linux';
}
static get archInt() {
if (os.arch() === 'ia32') return 32;
if (os.arch() === 'x64') return 64;
}
static get isArch32() {
return this.archInt === 32;
}
static get isArch64() {
return this.archInt === 64;
}
}
module.exports = System;

1
index.js Normal file → Executable file
View File

@@ -1,4 +1,5 @@
module.exports = { module.exports = {
System: require('./haxetool/system'),
Sdk: require('./haxetool/sdk'), Sdk: require('./haxetool/sdk'),
Haxe: require('./haxetool/haxe'), Haxe: require('./haxetool/haxe'),
FlashPlayer: require('./haxetool/flashplayer'), FlashPlayer: require('./haxetool/flashplayer'),

View File

@@ -1,6 +1,6 @@
{ {
"name": "gulp-haxetool", "name": "gulp-haxetool",
"version": "0.0.24", "version": "0.1.0",
"description": "HaXe Tool for Gulp", "description": "HaXe Tool for Gulp",
"main": "index.js", "main": "index.js",
"dependencies": { "dependencies": {