SearchDir

This commit is contained in:
SunSerega 2020-07-17 07:02:36 +03:00
parent cae6b94d4e
commit 9fee3a29d0
5 changed files with 29 additions and 26 deletions

View file

@ -369,7 +369,7 @@ namespace CodeCompletion
{
List<string> Dirs = new List<string>();
Dirs.AddRange(ddirs);
Dirs.Add(CodeCompletionController.comp.CompilerOptions.SearchDirectory);
Dirs.AddRange(CodeCompletionController.comp.CompilerOptions.SearchDirectory);
if (CodeCompletionController.StandartDirectories.ContainsKey(LibSourceDirectoryIdent))
Dirs.Add((string)CodeCompletionController.StandartDirectories[LibSourceDirectoryIdent]);
return CodeCompletionController.comp.FindSourceFileNameInDirs(unit_name, Dirs.ToArray());

View file

@ -10,8 +10,8 @@ using System.Reflection;
using PascalABCCompiler;
using PascalABCCompiler.TreeConverter;
using PascalABCCompiler.TreeRealization;
using PascalABCCompiler.Parsers;
using PascalABCCompiler.Parsers;
namespace CodeCompletion
{
public struct RetValue
@ -47,8 +47,8 @@ namespace CodeCompletion
private void InitModules()
{
try
{
string[] files = Directory.GetFiles(CodeCompletionController.comp.CompilerOptions.SearchDirectory, "*.pas");
{
string[] files = Directory.GetFiles(Path.Combine(CodeCompletionController.comp.CompilerOptions.SystemDirectory, "Lib"), "*.pas");
standard_units = new SymInfo[files.Length];
int i = 0;
foreach (string s in files)

View file

@ -164,6 +164,7 @@ using System.Reflection;
//using SyntaxTreeChanger;
using PascalABCCompiler.SyntaxTreeConverters;
using System.Text;
using System.Linq;
namespace PascalABCCompiler
{
@ -546,7 +547,7 @@ namespace PascalABCCompiler
//
public string SystemDirectory;
public string SearchDirectory;
public List<string> SearchDirectory;
private bool useDllForSystemUnits = false;
@ -645,12 +646,13 @@ namespace PascalABCCompiler
private void SetDirectories()
{
SystemDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName);
SearchDirectory = Path.Combine(SystemDirectory,"Lib");
SystemDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName);
StandartDirectories = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
StandartDirectories.Add("%PABCSYSTEM%", SystemDirectory);
ParserSearchPatchs = new string[1];
ParserSearchPatchs[0] = SearchDirectory;
ParserSearchPatchs = new string[] { Path.Combine(SystemDirectory, "Lib") };
SearchDirectory = ParserSearchPatchs.ToList();
}
@ -2456,7 +2458,7 @@ namespace PascalABCCompiler
res = Tuple.Create(res_s1, 1);
else if (FindFileInDirs(Path.GetFileName(fname), CompilerOptions.OutputDirectory) is string res_s2)
res = Tuple.Create(res_s2, 2);
else if (FindFileInDirs(fname, CompilerOptions.SearchDirectory) is string res_s3)
else if (FindFileInDirs(fname, CompilerOptions.SearchDirectory.ToArray()) is string res_s3)
res = Tuple.Create(res_s3, 3);
else
res = null;
@ -2477,7 +2479,7 @@ namespace PascalABCCompiler
if (FindSourceFileNameInDirs(fname, curr_path) is string res_s1)
res = Tuple.Create(res_s1, 1);
else if (FindSourceFileNameInDirs(fname, CompilerOptions.SearchDirectory) is string res_s3)
else if (FindSourceFileNameInDirs(fname, CompilerOptions.SearchDirectory.ToArray()) is string res_s3)
res = Tuple.Create(res_s3, 3);
else
res = null;
@ -2671,11 +2673,6 @@ namespace PascalABCCompiler
return res;
}
private bool FileInSearchDirectory(string FileName)
{
return Path.GetDirectoryName(FileName).ToLower() == CompilerOptions.SearchDirectory.ToLower();
}
public void AddStandartUnitsToUsesSection(SyntaxTree.compilation_unit cu)
{
//if (FileInSearchDirectory(cu.file_name)) return;

View file

@ -120,8 +120,7 @@ namespace VisualPascalABC
if (ToSend == null && File.Exists(StackTraceItem.SourceFileName))
ToSend = StackTraceItem;
if (Workbench.UserOptions.SkipStakTraceItemIfSourceFileInSystemDirectory &&
(Path.GetDirectoryName(StackTraceItem.SourceFileName) == WorkbenchServiceFactory.BuildService.CompilerOptions.SearchDirectory ||
Path.GetDirectoryName(StackTraceItem.SourceFileName) == WorkbenchServiceFactory.BuildService.CompilerOptions.SearchDirectory+"Source"))
StackTraceItem.SourceFileName.StartsWith(WorkbenchServiceFactory.BuildService.CompilerOptions.SystemDirectory))
continue;
if (!(bool)Workbench.VisualEnvironmentCompiler.SourceFilesProvider(StackTraceItem.SourceFileName, PascalABCCompiler.SourceFileOperation.Exists))
{

View file

@ -74,13 +74,19 @@ namespace PascalABCCompiler
Console.WriteLine("Bad value in 'Debug' directive '{0}'. Acceptable values are 0 or 1", value);
return false;
}
case "output":
co.OutputFileName = Path.GetFileName(value);
if (Path.IsPathRooted(value))
{
co.OutputDirectory = Path.GetDirectoryName(value);
}
return true;
case "output":
co.OutputFileName = Path.GetFileName(value);
if (Path.IsPathRooted(value))
{
co.OutputDirectory = Path.GetDirectoryName(value);
}
return true;
case "searchdir":
co.SearchDirectory.Insert(0, value); // .Insert, чтобы определённые пользователем папки имели бОльший приоритет, чем стандартная
return true;
default:
Console.WriteLine("No such directive name: '{0}'", name);
return false;
@ -105,6 +111,7 @@ namespace PascalABCCompiler
Console.WriteLine("Available directives:\n /Help /H /?\n /Debug:0(1)\n /output:[<path>\\name]\n");
Console.WriteLine("/output:[ <path>\\name ] compile into an executable called \"name\" and save it in \"path\" directory");
Console.WriteLine("/Debug:0 generates code with all .NET optimizations!");
Console.WriteLine("/SearchDir:<path> add \"path\" to list of standart unit search directories. Last added paths would be searched first");
}
public static int Main(string[] args)