Skip to content

Commit

Permalink
Merge branch 'dev' into kuh0005-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
PTKu authored Sep 5, 2024
2 parents 10eb625 + ef79bc3 commit b2d69bd
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ public interface ICompilerOptions
bool NoDependencyUpdate { get; set; }

bool IgnoreS7Pragmas { get; set; }

bool SkipDependencyCompilation { get; set; }
}
2 changes: 2 additions & 0 deletions src/AXSharp.compiler/src/AXSharp.Compiler/AXSharpConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public string OutputProjectFolder
public bool NoDependencyUpdate { get; set; }

public bool IgnoreS7Pragmas { get; set; }
public bool SkipDependencyCompilation { get; set; }


/// <summary>
Expand Down Expand Up @@ -155,5 +156,6 @@ private static void OverridesFromCli(ICompilerOptions fromConfig, ICompilerOptio
fromConfig.ProjectFile = string.IsNullOrEmpty(newCompilerOptions.ProjectFile) ? fromConfig.ProjectFile : newCompilerOptions.ProjectFile;
fromConfig.NoDependencyUpdate = newCompilerOptions.NoDependencyUpdate;
fromConfig.IgnoreS7Pragmas = newCompilerOptions.IgnoreS7Pragmas;
fromConfig.SkipDependencyCompilation = newCompilerOptions.SkipDependencyCompilation;
}
}
19 changes: 12 additions & 7 deletions src/AXSharp.compiler/src/AXSharp.Compiler/AXSharpProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ public void Generate()

var projectSources = AxProject.Sources.Select(p => (parseTree: STParser.ParseTextAsync(p).Result, source: p));

TargetProject.ProvisionProjectStructure();

var refParseTrees = GetReferences();


var toCompile = refParseTrees.Concat(projectSources.Select(p => p.parseTree));

var compilationResult = Compilation.Create(toCompile, new List<ISemanticAnalyzer>(), Compilation.Settings.Default).Result;
Expand Down Expand Up @@ -135,7 +138,7 @@ public void Generate()
}
}

TargetProject.ProvisionProjectStructure();
//TargetProject.ProvisionProjectStructure();
GenerateMetadata(compilationResult.Compilation);
TargetProject.GenerateResources();
TargetProject.GenerateCompanionData();
Expand Down Expand Up @@ -193,17 +196,20 @@ private static string EnsureFolder(string folder)

private IEnumerable<ISyntaxTree> GetReferences()
{
TargetProject.InstallAXSharpDependencies(AxProject.AXSharpReferences);

var referencedDependencies = TargetProject.LoadReferences();

if (!this.CompilerOptions.SkipDependencyCompilation)
{
CompileProjectReferences(referencedDependencies);
}

var dependencyMetadata = referencedDependencies
.Where(p => p.IsIxDependency)
.Select(p => p.MetadataPath)
.Select(p => JsonConvert.DeserializeObject<IEnumerable<string>>(File.ReadAllText(p)));


CompileProjectReferences(referencedDependencies);


var refParseTrees = dependencyMetadata.SelectMany(p => p)
.Select(s => STParser.ParseTextAsync(new StringText(s)).Result);

Expand All @@ -213,8 +219,7 @@ private IEnumerable<ISyntaxTree> GetReferences()
private static HashSet<string> compiled = new();

private void CompileProjectReferences(IEnumerable<IReference> referencedDependencies)
{
TargetProject.InstallAXSharpDependencies(AxProject.AXSharpReferences);
{
foreach (var ixProjectReference in AxProject.AXSharpReferences.OfType<AXSharpConfig>())
{

Expand Down
17 changes: 17 additions & 0 deletions src/AXSharp.compiler/src/AXSharp.Cs.Compiler/CsProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,21 @@ private static string GetExecutingAssemblyPath()
}


private string EnsureOutputFolder()
{
if (!Directory.Exists(AxSharpProject.OutputFolder))
{
Directory.CreateDirectory(AxSharpProject.OutputFolder);
}

return AxSharpProject.OutputFolder;
}

private void EnsureCsProjFile()
{
if (AxSharpProject.AxProject.ProjectInfo.Name != null)
{
EnsureOutputFolder();
string expectedCsProjFileFullPath = string.Empty;
string expectedCsProjFile = string.Empty;
if (string.IsNullOrEmpty(this.AxSharpProject.CompilerOptions?.ProjectFile))
Expand Down Expand Up @@ -315,6 +326,12 @@ public void InstallAXSharpDependencies(IEnumerable<object> dependencies)
if (compilerOptionsProjectFile != null)
{
var dependent = Path.Combine(this.AxSharpProject.OutputFolder, compilerOptionsProjectFile);

if (!File.Exists(dependent))
{
throw new Exception("Missing dependency file.");
}

foreach (var dependency in dependencies)
{

Expand Down
8 changes: 6 additions & 2 deletions src/AXSharp.compiler/src/ixc/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,23 @@ internal class Options : ICompilerOptions
public string? OutputProjectFolder { get; set; }

[Option('b', "use-base-symbol", Required = false, Default = false,
HelpText = "Will use base symbol in inherited types")]
HelpText = "Will use base symbol in inherited types. Obsolete used in early versions of sld")]
public bool UseBase { get; set; }

[Option('p', "project-file", Required = false, Default = "",
HelpText = "Output project file")]
public string? ProjectFile { get; set; }

[Option('u', "no-dependency-update", Required = false, Default = false,
HelpText = "Prevent dependency of twins from apax")]
HelpText = "Prevent dependency of twins from apax to install")]
public bool NoDependencyUpdate { get; set; }

[Option('s', "no-s7-pragmas", Required = false, Default = false,
HelpText = "Compiler ignores S7.Extern=ReadWrite & S7.Extern=ReadOnly. Compiles all types and members regardless comm settings.")]
public bool IgnoreS7Pragmas { get; set; }

[Option('d', "skip-deps", Required = false, Default = false,
HelpText = "Instructs the compiler to skip dependencies compilation of referenced AX# project.")]
public bool SkipDependencyCompilation { get; set; }
}

4 changes: 2 additions & 2 deletions src/AXSharp.compiler/src/ixc/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"ixc-simple-template": {
"commandName": "Project",

"workingDirectory": "c:\\W\\Develop\\gh\\ix-ax\\_axopen\\axopen.templates\\axopen.template.simple\\ax"
},
"ixc-template-ref": {
Expand All @@ -32,10 +33,9 @@
"commandName": "Project",
"workingDirectory": "C:\\W\\Develop\\gh\\ix-ax\\_axopen\\axopen\\src\\traversals\\apax\\"
},

"axopen-data": {
"commandName": "Project",
"workingDirectory": "c:\\W\\Develop\\gh\\ix-ax\\_axopen\\axopen\\src\\data\\app\\"
}
}
}
}
1 change: 1 addition & 0 deletions src/AXSharp.compiler/src/ixd/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ internal class Options : ICompilerOptions
public string? ProjectFile { get; set; }

public bool IgnoreS7Pragmas { get; set; }
public bool SkipDependencyCompilation { get; set; }
}
}
1 change: 1 addition & 0 deletions src/AXSharp.compiler/src/ixr/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ internal class Options : ICompilerOptions
public bool NoDependencyUpdate { get; set; }

public bool IgnoreS7Pragmas { get; set; }
public bool SkipDependencyCompilation { get; set; }
}
}

0 comments on commit b2d69bd

Please sign in to comment.