Merge pull request '上传copyarx工程' (#58) from home-lenovo-legion-r9000/上传-copyarx-工程 into main

Reviewed-on: #58
This commit was merged in pull request #58.
This commit is contained in:
gjm committed 2026-10-25 13:35:35 +08:00
commit e0f31a3e61
21 files changed
+425

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
+291
View File
@@ -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>();
}
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<string>();
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<string>();
if (!Directory.Exists(src_root))
{
Console.WriteLine("src_root 文件夹未找到!");
return;
}
if (!obj.TryGetValue("items", out jtok))
{
Console.WriteLine("文件未找到 items 配置。");
return;
}
JArray jar = jtok.ToObject<JArray>();
List<ItemData> items = new List<ItemData>();
foreach (JObject jo in jar)
{
ItemData data = new ItemData();
if (!jo.TryGetValue("Platform", out jtok)) continue;
data.Platform = jtok.ToObject<string>();
if (!jo.TryGetValue("Configuration", out jtok)) continue;
data.Configuration = jtok.ToObject<string>();
if (!jo.TryGetValue("PlatformToolset", out jtok)) continue;
data.PlatformToolset = jtok.ToObject<string>();
if (!jo.TryGetValue("arx", out jtok)) continue;
data.arx = jtok.ToObject<string>();
if (!jo.TryGetValue("useSrcRoot", out jtok)) continue;
data.useSrcRoot = jtok.ToObject<bool>();
if (!jo.TryGetValue("useDescRoot", out jtok)) continue;
data.useDescRoot = jtok.ToObject<bool>();
if (!jo.TryGetValue("src_path", out jtok)) continue;
data.src_path = jtok.ToObject<string>();
if (!jo.TryGetValue("desc_path", out jtok)) continue;
data.desc_path = jtok.ToObject<string>();
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;
}
}
}
}
@@ -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")]
+58
View File
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{EC7584F1-0269-40D4-BE57-6E3DCDC15781}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>copyArx</RootNamespace>
<AssemblyName>copyArx</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\SourceCode\Code2026\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\SourceCode\Code2026\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<Fakes Include="Fakes\Newtonsoft.Json.fakes" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+3
View File
@@ -0,0 +1,3 @@
<Solution>
<Project Path="copyArx.csproj" />
</Solution>
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
@@ -0,0 +1 @@
dd647ab234abe686b34b14273d41a8d4a8369e437c50b62208b39dbc46e3e89d
@@ -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
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
@@ -0,0 +1 @@
10019cbaed50ed9e96e7a189ee08aff14014657bc98f72d6c2da3d30198c3730
@@ -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
Whitespace-only changes.
Binary file not shown.
Binary file not shown.
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
</packages>