forked from Kode/khamake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJavaExporter.js
118 lines (100 loc) · 3.5 KB
/
JavaExporter.js
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
116
117
118
"use strict";
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 Options = require('./Options.js');
const Paths = require('./Paths.js');
const exportImage = require('./ImageTool.js');
const fs = require('fs-extra');
const HaxeProject = require('./HaxeProject.js');
class JavaExporter extends KhaExporter {
constructor(khaDirectory, directory) {
super(khaDirectory, directory);
this.directory = directory;
}
sysdir() {
return 'java';
}
exportSolution(name, platform, khaDirectory, haxeDirectory, from, _targetOptions) {
this.addSourceDirectory("Kha/Backends/" + this.backend());
this.createDirectory(this.directory.resolve(this.sysdir()));
const defines = [
'no-compilation',
'sys_' + platform,
'sys_g1', 'sys_g2',
'sys_a1'
];
const options = {
from: from.toString(),
to: path.join(this.sysdir(), 'Sources'),
sources: this.sources,
defines: defines,
parameters: this.parameters,
haxeDirectory: haxeDirectory.toString(),
system: this.sysdir(),
language: 'java',
width: this.width,
height: this.height,
name: name
};
HaxeProject(this.directory.toString(), options);
Files.removeDirectory(this.directory.resolve(Paths.get(this.sysdir(), "Sources")));
let result = Haxe.executeHaxe(this.directory, haxeDirectory, ['project-' + this.sysdir() + '.hxml']);
this.exportEclipseProject();
return result;
}
backend() {
return 'Java';
}
exportEclipseProject() {
this.writeFile(this.directory.resolve(Paths.get(this.sysdir(), ".classpath")));
this.p("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
this.p("<classpath>");
this.p("\t<classpathentry kind=\"src\" path=\"Sources/src\"/>");
this.p("\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>");
this.p("\t<classpathentry kind=\"output\" path=\"bin\"/>");
this.p("</classpath>");
this.closeFile();
this.writeFile(this.directory.resolve(Paths.get(this.sysdir(), ".project")));
this.p("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
this.p("<projectDescription>");
this.p("\t<name>" + this.getCurrentDirectoryName(this.directory) + "</name>");
this.p("\t<comment></comment>");
this.p("\t<projects>");
this.p("\t</projects>");
this.p("\t<buildSpec>");
this.p("\t\t<buildCommand>");
this.p("\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>");
this.p("\t\t\t<arguments>");
this.p("\t\t\t</arguments>");
this.p("\t\t</buildCommand>");
this.p("\t</buildSpec>");
this.p("\t<natures>");
this.p("\t\t<nature>org.eclipse.jdt.core.javanature</nature>");
this.p("\t</natures>");
this.p("</projectDescription>");
this.closeFile();
}
/*copyMusic(platform, from, to, encoders) {
this.copyFile(from, this.directory.resolve(this.sysdir()).resolve(to + '.wav'));
callback([to + '.wav']);
}*/
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) {
let format = exportImage(from, this.directory.resolve(this.sysdir()).resolve(to), asset, undefined, false);
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) {
return [to];
}
}
module.exports = JavaExporter;