Skip to content

Commit

Permalink
Updates to BuildConfigGen (#18069)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people committed Apr 5, 2023
1 parent 03a4b3b commit 66cae46
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 98 deletions.
12 changes: 12 additions & 0 deletions BuildConfigGen/EnsureUpdateModeVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,20 @@ internal string [] FileReadAllLines(string filePath)
}
}

internal bool FilesEqual(string sourcePath, string targetPath)
{
var resolvedTargetPath = ResolveFile(targetPath);

return Helpers.FilesEqual(sourcePath, resolvedTargetPath);
}

private string ResolveFile(string filePath)
{
if(!verifyOnly)
{
return filePath;
}

filePath = NormalizeFile(filePath);

string? sourceFile = null, tempFile = null;
Expand Down
109 changes: 56 additions & 53 deletions BuildConfigGen/Preprocessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ internal static void Preprocess(string file, IEnumerable<string> lines, ISet<str

command = startPreprocessMatch.Groups["command"].Value;
expression = startPreprocessMatch.Groups["expression"].Value;

currentExpression = expression;

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

if (command is not null && command == ifCommand)
if (command is not null)
{
if (inElseBlock)
switch (command)
{
validationErrors.Add($"Error {file}:{lineNumber}: nested #if block in #else block detected, not allowed");
}

if (inIfBlock)
{
validationErrors.Add($"Error {file}:{lineNumber}: nested #if block in #if or #ifelse block detected, not allowed");
}

inIfBlock = true;

if (currentExpression == configName)
{
ifBlockMatched = true;
}
}
case ifCommand:
if (inElseBlock)
{
validationErrors.Add($"Error {file}:{lineNumber}: nested #if block in #else block detected, not allowed");
}

if (command is not null && command == elseIfCommand)
{
if (!inIfBlock)
{
validationErrors.Add($"Error {file}:{lineNumber}: #elseif detected without matching #if block");
}
if (inIfBlock)
{
validationErrors.Add($"Error {file}:{lineNumber}: nested #if block in #if or #ifelse block detected, not allowed");
}

if (currentExpression == configName)
{
ifBlockMatched = true;
}
}
inIfBlock = true;

if (command is not null && command == elseCommand)
{
if (!inIfBlock)
{
validationErrors.Add($"Error {file}:{lineNumber}: #else detected without matching #if or #ifelse block");
}
if (currentExpression == configName)
{
ifBlockMatched = true;
}
break;
case elseIfCommand:
if (!inIfBlock)
{
validationErrors.Add($"Error {file}:{lineNumber}: #elseif detected without matching #if block");
}

inIfBlock = false;
inElseBlock = true;
currentExpression = null;
}
if (currentExpression == configName)
{
ifBlockMatched = true;
}
break;
case elseCommand:
if (!inIfBlock)
{
validationErrors.Add($"Error {file}:{lineNumber}: #else detected without matching #if or #ifelse block");
}

inIfBlock = false;
inElseBlock = true;
currentExpression = null;
break;
case endIfCommand:
if (inIfBlock || inElseBlock)
{
// do nothing
}
else
{
validationErrors.Add($"Error {file}:{lineNumber}: #endif detected without matching #if, #ifelse, or #else block");
}

if (command is not null && command == endIfCommand)
{
if (inIfBlock || inElseBlock)
{
// do nothing
inIfBlock = false;
currentExpression = null;
ifBlockMatched = false;
inElseBlock = false;
expressions.Clear();
break;
default:
validationErrors.Add($"Error {file}:{lineNumber}: unknown command {command}");
currentExpression = null;
break;
}
else
{
validationErrors.Add($"Error {file}:{lineNumber}: #endif detected without matching #if, #ifelse, or #else block");
}

inIfBlock = false;
currentExpression = null;
ifBlockMatched = false;
inElseBlock = false;
expressions.Clear();
}

// assert state
Expand Down
Loading

0 comments on commit 66cae46

Please sign in to comment.