This repository has been archived by the owner on Mar 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
463 lines (463 loc) · 14 KB
/
main.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
// Generated by Haxe 4.2.0
(function ($global) { "use strict";
var $estr = function() { return js_Boot.__string_rec(this,''); },$hxEnums = $hxEnums || {},$_;
function $extend(from, fields) {
var proto = Object.create(from);
for (var name in fields) proto[name] = fields[name];
if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString;
return proto;
}
function Main_main() {
var systemName = Sys.systemName();
switch(systemName) {
case "Linux":
Main_deleteDirectoryRecursively("hashlink");
process.stdout.write("---------------------");
process.stdout.write("\n");
var args = null;
if(args == null) {
js_node_ChildProcess.spawnSync("sudo apt-get install libpng-dev libturbojpeg-dev libvorbis-dev libopenal-dev libsdl2-dev libmbedtls-dev libuv1-dev",{ shell : true, stdio : "inherit"});
} else {
js_node_ChildProcess.spawnSync("sudo apt-get install libpng-dev libturbojpeg-dev libvorbis-dev libopenal-dev libsdl2-dev libmbedtls-dev libuv1-dev",args,{ stdio : "inherit"});
}
var args = null;
if(args == null) {
js_node_ChildProcess.spawnSync("sudo git clone https://github.com/HaxeFoundation/hashlink /usr/hashlink",{ shell : true, stdio : "inherit"});
} else {
js_node_ChildProcess.spawnSync("sudo git clone https://github.com/HaxeFoundation/hashlink /usr/hashlink",args,{ stdio : "inherit"});
}
process.chdir("/usr/hashlink");
var args = null;
if(args == null) {
js_node_ChildProcess.spawnSync("sudo make",{ shell : true, stdio : "inherit"});
} else {
js_node_ChildProcess.spawnSync("sudo make",args,{ stdio : "inherit"});
}
var args = null;
if(args == null) {
js_node_ChildProcess.spawnSync("sudo make all",{ shell : true, stdio : "inherit"});
} else {
js_node_ChildProcess.spawnSync("sudo make all",args,{ stdio : "inherit"});
}
var args = null;
if(args == null) {
js_node_ChildProcess.spawnSync("sudo make install",{ shell : true, stdio : "inherit"});
} else {
js_node_ChildProcess.spawnSync("sudo make install",args,{ stdio : "inherit"});
}
var args = null;
if(args == null) {
js_node_ChildProcess.spawnSync("sudo ldconfig",{ shell : true, stdio : "inherit"});
} else {
js_node_ChildProcess.spawnSync("sudo ldconfig",args,{ stdio : "inherit"});
}
var cmd = "echo \"" + process.cwd() + "\" >> " + process.env["GITHUB_PATH"];
var args = null;
if(args == null) {
js_node_ChildProcess.spawnSync(cmd,{ shell : true, stdio : "inherit"});
} else {
js_node_ChildProcess.spawnSync(cmd,args,{ stdio : "inherit"});
}
break;
case "Mac":
var args = null;
if(args == null) {
js_node_ChildProcess.spawnSync("/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"",{ shell : true, stdio : "inherit"});
} else {
js_node_ChildProcess.spawnSync("/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"",args,{ stdio : "inherit"});
}
var args = null;
if(args == null) {
js_node_ChildProcess.spawnSync("brew install hashlink",{ shell : true, stdio : "inherit"});
} else {
js_node_ChildProcess.spawnSync("brew install hashlink",args,{ stdio : "inherit"});
}
break;
case "Windows":
Main_deleteDirectoryRecursively("hashlink_windows");
process.stdout.write("---------------------");
process.stdout.write("\n");
var args = null;
if(args == null) {
js_node_ChildProcess.spawnSync("powershell.exe -Command wget -O hashlink.zip https://github.com/HaxeFoundation/hashlink/releases/download/1.11/hl-1.11.0-win.zip",{ shell : true, stdio : "inherit"});
} else {
js_node_ChildProcess.spawnSync("powershell.exe -Command wget -O hashlink.zip https://github.com/HaxeFoundation/hashlink/releases/download/1.11/hl-1.11.0-win.zip",args,{ stdio : "inherit"});
}
if(!sys_FileSystem.exists("hashlink_windows")) {
sys_FileSystem.createDirectory("hashlink_windows");
}
var args = null;
if(args == null) {
js_node_ChildProcess.spawnSync("powershell.exe -Command Expand-Archive hashlink.zip -DestinationPath hashlink_windows",{ shell : true, stdio : "inherit"});
} else {
js_node_ChildProcess.spawnSync("powershell.exe -Command Expand-Archive hashlink.zip -DestinationPath hashlink_windows",args,{ stdio : "inherit"});
}
process.chdir("hashlink_windows/hl-1.11.0-win");
var cmd = "powershell.exe -Command \"echo \"" + process.cwd() + "\" | Out-File -FilePath \"" + process.env["GITHUB_PATH"] + "\" -Encoding utf8 -Append\"";
var args = null;
if(args == null) {
js_node_ChildProcess.spawnSync(cmd,{ shell : true, stdio : "inherit"});
} else {
js_node_ChildProcess.spawnSync(cmd,args,{ stdio : "inherit"});
}
break;
}
if(systemName != "Mac") {
var v = process.cwd();
process.env["Hashlink"] = v;
var v = process.cwd();
process.env["HASHLINKPATH"] = v;
}
}
function Main_deleteDirectoryRecursively(dir) {
if(Sys.systemName() == "Windows") {
var cmd = "rmdir /s /q " + dir;
var args = null;
if(args == null) {
return js_node_ChildProcess.spawnSync(cmd,{ shell : true, stdio : "inherit"}).status;
} else {
return js_node_ChildProcess.spawnSync(cmd,args,{ stdio : "inherit"}).status;
}
} else {
var cmd = "rm -rf " + dir;
var args = null;
if(args == null) {
return js_node_ChildProcess.spawnSync(cmd,{ shell : true, stdio : "inherit"}).status;
} else {
return js_node_ChildProcess.spawnSync(cmd,args,{ stdio : "inherit"}).status;
}
}
}
Math.__name__ = true;
var Sys = function() { };
Sys.__name__ = true;
Sys.systemName = function() {
var _g = process.platform;
switch(_g) {
case "darwin":
return "Mac";
case "freebsd":
return "BSD";
case "linux":
return "Linux";
case "win32":
return "Windows";
default:
var other = _g;
return other;
}
};
var haxe_io_Output = function() { };
haxe_io_Output.__name__ = true;
var _$Sys_FileOutput = function(fd) {
this.fd = fd;
};
_$Sys_FileOutput.__name__ = true;
_$Sys_FileOutput.__super__ = haxe_io_Output;
_$Sys_FileOutput.prototype = $extend(haxe_io_Output.prototype,{
writeByte: function(c) {
js_node_Fs.writeSync(this.fd,String.fromCodePoint(c));
}
,writeBytes: function(s,pos,len) {
var data = s.b;
return js_node_Fs.writeSync(this.fd,js_node_buffer_Buffer.from(data.buffer,data.byteOffset,s.length),pos,len);
}
,writeString: function(s,encoding) {
js_node_Fs.writeSync(this.fd,s);
}
,flush: function() {
js_node_Fs.fsyncSync(this.fd);
}
,close: function() {
js_node_Fs.closeSync(this.fd);
}
});
var haxe_io_Input = function() { };
haxe_io_Input.__name__ = true;
var _$Sys_FileInput = function(fd) {
this.fd = fd;
};
_$Sys_FileInput.__name__ = true;
_$Sys_FileInput.__super__ = haxe_io_Input;
_$Sys_FileInput.prototype = $extend(haxe_io_Input.prototype,{
readByte: function() {
var buf = js_node_buffer_Buffer.alloc(1);
try {
js_node_Fs.readSync(this.fd,buf,0,1,null);
} catch( _g ) {
var e = haxe_Exception.caught(_g).unwrap();
if(e.code == "EOF") {
throw haxe_Exception.thrown(new haxe_io_Eof());
} else {
throw haxe_Exception.thrown(haxe_io_Error.Custom(e));
}
}
return buf[0];
}
,readBytes: function(s,pos,len) {
var data = s.b;
var buf = js_node_buffer_Buffer.from(data.buffer,data.byteOffset,s.length);
try {
return js_node_Fs.readSync(this.fd,buf,pos,len,null);
} catch( _g ) {
var e = haxe_Exception.caught(_g).unwrap();
if(e.code == "EOF") {
throw haxe_Exception.thrown(new haxe_io_Eof());
} else {
throw haxe_Exception.thrown(haxe_io_Error.Custom(e));
}
}
}
,close: function() {
js_node_Fs.closeSync(this.fd);
}
});
var haxe_Exception = function(message,previous,native) {
Error.call(this,message);
this.message = message;
this.__previousException = previous;
this.__nativeException = native != null ? native : this;
};
haxe_Exception.__name__ = true;
haxe_Exception.caught = function(value) {
if(((value) instanceof haxe_Exception)) {
return value;
} else if(((value) instanceof Error)) {
return new haxe_Exception(value.message,null,value);
} else {
return new haxe_ValueException(value,null,value);
}
};
haxe_Exception.thrown = function(value) {
if(((value) instanceof haxe_Exception)) {
return value.get_native();
} else if(((value) instanceof Error)) {
return value;
} else {
var e = new haxe_ValueException(value);
return e;
}
};
haxe_Exception.__super__ = Error;
haxe_Exception.prototype = $extend(Error.prototype,{
unwrap: function() {
return this.__nativeException;
}
,get_native: function() {
return this.__nativeException;
}
});
var haxe_ValueException = function(value,previous,native) {
haxe_Exception.call(this,String(value),previous,native);
this.value = value;
};
haxe_ValueException.__name__ = true;
haxe_ValueException.__super__ = haxe_Exception;
haxe_ValueException.prototype = $extend(haxe_Exception.prototype,{
unwrap: function() {
return this.value;
}
});
var haxe_io_Bytes = function(data) {
this.length = data.byteLength;
this.b = new Uint8Array(data);
this.b.bufferValue = data;
data.hxBytes = this;
data.bytes = this.b;
};
haxe_io_Bytes.__name__ = true;
var haxe_io_Encoding = $hxEnums["haxe.io.Encoding"] = { __ename__:true,__constructs__:null
,UTF8: {_hx_name:"UTF8",_hx_index:0,__enum__:"haxe.io.Encoding",toString:$estr}
,RawNative: {_hx_name:"RawNative",_hx_index:1,__enum__:"haxe.io.Encoding",toString:$estr}
};
haxe_io_Encoding.__constructs__ = [haxe_io_Encoding.UTF8,haxe_io_Encoding.RawNative];
var haxe_io_Eof = function() {
};
haxe_io_Eof.__name__ = true;
haxe_io_Eof.prototype = {
toString: function() {
return "Eof";
}
};
var haxe_io_Error = $hxEnums["haxe.io.Error"] = { __ename__:true,__constructs__:null
,Blocked: {_hx_name:"Blocked",_hx_index:0,__enum__:"haxe.io.Error",toString:$estr}
,Overflow: {_hx_name:"Overflow",_hx_index:1,__enum__:"haxe.io.Error",toString:$estr}
,OutsideBounds: {_hx_name:"OutsideBounds",_hx_index:2,__enum__:"haxe.io.Error",toString:$estr}
,Custom: ($_=function(e) { return {_hx_index:3,e:e,__enum__:"haxe.io.Error",toString:$estr}; },$_._hx_name="Custom",$_.__params__ = ["e"],$_)
};
haxe_io_Error.__constructs__ = [haxe_io_Error.Blocked,haxe_io_Error.Overflow,haxe_io_Error.OutsideBounds,haxe_io_Error.Custom];
var haxe_iterators_ArrayIterator = function(array) {
this.current = 0;
this.array = array;
};
haxe_iterators_ArrayIterator.__name__ = true;
haxe_iterators_ArrayIterator.prototype = {
hasNext: function() {
return this.current < this.array.length;
}
,next: function() {
return this.array[this.current++];
}
};
var js_Boot = function() { };
js_Boot.__name__ = true;
js_Boot.__string_rec = function(o,s) {
if(o == null) {
return "null";
}
if(s.length >= 5) {
return "<...>";
}
var t = typeof(o);
if(t == "function" && (o.__name__ || o.__ename__)) {
t = "object";
}
switch(t) {
case "function":
return "<function>";
case "object":
if(o.__enum__) {
var e = $hxEnums[o.__enum__];
var con = e.__constructs__[o._hx_index];
var n = con._hx_name;
if(con.__params__) {
s = s + "\t";
return n + "(" + ((function($this) {
var $r;
var _g = [];
{
var _g1 = 0;
var _g2 = con.__params__;
while(true) {
if(!(_g1 < _g2.length)) {
break;
}
var p = _g2[_g1];
_g1 = _g1 + 1;
_g.push(js_Boot.__string_rec(o[p],s));
}
}
$r = _g;
return $r;
}(this))).join(",") + ")";
} else {
return n;
}
}
if(((o) instanceof Array)) {
var str = "[";
s += "\t";
var _g = 0;
var _g1 = o.length;
while(_g < _g1) {
var i = _g++;
str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
}
str += "]";
return str;
}
var tostr;
try {
tostr = o.toString;
} catch( _g ) {
return "???";
}
if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
var s2 = o.toString();
if(s2 != "[object Object]") {
return s2;
}
}
var str = "{\n";
s += "\t";
var hasp = o.hasOwnProperty != null;
var k = null;
for( k in o ) {
if(hasp && !o.hasOwnProperty(k)) {
continue;
}
if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
continue;
}
if(str.length != 2) {
str += ", \n";
}
str += s + k + " : " + js_Boot.__string_rec(o[k],s);
}
s = s.substring(1);
str += "\n" + s + "}";
return str;
case "string":
return o;
default:
return String(o);
}
};
var js_node_ChildProcess = require("child_process");
var js_node_Fs = require("fs");
var js_node_KeyValue = {};
js_node_KeyValue.get_key = function(this1) {
return this1[0];
};
js_node_KeyValue.get_value = function(this1) {
return this1[1];
};
var js_node_Path = require("path");
var js_node_buffer_Buffer = require("buffer").Buffer;
var js_node_stream_WritableNewOptionsAdapter = {};
js_node_stream_WritableNewOptionsAdapter.from = function(options) {
if(!Object.prototype.hasOwnProperty.call(options,"final")) {
Object.defineProperty(options,"final",{ get : function() {
return options.final_;
}});
}
return options;
};
var js_node_url_URLSearchParamsEntry = {};
js_node_url_URLSearchParamsEntry._new = function(name,value) {
var this1 = [name,value];
return this1;
};
js_node_url_URLSearchParamsEntry.get_name = function(this1) {
return this1[0];
};
js_node_url_URLSearchParamsEntry.get_value = function(this1) {
return this1[1];
};
var sys_FileSystem = function() { };
sys_FileSystem.__name__ = true;
sys_FileSystem.exists = function(path) {
try {
js_node_Fs.accessSync(path);
return true;
} catch( _g ) {
return false;
}
};
sys_FileSystem.createDirectory = function(path) {
try {
js_node_Fs.mkdirSync(path);
} catch( _g ) {
var e = haxe_Exception.caught(_g).unwrap();
if(e.code == "ENOENT") {
sys_FileSystem.createDirectory(js_node_Path.dirname(path));
js_node_Fs.mkdirSync(path);
} else {
var stat;
try {
stat = js_node_Fs.statSync(path);
} catch( _g1 ) {
throw e;
}
if(!stat.isDirectory()) {
throw e;
}
}
}
};
if( String.fromCodePoint == null ) String.fromCodePoint = function(c) { return c < 0x10000 ? String.fromCharCode(c) : String.fromCharCode((c>>10)+0xD7C0)+String.fromCharCode((c&0x3FF)+0xDC00); }
String.__name__ = true;
Array.__name__ = true;
js_Boot.__toStr = ({ }).toString;
Main_main();
})({});