From 7fa0174a7bea6b12aecaf8cd8a09d0f709cd8ea6 Mon Sep 17 00:00:00 2001 From: shmyga Date: Tue, 3 Sep 2019 20:56:23 +0300 Subject: [PATCH] [all] fixes for windows --- README.md | 59 ++++++++++++++++++++++++++++++----------- example/gulpfile.js | 35 ++++++++++++++++++------ example/package.json | 8 +++--- haxetool/android.js | 4 +-- haxetool/flashplayer.js | 5 ++-- haxetool/haxe.js | 13 ++++----- haxetool/innosetup.js | 5 ++-- haxetool/sdk.js | 27 ------------------- haxetool/system.js | 27 +++++++++++++++++++ index.js | 1 + package.json | 2 +- 11 files changed, 117 insertions(+), 69 deletions(-) mode change 100644 => 100755 README.md mode change 100644 => 100755 example/gulpfile.js mode change 100644 => 100755 example/package.json mode change 100644 => 100755 haxetool/android.js create mode 100755 haxetool/system.js mode change 100644 => 100755 index.js diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 7562f69..3876ded --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ * Universal project config for simple HaXe build and OpenFL build. * Branch project config for many build presets (many OpenFL apps in one project). * Packaging linux output in DEB. +* Packaging windows output in exe install with InnoSetup. * Create html wrapper for flash output. ### Flaws @@ -15,9 +16,7 @@ * Hardcode build output in {projectDir}/target (need param in Project.Config). * HTML5 run output not caught. * Adobe AIR Build System in progress. -* Packaging Windows application in progress (with [Inno Setup](http://www.jrsoftware.org/isinfo.php)) -* OpenFL android build failed due to problems with Android NDK - +* Windows target depends Visual Studio 2017 build tools ## API @@ -60,10 +59,15 @@ create gulp tasks in module: ::test :flash:html + +:linux:archive :linux:deb + +:windows:archive +:windows:installer ``` -eg: ```gulp app:flash:build``` +eg: ```gulp app:flash:test``` ## Example @@ -75,12 +79,12 @@ eg: ```gulp app:flash:build``` "devDependencies": { "gulp": "^4.0.0", "gulp-clean": "^0.4.0", - "gulp-haxetool": "^0.0.21" + "gulp-haxetool": "^0.1.0" }, "haxeDependencies": { - "lime": "6.0.1", - "openfl": "7.0.0", - "hxcpp": "3.4.188" + "lime": "7.6.0", + "openfl": "8.9.2", + "hxcpp": "4.0.19" } } ``` @@ -108,7 +112,7 @@ class Main { const gulp = require('gulp'); const gulpClean = require('gulp-clean'); const packageInfo = require('./package.json'); -const {Sdk, Haxe, Project} = require('gulp-haxetool'); +const {System, Sdk, Haxe, Project} = require('gulp-haxetool'); //Sdk.dir = '/opt/sdk'; @@ -144,19 +148,38 @@ const project = new Project( Project.Platform.FLASH, Project.Platform.HTML5, Project.Platform.LINUX, + Project.Platform.WINDOWS, ], config ).bind(module); -module.exports.default = gulp.series( + +const defaultSeries = [ exports.clean, - exports.install, module.exports['app:flash:build'], - module.exports['app:html5:build'], - module.exports['app:linux:build'], module.exports['app:flash:html'], - module.exports['app:linux:deb'], -); + 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: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` @@ -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 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 windows app native: `gulp app:windows:test` + +Build and run android app: `gulp app:android:test` diff --git a/example/gulpfile.js b/example/gulpfile.js old mode 100644 new mode 100755 index f8b87db..3655c08 --- a/example/gulpfile.js +++ b/example/gulpfile.js @@ -1,7 +1,7 @@ const gulp = require('gulp'); const gulpClean = require('gulp-clean'); const packageInfo = require('./package.json'); -const {Sdk, Haxe, Project} = require('gulp-haxetool'); +const {System, Sdk, Haxe, Project} = require('gulp-haxetool'); //Sdk.dir = '/opt/sdk'; @@ -37,16 +37,35 @@ const project = new Project( Project.Platform.FLASH, Project.Platform.HTML5, Project.Platform.LINUX, + Project.Platform.WINDOWS, ], config -).bind(module, gulp); +).bind(module); -module.exports.default = gulp.series( + +const defaultSeries = [ exports.clean, - exports.install, module.exports['app:flash:build'], - module.exports['app:html5:build'], - module.exports['app:linux:build'], module.exports['app:flash:html'], - module.exports['app:linux:deb'], -); \ No newline at end of file + 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: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); diff --git a/example/package.json b/example/package.json old mode 100644 new mode 100755 index f5ecd14..ade4618 --- a/example/package.json +++ b/example/package.json @@ -4,11 +4,11 @@ "devDependencies": { "gulp": "^4.0.0", "gulp-clean": "^0.4.0", - "gulp-haxetool": "^0.0.21" + "gulp-haxetool": "^0.1.0" }, "haxeDependencies": { - "lime": "6.0.1", - "openfl": "7.0.0", - "hxcpp": "3.4.188" + "lime": "7.6.0", + "openfl": "8.9.2", + "hxcpp": "4.0.19" } } diff --git a/haxetool/android.js b/haxetool/android.js old mode 100644 new mode 100755 index 8c3f3fa..641166e --- a/haxetool/android.js +++ b/haxetool/android.js @@ -2,8 +2,8 @@ const fs = require('fs'); const path = require('path'); const exec = require('./exec'); const {StringWritable} = require('./tail'); +const System = require('./system'); const Command = require('../run/command'); - const through = require('through2'); const Sdk = require('./sdk'); const Env = require('./env'); @@ -25,7 +25,7 @@ class Android extends Sdk { } 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 (this.version.indexOf('.') > -1) { return `https://dl.google.com/android/repository/tools_r${this.version}-${system}.zip`; diff --git a/haxetool/flashplayer.js b/haxetool/flashplayer.js index a77d835..280ac37 100755 --- a/haxetool/flashplayer.js +++ b/haxetool/flashplayer.js @@ -4,6 +4,7 @@ const fse = require('fs-extra'); const os = require('os'); const through = require('through2'); const Sdk = require('./sdk'); +const System = require('./system'); const run = require('../run/index'); const {TailVinyl} = require('./tail'); @@ -29,9 +30,9 @@ class FlashPlayer extends Sdk { get link() { 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`; - } else if (Sdk.System.isLinux) { + } else if (System.isLinux) { return baseUrl + `flash_player_sa_linux${this.debug ? '_debug' : ''}.x86_64.tar.gz`; } else { throw `Unsupported os '${os.type()}'`; diff --git a/haxetool/haxe.js b/haxetool/haxe.js index 3beea3e..11a8474 100755 --- a/haxetool/haxe.js +++ b/haxetool/haxe.js @@ -4,6 +4,7 @@ const fse = require('fs-extra'); const path = require('path'); const exec = require('./exec'); const Sdk = require('./sdk'); +const System = require('./system'); const Env = require('./env'); const Neko = require('./neko'); const vfs = require('vinyl-fs'); @@ -13,9 +14,9 @@ const rename = require('gulp-rename'); class Haxe extends Sdk { getBin(name) { - if (Sdk.System.isWindows) { + if (System.isWindows) { return path.join(this.path, name + '.exe'); - } else if (Sdk.System.isLinux) { + } else if (System.isLinux) { const binPath = path.join(this.path, name); if (fs.existsSync(binPath)) { fs.chmodSync(binPath, 0o755); @@ -62,10 +63,10 @@ class Haxe extends Sdk { } get link() { - if (Sdk.System.isWindows) { + if (System.isWindows) { return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-win.zip`; - } else if (Sdk.System.isLinux) { - let arch = Sdk.System.archInt; + } else if (System.isLinux) { + let arch = System.archInt; 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'); fse.emptyDirSync(target); 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}/**/*`)); } diff --git a/haxetool/innosetup.js b/haxetool/innosetup.js index 09a0e2b..b586ac6 100755 --- a/haxetool/innosetup.js +++ b/haxetool/innosetup.js @@ -4,7 +4,6 @@ const os = require('os'); const path = require('path'); const Sdk = require('./sdk'); const exec = require('./exec'); -const Env = require('./env'); const template = require('lodash.template'); class InnoSetup extends Sdk { @@ -21,14 +20,14 @@ class InnoSetup extends Sdk { let result = super.prepare(strip); if (!this.prepared) { result = result.then(() => { - return exec(this.path, 'is.exe /VERYSILENT /SUPPRESSMSGBOXES'); + return exec(this.path, `is.exe /VERYSILENT /SUPPRESSMSGBOXES /DIR=${this.path}`); }); } return result; } get isccBin() { - return path.join(Env.get('ProgramFiles(x86)'), `Inno Setup ${this.version}`, 'ISCC.exe') + return path.join(this.path, 'ISCC.exe') } get prepared() { diff --git a/haxetool/sdk.js b/haxetool/sdk.js index e9e136f..7b59a9b 100755 --- a/haxetool/sdk.js +++ b/haxetool/sdk.js @@ -9,32 +9,6 @@ const progress = require('cli-progress'); const fse = require('fs-extra'); 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 { static createProgressBar() { @@ -151,6 +125,5 @@ class Sdk { } Sdk.Downloader = Downloader; -Sdk.System = System; module.exports = Sdk; diff --git a/haxetool/system.js b/haxetool/system.js new file mode 100755 index 0000000..7df206e --- /dev/null +++ b/haxetool/system.js @@ -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; diff --git a/index.js b/index.js old mode 100644 new mode 100755 index d6322d4..3f78bf7 --- a/index.js +++ b/index.js @@ -1,4 +1,5 @@ module.exports = { + System: require('./haxetool/system'), Sdk: require('./haxetool/sdk'), Haxe: require('./haxetool/haxe'), FlashPlayer: require('./haxetool/flashplayer'), diff --git a/package.json b/package.json index 7cfdf56..088573a 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gulp-haxetool", - "version": "0.0.24", + "version": "0.1.0", "description": "HaXe Tool for Gulp", "main": "index.js", "dependencies": {