Skip to content

Commit 3d019a1

Browse files
committed
Refactor logging and processing layer setup
Move Cpp2IL.Core logging setup from Il2CppGame to Program.cs. Extract default processing layers into Il2CppGame.GetDefaultProcessingLayers() and update Program.cs to use this method. Il2CppGame static constructor now only handles instruction set registration.
1 parent 019dd54 commit 3d019a1

2 files changed

Lines changed: 53 additions & 48 deletions

File tree

Il2CppInterop.CLI/Program.cs

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Cpp2IL.Core.ProcessingLayers;
1+
using Cpp2IL.Core.Logging;
22
using Il2CppInterop.Generator;
33

44
string gameExePath = args[0];
@@ -8,53 +8,18 @@
88
// Unstrip directory needs to contain all files recursively contained in these directories:
99
// \Editor\Data\MonoBleedingEdge\lib\mono\unityaot-win32
1010
// \Editor\Data\PlaybackEngines\windowsstandalonesupport\Variations\win64_player_nondevelopment_il2cpp\Data\Managed
11+
// For other platforms, the paths will be slightly different.
12+
13+
Logger.InfoLog += Console.WriteLine;
14+
Logger.WarningLog += Console.WriteLine;
15+
Logger.ErrorLog += Console.WriteLine;
16+
Logger.VerboseLog += Console.WriteLine;
1117

1218
Il2CppGame.Process(
1319
gameExePath,
1420
outputFolder,
1521
new AsmResolverDllOutputFormatBinding(),
16-
[
17-
new AttributeAnalysisProcessingLayer(), // Needed for recovery of unmanaged constraints
18-
//new StableRenamingProcessingLayer(),
19-
new UnstripProcessingLayer(), // Can be disabled for performance during development
20-
new InterfaceOverrideProcessingLayer(),
21-
new InvalidFieldRemovalProcessingLayer(),
22-
new Il2CppRenamingProcessingLayer(),
23-
new CleanRenamingProcessingLayer(),
24-
new ConflictRenamingProcessingLayer(),
25-
new AttributesOverrideProcessingLayer(),
26-
new PublicizerProcessingLayer(),
27-
new MscorlibAssemblyInjectionProcessingLayer(),
28-
new KnownTypeAssignmentProcessingLayer(),
29-
new ReferenceAssemblyInjectionProcessingLayer(),
30-
new InvisibleInterfaceProcessingLayer(),
31-
new ObjectInterfaceProcessingLayer(),
32-
new ReferenceReplacementProcessingLayer(),
33-
new AttributeRemovalProcessingLayer(),
34-
new IndexerAttributeInjectionProcessingLayer(),
35-
new PointerConstructorProcessingLayer(),
36-
new Il2CppTypeConstraintProcessingLayer(),
37-
new InitializationClassProcessingLayer(),
38-
new MarshallingProcessingLayer(),
39-
new BoxingProcessingLayer(),
40-
new PrimitiveImplicitConversionProcessingLayer(),
41-
new EnumProcessingLayer(),
42-
new ObjectOverridesProcessingLayer(),
43-
new ObjectInternalsProcessingLayer(),
44-
new MemberAttributeProcessingLayer(),
45-
new FieldAccessorProcessingLayer(),
46-
new EventProcessingLayer(),
47-
new ExceptionHierarchyProcessingLayer(),
48-
new MethodInvokerProcessingLayer(),
49-
new MethodBodyTranslationProcessingLayer(),
50-
new NativeMethodBodyProcessingLayer(),
51-
new DelegateConversionProcessingLayer(),
52-
new ByRefParameterOverloadProcessingLayer(),
53-
new UserFriendlyOverloadProcessingLayer(),
54-
new SystemInterfaceProcessingLayer(),
55-
new ConstantInitializationProcessingLayer(),
56-
new StaticConstructorProcessingLayer(),
57-
],
22+
Il2CppGame.GetDefaultProcessingLayers(),
5823
[new(UnstripBaseProcessingLayer.DirectoryKey, unstripDirectory)]);
5924
Console.WriteLine("Done!");
6025

