Skip to content

Commit 66cae46

Browse files
merlynomsftDmitrii Bobreshev (Akvelon INC)Your Name
authored
Updates to BuildConfigGen (#18069)
* Node16 switch wip * wip * poc update to buildConfigMapping * wip * wip * _ instead of dash - * wip * wip * wip * wip * wip * wip * wip * wip * Include task switching CodeGen to make.js - Add dev.sh and dev.cmd to build CodeGen via cmd (need to add downloading dotnet) - Add logic to change version in task.loc.json as well as in task.json - Add logic to add node16 handler to the generated task to run it under node16 handler and not node10 - Add check that task has node handler - Add check that task doesn't have node16 handler - Fixed problem with slash for unix compatibility * Include task switching CodeGen to make.js - Add gentask argument to call code generator for specific/all tasks and compile code generator is it's not compiled - Add logic to make.js build to build task from _generated folder firstly, and from Tasks folder if it's not found in _generated - Add logic to make.js test to test _generated tasks as well as usual Tasks - Resolved problem with Common folder in _generated folder * clean up * cleanup * Make Build Configs extensible Refactor / clean up * added --write-updates parameter. Default is verify-only * improve json formatting, error handling * Include task switching CodeGen to make.js - Add downloading dotnet sdk to dev.sh for CodeGen - Add pass-through arguments to BuildGen AzureIoTEdgeV2 * make dev.sh compatible with unix-like systems * added system to "override" files per-buildconfig * suppress up-to-date check for _buildConfigs presence in tasks directory * Include task switching CodeGen to make.js - Clean up some of the code in make.js - replace --write-updates with --validate option in make.js * Include task switching CodeGen to make.js - Add rebuild argument for gentask - Fix problem when directory not exists - Fix problem with generating task first time * fix: re-add missing mappings * Clean ups * added preprocessor * update so mapping matches mapping name on server * fix unexpected invalidation * fix issues where verification might fail when preprocessor is used prevent preprocessor from being used in _buildConfig overrides (not necessary to use both) fix directories been created when --write-updates not specified * disable generating _buildConfig/[config] as the precompile should take care of it * refactored verifier to write changes to temp files to compare. This change shouldn't change the output, but makes the verifiction logic more consistent and maintaintable * merged Node16 tasks * write major/minor version (in addition to patch) to task.loc.json verification fix when using file overrides * Add Node16 configurations for tasks * add DockerComposeV0 node upgrade * Update launch settings with DockerComposeV0 * Bump node16 versions * Correctly update AndroidSigningV2 * Correct DockerComposeV0 * fixup DownloadPackageV1 * Run config generation * Include task switching CodeGen to make.js - add --config attribute to make.js - add possibility to build only _generated version of the task without main task * Include task switching CodeGen to make.js - rename parameter from config to configs * Include task switching CodeGen to make.js - Task compilation fix for generated tasks * Include task switching CodeGen to make.js - Generated task update to be able to compile them and pass BuildConfigGenerator validation * move node16 changes to users/merlynop/node16updates * Remove non-BuildconfigGen changes --------- Co-authored-by: Dmitrii Bobreshev (Akvelon INC) <[email protected]> Co-authored-by: Your Name <[email protected]>
1 parent 03a4b3b commit 66cae46

File tree

4 files changed

+151
-98
lines changed

4 files changed

+151
-98
lines changed

BuildConfigGen/EnsureUpdateModeVerifier.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,20 @@ internal string [] FileReadAllLines(string filePath)
223223
}
224224
}
225225

