Skip to content

Commit

Permalink
patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Browse files Browse the repository at this point in the history
Problem:    MS-Windows: missing 32 and 64 bit files in installer.
Solution:   Include both 32 and 64 bit GvimExt and related dll files. Remove
            old Windows code from the installer. (Ken Takata, closes #2144)
  • Loading branch information
brammool committed Oct 14, 2017
1 parent 2c33d7b commit 6199d43
Show file tree
Hide file tree
Showing 8 changed files with 306 additions and 370 deletions.
23 changes: 17 additions & 6 deletions Makefile
Expand Up @@ -120,10 +120,14 @@ MINOR = 0
#
# MS-Windows:
# - Run make on Unix to update the ".mo" files.
# - Get libintl-8.dll, libiconv-2.dll and libgcc_s_sjlj-1.dll. E.g. from
# - Get 32 bit libintl-8.dll, libiconv-2.dll and libgcc_s_sjlj-1.dll. E.g. from
# https://mlocati.github.io/gettext-iconv-windows/ .
# Use the "shared-32.zip file and extract the archive to get the files.
# Put them in the top directory, "make dosrt" uses them.
# Put them in the gettext32 directory, "make dosrt" uses them.
# - Get 64 bit libintl-8.dll and libiconv-2.dll. E.g. from
# https://mlocati.github.io/gettext-iconv-windows/ .
# Use the "shared-64.zip file and extract the archive to get the files.
# Put them in the gettext64 directory, "make dosrt" uses them.
# - > make dossrc
# > make dosrt
# Unpack dist/vim##rt.zip and dist/vim##src.zip on an MS-Windows PC.
Expand Down Expand Up @@ -461,9 +465,13 @@ dosrt_files: dist prepare no_title.vim
cp $$i dist/vim/$(VIMRTDIR)/lang/$$n/LC_MESSAGES/vim.mo; \
fi \
done
cp libintl-8.dll dist/vim/$(VIMRTDIR)/
cp libiconv-2.dll dist/vim/$(VIMRTDIR)/
cp libgcc_s_sjlj-1.dll dist/vim/$(VIMRTDIR)/
mkdir dist/vim/$(VIMRTDIR)/gettext32
cp gettext32/libintl-8.dll dist/vim/$(VIMRTDIR)/gettext32/
cp gettext32/libiconv-2.dll dist/vim/$(VIMRTDIR)/gettext32/
cp gettext32/libgcc_s_sjlj-1.dll dist/vim/$(VIMRTDIR)/gettext32/
mkdir dist/vim/$(VIMRTDIR)/gettext64
cp gettext64/libintl-8.dll dist/vim/$(VIMRTDIR)/gettext64/
cp gettext64/libiconv-2.dll dist/vim/$(VIMRTDIR)/gettext64/


# Used before uploading. Don't delete the AAPDIR/sign files!
Expand All @@ -490,7 +498,10 @@ dosbin_gvim: dist no_title.vim dist/$(COMMENT_GVIM)
cp vimrun.exe dist/vim/$(VIMRTDIR)/vimrun.exe
cp installw32.exe dist/vim/$(VIMRTDIR)/install.exe
cp uninstalw32.exe dist/vim/$(VIMRTDIR)/uninstal.exe
cp gvimext.dll dist/vim/$(VIMRTDIR)/gvimext.dll
mkdir dist/vim/$(VIMRTDIR)/GvimExt32
cp gvimext.dll dist/vim/$(VIMRTDIR)/GvimExt32/gvimext.dll
mkdir dist/vim/$(VIMRTDIR)/GvimExt64
cp gvimext64.dll dist/vim/$(VIMRTDIR)/GvimExt64/gvimext.dll
cd dist && zip -9 -rD -z gvim$(VERSION).zip vim <$(COMMENT_GVIM)
cp gvim.pdb dist/gvim$(VERSION).pdb

Expand Down
34 changes: 31 additions & 3 deletions nsis/README.txt
@@ -1,5 +1,5 @@
This builds a one-click install for Vim for Win32 using the Nullsoft
Installation System (NSIS), available at http://www.nullsoft.com/free/nsis/
Installation System (NSIS), available at http://nsis.sourceforge.net/

To build the installable .exe:

Expand All @@ -17,8 +17,14 @@ To build the installable .exe:
uninstal.exe,
xxd/xxd.exe,

Then execute tools/rename.bat to rename the executables. (mv command is
required.)

3. Go to the GvimExt directory and build gvimext.dll (or get it from a binary
archive).
archive). Both 64- and 32-bit versions are needed and should be placed
as follows:
64-bit: src/GvimExt/gvimext64.dll
32-bit: src/GvimExt/gvimext.dll

