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

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Tue Apr 2 16:30:53 EDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG1711f5813a63: wix: add functionality to inject additional Features into installer (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6180?vs=14630&id=14633

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
@@ -39,6 +39,9 @@
                               'py2exe binary.'))
     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()
 
@@ -64,6 +67,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
@@ -179,8 +179,9 @@
 
 def build_installer(source_dir: pathlib.Path, python_exe: pathlib.Path,
                     msi_name='mercurial', version=None, post_build_fn=None,
-                    extra_packages_script: typing.Optional[str]=None,
-                    extra_wxs:typing.Optional[typing.Dict[str,str]]=None):
+                    extra_packages_script=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.
@@ -197,6 +198,8 @@
     print a null byte followed by a newline-separated list of packages that
     should be included in the exe.
     ``extra_wxs`` is a dict of {wxs_name: working_dir_for_wxs_build}.
+    ``extra_features`` is a list of additional named Features to include in
+    the build. These must match Feature names in one of the wxs scripts.
     """
     arch = 'x64' if r'\x64' in os.environ.get('LIB', '') else 'x86'
 
@@ -256,6 +259,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)
 
@@ -298,7 +304,7 @@
                            name: str, version=None, subject_name=None,
                            cert_path=None, cert_password=None,
                            timestamp_url=None, extra_packages_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(
@@ -312,7 +318,7 @@
                            msi_name=name.lower(), version=version,
                            post_build_fn=post_build_fn,
                            extra_packages_script=extra_packages_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