Skip to content

Commit d605778

Browse files
committed
Support "response files" #500
1 parent adf9b1b commit d605778

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

CSharp.lua.Launcher/Program.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
using System;
1818
using System.Collections.Generic;
1919
using System.Diagnostics;
20+
using System.IO;
2021
using System.Linq;
2122

2223
namespace CSharpLua {
@@ -44,11 +45,12 @@ class Program {
4445
-inline-property: inline some single-line properties
4546
-include : the root directory of the CoreSystem library, adds all the dependencies to a single file named out.lua
4647
-noconcurrent : close concurrent compile
48+
@file : read more options from the file
4749
";
4850
public static void Main(string[] args) {
4951
if (args.Length > 0) {
5052
try {
51-
var cmds = Utility.GetCommandLines(args);
53+
var cmds = Utility.GetCommandLines(ExpandResponseFiles(args));
5254
if (cmds.ContainsKey("-h")) {
5355
ShowHelpInfo();
5456
return;
@@ -138,5 +140,25 @@ private static string GetCSCArgument(string[] args) {
138140
}
139141
return null;
140142
}
143+
144+
private static string[] ExpandResponseFiles(string[] args) {
145+
List<string> list = new List<string>();
146+
foreach (string arg in args) {
147+
if (arg.StartsWith("@")) {
148+
string file = arg.Substring(1);
149+
string[] lines = File.ReadAllLines(file);
150+
foreach (string line in lines) {
151+
string trimLine = line.Trim();
152+
if (!string.IsNullOrEmpty(trimLine)) {
153+
string[] parts = trimLine.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
154+
list.AddRange(parts);
155+
}
156+
}
157+
} else {
158+
list.Add(arg);
159+
}
160+
}
161+
return list.ToArray();
162+
}
141163
}
142164
}

CSharp.lua/Utils.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,11 +1086,11 @@ private static void FillExternalTypeName(
10861086
INamedTypeSymbol typeSymbol,
10871087
Func<INamespaceSymbol, string, string> funcOfNamespace,
10881088
Func<INamedTypeSymbol, string> funcOfTypeName,
1089-
LuaSyntaxNodeTransform transfor = null) {
1089+
LuaSyntaxNodeTransform transform = null) {
10901090
var externalType = typeSymbol.ContainingType;
10911091
if (externalType != null) {
1092-
if (transfor is {IsNoneGenericTypeCounter: true} && !externalType.IsGenericType && !typeSymbol.IsGenericType) {
1093-
var curTypeDeclaration = transfor.CurTypeDeclaration;
1092+
if (transform?.IsNoneGenericTypeCounter == true && !externalType.IsGenericType && !typeSymbol.IsGenericType) {
1093+
var curTypeDeclaration = transform.CurTypeDeclaration;
10941094
if (curTypeDeclaration != null && curTypeDeclaration.CheckTypeName(externalType, out var classIdentifier)) {
10951095
sb.Append(classIdentifier.ValueText);
10961096
sb.Append('.');
@@ -1116,9 +1116,9 @@ public static string GetTypeShortName(
11161116
this INamedTypeSymbol typeSymbol,
11171117
Func<INamespaceSymbol, string, string> funcOfNamespace = null,
11181118
Func<INamedTypeSymbol, string> funcOfTypeName = null,
1119-
LuaSyntaxNodeTransform transfor = null) {
1119+
LuaSyntaxNodeTransform transform = null) {
11201120
StringBuilder sb = new StringBuilder();
1121-
FillExternalTypeName(sb, typeSymbol, funcOfNamespace, funcOfTypeName, transfor);
1121+
FillExternalTypeName(sb, typeSymbol, funcOfNamespace, funcOfTypeName, transform);
11221122
string typeName = funcOfTypeName?.Invoke(typeSymbol);
11231123
if (typeName != null) {
11241124
sb.Append(typeName);

0 commit comments

Comments
 (0)