Skip to content

Commit 7cb91a1

Browse files
authored
Merge pull request #452 from Inxton/451-feat-compiler-should-consider-conditional-pragmas
[FEAT] Compiler should consider conditional pragmas
2 parents 00efb35 + 777c8dd commit 7cb91a1

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

src/AXSharp.compiler/src/AXSharp.Compiler/AXSharpProject.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ public AXSharpProject(AxProject axProject, IEnumerable<Type> builderTypes, Type
101101
public void Generate()
102102
{
103103
Log.Logger.Information($"Compilation of project '{AxProject.SrcFolder}' started");
104-
105-
var projectSources = AxProject.Sources.Select(p => (parseTree: STParser.ParseTextAsync(p).Result, source: p));
104+
var projectSources = AxProject.Sources.Select(p => (parseTree: STParser.ParseTextAsync(p, SyntaxTreeOptions.Default, this.AxProject.ProjectInfo.Variables?.DefinedPreprocessorSymbols).Result, source: p));
106105

107106
TargetProject.ProvisionProjectStructure();
108107

src/AXSharp.compiler/src/AXSharp.Compiler/Apax.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ public Apax()
6161
/// </summary>
6262
public IDictionary<string, string>? Dependencies { get; set; }
6363

64+
/// <summary>
65+
/// Gets or sets variables section.
66+
/// This maps to the `variables` node in apax.yml.
67+
/// </summary>
68+
public ApaxVariables? Variables { get; set; }
69+
6470
/// <summary>
6571
/// Creates new instance of <see cref="Apax"/>.
6672
/// </summary>
@@ -135,4 +141,22 @@ public static void UpdateVersion(string apaxFile, string version)
135141
"'apax.yml' file was not found in the working directory. Make sure your current directory is simatic-ax project directory or provide source directory argument (for details see ixc --help)");
136142
}
137143
}
144+
}
145+
146+
/// <summary>
147+
/// Represents the `variables` section of apax.yml.
148+
/// </summary>
149+
public class ApaxVariables
150+
{
151+
/// <summary>
152+
/// Values for APAX build arguments. Maps to the YAML key `APAX_BUILD_ARGS`.
153+
/// </summary>
154+
[YamlMember(Alias = "APAX_BUILD_ARGS", ApplyNamingConventions = false)]
155+
public IEnumerable<string>? ApaxBuildArgs { get; set; }
156+
157+
/// <summary>
158+
/// Values for defined preprocessor symbols. Maps to the YAML key `DEFINED_PREPROCESSOR_SYMBOLS`.
159+
/// </summary>
160+
[YamlMember(Alias = "DEFINED_PREPROCESSOR_SYMBOLS", ApplyNamingConventions = false)]
161+
public IEnumerable<string>? DefinedPreprocessorSymbols { get; set; }
138162
}

0 commit comments

Comments
 (0)