Skip to content

Commit bff52c0

Browse files
authored
Regenerate WRC when running build.bat or generate-code.bat (#613)
* generate-code.bat: Also regen WRC * build-functions.psm1: Always regen WRC Even if not building WRC.
1 parent 641b7af commit bff52c0

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

Build/build-functions.psm1

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,22 @@ function Remove-ArtifactsDir {
1919

2020
function Update-GeneratedCode {
2121
# Regenerate source code since it occasionally happens that merged pull requests did not include all the regenerated code
22-
write-host -foreground blue "Generate code...`n---"
23-
write-host "$root\UnitsNet\Scripts\GenerateUnits.ps1"
22+
$genScriptDotNet = "$root/UnitsNet/Scripts/GenerateUnits.ps1"
23+
$genScriptWrc = "$root/UnitsNet.WindowsRuntimeComponent/Scripts/GenerateUnits.ps1"
2424

25-
& "$root\UnitsNet\Scripts\GenerateUnits.ps1"
25+
write-host -foreground blue "Generate code for .NET...`n---"
26+
write-host $genScriptDotNet
27+
& $genScriptDotNet
2628
if ($lastexitcode -ne 0) { exit 1 }
2729

28-
if (-not $IncludeWindowsRuntimeComponent) {
29-
write-host -foreground yellow "Skipping WindowsRuntimeComponent code regen."
30-
} else {
31-
& "$root\UnitsNet.WindowsRuntimeComponent\Scripts\GenerateUnits.ps1"
32-
if ($lastexitcode -ne 0) { exit 1 }
33-
}
30+
# Regenerate WRC code even if we are not building that target.
31+
# The reason is that build.bat will skip WRC build since most people don't have that dependency installed.
32+
# AppVeyor build server would still regen and build WRC regardless, but this way we also get the changes
33+
# into pull requests so they are visible and master branch is kept up-to-date.
34+
write-host -foreground blue "Generate code for Windows Runtime Component...`n---"
35+
write-host $genScriptWrc
36+
& $genScriptWrc
37+
if ($lastexitcode -ne 0) { exit 1 }
3438

3539
write-host -foreground blue "Generate code...END`n"
3640
}

generate-code.bat

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@echo off
22
SET scriptdir=%~dp0
3-
pushd "%scriptdir%UnitsNet\Scripts\
4-
powershell -ExecutionPolicy Bypass -NoProfile -File ".\GenerateUnits.ps1"
5-
popd
3+
powershell -ExecutionPolicy Bypass -NoProfile -File "%scriptdir%UnitsNet/Scripts/GenerateUnits.ps1"
4+
powershell -ExecutionPolicy Bypass -NoProfile -File "%scriptdir%UnitsNet.WindowsRuntimeComponent./Scripts/GenerateUnits.ps1"

0 commit comments

Comments
 (0)