C++: Generate output in a folder
This commit is contained in:
@@ -32,8 +32,8 @@ namespace Il2CppInspector.CLI
|
||||
[Option('p', "py-out", Required = false, HelpText = "IDA Python script output file", Default = "ida.py")]
|
||||
public string PythonOutFile { get; set; }
|
||||
|
||||
[Option('h', "cpp-out", Required = false, HelpText = "C++ header output file", Default = "il2cpp-types.h")]
|
||||
public string CppOutFile { get; set; }
|
||||
[Option('h', "cpp-out", Required = false, HelpText = "C++ scaffolding output path", Default = "cpp")]
|
||||
public string CppOutPath { get; set; }
|
||||
|
||||
[Option('e', "exclude-namespaces", Required = false, Separator = ',', HelpText = "Comma-separated list of namespaces to suppress in C# output, or 'none' to include all namespaces",
|
||||
Default = new [] {
|
||||
@@ -263,7 +263,7 @@ namespace Il2CppInspector.CLI
|
||||
|
||||
// C++ output
|
||||
using (new Benchmark("Generate C++ code")) {
|
||||
new CppScaffolding(appModel).WriteCppToFile(options.CppOutFile);
|
||||
new CppScaffolding(appModel).Write(options.CppOutPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,15 @@ namespace Il2CppInspector.Outputs
|
||||
|
||||
public CppScaffolding(AppModel model) => this.model = model;
|
||||
|
||||
public void WriteCppToFile(string outputFile) {
|
||||
using var fs = new FileStream(outputFile, FileMode.Create);
|
||||
public void Write(string outputPath) {
|
||||
// Ensure output directory exists and is not a file
|
||||
// A System.IOException will be thrown if it's a file'
|
||||
Directory.CreateDirectory(outputPath);
|
||||
|
||||
// Write il2cpp-types.h
|
||||
var typeHeaderFile = Path.Combine(outputPath, "il2cpp-types.h");
|
||||
|
||||
using var fs = new FileStream(typeHeaderFile, FileMode.Create);
|
||||
writer = new StreamWriter(fs, Encoding.UTF8);
|
||||
|
||||
writeLine("// Generated C++ file by Il2CppInspector - http://www.djkaty.com - https://github.com/djkaty");
|
||||
|
||||
@@ -419,17 +419,15 @@ namespace Il2CppInspectorGUI
|
||||
// C++ scaffolding
|
||||
case { rdoOutputCpp: var r } when r.IsChecked == true:
|
||||
|
||||
var cppSaveFileDialog = new SaveFileDialog {
|
||||
Filter = "C++ header file (*.h)|*.h|All files (*.*)|*.*",
|
||||
FileName = "il2cpp-types.h",
|
||||
CheckFileExists = false,
|
||||
OverwritePrompt = true
|
||||
var cppSaveFolderDialog = new VistaFolderBrowserDialog {
|
||||
Description = "Select save location",
|
||||
UseDescriptionForTitle = true
|
||||
};
|
||||
|
||||
if (cppSaveFileDialog.ShowDialog() == false)
|
||||
if (cppSaveFolderDialog.ShowDialog() == false)
|
||||
return;
|
||||
|
||||
var cppOutFile = cppSaveFileDialog.FileName;
|
||||
var cppOutPath = cppSaveFolderDialog.SelectedPath;
|
||||
|
||||
areaBusyIndicator.Visibility = Visibility.Visible;
|
||||
var selectedCppUnityVersion = ((UnityHeader)cboCppUnityVersion.SelectedItem)?.MinVersion;
|
||||
@@ -439,7 +437,7 @@ namespace Il2CppInspectorGUI
|
||||
model.Build(selectedCppUnityVersion, cppCompiler);
|
||||
|
||||
OnStatusUpdate(this, "Generating C++ scaffolding");
|
||||
new CppScaffolding(model).WriteCppToFile(cppOutFile);
|
||||
new CppScaffolding(model).Write(cppOutPath);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Il2CppInspector
|
||||
.WriteScriptToFile(testPath + $@"\test-ida-result{nameSuffix}.py");
|
||||
|
||||
new CppScaffolding(appModel)
|
||||
.WriteCppToFile(testPath + $@"\test-result{nameSuffix}.h");
|
||||
.Write(testPath + $@"\test-cpp-result{nameSuffix}");
|
||||
}
|
||||
|
||||
// Compare test results with expected results
|
||||
@@ -65,7 +65,7 @@ namespace Il2CppInspector
|
||||
var suffix = (i > 0 ? "-" + i : "");
|
||||
|
||||
compareFiles(testPath, suffix + ".cs", $"test-result{suffix}.cs");
|
||||
compareFiles(testPath, suffix + ".h", $"test-result{suffix}.h");
|
||||
compareFiles(testPath, suffix + ".h", $@"test-cpp-result{suffix}\il2cpp-types.h");
|
||||
compareFiles(testPath, suffix + ".py", $"test-ida-result{suffix}.py");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user