Patchwork D8474: packaging: isolate invocation of WiX to own function

login
register
mail settings
Submitter phabricator
Date April 22, 2020, 2:39 a.m.
Message ID <differential-rev-PHID-DREV-deiecvgrpcfplevqrzcq-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46203/
State Superseded
Headers show

Comments

phabricator - April 22, 2020, 2:39 a.m.
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Like we did for Inno, we want to split out the building
  of Mercurial from invoking the packaging tool so that we
  can introduce an alternate build mechanism.
  
  As part of this refactor, there are inconsequential changes
  to file layouts. Before, some shared files such as the
  WiX binaries and merge modules would be installed under
  build/. Now, they are installed under build/wix-*. This
  is to keep implementation simpler. But it also helps keep
  build state more isolated.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  contrib/packaging/hgpackaging/wix.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

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
@@ -341,7 +341,6 @@ 
 
     hg_build_dir = source_dir / 'build'
     dist_dir = source_dir / 'dist'
-    wix_dir = source_dir / 'contrib' / 'packaging' / 'wix'
 
     requirements_txt = (
         source_dir / 'contrib' / 'packaging' / 'requirements_win32.txt'
@@ -388,13 +387,41 @@ 
             print('removing %s' % p)
             p.unlink()
 
-    wix_pkg, wix_entry = download_entry('wix', hg_build_dir)
-    wix_path = hg_build_dir / ('wix-%s' % wix_entry['version'])
+    return run_wix_packaging(
+        source_dir,
+        build_dir,
+        staging_dir,
+        arch,
+        version=version,
+        orig_version=orig_version,
+        msi_name=msi_name,
+        extra_wxs=extra_wxs,
+        extra_features=extra_features,
+    )
+
+
+def run_wix_packaging(
+    source_dir: pathlib.Path,
+    build_dir: pathlib.Path,
+    staging_dir: pathlib.Path,
+    arch: str,
+    version: str,
+    orig_version: str,
+    msi_name: typing.Optional[str] = "mercurial",
+    extra_wxs: typing.Optional[typing.Dict[str, str]] = None,
+    extra_features: typing.Optional[typing.List[str]] = None,
+):
+    """Invokes WiX to package up a built Mercurial."""
+
+    wix_dir = source_dir / 'contrib' / 'packaging' / 'wix'
+
+    wix_pkg, wix_entry = download_entry('wix', build_dir)
+    wix_path = build_dir / ('wix-%s' % wix_entry['version'])
 
     if not wix_path.exists():
         extract_zip_to_directory(wix_pkg, wix_path)
 
-    ensure_vc90_merge_modules(hg_build_dir)
+    ensure_vc90_merge_modules(build_dir)
 
     source_build_rel = pathlib.Path(os.path.relpath(source_dir, build_dir))
 
@@ -413,7 +440,7 @@ 
     source = wix_dir / 'mercurial.wxs'
     defines['Version'] = version
     defines['Comments'] = 'Installs Mercurial version %s' % version
-    defines['VCRedistSrcDir'] = str(hg_build_dir)
+    defines['VCRedistSrcDir'] = str(build_dir)
     if extra_features:
         assert all(';' not in f for f in extra_features)
         defines['MercurialExtraFeatures'] = ';'.join(extra_features)