Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate preprocessor symbols #2439

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .github/AL-Go-Settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
"useProjectDependencies": true,
"repoVersion": "26.0",
"cleanModePreprocessorSymbols": [
"CLEAN17",
"CLEAN18",
"CLEAN19",
"CLEAN20",
"CLEAN21",
"CLEAN22",
"CLEAN23",
"CLEAN24",
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/TestPreprocessorSymbols/action.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if ($CurrentVersion -le 26) {

# Define the preprocessor symbols to check for
$symbolConfigs = @(
@{stem = "CLEAN"; lowerBound = ($CurrentVersion - 4); upperBound = $mainVersion},
@{stem = "CLEAN"; lowerBound = (Get-MinAllowedCleantagVersion); upperBound = $mainVersion},
aholstrup1 marked this conversation as resolved.
Show resolved Hide resolved
@{stem = "CLEANSCHEMA"; lowerBound = $schemaLowerBound; upperBound = $mainVersion + 3} # next lowerbound, after cleanup should be 25, then
)

Expand Down
14 changes: 14 additions & 0 deletions build/scripts/GuardingV2ExtensionsHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,18 @@ function Get-MaxAllowedObsoleteVersion() {
return [System.Version]::Parse($alGoSettings.repoVersion).Major
}

function Get-MinAllowedCleantagVersion() {
aholstrup1 marked this conversation as resolved.
Show resolved Hide resolved
Import-Module -Name $PSScriptRoot\EnlistmentHelperFunctions.psm1
[int] $currentVersion = (Get-ConfigValue -Key "repoVersion" -ConfigType AL-Go) -split '\.' | Select-Object -First 1
$lowerBound = $CurrentVersion - 4
return $lowerBound
}

function Get-PreprocessorSymbols() {
[int] $upperBound = Get-MaxAllowedObsoleteVersion
[int] $lowerBound = Get-MinAllowedCleantagVersion

return $lowerBound..$upperBound | ForEach-Object { "CLEAN$_" }
}

Export-ModuleMember -Function *-*
2 changes: 2 additions & 0 deletions build/scripts/PreCompileApp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ if($appType -eq 'app')
else {
Compile-AppInBcContainer @tempParameters | Out-Null
}

$parameters.Value["preprocessorsymbols"] = Get-PreprocessorSymbols
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the clean tags are set here, what's the point of cleanModePreprocessorSymbols setting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None. They're not used. But AL-Go fails if we don't set anything.

Maybe we should just write a warning here instead of throwing an error?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a defensive check, so not sure about a warning. How would you fix such a warning?

But why automation PRs? 🤔
My idea was just to add a check (in "Verify App Changes" maybe) that the cleanModePreprocessorSymbols are in order, based on the current version.
Then, to be on the safe side, Get-PreprocessorSymbols can dynamically add CLEAN preprocessor symbols for all versions between the current version and the version on main.

Generally speaking, CLEAN26 makes no sense in version 25. But so do all the clean builds we do all around, but main.

}

if(($appBuildMode -eq 'Strict') -and !(Test-IsStrictModeEnabled)) {
Expand Down
Loading