forked from Kode/khamake
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKoreExporter.js
More file actions
115 lines (102 loc) · 3.72 KB
/
KoreExporter.js
File metadata and controls
115 lines (102 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
"use strict";
const fs = require('fs-extra');
const path = require('path');
const KhaExporter = require('./KhaExporter.js');
const Converter = require('./Converter.js');
const Files = require('./Files.js');
const Haxe = require('./Haxe.js');
const Paths = require('./Paths.js');
const Platform = require('./Platform.js');
const exportImage = require('./ImageTool.js');
const HaxeProject = require('./HaxeProject.js');
class KoreExporter extends KhaExporter {
constructor(platform, khaDirectory, vr, directory) {
super(khaDirectory, directory);
this.platform = platform;
this.directory = directory;
this.addSourceDirectory(path.join(khaDirectory.toString(), 'Backends/Kore'));
this.vr = vr;
}
sysdir() {
return this.platform;
}
exportSolution(name, platform, khaDirectory, haxeDirectory, from, _targetOptions) {
let defines = [
'no-compilation',
'sys_' + platform,
'sys_g1', 'sys_g2', 'sys_g3', 'sys_g4',
'sys_a1', 'sys_a2'
];
if (this.vr === 'gearvr') {
defines.push('vr_gearvr');
}
else if (this.vr === 'cardboard') {
defines.push('vr_cardboard');
}
else if (this.vr === 'rift') {
defines.push('vr_rift');
}
const options = {
from: from.toString(),
to: path.join(this.sysdir() + '-build', 'Sources'),
sources: this.sources,
defines: defines,
parameters: this.parameters,
haxeDirectory: haxeDirectory.toString(),
system: this.sysdir(),
language: 'cpp',
width: this.width,
height: this.height,
name: name
};
HaxeProject(this.directory.toString(), options);
//Files.removeDirectory(this.directory.resolve(Paths.get(this.sysdir() + "-build", "Sources")));
return Haxe.executeHaxe(this.directory, haxeDirectory, ["project-" + this.sysdir() + ".hxml"]);
}
/*copyMusic(platform, from, to, encoders, callback) {
Files.createDirectories(this.directory.resolve(this.sysdir()).resolve(to).parent());
Converter.convert(from, this.directory.resolve(this.sysdir()).resolve(to + '.ogg'), encoders.oggEncoder, (success) => {
callback([to + '.ogg']);
});
}*/
copySound(platform, from, to, encoders) {
fs.copySync(from.toString(), this.directory.resolve(this.sysdir()).resolve(to + '.wav').toString(), { clobber: true });
return [to + '.wav'];
}
copyImage(platform, from, to, asset) {
if (platform === Platform.iOS && asset.compressed) {
let format = exportImage(from, this.directory.resolve(this.sysdir()).resolve(to), asset, 'pvr', true);
return [to + '.' + format];
}
/*else if (platform === Platform.Android && asset.compressed) {
var index = to.toString().lastIndexOf('.');
to = to.toString().substr(0, index) + '.astc';
asset.file = to.toString().replaceAll('\\', '/');
exportImage(from, this.directory.resolve(this.sysdir()).resolve(to), asset, 'astc', true, callback);
}*/
else {
let format = exportImage(from, this.directory.resolve(this.sysdir()).resolve(to), asset, undefined, true);
return [to + '.' + format];
}
}
copyBlob(platform, from, to) {
fs.copySync(from.toString(), this.directory.resolve(this.sysdir()).resolve(to).toString(), { clobber: true });
return [to];
}
copyVideo(platform, from, to, encoders) {
Files.createDirectories(this.directory.resolve(this.sysdir()).resolve(to).parent());
if (platform === Platform.iOS) {
Converter.convert(from, this.directory.resolve(this.sysdir()).resolve(to + '.mp4'), encoders.h264Encoder);
return [to + '.mp4'];
}
else if (platform === Platform.Android) {
Converter.convert(from, this.directory.resolve(this.sysdir()).resolve(to + '.ts'), encoders.h264Encoder);
return [to + '.ts'];
}
else {
Converter.convert(from, this.directory.resolve(this.sysdir()).resolve(to + '.ogv'), encoders.theoraEncoder);
return [to + '.ogv'];
}
}
}
module.exports = KoreExporter;