瀏覽代碼

install the MSVC runtime if it is not present on the target machine

The appropriate runtime is downloaded at the time of building the
installer and bundled with it i.e. no separate download is required.
Ashish Kulkarni 10 年之前
父節點
當前提交
f5efb5e2a1
共有 2 個文件被更改,包括 33 次插入1 次删除
  1. 7 0
      scripts/build.py
  2. 26 1
      wkhtmltox.nsi

+ 7 - 0
scripts/build.py

@@ -833,6 +833,10 @@ def build_source_tarball(config, basedir):
 MSVC_LOCATION = {
     'msvc2013': 'VS120COMNTOOLS'
 }
+MSVC_RUNTIME = {
+    'msvc2013-win32': ('18f81495bc5e6b293c69c28b0ac088a96debbab2', 'http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x86.exe'),
+    'msvc2013-win64': ('bef7e7cc1dcc45c0c11682d59c64843727557179', 'http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe')
+}
 
 def check_msvc(config):
     version, arch = rchop(config, '-dbg').split('-')
@@ -882,6 +886,9 @@ def build_msvc(config, basedir):
     version, simple_version = get_version(basedir)
     build_deplibs(config, basedir)
 
+    sha1, url = MSVC_RUNTIME[rchop(config, '-dbg')]
+    shutil.copy(download_file(url, sha1, basedir), os.path.join(basedir, config, 'vcredist.exe'))
+
     libdir = os.path.join(basedir, config, 'deplibs')
     qtdir  = os.path.join(basedir, config, 'qt')
     mkdir_p(qtdir)

+ 26 - 1
wkhtmltox.nsi

@@ -57,10 +57,28 @@ Function ${un}DeleteFiles
 FunctionEnd
 !macroend
 
+!macro CheckVCRedist
+!ifdef MSVC
+  InitPluginsDir
+  ClearErrors
+  ReadRegDWORD $R0 HKLM "SOFTWARE\Microsoft\DevDiv\vc\Servicing\12.0\RuntimeMinimum" "Install"
+  IfErrors need_vcruntime
+  IntCmp $R0 1 skip_vcruntime need_vcruntime need_vcruntime
+need_vcruntime:
+    File /oname=$PLUGINSDIR\vcredist.exe static-build\${TARGET}\vcredist.exe
+skip_vcruntime:
+!endif
+!macroend
+
 !insertmacro DeleteFiles ""
 !insertmacro DeleteFiles "un."
 
 Section "Install"
+!ifdef MSVC
+  IfFileExists "$PLUGINSDIR\vcredist.exe" 0 skip_vcruntime
+  ExecWait '"$PLUGINSDIR\vcredist.exe" /install /quiet /norestart' $R9
+skip_vcruntime:
+!endif
   Call DeleteFiles
 
   SetOutPath "$INSTDIR"
@@ -101,11 +119,18 @@ Section "Uninstall"
 SectionEnd
 
 Function .onInit
+!if "${ARCH}" == "win32"
+    !insertmacro CheckVCRedist
   ${If} ${RunningX64}
     SetRegView 64
+  ${EndIf}
+!endif
 !if "${ARCH}" == "win64"
+  ${If} ${RunningX64}
+    SetRegView 64
+    !insertmacro CheckVCRedist
   ${Else}
     Abort "Cannot install 64-bit binaries on a 32-bit OS"
-!endif
   ${EndIf}
+!endif
 FunctionEnd