From 4cfbc8b56e0784497204145ef9e19365ea2b8654 Mon Sep 17 00:00:00 2001 From: Aman Goel Date: Tue, 19 Sep 2023 10:08:55 -0700 Subject: [PATCH] [PObserve] Adds --pobserve-package option Adds hidden option -po to configure PObserve package name in generated output (defaults to .pobserve as before) --- Src/PCompiler/CompilerCore/Backend/Java/Constants.cs | 5 ++--- Src/PCompiler/CompilerCore/Backend/Java/JavaCompiler.cs | 2 +- .../CompilerCore/Backend/Java/JavaSourceGenerator.cs | 2 +- Src/PCompiler/CompilerCore/CompilerConfiguration.cs | 4 ++++ Src/PCompiler/CompilerCore/ICompilerConfiguration.cs | 1 + Src/PCompiler/PCommandLine/Options/PCompilerOptions.cs | 5 +++++ 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs b/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs index 93208a1a3..b21d20ad1 100644 --- a/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs +++ b/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs @@ -115,10 +115,10 @@ internal static string AsFFIComment(string line) 4.0.0 com.amazon.p - -project-name- + -package-name- 1.0-SNAPSHOT - -project-name- + -package-name- UTF-8 11 @@ -165,7 +165,6 @@ internal static string AsFFIComment(string line) - ${{buildDirectory}} . "; diff --git a/Src/PCompiler/CompilerCore/Backend/Java/JavaCompiler.cs b/Src/PCompiler/CompilerCore/Backend/Java/JavaCompiler.cs index e44a7859c..b9970193c 100644 --- a/Src/PCompiler/CompilerCore/Backend/Java/JavaCompiler.cs +++ b/Src/PCompiler/CompilerCore/Backend/Java/JavaCompiler.cs @@ -14,7 +14,7 @@ public void GenerateBuildScript(ICompilerConfiguration job) // create the pom.xml file var pomTemplate = Constants.pomTemplate; - pomTemplate = pomTemplate.Replace("-project-name-",job.ProjectName); + pomTemplate = pomTemplate.Replace("-package-name-",job.PObservePackageName); string foreignInclude = ""; var foreignFiles = job.InputForeignFiles.Where(x => x.EndsWith(".java")); diff --git a/Src/PCompiler/CompilerCore/Backend/Java/JavaSourceGenerator.cs b/Src/PCompiler/CompilerCore/Backend/Java/JavaSourceGenerator.cs index 46298d2fc..3af2b83b0 100644 --- a/Src/PCompiler/CompilerCore/Backend/Java/JavaSourceGenerator.cs +++ b/Src/PCompiler/CompilerCore/Backend/Java/JavaSourceGenerator.cs @@ -14,7 +14,7 @@ public abstract class JavaSourceGenerator internal NameManager Names => _context.Names; internal TypeManager Types => _context.Types; - internal String PackageName => $"{Job.ProjectName}.pobserve"; + internal String PackageName => $"{Job.PObservePackageName}"; /// /// Constructs a new Java source generator for a particular output file. diff --git a/Src/PCompiler/CompilerCore/CompilerConfiguration.cs b/Src/PCompiler/CompilerCore/CompilerConfiguration.cs index a72e0ed94..2af8de98f 100644 --- a/Src/PCompiler/CompilerCore/CompilerConfiguration.cs +++ b/Src/PCompiler/CompilerCore/CompilerConfiguration.cs @@ -16,6 +16,7 @@ public CompilerConfiguration() InputForeignFiles = new List(); Output = null; ProjectName = "generatedOutput"; + PObservePackageName = $"{ProjectName}.pobserve"; ProjectRootPath = new DirectoryInfo(Directory.GetCurrentDirectory()); LocationResolver = new DefaultLocationResolver(); Handler = new DefaultTranslationErrorHandler(LocationResolver); @@ -47,6 +48,7 @@ public CompilerConfiguration(ICompilerOutput output, DirectoryInfo outputDir, Co } } ProjectName = projectName ?? Path.GetFileNameWithoutExtension(inputFiles[0]); + PObservePackageName = $"{ProjectName}.pobserve"; ProjectRootPath = projectRoot; LocationResolver = new DefaultLocationResolver(); Handler = new DefaultTranslationErrorHandler(LocationResolver); @@ -59,6 +61,7 @@ public CompilerConfiguration(ICompilerOutput output, DirectoryInfo outputDir, Co public DirectoryInfo OutputDirectory { get; set; } public CompilerOutput OutputLanguage { get; set; } public string ProjectName { get; set; } + public string PObservePackageName { get; set; } public DirectoryInfo ProjectRootPath { get; set; } public ICodeGenerator Backend { get; set; } public IList InputPFiles { get; set; } @@ -79,6 +82,7 @@ public void Copy(CompilerConfiguration parsedConfig) LocationResolver = parsedConfig.LocationResolver; ProjectDependencies = parsedConfig.ProjectDependencies; ProjectName = parsedConfig.ProjectName; + PObservePackageName = parsedConfig.PObservePackageName; OutputLanguage = parsedConfig.OutputLanguage; ProjectRootPath = parsedConfig.ProjectRootPath; } diff --git a/Src/PCompiler/CompilerCore/ICompilerConfiguration.cs b/Src/PCompiler/CompilerCore/ICompilerConfiguration.cs index 3f30cc12b..2f524166c 100644 --- a/Src/PCompiler/CompilerCore/ICompilerConfiguration.cs +++ b/Src/PCompiler/CompilerCore/ICompilerConfiguration.cs @@ -8,6 +8,7 @@ namespace Plang.Compiler public interface ICompilerConfiguration { string ProjectName { get; } + string PObservePackageName { get; } DirectoryInfo ProjectRootPath { get; } CompilerOutput OutputLanguage { get; } ICompilerOutput Output { get; } diff --git a/Src/PCompiler/PCommandLine/Options/PCompilerOptions.cs b/Src/PCompiler/PCommandLine/Options/PCompilerOptions.cs index 2a2c3079e..b6b883d09 100644 --- a/Src/PCompiler/PCommandLine/Options/PCompilerOptions.cs +++ b/Src/PCompiler/PCommandLine/Options/PCompilerOptions.cs @@ -42,6 +42,8 @@ internal PCompilerOptions() var modes = Parser.AddArgument("mode", "md", "Compilation mode :: (bugfinding, verification, coverage, pobserve, stately). (default: bugfinding)"); modes.AllowedValues = new List() { "bugfinding", "verification", "coverage", "pobserve", "stately" }; modes.IsHidden = true; + + Parser.AddArgument("pobserve-package", "po", "PObserve package name").IsHidden = true; } /// @@ -169,6 +171,9 @@ private static void UpdateConfigurationWithParsedArgument(CompilerConfiguration compilerConfiguration.Backend = TargetLanguage.GetCodeGenerator(compilerConfiguration.OutputLanguage); } break; + case "pobserve-package": + compilerConfiguration.PObservePackageName = (string)option.Value; + break; case "pfiles": { var files = (string[])option.Value;