From c2fc86215c66522d5eb83f106ddf8040a4ea4d65 Mon Sep 17 00:00:00 2001 From: walon Date: Sat, 18 Dec 2021 18:50:03 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=89=B9=E6=80=A7=E3=80=91=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=20--output:tables,=20--output:include=5Ftables,=20--o?= =?UTF-8?q?utput:exclude=5Ftables=20=E7=94=A8=E4=BA=8E=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E5=8C=85=E5=90=AB=E6=88=96=E8=80=85=E6=8E=92=E9=99=A4=E6=9F=90?= =?UTF-8?q?=E4=BA=9B=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Luban.Job.Cfg/Source/Defs/DefAssembly.cs | 51 +++++++++++++++++++- src/Luban.Job.Cfg/Source/GenArgs.cs | 9 ++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/src/Luban.Job.Cfg/Source/Defs/DefAssembly.cs b/src/Luban.Job.Cfg/Source/Defs/DefAssembly.cs index c84e9be..6096cd0 100644 --- a/src/Luban.Job.Cfg/Source/Defs/DefAssembly.cs +++ b/src/Luban.Job.Cfg/Source/Defs/DefAssembly.cs @@ -70,6 +70,12 @@ namespace Luban.Job.Cfg.Defs public bool NeedL10nTextTranslate => ExportTextTable != null; + private HashSet _overrideOutputTables; + + private readonly HashSet _outputIncludeTables = new(); + + private readonly HashSet _outputExcludeTables = new(); + public void InitL10n(string textValueFieldName) { ExportTextTable = new TextTable(this, textValueFieldName); @@ -161,7 +167,10 @@ namespace Luban.Job.Cfg.Defs public List GetExportTables() { - return Types.Values.Where(t => t is DefTable ct && ct.NeedExport).Select(t => (DefTable)t).ToList(); + return Types.Values.Where(t => t is DefTable ct + && !_outputExcludeTables.Contains(t.FullName) + && (_outputIncludeTables.Contains(t.FullName) || (_overrideOutputTables == null ? ct.NeedExport : _overrideOutputTables.Contains(ct.FullName))) + ).Select(t => (DefTable)t).ToList(); } public List GetExportTypes() @@ -210,6 +219,11 @@ namespace Luban.Job.Cfg.Defs return _refGroups.TryGetValue(groupName, out var refGroup) ? refGroup : null; } + private IEnumerable SplitTableList(string tables) + { + return tables.Split(',').Select(t => t.Trim()); + } + public void Load(Defines defines, IAgent agent, GenArgs args) { LoadCommon(defines, agent, args); @@ -258,6 +272,41 @@ namespace Luban.Job.Cfg.Defs AddCfgTable(table); } + if (!string.IsNullOrWhiteSpace(args.OutputTables)) + { + foreach (var tableFullName in SplitTableList(args.OutputTables)) + { + if (GetCfgTable(tableFullName) == null) + { + throw new Exception($"--output:tables 参数中 table:'{tableFullName}' 不存在"); + } + _overrideOutputTables ??= new HashSet(); + _overrideOutputTables.Add(tableFullName); + } + } + if (!string.IsNullOrWhiteSpace(args.OutputIncludeTables)) + { + foreach (var tableFullName in SplitTableList(args.OutputIncludeTables)) + { + if (GetCfgTable(tableFullName) == null) + { + throw new Exception($"--output:include_tables 参数中 table:'{tableFullName}' 不存在"); + } + _outputIncludeTables.Add(tableFullName); + } + } + if (!string.IsNullOrWhiteSpace(args.OutputExcludeTables)) + { + foreach (var tableFullName in SplitTableList(args.OutputExcludeTables)) + { + if (GetCfgTable(tableFullName) == null) + { + throw new Exception($"--output:exclude_tables 参数中 table:'{tableFullName}' 不存在"); + } + _outputExcludeTables.Add(tableFullName); + } + } + _cfgServices.AddRange(defines.Services); foreach (var type in Types.Values) diff --git a/src/Luban.Job.Cfg/Source/GenArgs.cs b/src/Luban.Job.Cfg/Source/GenArgs.cs index 18d2c62..d34272a 100644 --- a/src/Luban.Job.Cfg/Source/GenArgs.cs +++ b/src/Luban.Job.Cfg/Source/GenArgs.cs @@ -23,6 +23,15 @@ namespace Luban.Job.Cfg [Option("input:convert_data_dir", Required = false, HelpText = "override input data dir with convert data dir")] public string InputConvertDataDir { get; set; } + [Option("output:tables", Required = false, HelpText = "override tables in export group with this list")] + public string OutputTables { get; set; } + + [Option("output:include_tables", Required = false, HelpText = "include tables")] + public string OutputIncludeTables { get; set; } + + [Option("output:exclude_tables", Required = false, HelpText = "exclude tables")] + public string OutputExcludeTables { get; set; } + [Option("output:data:resource_list_file", Required = false, HelpText = "output resource list file")] public string OutputDataResourceListFile { get; set; }