Uncrustify Conversion Detailed Plan and Extended Hard Freeze Update #1


Michael D Kinney
 

Hello,

Michael Kubacki and I have prepared the patches required to apply the
uncrustify changes and enable EDK II CI to check all submitted
patches have been run through uncrustify.

We have verified through the CompareBuild GitHub Action that the
format changes performed by uncrustify have no functional changes.
All of the OBJ, LIB, DLL, EFI, FFS, FV, and FD files match 100%
across 70 VS2019/GCC5 builds of all package/platform DSC files in
the edk2 repo.

The hard freeze will be extended after the edk2-stable202111 tag until
all uncrustify related changes are committed. We do not expect this
to take more than a few days. Do not push any PRs until the hard
freeze is lifted.

The changes are broken up into 7 patch series/PRs. The PRs are ordered
so they can be submitted using the normal submission process and EDK II
CI will pass for each one. Details are listed below.

Uncrustify 73.0.3 for EDK II
=============================
* Sources: https://dev.azure.com/projectmu/_git/Uncrustify
* Documentation: https://dev.azure.com/projectmu/Uncrustify/_wiki/wikis/Uncrustify.wiki/1/Project-Mu-(EDK-II)-Fork-Readme
* Download: https://dev.azure.com/projectmu/Uncrustify/_packaging?_a=package&feed=mu_uncrustify&package=mu-uncrustify-release&protocolType=NuGet&version=73.0.3

Installing Uncrustify
======================
The Uncrustify tool is installed automatically when the Pytools
environment is used and the stuart* commands are run to complete the
environment setup. Please see:

https://github.com/tianocore/edk2/tree/master/.pytool#running-ci-locally

Uncrustify can also be installed from the download page listed above
or built from sources from the source link above.

The Documentation link provides instruction on how to run uncrustify from
the command line or install as a Visual Studio Code plugin. The main
uncrustify documentation also describes how to integrate with a few other
editors.

We have also discussed a client side githook. That effort has not started.
Let us know if that is a feature you would find useful.

Developer impact for new code reviews
======================================
Once the uncrustify checker is active in EDK II CI, developers must
make sure their patches are run through the uncrustify tool before
sending the patches for review.

Developers must install and run uncrustify against changes files before
sending patch review emails or submitting PR for EDK II CI. If EDK II CI
detects and differences in soure formatting, then EDK II CI will fail
and the developer must run uncrustify and resubmit the patches.

Developer impact to patch series/PRs reviewed during edk2-stable201121 soft/hard freeze
=======================================================================================
Developers must rebase their changes after the uncrustify source changes are
committed. The branch with a preview of the uncrustify changes can be used
to start this rebase work.

https://github.com/mdkinney/edk2/tree/Bug_3737_3739_ApplyUncrustifyChanges_V5

Impacts to tracing history across the uncrusity changes
=======================================================
<<TBD details on how to use git blame>>
<<TBD details on other techniques>>

Order of PRs to apply during extended hard freeze
==================================================
1) Update EmulatorPkg Win Host [BuildOptions] MSFT CC_FLAGS to not force debug information
* https://bugzilla.tianocore.org/show_bug.cgi?id=3747
* https://github.com/mdkinney/edk2/tree/Bug_3747_EmulatorPkg_WinHost_ReproducibleBuild
* https://github.com/tianocore/edk2/pull/2215
* Required for EmulatorPkg to pass CompareBuild for VS2019 IA32/X64 builds.
* Status: Review complete

2) EccCheck should not revert staged and local changes
* https://bugzilla.tianocore.org/show_bug.cgi?id=2986
* https://github.com/mdkinney/edk2/tree/Bug_2986_EccCheckRemoveGitRevert_V2
* https://github.com/tianocore/edk2/pull/2216
* Required for EDK II CI to complete in a reasonable period of time when
processing the 4000+ source file style changes made by uncrustify.
* Also fixes critical bugs that can potentially corrupt git state when
EccCheck is run locally.
* Status:
Reviewed-by: Liming Gao mailto:gaoliming@byosoft.com.cn
Waiting for Review/Ack from .pytool maintainer.