226+
internal bool FilesEqual(string sourcePath, string targetPath)
227+
{
228+
var resolvedTargetPath = ResolveFile(targetPath);
229+
230+
return Helpers.FilesEqual(sourcePath, resolvedTargetPath);
231+
}
232+
226233
private string ResolveFile(string filePath)
227234
{
235+
if(!verifyOnly)
236+
{
237+
return filePath;
238+
}
239+
228240
filePath = NormalizeFile(filePath);
229241

230242
string? sourceFile = null, tempFile = null;

BuildConfigGen/Preprocessor.cs

Lines changed: 56 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ internal static void Preprocess(string file, IEnumerable<string> lines, ISet<str
7474

7575
command = startPreprocessMatch.Groups["command"].Value;
7676
expression = startPreprocessMatch.Groups["expression"].Value;
77+
7778
currentExpression = expression;
7879

7980
if (expressions.Contains(expression))
@@ -104,68 +105,70 @@ internal static void Preprocess(string file, IEnumerable<string> lines, ISet<str
104105
currentExpression = null;
105106
}
106107

107-
if (command is not null && command == ifCommand)
108+
if (command is not null)
108109
{
109-
if (inElseBlock)
110+
switch (command)
110111
{
111-
validationErrors.Add($"Error {file}:{lineNumber}: nested #if block in #else block detected, not allowed");
112-
}
113-
114-
if (inIfBlock)
115-
{
116-
validationErrors.Add($"Error {file}:{lineNumber}: nested #if block in #if or #ifelse block detected, not allowed");
117-
}
118-
119-
inIfBlock = true;
120-
121-
if (currentExpression == configName)
122-
{
123-
ifBlockMatched = true;
124-
}
125-
}
112+
case ifCommand:
113+
if (inElseBlock)
114+
{
115+
validationErrors.Add($"Error {file}:{lineNumber}: nested #if block in #else block detected, not allowed");
116+
}
126117

127-
if (command is not null && command == elseIfCommand)
128-
{
129-
if (!inIfBlock)
130-
{
131-
validationErrors.Add($"Error {file}:{lineNumber}: #elseif detected without matching #if block");
132-
}
118+
if (inIfBlock)
119+
{
120+
validationErrors.Add($"Error {file}:{lineNumber}: nested #if block in #if or #ifelse block detected, not allowed");
121+
}
133122

134-
if (currentExpression == configName)
135-
{
136-
ifBlockMatched = true;
137-
}
138-
}
123+
inIfBlock = true;
139124

140-
if (command is not null && command == elseCommand)
141-
{
142-
if (!inIfBlock)
143-
{
144-
validationErrors.Add($"Error {file}:{lineNumber}: #else detected without matching #if or #ifelse block");
145-
}
125+
if (currentExpression == configName)
126+
{
127+
ifBlockMatched = true;
128+
}
129+
break;
130+
case elseIfCommand:
131+
if (!inIfBlock)
132+
{
133+
validationErrors.Add($"Error {file}:{lineNumber}: #elseif detected without matching #if block");
134+
}
146135

147-
inIfBlock = false;
148-
inElseBlock = true;
149-
currentExpression = null;
150-
}
136+
if (currentExpression == configName)
137+
{
138+
ifBlockMatched = true;
139+
}
140+
break;
141+
case elseCommand:
142+
if (!inIfBlock)
143+
{
144+
validationErrors.Add($"Error {file}:{lineNumber}: #else detected without matching #if or #ifelse block");
145+
}
151146

147+
inIfBlock = false;
148+
inElseBlock = true;
149+
currentExpression = null;
150+
break;
151+
case endIfCommand:
152+
if (inIfBlock || inElseBlock)
153+
{
154+
// do nothing
155+
}
156+
else
157+
{
158+
validationErrors.Add($"Error {file}:{lineNumber}: #endif detected without matching #if, #ifelse, or #else block");
159+
}
152160

153-
if (command is not null && command == endIfCommand)
154-
{
155-
if (inIfBlock || inElseBlock)
156-
{
157-
// do nothing
161+
inIfBlock = false;
162+
currentExpression = null;
163+
ifBlockMatched = false;
164+
inElseBlock = false;
165+
expressions.Clear();
166+
break;
167+
default:
168+
validationErrors.Add($"Error {file}:{lineNumber}: unknown command {command}");
169+
currentExpression = null;
170+
break;
158171
}
159-
else
160-
{
161-
validationErrors.Add($"Error {file}:{lineNumber}: #endif detected without matching #if, #ifelse, or #else block");
162-
}
163-
164-
inIfBlock = false;
165-
currentExpression = null;
166-
ifBlockMatched = false;
167-
inElseBlock = false;
168-
expressions.Clear();
169172
}
170173

171174
// assert state

0 commit comments

Comments
 (0)