4. Go to the VisVim directory and build VisVim.dll (or get it from a binary
archive).
Expand All @@ -27,13 +33,35 @@ To build the installable .exe:
get them from a binary archive).

6. Get a "diff.exe" program and put it in the "../.." directory (above the
"vim61" directory, it's the same for all Vim versions).
"vim80" directory, it's the same for all Vim versions).
You can find one in previous Vim versions or in this archive:
http://www.mossbayeng.com/~ron/vim/diffutils.tar.gz
Also put winpty32.dll and winpty-agent.exe there.

7. Do "make uganda.nsis.txt" in runtime/doc. This requires sed, you may have
to do this on Unix. Make sure the file is in DOS file format!

8. Get gettext and iconv DLLs from the following site:
https://github.com/mlocati/gettext-iconv-windows/releases
Both 64- and 32-bit versions are needed.
Download the files gettextX.X.X.X-iconvX.XX-shared-{32,64}.zip, extract
DLLs and place them as follows:

<GETTEXT directory>
|
+ gettext32/
| libintl-8.dll
| libiconv-2.dll
| libgcc_s_sjlj-1.dll
|
` gettext64/
libintl-8.dll
libiconv-2.dll

The default <GETTEXT directory> is "..", however, you can change it by
passing /DGETTEXT=... option to the makensis command.


Install NSIS if you didn't do that already.
Also install UPX, if you want a compressed file.

Expand Down
87 changes: 71 additions & 16 deletions nsis/gvim.nsi
Expand Up @@ -20,8 +20,15 @@
!define VIMTOOLS ..\..
!endif

# Location of gettext.
# It must contain two directories: gettext32 and gettext64.
# See README.txt for detail.
!ifndef GETTEXT
!define GETTEXT ${VIMRT}
!endif

# Comment the next line if you don't have UPX.
# Get it at http://upx.sourceforge.net
# Get it at https://upx.github.io/
!define HAVE_UPX

# comment the next line if you do not want to add Native Language Support
Expand Down Expand Up @@ -328,24 +335,67 @@ Section "Add an Edit-with-Vim context menu entry"
SetOutPath $0
ClearErrors
SetOverwrite try

${If} ${RunningX64}
# Install 64-bit gvimext.dll into the GvimExt64 directory.
SetOutPath $0\GvimExt64
ClearErrors
File /oname=gvimext.dll ${VIMSRC}\GvimExt\gvimext64.dll
${Else}
File /oname=gvimext.dll ${VIMSRC}\GvimExt\gvimext.dll
!ifdef HAVE_NLS
File ${GETTEXT}\gettext64\libintl-8.dll
File ${GETTEXT}\gettext64\libiconv-2.dll
!endif

IfErrors 0 GvimExt64Done

# Can't copy gvimext.dll, create it under another name and rename it
# on next reboot.
GetTempFileName $3 $0\GvimExt64
File /oname=$3 ${VIMSRC}\GvimExt64\gvimext.dll
Rename /REBOOTOK $3 $0\GvimExt64\gvimext.dll
!ifdef HAVE_NLS
GetTempFileName $3 $0\GvimExt64
File /oname=$3 ${GETTEXT}\gettext64\libintl-8.dll
Rename /REBOOTOK $3 $0\GvimExt64\libintl-8.dll
GetTempFileName $3 $0\GvimExt64
File /oname=$3 ${GETTEXT}\gettext64\libiconv-2.dll
Rename /REBOOTOK $3 $0\GvimExt64\libiconv-2.dll
!endif
${EndIf}
IfErrors 0 GvimExtDone

GvimExt64Done:

# Install 32-bit gvimext.dll into the GvimExt32 directory.
SetOutPath $0\GvimExt32
ClearErrors

File /oname=gvimext.dll ${VIMSRC}\GvimExt\gvimext.dll
!ifdef HAVE_NLS
File ${GETTEXT}\gettext32\libintl-8.dll
File ${GETTEXT}\gettext32\libiconv-2.dll
File ${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll
!endif

IfErrors 0 GvimExt32Done

# Can't copy gvimext.dll, create it under another name and rename it on
# next reboot.
GetTempFileName $3 $0
${If} ${RunningX64}
File /oname=$3 ${VIMSRC}\GvimExt\gvimext64.dll
${Else}
File /oname=$3 ${VIMSRC}\GvimExt\gvimext.dll
${EndIf}
Rename /REBOOTOK $3 $0\gvimext.dll
GetTempFileName $3 $0\GvimExt32
File /oname=$3 ${VIMSRC}\GvimExt\gvimext.dll
Rename /REBOOTOK $3 $0\GvimExt32\gvimext.dll
!ifdef HAVE_NLS
GetTempFileName $3 $0\GvimExt32
File /oname=$3 ${GETTEXT}\gettext32\libintl-8.dll
Rename /REBOOTOK $3 $0\GvimExt32\libintl-8.dll
GetTempFileName $3 $0\GvimExt32
File /oname=$3 ${GETTEXT}\gettext32\libiconv-2.dll
Rename /REBOOTOK $3 $0\GvimExt32\libiconv-2.dll
GetTempFileName $3 $0\GvimExt32
File /oname=$3 ${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll
Rename /REBOOTOK $3 $0\GvimExt32\libgcc_s_sjlj-1.dll
!endif

GvimExtDone:
GvimExt32Done:
SetOverwrite lastused

# We don't have a separate entry for the "Open With..." menu, assume
Expand Down Expand Up @@ -394,10 +444,10 @@ SectionEnd
File ${VIMRT}\keymap\README.txt
File ${VIMRT}\keymap\*.vim
SetOutPath $0
File ${VIMRT}\libintl-8.dll
File ${VIMRT}\libiconv-2.dll
File /nonfatal ${VIMRT}\libwinpthread-1.dll
File /nonfatal ${VIMRT}\libgcc_s_sjlj-1.dll
File ${GETTEXT}\gettext32\libintl-8.dll
File ${GETTEXT}\gettext32\libiconv-2.dll
#File /nonfatal ${VIMRT}\libwinpthread-1.dll
File /nonfatal ${GETTEXT}\gettext32\libgcc_s_sjlj-1.dll
SectionEnd
!endif

Expand Down Expand Up @@ -437,6 +487,11 @@ Section Uninstall
$\nIt contains the Vim executables and runtime files." IDNO NoRemoveExes

Delete /REBOOTOK $0\*.dll
Delete /REBOOTOK $0\GvimExt32\*.dll
${If} ${RunningX64}
Delete /REBOOTOK $0\GvimExt64\*.dll
${EndIf}

ClearErrors
# Remove everything but *.dll files. Avoids that
# a lot remains when gvimext.dll cannot be deleted.
Expand Down
67 changes: 15 additions & 52 deletions src/GvimExt/gvimext.cpp
Expand Up @@ -38,7 +38,7 @@ STGMEDIUM medium;
HRESULT hres = 0;
UINT cbFiles = 0;

/* The buffers size used to be MAX_PATH (256 bytes), but that's not always
/* The buffers size used to be MAX_PATH (260 bytes), but that's not always
* enough */
#define BUFSIZE 1100

Expand Down Expand Up @@ -203,7 +203,7 @@ dyn_libintl_init(char *dir)
if (hLibintlDLL)
return 1;

// Load gettext library from the Vim runtime directory.
// Load gettext library from $VIMRUNTIME\GvimExt{64,32} directory.
// Add the directory to $PATH temporarily.
len = GetEnvironmentVariableW(L"PATH", NULL, 0);
len2 = MAX_PATH + 1 + len;
Expand All @@ -212,7 +212,11 @@ dyn_libintl_init(char *dir)
if (buf != NULL && buf2 != NULL)
{
GetEnvironmentVariableW(L"PATH", buf, len);
_snwprintf(buf2, len2, L"%S;%s", dir, buf);
#ifdef _WIN64
_snwprintf(buf2, len2, L"%S\\GvimExt64;%s", dir, buf);
#else
_snwprintf(buf2, len2, L"%S\\GvimExt32;%s", dir, buf);
#endif
SetEnvironmentVariableW(L"PATH", buf2);
hLibintlDLL = LoadLibrary(GETTEXT_DLL);
#ifdef GETTEXT_DLL_ALT
Expand Down Expand Up @@ -883,37 +887,7 @@ BOOL CShellExt::LoadMenuIcon()
return TRUE;
}

#ifdef WIN32
// This symbol is not defined in older versions of the SDK or Visual C++.

#ifndef VER_PLATFORM_WIN32_WINDOWS
# define VER_PLATFORM_WIN32_WINDOWS 1
#endif

static DWORD g_PlatformId;

//
// Set g_PlatformId to VER_PLATFORM_WIN32_NT (NT) or
// VER_PLATFORM_WIN32_WINDOWS (Win95).
//
static void
PlatformId(void)
{
static int done = FALSE;

if (!done)
{
OSVERSIONINFO ovi;

ovi.dwOSVersionInfoSize = sizeof(ovi);
GetVersionEx(&ovi);

g_PlatformId = ovi.dwPlatformId;
done = TRUE;
}
}

# ifndef __BORLANDC__
#ifndef __BORLANDC__
static char *
searchpath(char *name)
{
Expand All @@ -922,28 +896,17 @@ searchpath(char *name)

// There appears to be a bug in FindExecutableA() on Windows NT.
// Use FindExecutableW() instead...
PlatformId();
if (g_PlatformId == VER_PLATFORM_WIN32_NT)
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)name, -1,
(LPWSTR)widename, BUFSIZE);
if (FindExecutableW((LPCWSTR)widename, (LPCWSTR)"",
(LPWSTR)location) > (HINSTANCE)32)
{
MultiByteToWideChar(CP_ACP, 0, (LPCTSTR)name, -1,
(LPWSTR)widename, BUFSIZE);
if (FindExecutableW((LPCWSTR)widename, (LPCWSTR)"",
(LPWSTR)location) > (HINSTANCE)32)
{
WideCharToMultiByte(CP_ACP, 0, (LPWSTR)location, -1,
(LPSTR)widename, 2 * BUFSIZE, NULL, NULL);
return widename;
}
}
else
{
if (FindExecutableA((LPCTSTR)name, (LPCTSTR)"",
(LPTSTR)location) > (HINSTANCE)32)
return location;
WideCharToMultiByte(CP_ACP, 0, (LPWSTR)location, -1,
(LPSTR)widename, 2 * BUFSIZE, NULL, NULL);
return widename;
}
return (char *)"";
}
# endif
#endif

STDMETHODIMP CShellExt::InvokeGvim(HWND hParent,
Expand Down

0 comments on commit 6199d43

Please sign in to comment.