-
Notifications
You must be signed in to change notification settings - Fork 2
/
Importer.Darwin.GC.pas
117 lines (101 loc) · 4.12 KB
/
Importer.Darwin.GC.pas
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
namespace RemObjects.Elements.HI2;
uses
RemObjects.Elements.RTL;
type
Importer = public partial class
public
property GCSourceFolder: String; // for GC import, folder that has the GIT chdeckout from ssh://[email protected]/source/gc.git
property GCBinariesFolder: String; // for GC import, optional folder that has the GC binaries
method ImportGC;
begin
for each (a, v) in Darwin.AllIslandDarwinArchitectures do
ImportGC(a, v);
if defined("ECHOES") and CreateZips then begin
var lTargetZipName := Path.Combine(BaseFolder, "GC", "Darwin.zip");
writeLn($"Creating {lTargetZipName}");
CreateZip(Path.Combine(BaseFolder, "GC", "Darwin"), lTargetZipName);
end;
end;
method MergeGCArchitectures(aSDKName: String);
begin
MergeArchitectures(Path.Combine(BaseFolder, "GC", "Darwin", aSDKName), "gc.fx");
end;
method ImportGC(aArchitecture: Architecture; aVersion:String);
begin
var lJsonString := "{
'TargetString': '...',
'Version': '...',
'SDKVersionString': '...',
'SDKName': '...',
'Island': true,
'Imports': [
{
'Name': 'gc',
'Framework': false,
'Prefix': '',
'ForceNamespace': 'gc',
'Explicit': false,
'Files': [ 'gc.h' ],
'DepLibs': [ 'libgc.a' ],
'ImportDefs': []
}
],
'Defines': ['GC_THREADS', 'GC_NO_THREAD_DECLS'],
'Platform': 'Darwin'
}".Replace("'", '"');
var lBaseJson := JsonDocument.FromString(lJsonString);
var lTargetString := aArchitecture.Triple;
if length(aArchitecture.CpuType) > 0 then
lTargetString := lTargetString+";"+aArchitecture.CpuType;
lBaseJson["TargetString"] := lTargetString;
lBaseJson["Version"] := aVersion;
lBaseJson["SDKVersionString"] := aVersion;
lBaseJson["SDKName"] := aArchitecture.SDKName;
Folder.Create(BaseFolder);
var lBaseJsonFile := Path.Combine(BaseFolder, aArchitecture.Triple+".gc-json");
File.WriteText(lBaseJsonFile, lBaseJson.ToString);
var lArch := aArchitecture.Triple.SubstringToFirstOccurrenceOf("-");
var lSDK := aArchitecture.DisplaySDKName+" "+aVersion;
var lSDKName := aArchitecture.DisplaySDKName;
if aArchitecture.Simulator then begin
lSDK := lSDK+" Simulator";
lSDKName := lSDKName+" Simulator";
end
else if aArchitecture.MacCatalyst then begin
//lSDK := "UIKit for Mac "+aVersion;
lSDKName := "Mac Catalyst";
end;
var lOutPath := Path.Combine(BaseFolder, "GC", "Darwin", lSDKName, lArch);
var lArgs := new List<String>;
lArgs.Add("import");
lArgs.Add("--json="+lBaseJsonFile);
lArgs.Add("--fxpaths="+Path.Combine(SDKsBaseFolder, lSDK));
lArgs.Add("--include="+Path.Combine(GCSourceFolder, "include"));
lArgs.Add("--outpath="+lOutPath);
RunHI(lArgs);
if GCBinariesFolder:FolderExists then begin
//var lBinary := Path.Combine(GCBinariesFolder, "gc-"+aArchitecture.OS.ToLower+"-"+(if aArchitecture.Simulator then "-simulator" else "")+aArchitecture.Triple+".a");
//writeLn($"checking {lBinary}");
//if lBinary.FileExists then begin
//writeLn($'lBinary {lBinary}');
//File.CopyTo(lBinary, Path.Combine(lOutPath, "libgc.a"));
//end
/*else*/ begin
var lBinary := Path.Combine(GCBinariesFolder, lSDKName, aArchitecture.Arch, "libgc.a");
if lBinary.FileExists then begin
File.CopyTo(lBinary, Path.Combine(lOutPath, "libgc.a"));
end
else begin
lBinary := Path.Combine(GCBinariesFolder, lSDKName, aArchitecture.Arch, "libgc.a");
if lBinary.FileExists then begin
File.CopyTo(lBinary, Path.Combine(lOutPath, "libgc.a"));
end
else begin
writeLn("No binary at "+lBinary);
end;
end;
end;
end;
end;
end;
end.