3) Update pytool LicenseCheck plugin to use temp directory for diff output file
* https://bugzilla.tianocore.org/show_bug.cgi?id=3746
* https://github.com/mdkinney/edk2/tree/Bug_3746_LicenseCheckUseDiffOutputFile_V2
* https://github.com/tianocore/edk2/pull/2217
* Required to reduce EDK II CI build times.
* Status:
Acked-by: Michael Kubacki mailto:michael.kubacki@microsoft.com
Reviewed-by: Liming Gao mailto:gaoliming@byosoft.com.cn
Waiting for Review/Ack from .pytool maintainer.

4) Update Package YAML to ignore specific ECC files/errors
* https://bugzilla.tianocore.org/show_bug.cgi?id=3749
* https://github.com/mdkinney/edk2/tree/Bug_3749_EccCheckIgnoreFilesErrors
* https://github.com/tianocore/edk2/pull/2218
* Required to pass EccCheck
* Status
Partially reviewed

5) Update max job time from 60 min to 120 minutes in .azurepipelines/templates
* https://bugzilla.tianocore.org/show_bug.cgi?id=3750
* https://github.com/mdkinney/edk2/tree/Bug_3750_IncreaseAzurePipelinesTimeout
* https://github.com/tianocore/edk2/pull/2219
* Required to allow EccCheck of uncrustify changes to complete on Azure
Pipelines CI agents without timing out.
* Status:
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Waiting for Review/Ack from .azurepipelines maintainers

6) UncrustifyCheck EDK II CI Plugin
* https://bugzilla.tianocore.org/show_bug.cgi?id=3748
* https://github.com/makubacki/edk2/tree/add_uncrustify_ci_plugin_v5
* Required to enforce all PRs submitted to EDK II CI match uncrustify format.
* Status
Waiting for review

7) Uncrustify Source Changes
* https://bugzilla.tianocore.org/show_bug.cgi?id=3737
* https://bugzilla.tianocore.org/show_bug.cgi?id=3739
* https://github.com/mdkinney/edk2/tree/Bug_3737_3739_ApplyUncrustifyChanges_V5
* EFI_D_ -> DEBUG changes required to pass PatchCheck
* Uncrustify format changes required to pass UncrustifyCheck
* PR not created yet because it will fail EccCheck without BZ #3749
* Status:
Waiting for review by stewards

Combined Branch/PR for Review/Test
==================================
* Build Comparison results must pass 100% across the full set of PRs before
the individual PRs can be pushed in the order listed above.
* Branch: https://github.com/mdkinney/edk2/tree/TestOnly_Uncrustify_PR_Series
* PR: https://github.com/tianocore/edk2/pull/2220
Status = PASS
* CompareBuild:
Branch: https://github.com/mdkinney/edk2/tree/TestOnly_Uncrustify_PR_Series
--ref1: 198028bf5e46d17f9c502b4ae35ecc406e211c37
--ref2: TestOnly_Uncrustify_PR_Series
Extra Options: -n 4 --quiet
Results: https://github.com/mdkinney/edk2/actions/runs/1498056902
30 VS2019 build comparisons PASS
40 GCC5 build comparisons PASS
100% PASS

The following git log shows the set of patches from --ref1 to --ref 2across
which there are no differences in any of the OBJ/LIB/DLL/EFI/FFS/FV/FD files.

