packaging: add command line flag to add extra vars to pyoxidizer
authorAugie Fackler <augie@google.com>
Tue, 13 Jul 2021 11:37:57 -0400
changeset 47644 be37bb8d0c7c
parent 47643 11f834e7177d
child 47645 b41b4c1c644f
packaging: add command line flag to add extra vars to pyoxidizer This felt simpler than the previous incarnation of injecting content into the WiX build. I decided the easiest way to pass an arbitrary map into the process was some json - I may regret this, but time will tell on that. Differential Revision: https://phab.mercurial-scm.org/D11093
contrib/packaging/hgpackaging/cli.py
contrib/packaging/hgpackaging/wix.py
--- a/contrib/packaging/hgpackaging/cli.py	Mon Jul 12 15:56:25 2021 -0400
+++ b/contrib/packaging/hgpackaging/cli.py	Tue Jul 13 11:37:57 2021 -0400
@@ -64,6 +64,7 @@
     extra_packages_script=None,
     extra_wxs=None,
     extra_features=None,
+    extra_pyoxidizer_vars=None,
 ):
     if not pyoxidizer_target and not python:
         raise Exception("--python required unless building with PyOxidizer")
@@ -105,7 +106,7 @@
             "timestamp_url": sign_timestamp_url,
         }
 
-    fn(**kwargs)
+    fn(**kwargs, extra_pyoxidizer_vars=extra_pyoxidizer_vars)
 
 
 def get_parser():
@@ -168,6 +169,12 @@
             "in the installer from the extra wxs files"
         ),
     )
+
+    sp.add_argument(
+        "--extra-pyoxidizer-vars",
+        help="json map of extra variables to pass to pyoxidizer",
+    )
+
     sp.set_defaults(func=build_wix)
 
     return parser
--- a/contrib/packaging/hgpackaging/wix.py	Mon Jul 12 15:56:25 2021 -0400
+++ b/contrib/packaging/hgpackaging/wix.py	Tue Jul 13 11:37:57 2021 -0400
@@ -8,6 +8,7 @@
 # no-check-code because Python 3 native.
 
 import collections
+import json
 import os
 import pathlib
 import re
@@ -386,6 +387,7 @@
     extra_wxs: typing.Optional[typing.Dict[str, str]] = None,
     extra_features: typing.Optional[typing.List[str]] = None,
     signing_info: typing.Optional[typing.Dict[str, str]] = None,
+    extra_pyoxidizer_vars=None,
 ):
     """Build a WiX MSI installer using PyOxidizer."""
     hg_build_dir = source_dir / "build"
@@ -418,6 +420,9 @@
         if signing_info["timestamp_url"]:
             build_vars["TIME_STAMP_SERVER_URL"] = signing_info["timestamp_url"]
 
+    if extra_pyoxidizer_vars:
+        build_vars.update(json.loads(extra_pyoxidizer_vars))
+
     if extra_wxs:
         raise Exception(
             "support for extra .wxs files has been temporarily dropped"