forked from Kode/khamake
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSharpExporter.js
More file actions
118 lines (102 loc) · 3.85 KB
/
CSharpExporter.js
File metadata and controls
118 lines (102 loc) · 3.85 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
116
117
118
"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 Options = require('./Options.js');
const Paths = require('./Paths.js');
const exportImage = require('./ImageTool.js');
const uuid = require('./uuid.js');
const HaxeProject = require('./HaxeProject.js');
class CSharpExporter extends KhaExporter {
constructor(khaDirectory, directory) {
super(khaDirectory, directory);
this.directory = directory;
}
includeFiles(dir, baseDir) {
if (dir.path.length == 0 || !Files.exists(dir)) return;
let files = Files.newDirectoryStream(dir);
for (var f in files) {
let file = dir.resolve(files[f]);
if (Files.isDirectory(file)) this.includeFiles(file, baseDir);
else if (file.getFileName().endsWith(".cs")) {
this.p("<Compile Include=\"" + baseDir.relativize(file).toString().replaceAll('/', '\\') + "\" />", 2);
}
}
}
exportSolution(name, platform, khaDirectory, haxeDirectory, from, _targetOptions) {
this.addSourceDirectory("Kha/Backends/" + this.backend());
const defines = [
'no-root',
'no-compilation',
'sys_' + platform,
'sys_g1', 'sys_g2',
'sys_a1'
];
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: 'cs',
width: this.width,
height: this.height,
name: name
};
HaxeProject(this.directory.toString(), options);
Files.removeDirectory(this.directory.resolve(Paths.get(this.sysdir() + "-build", "Sources")));
let result = Haxe.executeHaxe(this.directory, haxeDirectory, ['project-' + this.sysdir() + '.hxml']);
const projectUuid = uuid.v4();
this.exportSLN(projectUuid);
this.exportCsProj(projectUuid);
this.exportResources();
return result;
}
exportSLN(projectUuid) {
this.writeFile(this.directory.resolve(Paths.get(this.sysdir() + "-build", "Project.sln")));
const solutionUuid = uuid.v4();
this.p("Microsoft Visual Studio Solution File, Format Version 11.00");
this.p("# Visual Studio 2010");
this.p("Project(\"{" + solutionUuid.toString().toUpperCase() + "}\") = \"HaxeProject\", \"Project.csproj\", \"{" + projectUuid.toString().toUpperCase() + "}\"");
this.p("EndProject");
this.p("Global");
this.p("GlobalSection(SolutionConfigurationPlatforms) = preSolution", 1);
this.p("Debug|x86 = Debug|x86", 2);
this.p("Release|x86 = Release|x86", 2);
this.p("EndGlobalSection", 1);
this.p("GlobalSection(ProjectConfigurationPlatforms) = postSolution", 1);
this.p("{" + projectUuid.toString().toUpperCase() + "}.Debug|x86.ActiveCfg = Debug|x86", 2);
this.p("{" + projectUuid.toString().toUpperCase() + "}.Debug|x86.Build.0 = Debug|x86", 2);
this.p("{" + projectUuid.toString().toUpperCase() + "}.Release|x86.ActiveCfg = Release|x86", 2);
this.p("{" + projectUuid.toString().toUpperCase() + "}.Release|x86.Build.0 = Release|x86", 2);
this.p("EndGlobalSection", 1);
this.p("GlobalSection(SolutionProperties) = preSolution", 1);
this.p("HideSolutionNode = FALSE", 2);
this.p("EndGlobalSection", 1);
this.p("EndGlobal");
this.closeFile();
}
/*copyMusic(platform, from, to, encoders) {
return [to];
}*/
copySound(platform, from, to, encoders) {
return [to];
}
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 = CSharpExporter;