--ref2 641895102bcc (HEAD -> TestOnly_Uncrustify_PR_Series) UnitTestFrameworkPkg: Apply uncrusitify changes
abdb2f5634db UefiPayloadPkg: Apply uncrusitify changes
cb9d471105c2 UefiCpuPkg: Apply uncrusitify changes
e52477cd96a1 StandaloneMmPkg: Apply uncrusitify changes
c94b69de1b0c SourceLevelDebugPkg: Apply uncrusitify changes
f4732a917d54 SignedCapsulePkg: Apply uncrusitify changes
815dcf7b2cd6 ShellPkg: Apply uncrusitify changes
8a699af3521c SecurityPkg: Apply uncrusitify changes
d5907a145b37 RedfishPkg: Apply uncrusitify changes
5ce406d3823b PcAtChipsetPkg: Apply uncrusitify changes
082006536617 OvmfPkg: Apply uncrusitify changes
9c670c478ab4 NetworkPkg: Apply uncrusitify changes
51fa52ef0066 MdePkg: Apply uncrusitify changes
1b4476301abb MdeModulePkg: Apply uncrusitify changes
3701ed8a5588 IntelFsp2WrapperPkg: Apply uncrusitify changes
87db8c3e8f31 IntelFsp2Pkg: Apply uncrusitify changes
add105d79021 FmpDevicePkg: Apply uncrusitify changes
f8543fc3e5c5 FatPkg: Apply uncrusitify changes
65b5fc52fbb4 EmulatorPkg: Apply uncrusitify changes
3f436d2570b0 EmbeddedPkg: Apply uncrusitify changes
cf01f39dd80d DynamicTablesPkg: Apply uncrusitify changes
550476264900 CryptoPkg: Apply uncrusitify changes
c09e92b19e13 ArmVirtPkg: Apply uncrusitify changes
3d86c449ef90 ArmPlatformPkg: Apply uncrusitify changes
bfa1b9c09f07 ArmPkg: Apply uncrusitify changes
541b0f55afa8 UefiCpuPkg: Change use of EFI_D_* to DEBUG_*
b783d2499182 SourceLevelDebugPkg: Change use of EFI_D_* to DEBUG_*
df1821d6ac0e ShellPkg: Change use of EFI_D_* to DEBUG_*
0c8159204288 SecurityPkg: Change use of EFI_D_* to DEBUG_*
cb6643c08293 PcAtChipsetPkg: Change use of EFI_D_* to DEBUG_*
db3f085cb414 OvmfPkg: Change use of EFI_D_* to DEBUG_*
04199e7b8779 NetworkPkg: Change use of EFI_D_* to DEBUG_*
a429397c68ef MdePkg: Change use of EFI_D_* to DEBUG_*
408daf989bb1 MdeModulePkg: Change use of EFI_D_* to DEBUG_*
7846ceaf387e FatPkg: Change use of EFI_D_* to DEBUG_*
9934d3b85a31 EmulatorPkg: Change use of EFI_D_* to DEBUG_*
e5b2066f2cc7 EmbeddedPkg: Change use of EFI_D_* to DEBUG_*
c4b99a53238f ArmVirtPkg: Change use of EFI_D_* to DEBUG_*
db8702afc3cf ArmPlatformPkg: Change use of EFI_D_* to DEBUG_*
f62ed485f30f ArmPkg: Change use of EFI_D_* to DEBUG_*
04e68228fbbb .pytool/Plugin/Uncrustify: Add Uncrustify plugin
3d136bbc9935 .azurepipelines/templates: Update max pipeline job time to 2 hours
34bd4be55e66 UnitTestFrameworkPkg: Update YAML to ignore specific ECC files/errors
793bedcdfb00 UefiPayloadPkg: Update YAML to ignore specific ECC files/errors
7e2e089a77f2 StandaloneMmPkg: Update YAML to ignore specific ECC files/errors
504e1839503c ShellPkg: Update YAML to ignore specific ECC files/errors
fda332b58dfb SecurityPkg: Update YAML to ignore specific ECC files/errors
8d24c7c5e971 MdePkg: Update YAML to ignore specific ECC files/errors
e1182fcdbcea MdeModulePkg: Update YAML to ignore specific ECC files/errors
8a2b93ad4848 EmulatorPkg: Update YAML to ignore specific ECC files/errors
eabfb14f432a CryptoPkg: Update YAML to ignore specific ECC files/errors
cc4fc209113e ArmVirtPkg: Update YAML to ignore specific ECC files/errors
9ec1a1f0e996 ArmPlatformPkg: Update YAML to ignore specific ECC files/errors
3e6a038a080a ArmPkg: Update YAML to ignore specific ECC files/errors
b93693132ec6 .pytools/Plugin/LicenseCheck: Use temp directory for git diff output
b9fee7fe9d75 .pytool/Plugin/EccCheck: Add performance optimizations
26164e6e120c .pytool/Plugin/EccCheck: Remove temp directory on exception
8715acca4b68 .pytool/Plugin/EccCheck: Remove RevertCode()
--ref1 198028bf5e46 EmulatorPkg/Win/Host: Update CC_FLAGS
e1e7306b5414 (origin/master) OvmfPkg/Library/ResetSystemLib: Fix Microvm VS2019 NOOPT build issue

Best regards,

Mike