Il2CppInterop.Generator/Il2CppGame.cs

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Cpp2IL.Core;
22
using Cpp2IL.Core.Api;
33
using Cpp2IL.Core.InstructionSets;
4+
using Cpp2IL.Core.ProcessingLayers;
45
using Cpp2IL.Plugin.StrippedCodeRegSupport;
56
using LibCpp2IL;
67

@@ -10,11 +11,6 @@ public static class Il2CppGame
1011
{
1112
static Il2CppGame()
1213
{
13-
Logger.InfoLog += Console.WriteLine;
14-
Logger.WarningLog += Console.WriteLine;
15-
Logger.ErrorLog += Console.WriteLine;
16-
Logger.VerboseLog += Console.WriteLine;
17-
1814
InstructionSetRegistry.RegisterInstructionSet<X86InstructionSet>(DefaultInstructionSets.X86_32);
1915
InstructionSetRegistry.RegisterInstructionSet<X86InstructionSet>(DefaultInstructionSets.X86_64);
2016
InstructionSetRegistry.RegisterInstructionSet<WasmInstructionSet>(DefaultInstructionSets.WASM);
@@ -75,4 +71,48 @@ private static string GetGameAssemblyPath(string gameDirectory)
7571
}
7672
throw new FileNotFoundException("Could not find GameAssembly binary in game directory.");
7773
}
74+
75+
public static List<Cpp2IlProcessingLayer> GetDefaultProcessingLayers() =>
76+
[
77+
new AttributeAnalysisProcessingLayer(), // Needed for recovery of unmanaged constraints
78+
//new StableRenamingProcessingLayer(),
79+
new UnstripProcessingLayer(), // Can be disabled for performance during development
80+
new InterfaceOverrideProcessingLayer(),
81+
new InvalidFieldRemovalProcessingLayer(),
82+
new Il2CppRenamingProcessingLayer(),
83+
new CleanRenamingProcessingLayer(),
84+
new ConflictRenamingProcessingLayer(),
85+
new AttributesOverrideProcessingLayer(),
86+
new PublicizerProcessingLayer(),
87+
new MscorlibAssemblyInjectionProcessingLayer(),
88+
new KnownTypeAssignmentProcessingLayer(),
89+
new ReferenceAssemblyInjectionProcessingLayer(),
90+
new InvisibleInterfaceProcessingLayer(),
91+
new ObjectInterfaceProcessingLayer(),
92+
new ReferenceReplacementProcessingLayer(),
93+
new AttributeRemovalProcessingLayer(),
94+
new IndexerAttributeInjectionProcessingLayer(),
95+
new PointerConstructorProcessingLayer(),
96+
new Il2CppTypeConstraintProcessingLayer(),
97+
new InitializationClassProcessingLayer(),
98+
new MarshallingProcessingLayer(),
99+
new BoxingProcessingLayer(),
100+
new PrimitiveImplicitConversionProcessingLayer(),
101+
new EnumProcessingLayer(),
102+
new ObjectOverridesProcessingLayer(),
103+
new ObjectInternalsProcessingLayer(),
104+
new MemberAttributeProcessingLayer(),
105+
new FieldAccessorProcessingLayer(),
106+
new EventProcessingLayer(),
107+
new ExceptionHierarchyProcessingLayer(),
108+
new MethodInvokerProcessingLayer(),
109+
new MethodBodyTranslationProcessingLayer(),
110+
new NativeMethodBodyProcessingLayer(),
111+
new DelegateConversionProcessingLayer(),
112+
new ByRefParameterOverloadProcessingLayer(),
113+
new UserFriendlyOverloadProcessingLayer(),
114+
new SystemInterfaceProcessingLayer(),
115+
new ConstantInitializationProcessingLayer(),
116+
new StaticConstructorProcessingLayer(),
117+
];
78118
}

0 commit comments

Comments
 (0)