D6180: wix: add functionality to inject additional Features into installer

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Tue Apr 2 10:33:06 EDT 2019


durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is the last bit required to be able to glue extra configs etc into
  the installer.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6180

AFFECTED FILES
  contrib/packaging/hgpackaging/wix.py
  contrib/packaging/wix/build.py
  contrib/packaging/wix/mercurial.wxs

CHANGE DETAILS

diff --git a/contrib/packaging/wix/mercurial.wxs b/contrib/packaging/wix/mercurial.wxs
--- a/contrib/packaging/wix/mercurial.wxs
+++ b/contrib/packaging/wix/mercurial.wxs
@@ -129,6 +129,11 @@
         <MergeRef Id='VCRuntime' />
         <MergeRef Id='VCRuntimePolicy' />
       </Feature>
+      <?if $(var.MercurialExtraFeatures)?>
+        <?foreach EXTRAFEAT in $(var.MercurialExtraFeatures)?>
+          <FeatureRef Id="$(var.EXTRAFEAT)" />
+        <?endforeach?>
+      <?endif?>
       <Feature Id='Locales' Title='Translations' Description='Translations' Level='1'>
         <ComponentGroupRef Id='localeFolder' />
         <ComponentRef Id='i18nFolder' />
diff --git a/contrib/packaging/wix/build.py b/contrib/packaging/wix/build.py
--- a/contrib/packaging/wix/build.py
+++ b/contrib/packaging/wix/build.py
@@ -38,6 +38,9 @@
                         help='Extra script to run after creating virtualenv.')
     parser.add_argument('--extra-wxs', 
                         help='CSV of path_to_wxs_file=working_dir_for_wxs_file')
+    parser.add_argument('--extra-features',
+                        help=('CSV of extra feature names to include '
+                              'in the installer from the extra wxs files'))
 
     args = parser.parse_args()
 
@@ -63,6 +66,8 @@
     if args.extra_wxs:
         kwargs['extra_wxs'] = dict(
             thing.split("=") for thing in args.extra_wxs.split(','))
+    if args.extra_features:
+        kwargs['extra_features'] = args.extra_features.split(',')
 
     if args.sign_sn or args.sign_cert:
         fn = build_signed_installer
diff --git a/contrib/packaging/hgpackaging/wix.py b/contrib/packaging/hgpackaging/wix.py
--- a/contrib/packaging/hgpackaging/wix.py
+++ b/contrib/packaging/hgpackaging/wix.py
@@ -180,7 +180,8 @@
 def build_installer(source_dir: pathlib.Path, python_exe: pathlib.Path,
                     msi_name='mercurial', version=None, post_build_fn=None,
                     extra_prebuild_script=None,
-                    extra_wxs:typing.Optional[typing.Dict[str,str]]=None):
+                    extra_wxs:typing.Optional[typing.Dict[str,str]]=None,
+                    extra_features:typing.Optional[typing.List[str]]=None):
     """Build a WiX MSI installer.
 
     ``source_dir`` is the path to the Mercurial source tree to use.
@@ -252,6 +253,9 @@
     defines['Version'] = version
     defines['Comments'] = 'Installs Mercurial version %s' % version
     defines['VCRedistSrcDir'] = str(hg_build_dir)
+    if extra_features:
+        assert all(';' not in f for f in extra_features)
+        defines['MercurialExtraFeatures'] = ';'.join(extra_features)
 
     run_candle(wix_path, build_dir, source, source_build_rel, defines=defines)
 
@@ -294,7 +298,7 @@
                            name: str, version=None, subject_name=None,
                            cert_path=None, cert_password=None,
                            timestamp_url=None, extra_prebuild_script=None,
-                           extra_wxs=None):
+                           extra_wxs=None, extra_features=None):
     """Build an installer with signed executables."""
 
     post_build_fn = make_post_build_signing_fn(
@@ -308,7 +312,7 @@
                            msi_name=name.lower(), version=version,
                            post_build_fn=post_build_fn,
                            extra_prebuild_script=extra_prebuild_script,
-                           extra_wxs=extra_wxs)
+                           extra_wxs=extra_wxs, extra_features=extra_features)
 
     description = '%s %s' % (name, version)
 



To: durin42, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list