pw_presubmit: Add substeps to software update

Bug: b/253021172
Change-Id: I525c7de5d03a780d14fc2fda57e322c5080a5b31
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/126003
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py b/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py
index a430132..05a6579 100755
--- a/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py
+++ b/pw_presubmit/py/pw_presubmit/pigweed_presubmit.py
@@ -304,34 +304,33 @@
     build.ninja(ctx, 'pi_pico')
 
 
-@_BUILD_FILE_FILTER.apply_to_check()
-def gn_software_update_build(ctx: PresubmitContext):
-    build.install_package(ctx, 'nanopb')
-    build.install_package(ctx, 'protobuf')
-    build.install_package(ctx, 'mbedtls')
-    build.install_package(ctx, 'micro-ecc')
-    build.gn_gen(
-        ctx,
-        dir_pw_third_party_protobuf='"{}"'.format(
+gn_software_update_build = build.GnGenNinja(
+    name='gn_software_update_build',
+    path_filter=_BUILD_FILE_FILTER,
+    packages=('nanopb', 'protobuf', 'mbedtls', 'micro-ecc'),
+    gn_args={
+        'dir_pw_third_party_protobuf': lambda ctx: '"{}"'.format(
             ctx.package_root / 'protobuf'
         ),
-        dir_pw_third_party_nanopb='"{}"'.format(ctx.package_root / 'nanopb'),
-        dir_pw_third_party_micro_ecc='"{}"'.format(
+        'dir_pw_third_party_nanopb': lambda ctx: '"{}"'.format(
+            ctx.package_root / 'nanopb'
+        ),
+        'dir_pw_third_party_micro_ecc': lambda ctx: '"{}"'.format(
             ctx.package_root / 'micro-ecc'
         ),
-        pw_crypto_ECDSA_BACKEND='"{}"'.format(
+        'pw_crypto_ECDSA_BACKEND': lambda ctx: '"{}"'.format(
             ctx.root / 'pw_crypto:ecdsa_uecc'
         ),
-        dir_pw_third_party_mbedtls='"{}"'.format(ctx.package_root / 'mbedtls'),
-        pw_crypto_SHA256_BACKEND='"{}"'.format(
+        'dir_pw_third_party_mbedtls': lambda ctx: '"{}"'.format(
+            ctx.package_root / 'mbedtls'
+        ),
+        'pw_crypto_SHA256_BACKEND': lambda ctx: '"{}"'.format(
             ctx.root / 'pw_crypto:sha256_mbedtls'
         ),
-        pw_C_OPTIMIZATION_LEVELS=_OPTIMIZATION_LEVELS,
-    )
-    build.ninja(
-        ctx,
-        *_at_all_optimization_levels('host_clang'),
-    )
+        'pw_C_OPTIMIZATION_LEVELS': _OPTIMIZATION_LEVELS,
+    },
+    ninja_targets=_at_all_optimization_levels('host_clang'),
+)
 
 
 @_BUILD_FILE_FILTER.apply_to_check()