From 94670c408df205e6cde2fbe5c52e88b36c148eed Mon Sep 17 00:00:00 2001 From: Sun Serega Date: Wed, 17 Nov 2021 16:10:37 +0200 Subject: [PATCH] /Define arg --- Compiler/Compiler.cs | 4 ++++ pabcnetc_clear/ConsoleCompiler.cs | 14 ++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index e8d555209..3ab9463d3 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -553,6 +553,8 @@ namespace PascalABCCompiler // public string SystemDirectory; + public List ForceDefines = new List(); + public List SearchDirectory; private bool useDllForSystemUnits = false; @@ -2981,6 +2983,7 @@ namespace PascalABCCompiler DefinesList.Add("RELEASE"); else DefinesList.Add("DEBUG"); + DefinesList.AddRange(CompilerOptions.ForceDefines); SyntaxTree.compilation_unit SyntaxTree = InternalParseText(FileName, SourceText, errorsList, warnings, DefinesList); if (errorsList.Count > 0) throw errorsList[0]; @@ -3277,6 +3280,7 @@ namespace PascalABCCompiler DefinesList.Add("RELEASE"); else DefinesList.Add("DEBUG"); + DefinesList.AddRange(CompilerOptions.ForceDefines); if (compilerOptions.UnitSyntaxTree != null) { CurrentUnit.SyntaxTree = compilerOptions.UnitSyntaxTree; diff --git a/pabcnetc_clear/ConsoleCompiler.cs b/pabcnetc_clear/ConsoleCompiler.cs index b44035169..a0f2ac4db 100644 --- a/pabcnetc_clear/ConsoleCompiler.cs +++ b/pabcnetc_clear/ConsoleCompiler.cs @@ -76,6 +76,10 @@ namespace PascalABCCompiler return false; } + case "define": + co.ForceDefines.Add(value); + return true; + case "output": co.OutputFileName = Path.GetFileName(value); if (Path.IsPathRooted(value)) @@ -111,12 +115,14 @@ namespace PascalABCCompiler Console.WriteLine("pabcnetcclear /directive1:value1 /directive2:value2 ... [inputfile]\n"); Console.WriteLine("Available directives:"); Console.WriteLine(" /Help /H /?"); - Console.WriteLine(" /Debug:0(1)"); - Console.WriteLine(" /output:[\\name]"); + Console.WriteLine(" /Debug:<0/1>"); + Console.WriteLine(" /Define:"); + Console.WriteLine(" /Output:<[path\\]name>"); Console.WriteLine(" /SearchDir:"); Console.WriteLine(); - Console.WriteLine("/output:[ \\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("/Help show this message"); + 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: add \"path\" to list of standart unit search directories. Last added paths would be searched first"); }