diff --git a/utility/copyArx/App.config b/utility/copyArx/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/utility/copyArx/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/utility/copyArx/Program.cs b/utility/copyArx/Program.cs new file mode 100644 index 0000000..8e1ec52 --- /dev/null +++ b/utility/copyArx/Program.cs @@ -0,0 +1,291 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace copyARX +{ + public class ItemData + { + public ItemData() + { + Platform = string.Empty; + Configuration = string.Empty; + PlatformToolset = string.Empty; + arx = string.Empty; + useSrcRoot = true; + useDescRoot = true; + src_path = string.Empty; + desc_path = string.Empty; + } + public ItemData(string platform, string config, string toolset, string arx) + { + Platform = platform; + Configuration = config; + PlatformToolset = toolset; + this.arx = arx; + } + + public bool compare(ItemData data) + { + if (Platform == data.Platform + && Configuration == data.Configuration + && PlatformToolset == data.PlatformToolset + && arx == data.arx) return true; + return false; + } + + public string Platform; + public string Configuration; + public string PlatformToolset; + public string arx; + public bool useSrcRoot; + public bool useDescRoot; + public string src_path; + public string desc_path; + } + + class Program + { + static void Main(string[] args) + { + // 共七个参数,最后一个可以没有 + + bool bCMake = args[0] == "CMAKE"; + + if (bCMake) + { + if (args.Length < 4) + { + System.Console.WriteLine("参数不足,请重新配置. -cmake"); + } + + string sArxPath = args[1], // 需要copy的文件名 + sSDKVer = args[2], // sdk版本 + sJson = args[3]; // json文件 + + if (!File.Exists(sJson)) + { + Console.WriteLine(sJson + "文件未找到。"); + return; + } + + if (!File.Exists(sArxPath)) + { + Console.WriteLine(sArxPath + "文件未找到。"); + return; + } + + string sSHEnvPath = string.Empty; + using (StreamReader reader = File.OpenText(sJson)) + { + JObject obj = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); + JToken jtok = string.Empty; + if (!obj.TryGetValue("desc_root", out jtok)) + { + Console.WriteLine("文件未找到 desc_root 配置。"); + return; + } + sSHEnvPath = jtok.ToObject(); + } + + string dest_dir = sSHEnvPath + "\\" + sSDKVer; + if (!Directory.Exists(dest_dir)) + { + Console.WriteLine(string.Format("{0} 文件夹未找到!", dest_dir)); + return; + } + + string dest_arx = dest_dir + "\\" + Path.GetFileName(sArxPath); + File.Copy(sArxPath, dest_arx, true); + Console.WriteLine(string.Format("拷贝文件从:\n {0}\n 到:\n {1} \n成功.", sArxPath, dest_arx)); + return; + } + + if (args.Length < 6) + { + System.Console.WriteLine("参数不足,请重新配置," + , "(例如:$(ProjectName) $(PlatformToolset) $(Configuration) $(Platform) $(TargetExt) exepath.txt sysPath)"); + } + + string project = args[0] // 工程名 + , toolset = args[1] // v90~v140 + , config = args[2] // debug | release + , platform = args[3] // win32 | x64 + , ext = args[4] // 扩展名 + , cnfPath = args[5] // 记录 earthworm 所在主目录的文件 + , srcPath = Process.GetCurrentProcess().MainModule.FileName; // 执行文件所在目录 + + string subSys = string.Empty; + if (args.Length > 6) + subSys = args[6]; + + srcPath = srcPath.Substring(0, srcPath.LastIndexOf("\\")); + cnfPath = srcPath + "\\" + cnfPath; + srcPath = srcPath.Substring(0, srcPath.LastIndexOf("\\")) + "\\"; + + if (!File.Exists(cnfPath)) + { + Console.WriteLine(cnfPath + "文件未找到。"); + return; + } + + using (StreamReader reader = File.OpenText(cnfPath)) + { + JObject obj = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); + + JToken jtok = string.Empty; + if (!obj.TryGetValue("desc_root", out jtok)) + { + Console.WriteLine("文件未找到 desc_root 配置。"); + return; + } + string desc_root = jtok.ToObject(); + if (!Directory.Exists(desc_root)) + { + Console.WriteLine("desc_root 文件夹未找到!"); + return; + } + + if (!obj.TryGetValue("src_root", out jtok)) + { + Console.WriteLine("文件未找到 src_root 配置。"); + return; + } + + string src_root = jtok.ToObject(); + if (!Directory.Exists(src_root)) + { + Console.WriteLine("src_root 文件夹未找到!"); + return; + } + + if (!obj.TryGetValue("items", out jtok)) + { + Console.WriteLine("文件未找到 items 配置。"); + return; + } + JArray jar = jtok.ToObject(); + + List items = new List(); + foreach (JObject jo in jar) + { + ItemData data = new ItemData(); + if (!jo.TryGetValue("Platform", out jtok)) continue; + data.Platform = jtok.ToObject(); + if (!jo.TryGetValue("Configuration", out jtok)) continue; + data.Configuration = jtok.ToObject(); + if (!jo.TryGetValue("PlatformToolset", out jtok)) continue; + data.PlatformToolset = jtok.ToObject(); + if (!jo.TryGetValue("arx", out jtok)) continue; + data.arx = jtok.ToObject(); + if (!jo.TryGetValue("useSrcRoot", out jtok)) continue; + data.useSrcRoot = jtok.ToObject(); + if (!jo.TryGetValue("useDescRoot", out jtok)) continue; + data.useDescRoot = jtok.ToObject(); + if (!jo.TryGetValue("src_path", out jtok)) continue; + data.src_path = jtok.ToObject(); + if (!jo.TryGetValue("desc_path", out jtok)) continue; + data.desc_path = jtok.ToObject(); + items.Add(data); + } + + ItemData input = new ItemData(platform, config, toolset, subSys); + + string srcDirArx = string.Empty; + string srcDirCore = string.Empty; + string srcfile = string.Empty; + string descFile = string.Empty; + + bool bFindItem = false; + ItemData item = new ItemData(); + foreach (ItemData it in items) + { + if (!it.compare(input)) + continue; + else + { + item = it; + bFindItem = true; + } + } + + if (!bFindItem) + { + Console.WriteLine("没有找到相关的配置项!"); + return; + } + + if (item.useSrcRoot) + { + srcDirArx = string.Format("{0}\\{1}\\{2}{3}" + , src_root + , item.src_path + , project + , ext); + + srcDirCore = string.Format("{0}\\{1}-[]-[]\\{2}{3}" + , src_root + , item.src_path + , project + , ext); + + if (File.Exists(srcDirArx) && !File.Exists(srcDirCore)) + { + srcfile = srcDirArx; + } + else if (!File.Exists(srcDirArx) && File.Exists(srcDirCore)) + { + srcfile = srcDirCore; + } + else if (File.Exists(srcDirArx) && File.Exists(srcDirCore)) + { + DateTime dtArx = File.GetCreationTime(srcDirArx); + DateTime dtCore = File.GetCreationTime(srcDirCore); + if (dtArx >= dtCore) // 两个目录下都有这个文件,取新的 + srcfile = srcDirArx; + else + srcfile = srcDirCore; + } + else + { + Console.WriteLine(string.Format("{0}未找到!", project + ext)); + return; + } + } + else + { + srcfile = item.src_path + "\\" + project + ext; + } + + if (!File.Exists(srcfile)) + { + Console.WriteLine(string.Format("{0}未找到!", srcfile)); + return; + } + + if (item.useDescRoot) + { + descFile = desc_root + "\\" + item.desc_path + "\\"; + } + else + { + descFile = item.desc_path + "\\"; + } + + if (!Directory.Exists(descFile)) + { + Console.WriteLine(string.Format("{0}未找到!"), descFile); + return; + } + + descFile += project + ext; + File.Copy(srcfile, descFile, true); + Console.WriteLine(string.Format("拷贝文件从:\n {0}\n 到:\n {1} \n成功.", srcfile, descFile)); + return; + } + } + } +} diff --git a/utility/copyArx/Properties/AssemblyInfo.cs b/utility/copyArx/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e68bdb1 --- /dev/null +++ b/utility/copyArx/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("copyArx")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("copyArx")] +[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ec7584f1-0269-40d4-be57-6e3dcdc15781")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/utility/copyArx/copyArx.csproj b/utility/copyArx/copyArx.csproj new file mode 100644 index 0000000..4a93704 --- /dev/null +++ b/utility/copyArx/copyArx.csproj @@ -0,0 +1,58 @@ + + + + + Debug + AnyCPU + {EC7584F1-0269-40D4-BE57-6E3DCDC15781} + Exe + copyArx + copyArx + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + ..\..\SourceCode\Code2026\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\SourceCode\Code2026\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/utility/copyArx/copyArx.slnx b/utility/copyArx/copyArx.slnx new file mode 100644 index 0000000..9543681 --- /dev/null +++ b/utility/copyArx/copyArx.slnx @@ -0,0 +1,3 @@ + + + diff --git a/utility/copyArx/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs b/utility/copyArx/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs new file mode 100644 index 0000000..3871b18 --- /dev/null +++ b/utility/copyArx/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] diff --git a/utility/copyArx/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/utility/copyArx/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..01f29e9 Binary files /dev/null and b/utility/copyArx/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/utility/copyArx/obj/Debug/copyArx.csproj.AssemblyReference.cache b/utility/copyArx/obj/Debug/copyArx.csproj.AssemblyReference.cache new file mode 100644 index 0000000..10fbdc4 Binary files /dev/null and b/utility/copyArx/obj/Debug/copyArx.csproj.AssemblyReference.cache differ diff --git a/utility/copyArx/obj/Debug/copyArx.csproj.CoreCompileInputs.cache b/utility/copyArx/obj/Debug/copyArx.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..a7bc6a9 --- /dev/null +++ b/utility/copyArx/obj/Debug/copyArx.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +dd647ab234abe686b34b14273d41a8d4a8369e437c50b62208b39dbc46e3e89d diff --git a/utility/copyArx/obj/Debug/copyArx.csproj.FileListAbsolute.txt b/utility/copyArx/obj/Debug/copyArx.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..adfaaee --- /dev/null +++ b/utility/copyArx/obj/Debug/copyArx.csproj.FileListAbsolute.txt @@ -0,0 +1,8 @@ +D:\shs-code\SourceCode\Code2026\copyArx.exe.config +D:\shs-code\SourceCode\Code2026\copyArx.exe +D:\shs-code\SourceCode\Code2026\copyArx.pdb +D:\shs-code\utility\copyArx\obj\Debug\copyArx.csproj.AssemblyReference.cache +D:\shs-code\utility\copyArx\obj\Debug\copyArx.csproj.CoreCompileInputs.cache +D:\shs-code\utility\copyArx\obj\Debug\copyArx.csproj.Up2Date +D:\shs-code\utility\copyArx\obj\Debug\copyArx.exe +D:\shs-code\utility\copyArx\obj\Debug\copyArx.pdb diff --git a/utility/copyArx/obj/Debug/copyArx.exe b/utility/copyArx/obj/Debug/copyArx.exe new file mode 100644 index 0000000..5e27c79 Binary files /dev/null and b/utility/copyArx/obj/Debug/copyArx.exe differ diff --git a/utility/copyArx/obj/Debug/copyArx.pdb b/utility/copyArx/obj/Debug/copyArx.pdb new file mode 100644 index 0000000..20dc7c5 Binary files /dev/null and b/utility/copyArx/obj/Debug/copyArx.pdb differ diff --git a/utility/copyArx/obj/Release/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs b/utility/copyArx/obj/Release/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs new file mode 100644 index 0000000..3871b18 --- /dev/null +++ b/utility/copyArx/obj/Release/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] diff --git a/utility/copyArx/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache b/utility/copyArx/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..1b05281 Binary files /dev/null and b/utility/copyArx/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/utility/copyArx/obj/Release/copyArx.csproj.AssemblyReference.cache b/utility/copyArx/obj/Release/copyArx.csproj.AssemblyReference.cache new file mode 100644 index 0000000..10fbdc4 Binary files /dev/null and b/utility/copyArx/obj/Release/copyArx.csproj.AssemblyReference.cache differ diff --git a/utility/copyArx/obj/Release/copyArx.csproj.CoreCompileInputs.cache b/utility/copyArx/obj/Release/copyArx.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..0d22724 --- /dev/null +++ b/utility/copyArx/obj/Release/copyArx.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +10019cbaed50ed9e96e7a189ee08aff14014657bc98f72d6c2da3d30198c3730 diff --git a/utility/copyArx/obj/Release/copyArx.csproj.FileListAbsolute.txt b/utility/copyArx/obj/Release/copyArx.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..9e5abbe --- /dev/null +++ b/utility/copyArx/obj/Release/copyArx.csproj.FileListAbsolute.txt @@ -0,0 +1,9 @@ +D:\shs-code\utility\copyArx\bin\Release\copyArx.exe.config +D:\shs-code\utility\copyArx\bin\Release\copyArx.exe +D:\shs-code\utility\copyArx\bin\Release\copyArx.pdb +D:\shs-code\utility\copyArx\bin\Release\Newtonsoft.Json.dll +D:\shs-code\utility\copyArx\obj\Release\copyArx.csproj.AssemblyReference.cache +D:\shs-code\utility\copyArx\obj\Release\copyArx.csproj.CoreCompileInputs.cache +D:\shs-code\utility\copyArx\obj\Release\copyArx.csproj.Up2Date +D:\shs-code\utility\copyArx\obj\Release\copyArx.exe +D:\shs-code\utility\copyArx\obj\Release\copyArx.pdb diff --git a/utility/copyArx/obj/Release/copyArx.csproj.Up2Date b/utility/copyArx/obj/Release/copyArx.csproj.Up2Date new file mode 100644 index 0000000..e69de29 diff --git a/utility/copyArx/obj/Release/copyArx.exe b/utility/copyArx/obj/Release/copyArx.exe new file mode 100644 index 0000000..2a8071d Binary files /dev/null and b/utility/copyArx/obj/Release/copyArx.exe differ diff --git a/utility/copyArx/obj/Release/copyArx.pdb b/utility/copyArx/obj/Release/copyArx.pdb new file mode 100644 index 0000000..10b38d1 Binary files /dev/null and b/utility/copyArx/obj/Release/copyArx.pdb differ diff --git a/utility/copyArx/packages.config b/utility/copyArx/packages.config new file mode 100644 index 0000000..5eaa239 --- /dev/null +++ b/utility/copyArx/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file