Script: Allow script target API to be passed as argument
This commit is contained in:
@@ -271,7 +271,7 @@ namespace Il2CppInspector.CLI
|
|||||||
|
|
||||||
// IDA Python script output
|
// IDA Python script output
|
||||||
using (new Benchmark("Generate IDAPython script")) {
|
using (new Benchmark("Generate IDAPython script")) {
|
||||||
new IDAPythonScript(appModel).WriteScriptToFile(options.PythonOutFile,
|
new IDAPythonScript(appModel).WriteScriptToFile(options.PythonOutFile, "IDA",
|
||||||
Path.Combine(options.CppOutPath, "appdata/il2cpp-types.h"),
|
Path.Combine(options.CppOutPath, "appdata/il2cpp-types.h"),
|
||||||
options.JsonOutPath);
|
options.JsonOutPath);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using System.IO;
|
|||||||
using Il2CppInspector.Reflection;
|
using Il2CppInspector.Reflection;
|
||||||
using Il2CppInspector.Model;
|
using Il2CppInspector.Model;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Il2CppInspector.Outputs
|
namespace Il2CppInspector.Outputs
|
||||||
{
|
{
|
||||||
@@ -25,7 +26,11 @@ namespace Il2CppInspector.Outputs
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Output script file
|
// Output script file
|
||||||
public void WriteScriptToFile(string outputFile, string existingTypeHeaderFIle = null, string existingJsonMetadataFile = null) {
|
public void WriteScriptToFile(string outputFile, string target, string existingTypeHeaderFIle = null, string existingJsonMetadataFile = null) {
|
||||||
|
|
||||||
|
// Check that target script API is valid
|
||||||
|
if (!GetAvailableTargets().Contains(target))
|
||||||
|
throw new InvalidOperationException("Unknown script API target: " + target);
|
||||||
|
|
||||||
// Write types file first if it hasn't been specified
|
// Write types file first if it hasn't been specified
|
||||||
var typeHeaderFile = Path.Combine(Path.GetDirectoryName(outputFile), Path.GetFileNameWithoutExtension(outputFile) + ".h");
|
var typeHeaderFile = Path.Combine(Path.GetDirectoryName(outputFile), Path.GetFileNameWithoutExtension(outputFile) + ".h");
|
||||||
@@ -47,13 +52,10 @@ namespace Il2CppInspector.Outputs
|
|||||||
|
|
||||||
var jsonMetadataRelativePath = getRelativePath(outputFile, jsonMetadataFile);
|
var jsonMetadataRelativePath = getRelativePath(outputFile, jsonMetadataFile);
|
||||||
|
|
||||||
// TODO: Replace with target selector
|
|
||||||
var targetApi = "IDA";
|
|
||||||
|
|
||||||
var ns = typeof(IDAPythonScript).Namespace + ".ScriptResources";
|
var ns = typeof(IDAPythonScript).Namespace + ".ScriptResources";
|
||||||
var preamble = ResourceHelper.GetText(ns + ".shared-preamble.py");
|
var preamble = ResourceHelper.GetText(ns + ".shared-preamble.py");
|
||||||
var main = ResourceHelper.GetText(ns + ".shared-main.py");
|
var main = ResourceHelper.GetText(ns + ".shared-main.py");
|
||||||
var api = ResourceHelper.GetText($"{ns}.Targets.{targetApi}.py");
|
var api = ResourceHelper.GetText($"{ns}.Targets.{target}.py");
|
||||||
|
|
||||||
var script = string.Join("\n", new [] { preamble, api, main })
|
var script = string.Join("\n", new [] { preamble, api, main })
|
||||||
.Replace("%SCRIPTFILENAME%", Path.GetFileName(outputFile))
|
.Replace("%SCRIPTFILENAME%", Path.GetFileName(outputFile))
|
||||||
|
|||||||
@@ -431,7 +431,7 @@ namespace Il2CppInspectorGUI
|
|||||||
model.Build(selectedIdaUnityVersion, CppCompilerType.GCC);
|
model.Build(selectedIdaUnityVersion, CppCompilerType.GCC);
|
||||||
|
|
||||||
OnStatusUpdate(this, "Generating IDAPython script");
|
OnStatusUpdate(this, "Generating IDAPython script");
|
||||||
new IDAPythonScript(model).WriteScriptToFile(idaOutFile);
|
new IDAPythonScript(model).WriteScriptToFile(idaOutFile, "IDA");
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user