Skip to content

Commit

Permalink
[PObserve] Adds --pobserve-package <string> option
Browse files Browse the repository at this point in the history
Adds hidden option -po <str> to configure PObserve package name in generated output (defaults to <project-name>.pobserve as before)
  • Loading branch information
aman-goel committed Sep 19, 2023
1 parent fa520e2 commit 4cfbc8b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
5 changes: 2 additions & 3 deletions Src/PCompiler/CompilerCore/Backend/Java/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ internal static string AsFFIComment(string line)
<modelVersion>4.0.0</modelVersion>
<groupId>com.amazon.p</groupId>
<artifactId>-project-name-</artifactId>
<artifactId>-package-name-</artifactId>
<version>1.0-SNAPSHOT</version>
<name>-project-name-</name>
<name>-package-name-</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
Expand Down Expand Up @@ -165,7 +165,6 @@ internal static string AsFFIComment(string line)
</executions>
</plugin>
</plugins>
<directory>${{buildDirectory}}</directory>
<sourceDirectory>.</sourceDirectory>
</build>
</project>";
Expand Down
2 changes: 1 addition & 1 deletion Src/PCompiler/CompilerCore/Backend/Java/JavaCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}";

/// <summary>
/// Constructs a new Java source generator for a particular output file.
Expand Down
4 changes: 4 additions & 0 deletions Src/PCompiler/CompilerCore/CompilerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public CompilerConfiguration()
InputForeignFiles = new List<string>();
Output = null;
ProjectName = "generatedOutput";
PObservePackageName = $"{ProjectName}.pobserve";
ProjectRootPath = new DirectoryInfo(Directory.GetCurrentDirectory());
LocationResolver = new DefaultLocationResolver();
Handler = new DefaultTranslationErrorHandler(LocationResolver);
Expand Down Expand Up @@ -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);
Expand All @@ -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<string> InputPFiles { get; set; }
Expand All @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions Src/PCompiler/CompilerCore/ICompilerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
5 changes: 5 additions & 0 deletions Src/PCompiler/PCommandLine/Options/PCompilerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>() { "bugfinding", "verification", "coverage", "pobserve", "stately" };
modes.IsHidden = true;

Parser.AddArgument("pobserve-package", "po", "PObserve package name").IsHidden = true;
}

/// <summary>
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4cfbc8b

Please sign in to comment.