internal static LuaSyntaxGenerator CreateGeneratorForFolder(CompilerSettings settings, LuaSyntaxGenerator.SettingInfo settingInfo) { var folderPath = settings.input_; var files = GetFolderSourceFiles(folderPath); var packageBaseFolders = new List <string>(); var codes = files.Select(i => (File.ReadAllText(i), i)); var libs = GetLibs(settings.libs_, out var luaModuleLibs); settingInfo.LuaModuleLibs = luaModuleLibs.ToHashSet(); if (Directory.Exists(folderPath)) { settingInfo.AddBaseFolder(folderPath, false); } else if (files.Count() == 1) { settingInfo.AddBaseFolder(new FileInfo(files.Single()).DirectoryName, true); } else { // throw new NotImplementedException("Unable to determine basefolder(s) when the input is a list of source files."); } return(new LuaSyntaxGenerator(codes, libs, settings.cscArguments_, settings.metas_, settingInfo)); }
internal static LuaSyntaxGenerator CreateGeneratorForProject(CompilerSettings settings, LuaSyntaxGenerator.SettingInfo settingInfo) { var projectPath = settings.input_; var mainProject = ProjectHelper.ParseProject(projectPath, IsCompileDebug(settings.cscArguments_) ? configurationDebug : configurationRelease); var projects = mainProject?.EnumerateProjects().ToArray(); var packages = PackageHelper.EnumeratePackages(mainProject.TargetFrameworkVersions.First(), projects.Select(project => project.project)); var files = GetProjectsSourceFiles(projects); var packageBaseFolders = new List <string>(); if (packages != null) { var searchDirectories = new HashSet <string>(StringComparer.OrdinalIgnoreCase); foreach (var package in packages) { if (IsDecompile(package, settings)) { PackageHelper.EnumerateLibs(package, out var baseFolder); if (string.IsNullOrWhiteSpace(baseFolder)) { continue; } searchDirectories.Add(baseFolder); } } foreach (var package in packages) { var packageFiles = PackageHelper.EnumerateSourceFiles(package, out var baseFolder).ToArray(); if (packageFiles.Length > 0) { files = files.Concat(packageFiles); packageBaseFolders.Add(baseFolder); } if (IsDecompile(package, settings)) { var packageLibs = PackageHelper.EnumerateLibs(package, out baseFolder).ToArray(); if (packageLibs.Length > 0) { var folderInfo = new DirectoryInfo(baseFolder); while (!string.Equals(folderInfo.Name, "packages", StringComparison.OrdinalIgnoreCase)) { folderInfo = folderInfo.Parent; } baseFolder = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "CSharpLua", "packages", baseFolder[(folderInfo.FullName.Length + 1)..]);
public Compiler(string input, string output, string lib, string meta, string?packageIncl, string?packageExcl, string csc, bool isClassic, string?atts, string?enums) { Settings = new CompilerSettings(input, output, lib, meta, packageIncl, packageExcl, csc, isClassic, atts, enums); }