Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9e8976e85 | ||
|
|
f417fcac73 |
@@ -6,194 +6,119 @@
|
||||
|
||||
### Dignity
|
||||
|
||||
* Automatically download HaXe SDK, Neko, FlashPlayer, Android SDK, +(Adobe AIR SDK).
|
||||
* 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.
|
||||
- Automatically download HaXe SDK, Neko, FlashPlayer (or RufflePlayer), Android SDK.
|
||||
- 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
|
||||
|
||||
* Hardcode build output in {projectDir}/target (need param in Project.Config).
|
||||
* HTML5 run output not caught.
|
||||
* Adobe AIR Build System in progress.
|
||||
* Windows target depends Visual Studio 2017 build tools
|
||||
|
||||
## API
|
||||
|
||||
### Project.Config
|
||||
|
||||
#### constructor
|
||||
|
||||
* **meta**: meta information
|
||||
* **title**: application title
|
||||
* **filename**: application filename
|
||||
* **icon**: path to icon file
|
||||
* **pack**: package name for OpenFL
|
||||
* **author**: author name for DEB packaging
|
||||
* **company**: company name for OpenFL
|
||||
* **version**: application version
|
||||
* **name**: name for output directory
|
||||
* **libs**: list of haxe dependencies
|
||||
* **sources**: list of HaXe sources
|
||||
* **assets**: list of resources
|
||||
* **main**: main class name
|
||||
* **macros**: list of macros
|
||||
|
||||
### Project
|
||||
|
||||
#### constructor
|
||||
|
||||
* **buildSystem**: Project.BuildSystem
|
||||
* **platforms**: Project.Platform (list supported)
|
||||
* **config**: Project.Config
|
||||
|
||||
#### bind
|
||||
|
||||
* **module**
|
||||
|
||||
create gulp tasks in module:
|
||||
|
||||
```
|
||||
<config.name>:<platform>:build
|
||||
<config.name>:<platform>:run
|
||||
<config.name>:<platform>:test
|
||||
|
||||
<config.name>:flash:html
|
||||
|
||||
<config.name>:linux:archive
|
||||
<config.name>:linux:deb
|
||||
|
||||
<config.name>:windows:archive
|
||||
<config.name>:windows:installer
|
||||
```
|
||||
|
||||
eg: ```gulp app:flash:test```
|
||||
- Hardcode build output in {projectDir}/target (need param in Project.Config).
|
||||
- HTML5 run output not caught.
|
||||
- Adobe AIR Build System in progress.
|
||||
- Windows target depends Visual Studio 2017 build tools
|
||||
|
||||
## Example
|
||||
|
||||
[package.json](example/package.json)
|
||||
[Example project](./example)
|
||||
|
||||
[`package.json`](./example/package.json)
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "app",
|
||||
"name": "example",
|
||||
"type": "module",
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
"tasks": "hxt",
|
||||
"build": "hxt default",
|
||||
"dev": "hxt app:flash:test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp": "^4.0.0",
|
||||
"gulp-clean": "^0.4.0",
|
||||
"gulp-haxetool": "^0.1.0"
|
||||
},
|
||||
"haxeDependencies": {
|
||||
"lime": "7.6.0",
|
||||
"openfl": "8.9.2",
|
||||
"hxcpp": "4.0.19"
|
||||
"gulp-haxetool": "^1.2.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
[src/Main.hx](example/src/Main.hx)
|
||||
```haxe
|
||||
import flash.display.Shape;
|
||||
import flash.Lib;
|
||||
[`haxetool.json`](./example/haxetool.json)
|
||||
|
||||
class Main {
|
||||
JSON schema: https://shmyga.ru/public/haxetool.schema.json
|
||||
|
||||
public static function main() {
|
||||
trace("Hello world!");
|
||||
var shape = new Shape();
|
||||
shape.graphics.beginFill(0x00ff00);
|
||||
shape.graphics.drawCircle(50, 50, 20);
|
||||
shape.graphics.endFill();
|
||||
Lib.current.addChild(shape);
|
||||
```json
|
||||
{
|
||||
"app": {
|
||||
"buildSystem": "openfl",
|
||||
"platforms": ["flash", "html5", "linux", "windows", "android"],
|
||||
"config": {
|
||||
"meta": {
|
||||
"title": "Example",
|
||||
"filename": "example",
|
||||
"icon": "./resources/icon.jpg",
|
||||
"pack": "com.example",
|
||||
"author": "Anonim <anonim@anonim.com>",
|
||||
"company": "Any company"
|
||||
},
|
||||
"libs": {
|
||||
"lime": "8.3.2",
|
||||
"openfl": "9.5.2",
|
||||
"hxcpp": "4.3.2"
|
||||
},
|
||||
"sources": ["src"],
|
||||
"main": "Main"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
[gulpfile.js](example/gulpfile.js)
|
||||
```javascript
|
||||
const gulp = require('gulp');
|
||||
const gulpClean = require('gulp-clean');
|
||||
const packageInfo = require('./package.json');
|
||||
const {System, Sdk, Haxe, Project} = require('gulp-haxetool');
|
||||
## Commands
|
||||
|
||||
//Sdk.dir = '/opt/sdk';
|
||||
### Display tasks list
|
||||
|
||||
exports.clean = function clean() {
|
||||
return gulp.src('target/*', {read: false}).pipe(gulpClean());
|
||||
};
|
||||
```bash
|
||||
npx hxt
|
||||
```
|
||||
|
||||
exports.install = function install() {
|
||||
const haxe = new Haxe();
|
||||
return haxe.prepare().then(() => haxe.install(packageInfo.haxeDependencies));
|
||||
};
|
||||
### Build and pack all presets platform variants
|
||||
|
||||
const config = new Project.Config({
|
||||
meta: {
|
||||
title: 'Application',
|
||||
filename: 'app',
|
||||
icon: './resources/icon.jpg',
|
||||
pack: 'com.example',
|
||||
author: 'Anonim <anonim@anonim.com>',
|
||||
company: 'Any company',
|
||||
version: packageInfo.version,
|
||||
},
|
||||
name: 'app',
|
||||
libs: packageInfo.haxeDependencies,
|
||||
sources: ['src'],
|
||||
assets: ['resources'],
|
||||
main: 'Main',
|
||||
});
|
||||
Results places in `target` directory
|
||||
|
||||
const project = new Project(
|
||||
Project.BuildSystem.OPENFL,
|
||||
[
|
||||
Project.Platform.FLASH,
|
||||
Project.Platform.HTML5,
|
||||
Project.Platform.LINUX,
|
||||
Project.Platform.WINDOWS,
|
||||
```bash
|
||||
npx hxt default
|
||||
```
|
||||
|
||||
### Build and run platform target
|
||||
|
||||
```bash
|
||||
npx hxt <preset>:<platform>:test
|
||||
```
|
||||
```bash
|
||||
npx hxt app:flash:test
|
||||
npx hxt app:html5:test
|
||||
npx hxt app:linux:test
|
||||
npx hxt app:android:test
|
||||
npx hxt app:windows:test
|
||||
```
|
||||
|
||||
## VS Code settings
|
||||
|
||||
JSON schema for `haxetool.json`
|
||||
|
||||
```json
|
||||
{
|
||||
...
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": [
|
||||
"/haxetool.json"
|
||||
],
|
||||
config
|
||||
).bind(module);
|
||||
|
||||
|
||||
const defaultSeries = [
|
||||
exports.clean,
|
||||
module.exports['app:flash:build'],
|
||||
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:android:build'],
|
||||
);
|
||||
"url": "https://shmyga.ru/public/haxetool.schema.json"
|
||||
}
|
||||
],
|
||||
"json.schemaDownload.trustedDomains": {
|
||||
"https://shmyga.ru/": true
|
||||
},
|
||||
...
|
||||
}
|
||||
|
||||
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 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 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`
|
||||
|
||||
@@ -9,14 +9,12 @@
|
||||
"icon": "./resources/icon.jpg",
|
||||
"pack": "com.example",
|
||||
"author": "Anonim <anonim@anonim.com>",
|
||||
"company": "Any company",
|
||||
"version": "<%=package.version%>"
|
||||
"company": "Any company"
|
||||
},
|
||||
"haxe": "4.2.5",
|
||||
"libs": {
|
||||
"lime": "8.0.0",
|
||||
"openfl": "9.2.0",
|
||||
"hxcpp": "4.2.1"
|
||||
"lime": "8.3.2",
|
||||
"openfl": "9.5.2",
|
||||
"hxcpp": "4.3.2"
|
||||
},
|
||||
"sources": ["src"],
|
||||
"main": "Main"
|
||||
|
||||
@@ -92,7 +92,7 @@ class ProgressBar {
|
||||
const progressBar = new ProgressBar();
|
||||
|
||||
export const download = async (url: string, dest: string, options?: DownloadOptions): Promise<void> => {
|
||||
options = Object.assign({}, DEFAULT_OPTIONS, options);
|
||||
options = { ...DEFAULT_OPTIONS, ...options };
|
||||
fse.ensureDirSync(dest);
|
||||
let stream: Request = got.stream(url);
|
||||
if (options.progress) {
|
||||
|
||||
+5
-2
@@ -121,10 +121,13 @@ export class Config {
|
||||
}
|
||||
|
||||
afterUpdate() {
|
||||
if (this.meta.mobileWidth === null) this.meta.mobileWidth = this.meta.width;
|
||||
if (this.meta.mobileHeight === null && this.meta.mobileWidth)
|
||||
if (this.meta.mobileWidth === null) {
|
||||
this.meta.mobileWidth = this.meta.width;
|
||||
}
|
||||
if (this.meta.mobileHeight === null && this.meta.mobileWidth) {
|
||||
this.meta.mobileHeight = Math.round(this.meta.mobileWidth / 2.222222222);
|
||||
}
|
||||
}
|
||||
|
||||
branch(params: ConfigParams) {
|
||||
const result = new Config();
|
||||
|
||||
+3
-1
@@ -26,7 +26,9 @@ export class Haxe extends Sdk {
|
||||
static VERSION_4_0_2 = "4.0.2";
|
||||
static VERSION_4_0_3 = "4.0.3";
|
||||
static VERSION_4_0_5 = "4.0.5";
|
||||
static VERSION_4 = Haxe.VERSION_4_0_5;
|
||||
static VERSION_4_2_5 = "4.2.5";
|
||||
static VERSION_4_3_7 = "4.3.7";
|
||||
static VERSION_4 = Haxe.VERSION_4_3_7;
|
||||
static VERSION = Haxe.VERSION_4;
|
||||
|
||||
static buildDir = path.join(process.cwd(), "build");
|
||||
|
||||
+3
-1
@@ -44,7 +44,9 @@ export class Neko extends Sdk {
|
||||
static ID = "neko";
|
||||
|
||||
static VERSION_2_2_0 = "2.2.0";
|
||||
static VERSION = Neko.VERSION_2_2_0;
|
||||
static VERSION_2_4_0 = "2.4.0";
|
||||
static VERSION_2_4_1 = "2.4.1";
|
||||
static VERSION = Neko.VERSION_2_4_1;
|
||||
|
||||
constructor(version?: string) {
|
||||
super(Neko.ID, version || Neko.VERSION);
|
||||
|
||||
@@ -20,7 +20,7 @@ export class LinuxDEBPacker extends Packer {
|
||||
const target = this.targetPath;
|
||||
const buildDir = path.join(os.tmpdir(), "build", this.config.name, "debian");
|
||||
const iconfile = `${this.config.meta.filename}${path.extname(this.config.meta.icon!)}`;
|
||||
const desktop = template.render("linux/app.desktop", Object.assign({ iconfile: iconfile }, this.config));
|
||||
const desktop = template.render("linux/app.desktop", { iconfile: iconfile, ...this.config });
|
||||
fse.ensureDirSync(`${buildDir}/usr/share/applications`);
|
||||
fs.writeFileSync(`${buildDir}/usr/share/applications/${this.config.meta.filename}.desktop`, desktop);
|
||||
fse.copySync(`${target}`, `${buildDir}/usr/share/${this.config.meta.filename}/`);
|
||||
|
||||
@@ -35,7 +35,7 @@ export class Preset {
|
||||
public packageInfo: Record<string, any>;
|
||||
|
||||
constructor(options: Record<string, ProjectPreset>, config?: PresetConfig, packageInfo?: Record<string, any>) {
|
||||
this.config = Object.assign(DEFAULT_CONFIG, config || {});
|
||||
this.config = { ...DEFAULT_CONFIG, ...(config || {}) };
|
||||
this.packageInfo = packageInfo || {};
|
||||
for (const [k, v] of Object.entries(options)) {
|
||||
options[k] = this.fillPreset(v);
|
||||
@@ -55,16 +55,16 @@ export class Preset {
|
||||
}
|
||||
|
||||
compile(): Project[] {
|
||||
const config = new Config(this.options["default"]?.config);
|
||||
if (this.packageInfo.haxeDependencies) {
|
||||
config.update({ libs: this.packageInfo.haxeDependencies });
|
||||
}
|
||||
const config = new Config({
|
||||
meta: { version: this.packageInfo.version },
|
||||
...(this.options["default"]?.config || {}),
|
||||
});
|
||||
const projects: Project[] = [];
|
||||
for (const [k, v] of Object.entries(this.options)) {
|
||||
if (k == "default") {
|
||||
continue;
|
||||
}
|
||||
const projectConfig = config.branch(Object.assign(v.config, { name: k }));
|
||||
const projectConfig = config.branch({ ...v.config, name: k });
|
||||
projects.push(new Project(v.buildSystem!, v.platforms!, projectConfig));
|
||||
}
|
||||
return projects;
|
||||
|
||||
+4
-6
@@ -14,15 +14,13 @@ export class Command {
|
||||
constructor(command: string, options?: any) {
|
||||
this.command = command;
|
||||
this.isWindows = process.platform.lastIndexOf("win") === 0;
|
||||
this.options = Object.assign(
|
||||
{
|
||||
this.options = {
|
||||
cwd: process.cwd(),
|
||||
env: process.env,
|
||||
verbosity: options && options.silent ? 1 : 2,
|
||||
verbosity: options?.silent ? 1 : 2,
|
||||
usePowerShell: false,
|
||||
},
|
||||
options || {},
|
||||
);
|
||||
...(options || {}),
|
||||
};
|
||||
|
||||
let previousPath;
|
||||
previousPath = this.options.env.PATH;
|
||||
|
||||
Reference in New Issue
Block a user