Skip to content

Commit

Permalink
-s argument supports passing source path list
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghuan committed Oct 15, 2019
1 parent a327854 commit 41eb720
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
6 changes: 3 additions & 3 deletions CSharp.lua.Launcher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace CSharpLua {
class Program {
private const string kHelpCmdString = @"Usage: CSharp.lua [-s srcfolder] [-d dstfolder]
Arguments
-s : source directory, all *.cs files will be compiled
-s : can be a directory where all cs files will be compiled, or a list of files, using ';' or ',' to separate
-d : destination directory, will put the out lua files
Options
Expand Down Expand Up @@ -57,7 +57,7 @@ public static void Main(string[] args) {
var sw = new Stopwatch();
sw.Start();

string folder = cmds.GetArgument("-s");
string input = cmds.GetArgument("-s");
string output = cmds.GetArgument("-d");
string lib = cmds.GetArgument("-l", true);
string meta = cmds.GetArgument("-m", true);
Expand All @@ -75,7 +75,7 @@ public static void Main(string[] args) {
bool isModule = cmds.ContainsKey("-module");
bool isInlineSimpleProperty = cmds.ContainsKey("-inline-property");
bool isPreventDebugObject = cmds.ContainsKey("-p");
Compiler c = new Compiler(folder, output, lib, meta, csc, isClassic, atts, enums) {
Compiler c = new Compiler(input, output, lib, meta, csc, isClassic, atts, enums) {
IsExportMetadata = isExportMetadata,
IsModule = isModule,
IsInlineSimpleProperty = isInlineSimpleProperty,
Expand Down
17 changes: 12 additions & 5 deletions CSharp.lua/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public sealed class Compiler {
private const string kSystemMeta = "~/System.xml";
private const char kLuaModuleSuffix = '!';

private readonly string folder_;
private readonly string input_;
private readonly string output_;
private readonly string[] libs_;
private readonly string[] metas_;
Expand All @@ -43,8 +43,8 @@ public sealed class Compiler {
public bool IsInlineSimpleProperty { get; set; }
public bool IsPreventDebugObject { get; set; }

public Compiler(string folder, string output, string lib, string meta, string csc, bool isClassic, string atts, string enums) {
folder_ = folder;
public Compiler(string input, string output, string lib, string meta, string csc, bool isClassic, string atts, string enums) {
input_ = input;
output_ = output;
libs_ = Utility.Split(lib);
metas_ = Utility.Split(meta);
Expand Down Expand Up @@ -139,14 +139,21 @@ public void CompileSingleFile(string fileName, IEnumerable<string> luaSystemLibs
GetGenerator().GenerateSingleFile(fileName, output_, luaSystemLibs);
}

private IEnumerable<string> GetSourceFiles() {
if (Directory.Exists(input_)) {
return Directory.EnumerateFiles(input_, "*.cs", SearchOption.AllDirectories);
}
return Utility.Split(input_, true);
}

private LuaSyntaxGenerator GetGenerator() {
var files = Directory.EnumerateFiles(folder_, "*.cs", SearchOption.AllDirectories);
var files = GetSourceFiles();
var codes = files.Select(i => (File.ReadAllText(i), i));
var libs = GetLibs(libs_, out var luaModuleLibs);
var setting = new LuaSyntaxGenerator.SettingInfo() {
IsClassic = isClassic_,
IsExportMetadata = IsExportMetadata,
BaseFolder = folder_,
BaseFolder = input_,
Attributes = attributes_,
Enums = enums_,
LuaModuleLibs = new HashSet<string>(luaModuleLibs),
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ https://yanghuan.github.io/external/bridgelua-editor/index.html
D:\>dotnet CSharp.Lua.Launcher.dll -h
Usage: CSharp.lua [-s srcfolder] [-d dstfolder]
Arguments
-s : source directory, all *.cs files whill be compiled
-s : can be a directory where all cs files will be compiled, or a list of files, using ';' or ',' to separate
-d : destination directory, will put the out lua files
Options
Expand Down

0 comments on commit 41eb720

Please sign in to comment.