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