This commit is contained in:
Dante
2026-05-21 23:40:20 -07:00
parent 3e2915dff7
commit 877a69d844
5737 changed files with 29796 additions and 1589684 deletions

View File

@ -59,6 +59,27 @@ class AssetConverter {
}
return { name: nameValue, destination: destination };
}
canDecodeFormat(ext) {
var _a, _b, _c, _d, _e, _f;
// without ffmpeg we need to encode mp3 and ogg files
const hasFFmpeg = !!this.options.ffmpeg;
const hasFFmpegOgg = (_b = (_a = this.options.ogg) === null || _a === void 0 ? void 0 : _a.includes('ffmpeg')) !== null && _b !== void 0 ? _b : false;
const hasFFmpegMp3 = (_d = (_c = this.options.mp3) === null || _c === void 0 ? void 0 : _c.includes('ffmpeg')) !== null && _d !== void 0 ? _d : false;
const hasFFmpegAac = (_f = (_e = this.options.aac) === null || _e === void 0 ? void 0 : _e.includes('ffmpeg')) !== null && _f !== void 0 ? _f : false;
switch (ext) {
case '.wav':
return true;
case '.ogg':
return hasFFmpeg || (hasFFmpegOgg && (hasFFmpegMp3 || hasFFmpegAac));
case '.mp3':
// lame can decode mp3, so we only need ogg ffmpeg encoder
return hasFFmpeg || (hasFFmpegOgg && !!this.options.mp3);
case '.flac':
return hasFFmpeg;
default:
return false;
}
}
watch(watch, match, temp, options) {
return new Promise((resolve, reject) => {
let ready = false;
@ -69,11 +90,15 @@ class AssetConverter {
let outPath = fileinfo.name;
// with subfolders
if (options.destination) {
const from = path.resolve(options.baseDir, '..');
// remove trailing slash
const nameBaseDir = options.nameBaseDir.replace(/\/$/, '');
const lastIndex = options.baseDir.lastIndexOf(nameBaseDir);
const from = path.resolve(options.baseDir.substring(0, lastIndex));
outPath = AssetConverter.replacePattern(options.destination, fileinfo.name, fileinfo, options, from);
}
log.info('Reexporting ' + outPath + fileinfo.ext);
switch (fileinfo.ext) {
const ext = fileinfo.ext.toLowerCase();
log.info('Reexporting ' + outPath + ext);
switch (ext) {
case '.png':
case '.jpg':
case '.jpeg':
@ -85,6 +110,9 @@ class AssetConverter {
case '.mp3':
case '.flac':
case '.wav': {
if (!this.canDecodeFormat(ext)) {
log.error(`Error: ${fileinfo.base} should be in wav format, or use \`--ffmpeg path/to/ffmpeg\` option to convert ogg/mp3/flac files`);
}
await this.exporter.copySound(this.platform, file, outPath, {});
break;
}
@ -100,10 +128,10 @@ class AssetConverter {
await this.exporter.copyFont(this.platform, file, outPath, {});
break;
default:
await this.exporter.copyBlob(this.platform, file, outPath + fileinfo.ext, {});
await this.exporter.copyBlob(this.platform, file, outPath + ext, {});
}
for (let callback of ProjectFile_1.Callbacks.postAssetReexporting) {
callback(outPath + fileinfo.ext);
callback(outPath + ext);
}
};
this.watcher.on('add', (file) => {
@ -129,8 +157,7 @@ class AssetConverter {
if (fs.existsSync(cachePath)) {
cache = JSON.parse(fs.readFileSync(cachePath, 'utf8'));
}
const self = this;
async function convertAsset(file, index) {
const convertAsset = async (file, index) => {
let fileinfo = path.parse(file);
log.info('Exporting asset ' + (index + 1) + ' of ' + files.length + ' (' + fileinfo.base + ').');
const ext = fileinfo.ext.toLowerCase();
@ -139,13 +166,13 @@ class AssetConverter {
case '.jpg':
case '.jpeg':
case '.hdr': {
let exportInfo = AssetConverter.createExportInfo(fileinfo, false, options, self.exporter.options.from);
let exportInfo = AssetConverter.createExportInfo(fileinfo, false, options, this.exporter.options.from);
let images;
if (options.noprocessing) {
images = await self.exporter.copyBlob(self.platform, file, exportInfo.destination, options);
images = await this.exporter.copyBlob(this.platform, file, exportInfo.destination, options);
}
else {
images = await self.exporter.copyImage(self.platform, file, exportInfo.destination, options, cache);
images = await this.exporter.copyImage(this.platform, file, exportInfo.destination, options, cache);
}
if (!options.notinlist) {
parsedFiles.push({ name: exportInfo.name, from: file, type: 'image', files: images.files, file_sizes: images.sizes, original_width: options.original_width, original_height: options.original_height, readable: options.readable });
@ -156,13 +183,17 @@ class AssetConverter {
case '.mp3':
case '.flac':
case '.wav': {
let exportInfo = AssetConverter.createExportInfo(fileinfo, false, options, self.exporter.options.from);
let exportInfo = AssetConverter.createExportInfo(fileinfo, false, options, this.exporter.options.from);
let sounds;
if (options.noprocessing) {
sounds = await self.exporter.copyBlob(self.platform, file, exportInfo.destination, options);
sounds = await this.exporter.copyBlob(this.platform, file, exportInfo.destination, options);
}
else {
sounds = await self.exporter.copySound(self.platform, file, exportInfo.destination, options);
if (!this.canDecodeFormat(ext)) {
log.error(`Error: ${fileinfo.base} should be in wav format, or use \`--ffmpeg\` option to convert ogg/mp3/flac files`);
process.exit(1);
}
sounds = await this.exporter.copySound(this.platform, file, exportInfo.destination, options);
}
if (sounds.files.length === 0) {
throw 'Audio file ' + file + ' could not be exported, you have to specify a path to ffmpeg.';
@ -173,13 +204,13 @@ class AssetConverter {
break;
}
case '.ttf': {
let exportInfo = AssetConverter.createExportInfo(fileinfo, false, options, self.exporter.options.from);
let exportInfo = AssetConverter.createExportInfo(fileinfo, false, options, this.exporter.options.from);
let fonts;
if (options.noprocessing) {
fonts = await self.exporter.copyBlob(self.platform, file, exportInfo.destination, options);
fonts = await this.exporter.copyBlob(this.platform, file, exportInfo.destination, options);
}
else {
fonts = await self.exporter.copyFont(self.platform, file, exportInfo.destination, options);
fonts = await this.exporter.copyFont(this.platform, file, exportInfo.destination, options);
}
if (!options.notinlist) {
parsedFiles.push({ name: exportInfo.name, from: file, type: 'font', files: fonts.files, file_sizes: fonts.sizes, original_width: undefined, original_height: undefined, readable: undefined });
@ -191,13 +222,13 @@ class AssetConverter {
case '.mov':
case '.wmv':
case '.avi': {
let exportInfo = AssetConverter.createExportInfo(fileinfo, false, options, self.exporter.options.from);
let exportInfo = AssetConverter.createExportInfo(fileinfo, false, options, this.exporter.options.from);
let videos;
if (options.noprocessing) {
videos = await self.exporter.copyBlob(self.platform, file, exportInfo.destination, options);
videos = await this.exporter.copyBlob(this.platform, file, exportInfo.destination, options);
}
else {
videos = await self.exporter.copyVideo(self.platform, file, exportInfo.destination, options);
videos = await this.exporter.copyVideo(this.platform, file, exportInfo.destination, options);
}
if (videos.files.length === 0) {
log.error('Video file ' + file + ' could not be exported, you have to specify a path to ffmpeg.');
@ -208,15 +239,15 @@ class AssetConverter {
break;
}
default: {
let exportInfo = AssetConverter.createExportInfo(fileinfo, true, options, self.exporter.options.from);
let blobs = await self.exporter.copyBlob(self.platform, file, exportInfo.destination, options);
let exportInfo = AssetConverter.createExportInfo(fileinfo, true, options, this.exporter.options.from);
let blobs = await this.exporter.copyBlob(this.platform, file, exportInfo.destination, options);
if (!options.notinlist) {
parsedFiles.push({ name: exportInfo.name, from: file, type: 'blob', files: blobs.files, file_sizes: blobs.sizes, original_width: undefined, original_height: undefined, readable: undefined });
}
break;
}
}
}
};
if (this.options.parallelAssetConversion !== 0) {
let todo = files.map((file, index) => {
return async () => {

View File

@ -38,6 +38,9 @@ function convert(inFilename, outFilename, encoder, args = null) {
else
options.push(parts[i]);
}
if (fs.existsSync(outFilename.toString())) {
fs.unlinkSync(outFilename.toString());
}
// About stdio ignore: https://stackoverflow.com/a/20792428
let process = child_process.spawn(exe, options, { stdio: 'ignore' });
process.on('close', (code) => {

View File

@ -1,137 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KincExporter = void 0;
const fs = require("fs-extra");
const path = require("path");
const defaults = require("../defaults");
const KhaExporter_1 = require("./KhaExporter");
const Converter_1 = require("../Converter");
const GraphicsApi_1 = require("../GraphicsApi");
const Platform_1 = require("../Platform");
const ImageTool_1 = require("../ImageTool");
class KincExporter extends KhaExporter_1.KhaExporter {
constructor(options) {
super(options);
this.slowgc = options.slowgc;
// Files.removeDirectory(this.directory.resolve(Paths.get(this.sysdir() + "-build", "Sources")));
}
backend() {
return 'Kinc-hxcpp';
}
haxeOptions(name, targetOptions, defines) {
defines.push('no-compilation');
defines.push('include-prefix=hxinc');
if (!this.slowgc) {
defines.push('HXCPP_GC_GENERATIONAL');
}
defines.push('sys_' + this.options.target);
defines.push('sys_kore');
defines.push('sys_g1');
defines.push('sys_g2');
defines.push('sys_g3');
defines.push('sys_g4');
defines.push('sys_a1');
defines.push('sys_a2');
defines.push('kha_cpp');
defines.push('kha_' + this.options.target);
defines.push('kha_' + this.options.target + '_native');
defines.push('kha_' + this.options.target + '_cpp');
let graphics = this.options.graphics;
if (graphics === GraphicsApi_1.GraphicsApi.Default) {
graphics = defaults.graphicsApi(this.options.target);
}
defines.push('kha_' + graphics);
defines.push('kha_kore');
defines.push('kha_g1');
defines.push('kha_g2');
defines.push('kha_g3');
defines.push('kha_g4');
defines.push('kha_a1');
defines.push('kha_a2');
if (this.options.vr === 'gearvr') {
defines.push('vr_gearvr');
}
else if (this.options.vr === 'cardboard') {
defines.push('vr_cardboard');
}
else if (this.options.vr === 'rift') {
defines.push('vr_rift');
}
if (this.options.raytrace === 'dxr') {
defines.push('kha_dxr');
}
return {
from: this.options.from,
to: path.join(this.sysdir() + '-build', 'Sources'),
sources: this.sources,
libraries: this.libraries,
defines: defines,
parameters: this.parameters,
haxeDirectory: this.options.haxe,
system: this.sysdir(),
language: 'cpp',
width: this.width,
height: this.height,
name: name,
main: this.options.main,
};
}
async export(name, targetOptions, haxeOptions) {
}
async copySound(platform, from, to, options) {
if (options.quality < 1) {
fs.ensureDirSync(path.join(this.options.to, this.sysdir(), path.dirname(to)));
await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.ogg'), this.options.ogg);
return { files: [to + '.ogg'], sizes: [1] };
}
else {
if (from.endsWith('.wav')) {
fs.copySync(from.toString(), path.join(this.options.to, this.sysdir(), to + '.wav'), { overwrite: true });
}
else {
throw 'Can not convert ' + from + ' to wav format.';
}
return { files: [to + '.wav'], sizes: [1] };
}
}
async copyImage(platform, from, to, options, cache) {
if (platform === Platform_1.Platform.iOS && options.quality < 1) {
let format = await (0, ImageTool_1.exportImage)(this.options.kha, this.options.kraffiti, from, path.join(this.options.to, this.sysdir(), to), options, 'pvr', true, false, cache);
return { files: [to + '.' + format], sizes: [1] };
}
else if (platform === Platform_1.Platform.Windows && options.quality < 1 && (this.options.graphics === GraphicsApi_1.GraphicsApi.OpenGL || this.options.graphics === GraphicsApi_1.GraphicsApi.Vulkan)) {
// let format = await exportImage(this.options.kha, from, path.join(this.options.to, this.sysdir(), to), options, 'ASTC', true, false, cache);
let format = await (0, ImageTool_1.exportImage)(this.options.kha, this.options.kraffiti, from, path.join(this.options.to, this.sysdir(), to), options, 'DXT5', true, false, cache);
return { files: [to + '.' + format], sizes: [1] };
}
else {
let format = await (0, ImageTool_1.exportImage)(this.options.kha, this.options.kraffiti, from, path.join(this.options.to, this.sysdir(), to), options, 'lz4', true, false, cache);
return { files: [to + '.' + format], sizes: [1] };
}
}
async copyBlob(platform, from, to) {
fs.copySync(from.toString(), path.join(this.options.to, this.sysdir(), to), { overwrite: true });
return { files: [to], sizes: [1] };
}
async copyVideo(platform, from, to) {
fs.ensureDirSync(path.join(this.options.to, this.sysdir(), path.dirname(to)));
if (platform === Platform_1.Platform.Windows) {
await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.avi'), this.options.h264);
return { files: [to + '.avi'], sizes: [1] };
}
else if (platform === Platform_1.Platform.iOS || platform === Platform_1.Platform.OSX) {
await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.mp4'), this.options.h264);
return { files: [to + '.mp4'], sizes: [1] };
}
else if (platform === Platform_1.Platform.Android) {
await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.ts'), this.options.h264);
return { files: [to + '.ts'], sizes: [1] };
}
else {
await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.ogv'), this.options.theora);
return { files: [to + '.ogv'], sizes: [1] };
}
}
}
exports.KincExporter = KincExporter;
//# sourceMappingURL=KincExporter.js.map

View File

@ -1,124 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KincHLExporter = void 0;
const fs = require("fs-extra");
const path = require("path");
const defaults = require("../defaults");
const KhaExporter_1 = require("./KhaExporter");
const Converter_1 = require("../Converter");
const GraphicsApi_1 = require("../GraphicsApi");
const Platform_1 = require("../Platform");
const ImageTool_1 = require("../ImageTool");
class KincHLExporter extends KhaExporter_1.KhaExporter {
constructor(options) {
super(options);
// Files.removeDirectory(this.directory.resolve(Paths.get(this.sysdir() + "-build", "Sources")));
}
backend() {
return 'Kinc-HL';
}
haxeOptions(name, targetOptions, defines) {
defines.push('no-compilation');
defines.push('sys_' + this.options.target);
defines.push('sys_g1');
defines.push('sys_g2');
defines.push('sys_g3');
defines.push('sys_g4');
defines.push('sys_a1');
defines.push('sys_a2');
defines.push('kha_hl');
defines.push('kha_' + this.options.target);
defines.push('kha_' + this.options.target + '_hl');
let graphics = this.options.graphics;
if (graphics === GraphicsApi_1.GraphicsApi.Default) {
graphics = defaults.graphicsApi(this.options.target);
}
defines.push('kha_' + graphics);
defines.push('kha_g1');
defines.push('kha_g2');
defines.push('kha_g3');
defines.push('kha_g4');
defines.push('kha_a1');
defines.push('kha_a2');
if (this.options.vr === 'gearvr') {
defines.push('vr_gearvr');
}
else if (this.options.vr === 'cardboard') {
defines.push('vr_cardboard');
}
else if (this.options.vr === 'rift') {
defines.push('vr_rift');
}
if (this.options.raytrace === 'dxr') {
defines.push('kha_dxr');
}
return {
from: this.options.from,
to: path.join(this.sysdir() + '-build', 'sources.c'),
sources: this.sources,
libraries: this.libraries,
defines: defines,
parameters: this.parameters,
haxeDirectory: this.options.haxe,
system: this.sysdir(),
language: 'hl',
width: this.width,
height: this.height,
name: name,
main: this.options.main,
};
}
async export(name, targetOptions, haxeOptions) {
}
async copySound(platform, from, to, options) {
if (options.quality < 1) {
fs.ensureDirSync(path.join(this.options.to, this.sysdir(), path.dirname(to)));
let ogg = await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.ogg'), this.options.ogg);
return { files: [to + '.ogg'], sizes: [1] };
}
else {
fs.copySync(from.toString(), path.join(this.options.to, this.sysdir(), to + '.wav'), { overwrite: true });
return { files: [to + '.wav'], sizes: [1] };
}
}
async copyImage(platform, from, to, options, cache) {
if (platform === Platform_1.Platform.iOS && options.quality < 1) {
let format = await (0, ImageTool_1.exportImage)(this.options.kha, this.options.kraffiti, from, path.join(this.options.to, this.sysdir(), to), options, 'pvr', true, false, cache);
return { files: [to + '.' + format], sizes: [1] };
}
else if (platform === Platform_1.Platform.Windows && options.quality < 1 && (this.options.graphics === GraphicsApi_1.GraphicsApi.OpenGL || this.options.graphics === GraphicsApi_1.GraphicsApi.Vulkan)) {
// let format = await exportImage(this.options.kha, from, path.join(this.options.to, this.sysdir(), to), options, 'ASTC', true, false, cache);
let format = await (0, ImageTool_1.exportImage)(this.options.kha, this.options.kraffiti, from, path.join(this.options.to, this.sysdir(), to), options, 'DXT5', true, false, cache);
return { files: [to + '.' + format], sizes: [1] };
}
else {
let format = await (0, ImageTool_1.exportImage)(this.options.kha, this.options.kraffiti, from, path.join(this.options.to, this.sysdir(), to), options, 'lz4', true, false, cache);
return { files: [to + '.' + format], sizes: [1] };
}
}
async copyBlob(platform, from, to) {
fs.copySync(from.toString(), path.join(this.options.to, this.sysdir(), to).toString(), { overwrite: true });
return { files: [to], sizes: [1] };
}
async copyVideo(platform, from, to) {
fs.ensureDirSync(path.join(this.options.to, this.sysdir(), path.dirname(to)));
if (platform === Platform_1.Platform.Windows) {
await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.avi'), this.options.h264);
return { files: [to + '.avi'], sizes: [1] };
}
else if (platform === Platform_1.Platform.iOS || platform === Platform_1.Platform.OSX) {
await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.mp4'), this.options.h264);
return { files: [to + '.mp4'], sizes: [1] };
}
else if (platform === Platform_1.Platform.Android) {
await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.ts'), this.options.h264);
return { files: [to + '.ts'], sizes: [1] };
}
else {
await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.ogv'), this.options.theora);
return { files: [to + '.ogv'], sizes: [1] };
}
}
}
exports.KincHLExporter = KincHLExporter;
//# sourceMappingURL=KincHLExporter.js.map

View File

@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KoreExporter = void 0;
const fs = require("fs-extra");
const path = require("path");
const defaults = require("../defaults");
@ -8,6 +9,7 @@ const Converter_1 = require("../Converter");
const GraphicsApi_1 = require("../GraphicsApi");
const Platform_1 = require("../Platform");
const ImageTool_1 = require("../ImageTool");
const log = require("../log");
class KoreExporter extends KhaExporter_1.KhaExporter {
constructor(options) {
super(options);
@ -15,7 +17,7 @@ class KoreExporter extends KhaExporter_1.KhaExporter {
// Files.removeDirectory(this.directory.resolve(Paths.get(this.sysdir() + "-build", "Sources")));
}
backend() {
return 'Kore';
return 'Kore-hxcpp';
}
haxeOptions(name, targetOptions, defines) {
defines.push('no-compilation');
@ -80,7 +82,7 @@ class KoreExporter extends KhaExporter_1.KhaExporter {
async copySound(platform, from, to, options) {
if (options.quality < 1) {
fs.ensureDirSync(path.join(this.options.to, this.sysdir(), path.dirname(to)));
await Converter_1.convert(from, path.join(this.options.to, this.sysdir(), to + '.ogg'), this.options.ogg);
await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.ogg'), this.options.ogg);
return { files: [to + '.ogg'], sizes: [1] };
}
else {
@ -88,23 +90,24 @@ class KoreExporter extends KhaExporter_1.KhaExporter {
fs.copySync(from.toString(), path.join(this.options.to, this.sysdir(), to + '.wav'), { overwrite: true });
}
else {
throw 'Can not convert ' + from + ' to wav format.';
log.error('Can not convert ' + from + ' to wav format.\nSet `{quality: 0.99}` in `project.addAssets` if you want to convert your files to `ogg`.');
process.exit(1);
}
return { files: [to + '.wav'], sizes: [1] };
}
}
async copyImage(platform, from, to, options, cache) {
if (platform === Platform_1.Platform.iOS && options.quality < 1) {
let format = await ImageTool_1.exportImage(this.options.kha, from, path.join(this.options.to, this.sysdir(), to), options, 'pvr', true, false, cache);
let format = await (0, ImageTool_1.exportImage)(this.options.kha, this.options.kraffiti, from, path.join(this.options.to, this.sysdir(), to), options, 'pvr', true, false, cache);
return { files: [to + '.' + format], sizes: [1] };
}
else if (platform === Platform_1.Platform.Windows && options.quality < 1 && (this.options.graphics === GraphicsApi_1.GraphicsApi.OpenGL || this.options.graphics === GraphicsApi_1.GraphicsApi.Vulkan)) {
// let format = await exportImage(this.options.kha, from, path.join(this.options.to, this.sysdir(), to), options, 'ASTC', true, false, cache);
let format = await ImageTool_1.exportImage(this.options.kha, from, path.join(this.options.to, this.sysdir(), to), options, 'DXT5', true, false, cache);
let format = await (0, ImageTool_1.exportImage)(this.options.kha, this.options.kraffiti, from, path.join(this.options.to, this.sysdir(), to), options, 'DXT5', true, false, cache);
return { files: [to + '.' + format], sizes: [1] };
}
else {
let format = await ImageTool_1.exportImage(this.options.kha, from, path.join(this.options.to, this.sysdir(), to), options, 'lz4', true, false, cache);
let format = await (0, ImageTool_1.exportImage)(this.options.kha, this.options.kraffiti, from, path.join(this.options.to, this.sysdir(), to), options, 'lz4', true, false, cache);
return { files: [to + '.' + format], sizes: [1] };
}
}
@ -115,19 +118,19 @@ class KoreExporter extends KhaExporter_1.KhaExporter {
async copyVideo(platform, from, to) {
fs.ensureDirSync(path.join(this.options.to, this.sysdir(), path.dirname(to)));
if (platform === Platform_1.Platform.Windows) {
await Converter_1.convert(from, path.join(this.options.to, this.sysdir(), to + '.avi'), this.options.h264);
await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.avi'), this.options.h264);
return { files: [to + '.avi'], sizes: [1] };
}
else if (platform === Platform_1.Platform.iOS || platform === Platform_1.Platform.OSX) {
await Converter_1.convert(from, path.join(this.options.to, this.sysdir(), to + '.mp4'), this.options.h264);
await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.mp4'), this.options.h264);
return { files: [to + '.mp4'], sizes: [1] };
}
else if (platform === Platform_1.Platform.Android) {
await Converter_1.convert(from, path.join(this.options.to, this.sysdir(), to + '.ts'), this.options.h264);
await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.ts'), this.options.h264);
return { files: [to + '.ts'], sizes: [1] };
}
else {
await Converter_1.convert(from, path.join(this.options.to, this.sysdir(), to + '.ogv'), this.options.theora);
await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.ogv'), this.options.theora);
return { files: [to + '.ogv'], sizes: [1] };
}
}

View File

@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KoreHLExporter = void 0;
const fs = require("fs-extra");
const path = require("path");
const defaults = require("../defaults");
@ -8,13 +9,14 @@ const Converter_1 = require("../Converter");
const GraphicsApi_1 = require("../GraphicsApi");
const Platform_1 = require("../Platform");
const ImageTool_1 = require("../ImageTool");
const log = require("../log");
class KoreHLExporter extends KhaExporter_1.KhaExporter {
constructor(options) {
super(options);
// Files.removeDirectory(this.directory.resolve(Paths.get(this.sysdir() + "-build", "Sources")));
}
backend() {
return 'KoreHL';
return 'Kore-HL';
}
haxeOptions(name, targetOptions, defines) {
defines.push('no-compilation');
@ -72,26 +74,32 @@ class KoreHLExporter extends KhaExporter_1.KhaExporter {
async copySound(platform, from, to, options) {
if (options.quality < 1) {
fs.ensureDirSync(path.join(this.options.to, this.sysdir(), path.dirname(to)));
let ogg = await Converter_1.convert(from, path.join(this.options.to, this.sysdir(), to + '.ogg'), this.options.ogg);
let ogg = await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.ogg'), this.options.ogg);
return { files: [to + '.ogg'], sizes: [1] };
}
else {
fs.copySync(from.toString(), path.join(this.options.to, this.sysdir(), to + '.wav'), { overwrite: true });
if (from.endsWith('.wav')) {
fs.copySync(from.toString(), path.join(this.options.to, this.sysdir(), to + '.wav'), { overwrite: true });
}
else {
log.error('Can not convert ' + from + ' to wav format.\nSet `{quality: 0.99}` in `project.addAssets` if you want to convert your files to `ogg`.');
process.exit(1);
}
return { files: [to + '.wav'], sizes: [1] };
}
}
async copyImage(platform, from, to, options, cache) {
if (platform === Platform_1.Platform.iOS && options.quality < 1) {
let format = await ImageTool_1.exportImage(this.options.kha, from, path.join(this.options.to, this.sysdir(), to), options, 'pvr', true, false, cache);
let format = await (0, ImageTool_1.exportImage)(this.options.kha, this.options.kraffiti, from, path.join(this.options.to, this.sysdir(), to), options, 'pvr', true, false, cache);
return { files: [to + '.' + format], sizes: [1] };
}
else if (platform === Platform_1.Platform.Windows && options.quality < 1 && (this.options.graphics === GraphicsApi_1.GraphicsApi.OpenGL || this.options.graphics === GraphicsApi_1.GraphicsApi.Vulkan)) {
// let format = await exportImage(this.options.kha, from, path.join(this.options.to, this.sysdir(), to), options, 'ASTC', true, false, cache);
let format = await ImageTool_1.exportImage(this.options.kha, from, path.join(this.options.to, this.sysdir(), to), options, 'DXT5', true, false, cache);
let format = await (0, ImageTool_1.exportImage)(this.options.kha, this.options.kraffiti, from, path.join(this.options.to, this.sysdir(), to), options, 'DXT5', true, false, cache);
return { files: [to + '.' + format], sizes: [1] };
}
else {
let format = await ImageTool_1.exportImage(this.options.kha, from, path.join(this.options.to, this.sysdir(), to), options, 'lz4', true, false, cache);
let format = await (0, ImageTool_1.exportImage)(this.options.kha, this.options.kraffiti, from, path.join(this.options.to, this.sysdir(), to), options, 'lz4', true, false, cache);
return { files: [to + '.' + format], sizes: [1] };
}
}
@ -102,19 +110,19 @@ class KoreHLExporter extends KhaExporter_1.KhaExporter {
async copyVideo(platform, from, to) {
fs.ensureDirSync(path.join(this.options.to, this.sysdir(), path.dirname(to)));
if (platform === Platform_1.Platform.Windows) {
await Converter_1.convert(from, path.join(this.options.to, this.sysdir(), to + '.avi'), this.options.h264);
await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.avi'), this.options.h264);
return { files: [to + '.avi'], sizes: [1] };
}
else if (platform === Platform_1.Platform.iOS || platform === Platform_1.Platform.OSX) {
await Converter_1.convert(from, path.join(this.options.to, this.sysdir(), to + '.mp4'), this.options.h264);
await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.mp4'), this.options.h264);
return { files: [to + '.mp4'], sizes: [1] };
}
else if (platform === Platform_1.Platform.Android) {
await Converter_1.convert(from, path.join(this.options.to, this.sysdir(), to + '.ts'), this.options.h264);
await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.ts'), this.options.h264);
return { files: [to + '.ts'], sizes: [1] };
}
else {
await Converter_1.convert(from, path.join(this.options.to, this.sysdir(), to + '.ogv'), this.options.theora);
await (0, Converter_1.convert)(from, path.join(this.options.to, this.sysdir(), to + '.ogv'), this.options.theora);
return { files: [to + '.ogv'], sizes: [1] };
}
}

View File

@ -8,6 +8,7 @@ const KhaExporter_1 = require("./KhaExporter");
const Converter_1 = require("../Converter");
const GraphicsApi_1 = require("../GraphicsApi");
const ImageTool_1 = require("../ImageTool");
const log = require("../log");
class KromExporter extends KhaExporter_1.KhaExporter {
constructor(options) {
super(options);
@ -68,7 +69,13 @@ class KromExporter extends KhaExporter_1.KhaExporter {
return { files: [to + '.ogg'], sizes: [1] };
}
else {
fs.copySync(from.toString(), path.join(this.options.to, this.sysdir(), to + '.wav'), { overwrite: true });
if (from.endsWith('.wav')) {
fs.copySync(from.toString(), path.join(this.options.to, this.sysdir(), to + '.wav'), { overwrite: true });
}
else {
log.error('Can not convert ' + from + ' to wav format.\nSet `{quality: 0.99}` in `project.addAssets` if you want to convert your files to `ogg`.');
process.exit(1);
}
return { files: [to + '.wav'], sizes: [1] };
}
}

View File

@ -61,7 +61,9 @@ class HaxeCompiler {
this.scheduleCompile();
});
this.startCompilationServer();
this.triggerCompilationServer();
setTimeout(() => {
this.triggerCompilationServer();
}, 50);
}
else {
try {
@ -176,9 +178,11 @@ class HaxeCompiler {
process.stdout.write('\x1Bc');
log.info('Haxe compile end.');
if (this.isLiveReload) {
this.wsClients.forEach(client => {
client.send(JSON.stringify({}));
});
setTimeout(() => {
this.wsClients.forEach(client => {
client.send(JSON.stringify({}));
});
}, 200);
}
for (let callback of ProjectFile_1.Callbacks.postHaxeRecompilation) {
callback();
@ -216,14 +220,6 @@ class HaxeCompiler {
});
});
}
static spinRename(from, to) {
for (;;) {
if (fs.existsSync(from)) {
fs.renameSync(from, to);
return;
}
}
}
}
exports.HaxeCompiler = HaxeCompiler;
//# sourceMappingURL=HaxeCompiler.js.map

View File

@ -112,12 +112,14 @@ function hxml(projectdir, options) {
data += unique('-cp ' + path.relative(projectdir, path.resolve(options.from, options.sources[i])) + '\n'); // from.resolve('build').relativize(from.resolve(this.sources[i])).toString());
}
}
for (let i = 0; i < options.libraries.length; ++i) {
if (path.isAbsolute(options.libraries[i].libpath)) {
data += unique('-cp ' + options.libraries[i].libpath + '\n');
for (const lib of options.libraries) {
if (lib.classPathIsAdded)
continue;
if (path.isAbsolute(lib.libpath)) {
data += unique('-cp ' + lib.libpath + '\n');
}
else {
data += unique('-cp ' + path.relative(projectdir, path.resolve(options.from, options.libraries[i].libpath)) + '\n'); // from.resolve('build').relativize(from.resolve(this.sources[i])).toString());
data += unique('-cp ' + path.relative(projectdir, path.resolve(options.from, lib.libpath)) + '\n'); // from.resolve('build').relativize(from.resolve(this.sources[i])).toString());
}
}
for (let d in options.defines) {

View File

@ -38,7 +38,7 @@ function findIcon(icon, from, options) {
if (fs.existsSync(path.join(from, 'icon.png')))
return path.join(from, 'icon.png');
else
return path.join(options.kha, 'Kinc', 'Tools', exec.sysdir(), 'icon.png');
return path.join(options.kha, 'Kore', 'Tools', exec.sysdir(), 'icon.png');
}
function exportIco(icon, to, from, options) {
run(options.kraffiti, findIcon(icon, from.toString(), options), to.toString(), 0, 0, 'ico', undefined, false, function () { });

View File

@ -7,6 +7,13 @@ const path = require("path");
const log = require("./log");
const ProjectFile_1 = require("./ProjectFile");
class Library {
constructor() {
/**
* If haxelib `classPath` is specified,
* we don't add `libpath` as `-cp` to `hxml`.
*/
this.classPathIsAdded = false;
}
}
exports.Library = Library;
class Target {
@ -66,7 +73,7 @@ class Project {
if (!path.isAbsolute(projectDir)) {
projectDir = path.join(this.scriptdir, projectDir);
}
if (!fs.existsSync(path.join(projectDir, 'khafile.js')) && (fs.existsSync(path.join(projectDir, 'kincfile.js')) || fs.existsSync(path.join(projectDir, 'korefile.js')) || fs.existsSync(path.join(projectDir, 'kfile.js')))) {
if (!fs.existsSync(path.join(projectDir, 'khafile.js')) && (fs.existsSync(path.join(projectDir, 'kfile.js')) || fs.existsSync(path.join(projectDir, 'korefile.js')) || fs.existsSync(path.join(projectDir, 'kincfile.js')))) {
this.libraries.push({
libpath: projectDir,
libroot: projectDir
@ -176,14 +183,13 @@ class Project {
}
addLibrary(library) {
this.addDefine(library);
let self = this;
function findLibraryDirectory(name) {
const findLibraryDirectory = (name) => {
if (path.isAbsolute(name)) {
return { libpath: name, libroot: name };
}
// Tries to load the default library from inside the kha project.
// e.g. 'Libraries/wyngine'
let libpath = path.join(self.scriptdir, self.localLibraryPath, name);
let libpath = path.join(this.scriptdir, this.localLibraryPath, name);
if (fs.existsSync(libpath) && fs.statSync(libpath).isDirectory()) {
let dir = path.resolve(libpath);
return { libpath: dir, libroot: dir };
@ -223,7 +229,7 @@ class Project {
log.error('Error: Library ' + name + ' not found.');
log.error('Add it to the \'Libraries\' subdirectory of your project. You may also install it via haxelib but that\'s less cool.');
throw 'Library ' + name + ' not found.';
}
};
let libInfo = findLibraryDirectory(library);
let dir = libInfo.libpath;
if (dir !== '') {
@ -231,17 +237,18 @@ class Project {
if (elem.libroot === libInfo.libroot)
return '';
}
this.libraries.push({
const lib = {
libpath: dir,
libroot: libInfo.libroot
});
};
this.libraries.push(lib);
// If this is a haxelib library, there must be a haxelib.json
if (fs.existsSync(path.join(dir, 'haxelib.json'))) {
let options = JSON.parse(fs.readFileSync(path.join(dir, 'haxelib.json'), 'utf8'));
// If there is a classPath value, add that directory to be loaded.
// Otherwise, just load the current path.
if (options.classPath) {
// TODO find an example haxelib that has a classPath value
lib.classPathIsAdded = true;
this.sources.push(path.join(dir, options.classPath));
}
else {

View File

@ -197,14 +197,13 @@ class ShaderCompiler {
this.watcher.on('ready', async () => {
ready = true;
let compiledShaders = [];
const self = this;
async function compile(shader, index) {
const compile = async (shader, index) => {
let parsed = path.parse(shader);
if (self.isSupported(shader)) {
if (this.isSupported(shader)) {
log.info('Compiling shader ' + (index + 1) + ' of ' + shaders.length + ' (' + parsed.base + ').');
let compiledShader = null;
try {
compiledShader = await self.compileShader(shader, options, recompileAll);
compiledShader = await this.compileShader(shader, options, recompileAll);
}
catch (error) {
log.error('Compiling shader ' + (index + 1) + ' of ' + shaders.length + ' (' + parsed.base + ') failed:');
@ -223,9 +222,9 @@ class ShaderCompiler {
}
if (compiledShader.files != null && compiledShader.files.length === 0) {
// TODO: Remove when krafix has been recompiled everywhere
compiledShader.files.push(parsed.name + '.' + self.type);
compiledShader.files.push(parsed.name + '.' + this.type);
}
compiledShader.name = AssetConverter_1.AssetConverter.createExportInfo(parsed, false, options, self.exporter.options.from).name;
compiledShader.name = AssetConverter_1.AssetConverter.createExportInfo(parsed, false, options, this.exporter.options.from).name;
compiledShaders.push(compiledShader);
}
else {
@ -233,7 +232,7 @@ class ShaderCompiler {
}
++index;
return Promise.resolve();
}
};
if (this.options.parallelAssetConversion !== 0) {
let todo = shaders.map((shader, index) => {
return async () => {

View File

@ -29,7 +29,12 @@ function sysdir() {
return 'freebsd_x64';
}
else {
return 'macos';
if (os.arch() === 'arm64')
return 'macos_arm64';
else if (os.arch() === 'x64')
return 'macos_x64';
else
throw 'Unsupported CPU';
}
}
exports.sysdir = sysdir;

View File

@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.get = exports.init = void 0;
const path = require("path");
const exec_1 = require("./exec");
let korepath = path.join(__dirname, '..', '..', '..', 'Kinc', 'Tools', (0, exec_1.sysdir)());
let korepath = path.join(__dirname, '..', '..', '..', 'Kore', 'Tools', (0, exec_1.sysdir)());
function init(options) {
korepath = path.join(options.kha, 'Kinc', 'Tools', (0, exec_1.sysdir)());
korepath = path.join(options.kha, 'Kore', 'Tools', (0, exec_1.sysdir)());
}
exports.init = init;
function get() {

View File

@ -18,8 +18,8 @@ const FlashExporter_1 = require("./Exporters/FlashExporter");
const Html5Exporter_1 = require("./Exporters/Html5Exporter");
const Html5WorkerExporter_1 = require("./Exporters/Html5WorkerExporter");
const JavaExporter_1 = require("./Exporters/JavaExporter");
const KincExporter_1 = require("./Exporters/KincExporter");
const KincHLExporter_1 = require("./Exporters/KincHLExporter");
const KoreExporter_1 = require("./Exporters/KoreExporter");
const KoreHLExporter_1 = require("./Exporters/KoreHLExporter");
const KromExporter_1 = require("./Exporters/KromExporter");
const NodeExporter_1 = require("./Exporters/NodeExporter");
const PlayStationMobileExporter_1 = require("./Exporters/PlayStationMobileExporter");
@ -78,12 +78,12 @@ function createKorefile(name, exporter, options, targetOptions, libraries, cdefi
let buildpath = path.relative(options.from, path.join(options.to, exporter.sysdir() + '-build')).replace(/\\/g, '/');
if (buildpath.startsWith('..'))
buildpath = path.resolve(path.join(options.from.toString(), buildpath));
out += 'await project.addProject(\'' + path.join(options.kha, 'Kinc').replace(/\\/g, '/') + '\');\n';
out += 'await project.addProject(\'' + path.join(options.kha, 'Kore').replace(/\\/g, '/') + '\');\n';
out += 'await project.addProject(\'' + buildpath.replace(/\\/g, '/') + '\');\n';
if (korehl)
out += 'await project.addProject(\'' + path.join(options.kha, 'Backends', 'Kinc-HL').replace(/\\/g, '/') + '\');\n';
out += 'await project.addProject(\'' + path.join(options.kha, 'Backends', 'Kore-HL').replace(/\\/g, '/') + '\');\n';
else
out += 'await project.addProject(\'' + path.join(options.kha, 'Backends', 'Kinc-hxcpp').replace(/\\/g, '/') + '\');\n';
out += 'await project.addProject(\'' + path.join(options.kha, 'Backends', 'Kore-hxcpp').replace(/\\/g, '/') + '\');\n';
for (let lib of libraries) {
let libPath = lib.libpath.replace(/\\/g, '/');
out += 'if (fs.existsSync(path.join(\'' + libPath + '\', \'kfile.js\')) || fs.existsSync(path.join(\'' + libPath + '\', \'kincfile.js\')) || fs.existsSync(path.join(\'' + libPath + '\', \'korefile.js\'))) {\n';
@ -153,11 +153,10 @@ async function exportProjectFiles(name, resourceDir, options, exporter, kore, ko
let buildDir = path.join(options.to, exporter.sysdir() + '-build');
if (options.haxe !== '' && kore && !options.noproject) {
// If target is a Kore project, generate additional project folders here.
// generate the kincfile.js
// generate the kfile.js
fs.copySync(path.join(__dirname, '..', 'Data', 'hxcpp', 'kfile.js'), path.join(buildDir, 'kfile.js'), { overwrite: true });
fs.writeFileSync(path.join(options.to, 'kfile.js'), createKorefile(name, exporter, options, targetOptions, libraries, cdefines, cflags, cppflags, stackSize, version, id, false, icon));
// Similar to khamake.js -> main.js -> run(...)
// We now do kincmake.js -> main.js -> run(...)
// This will create additional project folders for the target,
// e.g. 'build/pi-build'
try {
@ -251,7 +250,7 @@ function checkKorePlatform(platform) {
|| platform === 'ps4'
|| platform === 'xboxone'
|| platform === 'switch'
|| platform === 'xboxscarlett'
|| platform === 'xboxseries'
|| platform === 'ps5'
|| platform === 'freebsd';
}
@ -332,7 +331,7 @@ async function exportKhaProject(options) {
log.error(`Unknown platform: ${target} (baseTarget=$${baseTarget})`);
return Promise.reject('');
}
exporter = new KincHLExporter_1.KincHLExporter(options);
exporter = new KoreHLExporter_1.KoreHLExporter(options);
}
else {
kore = true;
@ -341,7 +340,7 @@ async function exportKhaProject(options) {
log.error(`Unknown platform: ${target} (baseTarget=$${baseTarget})`);
return Promise.reject('');
}
exporter = new KincExporter_1.KincExporter(options);
exporter = new KoreExporter_1.KoreExporter(options);
}
break;
}
@ -612,16 +611,28 @@ async function run(options, loglog) {
let haxepath = path.join(options.kha, 'Tools', (0, exec_1.sysdir)());
if (fs.existsSync(haxepath) && fs.statSync(haxepath).isDirectory())
options.haxe = haxepath;
else
log.error('Haxe not found at ' + haxepath);
}
else {
log.info('Using Haxe from ' + options.haxe);
}
if (!options.krafix) {
let krafixpath = path.join(options.kha, 'Kinc', 'Tools', (0, exec_1.sysdir)(), 'krafix' + (0, exec_1.sys)());
let krafixpath = path.join(options.kha, 'Kore', 'Tools', (0, exec_1.sysdir)(), 'krafix' + (0, exec_1.sys)());
if (fs.existsSync(krafixpath))
options.krafix = krafixpath;
else
log.error('krafix not found at ' + krafixpath);
}
else {
log.info('Using krafix from ' + options.krafix);
}
if (!options.kraffiti) {
const kraffitipath = path.join(options.kha, 'Kinc', 'Tools', (0, exec_1.sysdir)(), 'kraffiti' + (0, exec_1.sys)());
const kraffitipath = path.join(options.kha, 'Kore', 'Tools', (0, exec_1.sysdir)(), 'kraffiti' + (0, exec_1.sys)());
if (fs.existsSync(kraffitipath))
options.kraffiti = kraffitipath;
else
log.error('kraffiti not found at ' + kraffitipath);
}
else {
log.info('Using kraffiti from ' + options.kraffiti);
@ -636,11 +647,15 @@ async function run(options, loglog) {
let oggpath = path.join(options.kha, 'Tools', (0, exec_1.sysdir)(), 'oggenc' + (0, exec_1.sys)());
if (fs.existsSync(oggpath))
options.ogg = oggpath + ' {in} -o {out} --quiet';
else
log.error('oggenc not found at ' + oggpath);
}
if (!options.mp3) {
let lamepath = path.join(options.kha, 'Tools', (0, exec_1.sysdir)(), 'lame' + (0, exec_1.sys)());
if (fs.existsSync(lamepath))
options.mp3 = lamepath + ' {in} {out}';
else
log.error('lame not found at ' + lamepath);
}
// if (!options.kravur) {
// let kravurpath = path.join(options.kha, 'Tools', 'kravur', 'kravur' + sys());
@ -662,8 +677,7 @@ async function run(options, loglog) {
options.theora = options.ffmpeg + ' -nostdin -i {in} {out}';
}
if (options.target === 'emscripten') {
console.log();
console.log('Please note that the html5 target\n'
log.info('\nPlease note that the html5 target\n'
+ 'is usually a better choice.\n'
+ 'In particular the html5 target usually runs faster\n'
+ 'than the emscripten target. That is because\n'
@ -672,8 +686,7 @@ async function run(options, loglog) {
+ 'all of the optimizations in modern JavaScript\n'
+ 'runtimes. The emscripten target on the other hand\n'
+ 'has to provide its own garbage collector and many\n'
+ 'other performance critical pieces of infrastructure.');
console.log();
+ 'other performance critical pieces of infrastructure.\n');
}
let name = '';
try {