|
1 | | -namespace EventHorizon.Blazor.TypeScript.Interop.Generator.ConsoleApp |
| 1 | +namespace EventHorizon.Blazor.TypeScript.Interop.Generator.ConsoleApp; |
| 2 | + |
| 3 | +using System.Collections.Generic; |
| 4 | +using System.Diagnostics; |
| 5 | +using System.IO; |
| 6 | +using EventHorizon.Blazor.TypeScript.Interop.Generator.Formatter; |
| 7 | +using EventHorizon.Blazor.TypeScript.Interop.Generator.Logging; |
| 8 | +using ServerGenerator = Blazor.Interop.Generator.GenerateInteropSource; |
| 9 | +using ServerProjectWriter = Blazor.Interop.Generator.Writers.Project.ServerProjectWriter; |
| 10 | +using WasmGenerator = GenerateSource; |
| 11 | +using WasmProjectWriter = Writers.Project.ProjectWriter; |
| 12 | + |
| 13 | +public class Program |
2 | 14 | { |
3 | | - using System.Collections.Generic; |
4 | | - using System.Diagnostics; |
5 | | - using System.IO; |
6 | | - using EventHorizon.Blazor.TypeScript.Interop.Generator.Formatter; |
7 | | - using EventHorizon.Blazor.TypeScript.Interop.Generator.Logging; |
| 15 | + static void Main(string[] args) |
| 16 | + { |
| 17 | + // pre-05/26/2024 - 75084ms/71877ms to generate. |
| 18 | + // 05/26/2024 - 26662ms/27904ms/27486ms to generate. |
| 19 | + Run(AstParser.Model.ASTParserType.NodeJS, true, "EventHorizon.Blazor.BabylonJS.NodeJS"); |
8 | 20 |
|
9 | | - using ServerGenerator = Blazor.Interop.Generator.GenerateInteropSource; |
10 | | - using ServerProjectWriter = Blazor.Interop.Generator.Writers.Project.ServerProjectWriter; |
11 | | - using WasmGenerator = GenerateSource; |
12 | | - using WasmProjectWriter = Writers.Project.ProjectWriter; |
| 21 | + // pre-05/26/2024 - 22027ms/19835ms/18236ms to generate. |
| 22 | + // 05/26/2024 - 10116ms/9721ms/9762ms to generate. |
| 23 | + Run(AstParser.Model.ASTParserType.Sdcb, true, "EventHorizon.Blazor.BabylonJS.WASM"); |
| 24 | + |
| 25 | + // 05/26/2024 - 10545ms/10603ms/10318ms to generate. |
| 26 | + Run(AstParser.Model.ASTParserType.Sdcb, false, "EventHorizon.Blazor.BabylonJS.Server"); |
| 27 | + } |
13 | 28 |
|
14 | | - public class Program |
| 29 | + static void Run(AstParser.Model.ASTParserType type, bool useWasm, string projectAssembly) |
15 | 30 | { |
16 | | - static void Main(string[] args) |
| 31 | + var stopwatch = Stopwatch.StartNew(); |
| 32 | + //var projectAssembly = "EventHorizon.Blazor.BabylonJS.WASM"; |
| 33 | + var projectGenerationLocation = Path.Combine("..", "_generated"); |
| 34 | + |
| 35 | + var sourceDirectory = Path.Combine(".", "SourceFiles"); |
| 36 | + var textFormatter = new CSharpTextFormatter(); |
| 37 | + var sourceFiles = new List<string> |
17 | 38 | { |
18 | | - //Run(AstParser.Model.ASTParserType.NodeJS, true); // 75084ms/71877ms to generate. |
19 | | - Run( |
20 | | - AstParser.Model.ASTParserType.Sdcb, |
21 | | - true, |
22 | | - "EventHorizon.Blazor.BabylonJS.WASM" |
23 | | - ); // 22027ms/19835ms/18236ms to generate. |
24 | | - //Run( |
25 | | - // AstParser.Model.ASTParserType.Sdcb, |
26 | | - // false, |
27 | | - // "EventHorizon.Blazor.BabylonJS.Server" |
28 | | - //); |
29 | | - } |
30 | | - static void Run( |
31 | | - AstParser.Model.ASTParserType type, |
32 | | - bool useWasm, |
33 | | - string projectAssembly |
34 | | - ) |
| 39 | + //"testing.d.ts", |
| 40 | + "babylon.d.ts", |
| 41 | + "babylon.gui.d.ts", |
| 42 | + }; |
| 43 | + var generationList = new List<string> |
35 | 44 | { |
36 | | - var stopwatch = Stopwatch.StartNew(); |
37 | | - //var projectAssembly = "EventHorizon.Blazor.BabylonJS.WASM"; |
38 | | - var projectGenerationLocation = Path.Combine( |
39 | | - "..", |
40 | | - "_generated" |
41 | | - ); |
| 45 | + //"Everything", |
| 46 | + "Scene", |
| 47 | + "VertexBuffer", |
| 48 | + "ICameraInput", |
| 49 | + "AbstractActionManager", |
| 50 | + "ICustomAnimationFrameRequester", |
| 51 | + "IAction", |
| 52 | + "Vector3", |
| 53 | + "EventState", |
| 54 | + "Observable", |
| 55 | + "Container", |
| 56 | + "Control", |
| 57 | + "Button", |
| 58 | + "UniversalCamera", |
| 59 | + "ArcRotateCamera", |
| 60 | + "PointLight", |
| 61 | + "Grid", |
| 62 | + "StackPanel", |
| 63 | + "MeshBuilder", |
| 64 | + "StandardMaterial", |
| 65 | + "Texture", |
| 66 | + "HemisphericLight", |
| 67 | + "PointerInfo", |
| 68 | + "PointerInfoBase", |
| 69 | + "SceneLoader", |
| 70 | + "ParticleHelper", |
| 71 | + "Sound", |
| 72 | + "Tools", |
| 73 | + }; |
42 | 74 |
|
43 | | - var sourceDirectory = Path.Combine( |
44 | | - ".", |
45 | | - "SourceFiles" |
46 | | - ); |
47 | | - var textFormatter = new NoFormattingTextFormatter(); |
48 | | - var sourceFiles = new List<string> |
49 | | - { |
50 | | - //"testing.d.ts", |
51 | | - "babylon.d.ts", |
52 | | - "babylon.gui.d.ts", |
53 | | - }; |
54 | | - var generationList = new List<string> |
55 | | - { |
56 | | - //"Everything", |
57 | | - "Scene", |
58 | | - "VertexBuffer", |
59 | | - "ICameraInput", |
60 | | - "AbstractActionManager", |
61 | | - "ICustomAnimationFrameRequester", |
62 | | - "IAction", |
63 | | - "Vector3", |
64 | | - "EventState", |
65 | | - "Observable", |
66 | | - "Container", |
67 | | - "Control", |
68 | | - "Button", |
69 | | - "UniversalCamera", |
70 | | - "ArcRotateCamera", |
71 | | - "PointLight", |
72 | | - "Grid", |
73 | | - "StackPanel", |
74 | | - "MeshBuilder", |
75 | | - "StandardMaterial", |
76 | | - "Texture", |
77 | | - "HemisphericLight", |
78 | | - "PointerInfo", |
79 | | - "PointerInfoBase", |
80 | | - "SceneLoader", |
81 | | - "ParticleHelper", |
82 | | - "Sound", |
83 | | - "Tools", |
84 | | - }; |
| 75 | + // Remove any already Generated Source. |
| 76 | + if (Directory.Exists(Path.Combine(projectGenerationLocation, projectAssembly))) |
| 77 | + { |
| 78 | + Directory.Delete(Path.Combine(projectGenerationLocation, projectAssembly), true); |
| 79 | + } |
| 80 | + GlobalLogger.Info("Removed Generation Directory"); |
85 | 81 |
|
86 | | - // Remove any already Generated Source. |
87 | | - if (Directory.Exists(Path.Combine( |
| 82 | + if (useWasm) |
| 83 | + { |
| 84 | + GlobalLogger.Info("Running Wasm Generator"); |
| 85 | + var writer = new WasmProjectWriter(projectGenerationLocation, projectAssembly); |
| 86 | + new WasmGenerator().Run( |
| 87 | + projectAssembly, |
| 88 | + sourceDirectory, |
| 89 | + sourceFiles, |
| 90 | + generationList, |
| 91 | + writer, |
| 92 | + textFormatter, |
| 93 | + new Dictionary<string, string> { { "BABYLON.PointerInfoBase | type", "int" } }, |
| 94 | + type |
| 95 | + ); |
| 96 | + } |
| 97 | + else |
| 98 | + { |
| 99 | + GlobalLogger.Info("Running Server Generator"); |
| 100 | + // For the Server Generator, we don't want to format the text. So we use the NoFormattingTextFormatter. |
| 101 | + // We want to let the Server Project Writer handle the formatting. |
| 102 | + var noFormattingTextFormatter = new NoFormattingTextFormatter(); |
| 103 | + var writer = new ServerProjectWriter( |
88 | 104 | projectGenerationLocation, |
89 | | - projectAssembly |
90 | | - ))) |
91 | | - { |
92 | | - Directory.Delete( |
93 | | - Path.Combine( |
94 | | - projectGenerationLocation, |
95 | | - projectAssembly |
96 | | - ), |
97 | | - true |
98 | | - ); |
99 | | - } |
100 | | - GlobalLogger.Info("Removed Generation Directory"); |
101 | | - |
102 | | - if (useWasm) |
103 | | - { |
104 | | - GlobalLogger.Info("Running Wasm Generator"); |
105 | | - var writer = new WasmProjectWriter( |
106 | | - projectGenerationLocation, |
107 | | - projectAssembly |
108 | | - ); |
109 | | - new WasmGenerator().Run( |
110 | | - projectAssembly, |
111 | | - sourceDirectory, |
112 | | - sourceFiles, |
113 | | - generationList, |
114 | | - writer, |
115 | | - textFormatter, |
116 | | - new Dictionary<string, string> |
117 | | - { |
118 | | - { "BABYLON.PointerInfoBase | type", "int" } |
119 | | - }, |
120 | | - type |
121 | | - ); |
122 | | - } |
123 | | - else |
124 | | - { |
125 | | - GlobalLogger.Info("Running Server Generator"); |
126 | | - var writer = new ServerProjectWriter( |
127 | | - projectGenerationLocation, |
128 | | - projectAssembly |
129 | | - ); |
130 | | - new ServerGenerator().Run( |
131 | | - projectAssembly, |
132 | | - sourceDirectory, |
133 | | - sourceFiles, |
134 | | - generationList, |
135 | | - writer, |
136 | | - textFormatter, |
137 | | - new Dictionary<string, string> |
138 | | - { |
139 | | - { "BABYLON.PointerInfoBase | type", "int" } |
140 | | - }, |
141 | | - type |
142 | | - ); |
143 | | - } |
144 | | - stopwatch.Stop(); |
145 | | - GlobalLogger.Info("Removed Generation Directory"); |
146 | | - GlobalLogger.Info($"Took {stopwatch.ElapsedMilliseconds}ms to generate."); |
| 105 | + projectAssembly, |
| 106 | + textFormatter |
| 107 | + ); |
| 108 | + new ServerGenerator().Run( |
| 109 | + projectAssembly, |
| 110 | + sourceDirectory, |
| 111 | + sourceFiles, |
| 112 | + generationList, |
| 113 | + writer, |
| 114 | + noFormattingTextFormatter, |
| 115 | + new Dictionary<string, string> { { "BABYLON.PointerInfoBase | type", "int" } }, |
| 116 | + type |
| 117 | + ); |
147 | 118 | } |
| 119 | + stopwatch.Stop(); |
| 120 | + GlobalLogger.Info("Removed Generation Directory"); |
| 121 | + GlobalLogger.Info($"Took {stopwatch.ElapsedMilliseconds}ms to generate."); |
148 | 122 | } |
149 | 123 | } |
0 commit comments