Skip to content

Commit afde13b

Browse files
committed
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Problem: A lot of code is shared between vim.exe and gvim.exe. Solution: Optionally put the shared code in vim.dll. (Ken Takata, closes #4287)
1 parent ab4cece commit afde13b

42 files changed

Lines changed: 1200 additions & 466 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ src/auto/pathdef.c
3333
*.suo
3434
*.res
3535
*.RES
36+
vim*.dll
37+
vim*.lib
3638
src/if_perl.c
3739
src/pathdef.c
3840
src/Obj*/pathdef.c

Filelist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ SRC_DOS = \
454454
src/iscygpty.h \
455455
src/iid_ole.c \
456456
src/os_dos.h \
457+
src/os_w32dll.c \
457458
src/os_w32exe.c \
458459
src/os_win32.c \
459460
src/os_mswin.c \

nsis/gvim.nsi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ Section "$(str_section_exe)" id_section_exe
322322

323323
SetOutPath $0
324324
File /oname=gvim.exe ${VIMSRC}\gvim_ole.exe
325+
!if /FileExists "${VIMSRC}\vim${BIT}.dll"
326+
File ${VIMSRC}\vim${BIT}.dll
327+
!endif
325328
File /oname=install.exe ${VIMSRC}\installw32.exe
326329
File /oname=uninstal.exe ${VIMSRC}\uninstalw32.exe
327330
File ${VIMSRC}\vimrun.exe

runtime/doc/gui_w32.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*gui_w32.txt* For Vim version 8.1. Last change: 2017 Oct 27
1+
*gui_w32.txt* For Vim version 8.1. Last change: 2019 Apr 28
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -31,6 +31,17 @@ The GUI will always run in the Windows subsystem. Mostly shells automatically
3131
return with a command prompt after starting gvim. If not, you should use the
3232
"start" command: >
3333
start gvim [options] file ..
34+
< *E988*
35+
The console version with the |-g| option may also start the GUI by executing
36+
gvim.exe: >
37+
vim -g [options] file ..
38+
To make this work, gvim.exe must exist in the same directory as the vim.exe,
39+
and this feature must be enabled at compile time.
40+
41+
One may also use `:gui` from the console version. However, this is an
42+
experimental feature and this feature must be enabled at compile time.
43+
It uses a session file to recreate the current state of the console Vim in the
44+
GUI Vim.
3445

3546
Note: All fonts (bold, italic) must be of the same size!!! If you don't do
3647
this, text will disappear or mess up the display. Vim does not check the font

src/Make_cyg_ming.mak

Lines changed: 93 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,19 @@ FEATURES=HUGE
3636
DEBUG=no
3737

3838
# set to yes to create a mapfile
39-
# MAP=yes
39+
#MAP=yes
4040

4141
# set to SIZE for size, SPEED for speed, MAXSPEED for maximum optimization
4242
OPTIMIZE=MAXSPEED
4343

4444
# set to yes to make gvim, no for vim
4545
GUI=yes
4646

47+
# set to yes to enable the DLL support (EXPERIMENTAL).
48+
# Creates vim{32,64}.dll, and stub gvim.exe and vim.exe.
49+
# "GUI" should be also set to "yes".
50+
#VIMDLL=yes
51+
4752
# set to no if you do not want to use DirectWrite (DirectX)
4853
# MinGW-w64 is needed, and ARCH should be set to i686 or x86-64.
4954
DIRECTX=yes
@@ -687,7 +692,7 @@ else # SPEED
687692
CFLAGS += -O2
688693
endif
689694
endif
690-
CFLAGS += -s
695+
LFLAGS += -s
691696
endif
692697

693698
LIB = -lkernel32 -luser32 -lgdi32 -ladvapi32 -lcomdlg32 -lcomctl32 -lnetapi32 -lversion
@@ -739,7 +744,6 @@ OBJ = \
739744
$(OUTDIR)/ops.o \
740745
$(OUTDIR)/option.o \
741746
$(OUTDIR)/os_mswin.o \
742-
$(OUTDIR)/os_w32exe.o \
743747
$(OUTDIR)/os_win32.o \
744748
$(OUTDIR)/pathdef.o \
745749
$(OUTDIR)/popupmnu.o \
@@ -760,10 +764,17 @@ OBJ = \
760764
$(OUTDIR)/usercmd.o \
761765
$(OUTDIR)/userfunc.o \
762766
$(OUTDIR)/version.o \
763-
$(OUTDIR)/vimrc.o \
764767
$(OUTDIR)/winclip.o \
765768
$(OUTDIR)/window.o
766769

770+
ifeq ($(VIMDLL),yes)
771+
OBJ += $(OUTDIR)/os_w32dll.o $(OUTDIR)/vimrcd.o
772+
EXEOBJC = $(OUTDIR)/os_w32exec.o $(OUTDIR)/vimrcc.o
773+
EXEOBJG = $(OUTDIR)/os_w32exeg.o $(OUTDIR)/vimrcg.o
774+
else
775+
OBJ += $(OUTDIR)/os_w32exe.o $(OUTDIR)/vimrc.o
776+
endif
777+
767778
ifdef PERL
768779
OBJ += $(OUTDIR)/if_perl.o
769780
endif
@@ -870,16 +881,36 @@ endif
870881

871882
LFLAGS += -municode
872883

873-
ifeq ($(GUI),yes)
884+
ifeq ($(VIMDLL),yes)
885+
VIMEXE := vim$(DEBUG_SUFFIX).exe
886+
GVIMEXE := gvim$(DEBUG_SUFFIX).exe
887+
ifeq ($(ARCH),x86-64)
888+
VIMDLLBASE := vim64$(DEBUG_SUFFIX)
889+
else
890+
VIMDLLBASE := vim32$(DEBUG_SUFFIX)
891+
endif
892+
TARGET = $(VIMDLLBASE).dll
893+
LFLAGS += -shared
894+
EXELFLAGS += -municode
895+
ifneq ($(DEBUG),yes)
896+
EXELFLAGS += -s
897+
endif
898+
DEFINES += $(DEF_GUI) -DVIMDLL
899+
OBJ += $(GUIOBJ) $(CUIOBJ)
900+
OUTDIR = dobj$(DEBUG_SUFFIX)$(MZSCHEME_SUFFIX)$(ARCH)
901+
MAIN_TARGET = $(GVIMEXE) $(VIMEXE) $(VIMDLLBASE).dll
902+
else ifeq ($(GUI),yes)
874903
TARGET := gvim$(DEBUG_SUFFIX).exe
875904
DEFINES += $(DEF_GUI)
876905
OBJ += $(GUIOBJ)
877906
LFLAGS += -mwindows
878907
OUTDIR = gobj$(DEBUG_SUFFIX)$(MZSCHEME_SUFFIX)$(ARCH)
908+
MAIN_TARGET = $(TARGET)
879909
else
880910
OBJ += $(CUIOBJ)
881911
TARGET := vim$(DEBUG_SUFFIX).exe
882912
OUTDIR = obj$(DEBUG_SUFFIX)$(MZSCHEME_SUFFIX)$(ARCH)
913+
MAIN_TARGET = $(TARGET)
883914
endif
884915

885916
ifdef GETTEXT
@@ -955,7 +986,7 @@ ifeq (yes, $(MAP))
955986
LFLAGS += -Wl,-Map=$(TARGET).map
956987
endif
957988

958-
all: $(TARGET) vimrun.exe xxd/xxd.exe tee/tee.exe install.exe uninstal.exe GvimExt/gvimext.dll
989+
all: $(MAIN_TARGET) vimrun.exe xxd/xxd.exe tee/tee.exe install.exe uninstal.exe GvimExt/gvimext.dll
959990

960991
vimrun.exe: vimrun.c
961992
$(CC) $(CFLAGS) -o vimrun.exe vimrun.c $(LIB)
@@ -966,8 +997,19 @@ install.exe: dosinst.c
966997
uninstal.exe: uninstal.c
967998
$(CC) $(CFLAGS) -o uninstal.exe uninstal.c $(LIB)
968999

1000+
ifeq ($(VIMDLL),yes)
1001+
$(TARGET): $(OUTDIR) $(OBJ)
1002+
$(LINK) $(CFLAGS) $(LFLAGS) -o $@ $(OBJ) $(LIB) -lole32 -luuid -lgdi32 $(LUA_LIB) $(MZSCHEME_LIBDIR) $(MZSCHEME_LIB) $(PYTHONLIB) $(PYTHON3LIB) $(RUBYLIB)
1003+
1004+
$(GVIMEXE): $(OUTDIR) $(EXEOBJG) $(VIMDLLBASE).dll
1005+
$(CC) -L. $(EXELFLAGS) -mwindows -o $@ $(EXEOBJG) -l$(VIMDLLBASE)
1006+
1007+
$(VIMEXE): $(OUTDIR) $(EXEOBJC) $(VIMDLLBASE).dll
1008+
$(CC) -L. $(EXELFLAGS) -o $@ $(EXEOBJC) -l$(VIMDLLBASE)
1009+
else
9691010
$(TARGET): $(OUTDIR) $(OBJ)
9701011
$(LINK) $(CFLAGS) $(LFLAGS) -o $@ $(OBJ) $(LIB) -lole32 -luuid $(LUA_LIB) $(MZSCHEME_LIBDIR) $(MZSCHEME_LIB) $(PYTHONLIB) $(PYTHON3LIB) $(RUBYLIB)
1012+
endif
9711013

9721014
upx: exes
9731015
upx gvim.exe
@@ -996,7 +1038,7 @@ clean:
9961038
-$(DEL) $(OUTDIR)$(DIRSLASH)*.o
9971039
-$(DEL) $(OUTDIR)$(DIRSLASH)*.res
9981040
-rmdir $(OUTDIR)
999-
-$(DEL) $(TARGET) vimrun.exe install.exe uninstal.exe
1041+
-$(DEL) $(MAIN_TARGET) vimrun.exe install.exe uninstal.exe
10001042
-$(DEL) pathdef.c
10011043
ifdef PERL
10021044
-$(DEL) if_perl.c
@@ -1025,125 +1067,109 @@ $(OUTDIR)/if_python3.o: if_python3.c if_py_both.h $(INCL)
10251067
$(OUTDIR)/%.o : %.c $(INCL)
10261068
$(CC) -c $(CFLAGS) $< -o $@
10271069

1028-
$(OUTDIR)/vimrc.o: vim.rc version.h gui_w32_rc.h
1070+
ifeq ($(VIMDLL),yes)
1071+
$(OUTDIR)/vimrcc.o: vim.rc gvim.exe.mnf version.h gui_w32_rc.h vim.ico
1072+
$(WINDRES) $(WINDRES_FLAGS) $(DEFINES) -UFEAT_GUI_MSWIN \
1073+
--input-format=rc --output-format=coff -i vim.rc -o $@
1074+
1075+
$(OUTDIR)/vimrcg.o: vim.rc gvim.exe.mnf version.h gui_w32_rc.h vim.ico
1076+
$(WINDRES) $(WINDRES_FLAGS) $(DEFINES) \
1077+
--input-format=rc --output-format=coff -i vim.rc -o $@
1078+
1079+
$(OUTDIR)/vimrcd.o: vim.rc version.h gui_w32_rc.h \
1080+
tools.bmp tearoff.bmp vim.ico vim_error.ico \
1081+
vim_alert.ico vim_info.ico vim_quest.ico
1082+
$(WINDRES) $(WINDRES_FLAGS) $(DEFINES) -DRCDLL -DVIMDLLBASE=\\\"$(VIMDLLBASE)\\\" \
1083+
--input-format=rc --output-format=coff -i vim.rc -o $@
1084+
else
1085+
$(OUTDIR)/vimrc.o: vim.rc gvim.exe.mnf version.h gui_w32_rc.h \
1086+
tools.bmp tearoff.bmp vim.ico vim_error.ico \
1087+
vim_alert.ico vim_info.ico vim_quest.ico
10291088
$(WINDRES) $(WINDRES_FLAGS) $(DEFINES) \
10301089
--input-format=rc --output-format=coff -i vim.rc -o $@
1090+
endif
10311091

10321092
$(OUTDIR):
10331093
$(MKDIR) $(OUTDIR)
10341094

10351095
$(OUTDIR)/gui_dwrite.o: gui_dwrite.cpp $(INCL) gui_dwrite.h
1036-
$(CC) -c $(CFLAGS) $(CXXFLAGS) gui_dwrite.cpp -o $(OUTDIR)/gui_dwrite.o
1096+
$(CC) -c $(CFLAGS) $(CXXFLAGS) gui_dwrite.cpp -o $@
10371097

10381098
$(OUTDIR)/gui.o: gui.c $(INCL) $(GUI_INCL)
1039-
$(CC) -c $(CFLAGS) gui.c -o $(OUTDIR)/gui.o
1099+
$(CC) -c $(CFLAGS) gui.c -o $@
10401100

10411101
$(OUTDIR)/beval.o: beval.c $(INCL) $(GUI_INCL)
1042-
$(CC) -c $(CFLAGS) beval.c -o $(OUTDIR)/beval.o
1102+
$(CC) -c $(CFLAGS) beval.c -o $@
10431103

10441104
$(OUTDIR)/gui_beval.o: gui_beval.c $(INCL) $(GUI_INCL)
1045-
$(CC) -c $(CFLAGS) gui_beval.c -o $(OUTDIR)/gui_beval.o
1105+
$(CC) -c $(CFLAGS) gui_beval.c -o $@
10461106

10471107
$(OUTDIR)/gui_w32.o: gui_w32.c $(INCL) $(GUI_INCL)
1048-
$(CC) -c $(CFLAGS) gui_w32.c -o $(OUTDIR)/gui_w32.o
1108+
$(CC) -c $(CFLAGS) gui_w32.c -o $@
10491109

10501110
$(OUTDIR)/if_cscope.o: if_cscope.c $(INCL) if_cscope.h
1051-
$(CC) -c $(CFLAGS) if_cscope.c -o $(OUTDIR)/if_cscope.o
1111+
$(CC) -c $(CFLAGS) if_cscope.c -o $@
10521112

10531113
$(OUTDIR)/if_mzsch.o: if_mzsch.c $(INCL) $(MZSCHEME_INCL) $(MZ_EXTRA_DEP)
1054-
$(CC) -c $(CFLAGS) if_mzsch.c -o $(OUTDIR)/if_mzsch.o
1114+
$(CC) -c $(CFLAGS) if_mzsch.c -o $@
10551115

10561116
mzscheme_base.c:
10571117
$(MZSCHEME)/mzc --c-mods mzscheme_base.c ++lib scheme/base
10581118

10591119
# Remove -D__IID_DEFINED__ for newer versions of the w32api
10601120
$(OUTDIR)/if_ole.o: if_ole.cpp $(INCL) if_ole.h
1061-
$(CC) $(CFLAGS) $(CXXFLAGS) -c -o $(OUTDIR)/if_ole.o if_ole.cpp
1121+
$(CC) -c $(CFLAGS) $(CXXFLAGS) if_ole.cpp -o $@
10621122

10631123
auto/if_perl.c: if_perl.xs typemap
10641124
$(XSUBPP) -prototypes -typemap \
10651125
$(PERLTYPEMAP) if_perl.xs -output $@
10661126

10671127
$(OUTDIR)/if_perl.o: auto/if_perl.c $(INCL)
1068-
$(CC) -c $(CFLAGS) auto/if_perl.c -o $(OUTDIR)/if_perl.o
1128+
$(CC) -c $(CFLAGS) auto/if_perl.c -o $@
10691129

10701130

10711131
$(OUTDIR)/if_ruby.o: if_ruby.c $(INCL)
10721132
ifeq (16, $(RUBY))
1073-
$(CC) $(CFLAGS) -U_WIN32 -c -o $(OUTDIR)/if_ruby.o if_ruby.c
1133+
$(CC) $(CFLAGS) -U_WIN32 -c -o $@ if_ruby.c
10741134
endif
10751135

10761136
$(OUTDIR)/iscygpty.o: iscygpty.c $(CUI_INCL)
10771137
$(CC) -c $(CFLAGS) iscygpty.c -o $(OUTDIR)/iscygpty.o -U_WIN32_WINNT -D_WIN32_WINNT=0x0600 -DUSE_DYNFILEID -DENABLE_STUB_IMPL
10781138

10791139
$(OUTDIR)/main.o: main.c $(INCL) $(CUI_INCL)
1080-
$(CC) -c $(CFLAGS) main.c -o $(OUTDIR)/main.o
1140+
$(CC) -c $(CFLAGS) main.c -o $@
10811141

10821142
$(OUTDIR)/netbeans.o: netbeans.c $(INCL) $(NBDEBUG_INCL) $(NBDEBUG_SRC)
1083-
$(CC) -c $(CFLAGS) netbeans.c -o $(OUTDIR)/netbeans.o
1143+
$(CC) -c $(CFLAGS) netbeans.c -o $@
1144+
1145+
$(OUTDIR)/os_w32exec.o: os_w32exe.c $(INCL)
1146+
$(CC) -c $(CFLAGS) -UFEAT_GUI_MSWIN os_w32exe.c -o $@
1147+
1148+
$(OUTDIR)/os_w32exeg.o: os_w32exe.c $(INCL)
1149+
$(CC) -c $(CFLAGS) os_w32exe.c -o $@
10841150

10851151
$(OUTDIR)/os_win32.o: os_win32.c $(INCL) $(MZSCHEME_INCL)
1086-
$(CC) -c $(CFLAGS) os_win32.c -o $(OUTDIR)/os_win32.o
1152+
$(CC) -c $(CFLAGS) os_win32.c -o $@
10871153

10881154
$(OUTDIR)/regexp.o: regexp.c regexp_nfa.c $(INCL)
1089-
$(CC) -c $(CFLAGS) regexp.c -o $(OUTDIR)/regexp.o
1155+
$(CC) -c $(CFLAGS) regexp.c -o $@
10901156

10911157
$(OUTDIR)/terminal.o: terminal.c $(INCL) $(TERM_DEPS)
1092-
$(CC) -c $(CFLAGS) terminal.c -o $(OUTDIR)/terminal.o
1093-
1094-
$(OUTDIR)/textprop.o: textprop.c $(INCL)
1095-
$(CC) -c $(CFLAGS) textprop.c -o $(OUTDIR)/textprop.o
1158+
$(CC) -c $(CFLAGS) terminal.c -o $@
10961159

10971160

10981161
CCCTERM = $(CC) -c $(CFLAGS) -Ilibvterm/include -DINLINE="" \
10991162
-DVSNPRINTF=vim_vsnprintf \
11001163
-DIS_COMBINING_FUNCTION=utf_iscomposing_uint \
11011164
-DWCWIDTH_FUNCTION=utf_uint2cells
11021165

1103-
$(OUTDIR)/encoding.o: libvterm/src/encoding.c $(TERM_DEPS)
1104-
$(CCCTERM) libvterm/src/encoding.c -o $@
1105-
1106-
$(OUTDIR)/keyboard.o: libvterm/src/keyboard.c $(TERM_DEPS)
1107-
$(CCCTERM) libvterm/src/keyboard.c -o $@
1108-
1109-
$(OUTDIR)/mouse.o: libvterm/src/mouse.c $(TERM_DEPS)
1110-
$(CCCTERM) libvterm/src/mouse.c -o $@
1111-
1112-
$(OUTDIR)/parser.o: libvterm/src/parser.c $(TERM_DEPS)
1113-
$(CCCTERM) libvterm/src/parser.c -o $@
1114-
1115-
$(OUTDIR)/pen.o: libvterm/src/pen.c $(TERM_DEPS)
1116-
$(CCCTERM) libvterm/src/pen.c -o $@
1166+
$(OUTDIR)/%.o : libvterm/src/%.c $(TERM_DEPS)
1167+
$(CCCTERM) $< -o $@
11171168

1118-
$(OUTDIR)/termscreen.o: libvterm/src/termscreen.c $(TERM_DEPS)
1119-
$(CCCTERM) libvterm/src/termscreen.c -o $@
11201169

1121-
$(OUTDIR)/state.o: libvterm/src/state.c $(TERM_DEPS)
1122-
$(CCCTERM) libvterm/src/state.c -o $@
1123-
1124-
$(OUTDIR)/unicode.o: libvterm/src/unicode.c $(TERM_DEPS)
1125-
$(CCCTERM) libvterm/src/unicode.c -o $@
1126-
1127-
$(OUTDIR)/vterm.o: libvterm/src/vterm.c $(TERM_DEPS)
1128-
$(CCCTERM) libvterm/src/vterm.c -o $@
1129-
1130-
$(OUTDIR)/xdiffi.o: xdiff/xdiffi.c $(XDIFF_DEPS)
1131-
$(CC) -c $(CFLAGS) xdiff/xdiffi.c -o $(OUTDIR)/xdiffi.o
1132-
1133-
$(OUTDIR)/xemit.o: xdiff/xemit.c $(XDIFF_DEPS)
1134-
$(CC) -c $(CFLAGS) xdiff/xemit.c -o $(OUTDIR)/xemit.o
1135-
1136-
$(OUTDIR)/xprepare.o: xdiff/xprepare.c $(XDIFF_DEPS)
1137-
$(CC) -c $(CFLAGS) xdiff/xprepare.c -o $(OUTDIR)/xprepare.o
1138-
1139-
$(OUTDIR)/xutils.o: xdiff/xutils.c $(XDIFF_DEPS)
1140-
$(CC) -c $(CFLAGS) xdiff/xutils.c -o $(OUTDIR)/xutils.o
1141-
1142-
$(OUTDIR)/xhistogram.o: xdiff/xhistogram.c $(XDIFF_DEPS)
1143-
$(CC) -c $(CFLAGS) xdiff/xhistogram.c -o $(OUTDIR)/xhistogram.o
1170+
$(OUTDIR)/%.o : xdiff/%.c $(XDIFF_DEPS)
1171+
$(CC) -c $(CFLAGS) $< -o $@
11441172

1145-
$(OUTDIR)/xpatience.o: xdiff/xpatience.c $(XDIFF_DEPS)
1146-
$(CC) -c $(CFLAGS) xdiff/xpatience.c -o $(OUTDIR)/xpatience.o
11471173

11481174
pathdef.c: $(INCL)
11491175
ifneq (sh.exe, $(SHELL))

0 commit comments

Comments
 (0)