]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0657: MS-Windows: MSVC build time can be optimized v9.1.0657
authorKen Takata <kentkt@csc.jp>
Sat, 3 Aug 2024 12:40:35 +0000 (14:40 +0200)
committerChristian Brabandt <cb@256bit.org>
Sat, 3 Aug 2024 12:40:35 +0000 (14:40 +0200)
Problem:  MS-Windows: MSVC build time can be optimized
Solution: Stop using Powershell, show detected version, read _MSC_VER
          and _MSC_FULL_VER in a single cl execution. (Ken Takata)

closes: #15421

Signed-off-by: Ken Takata <kentkt@csc.jp>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/Make_mvc.mak
src/version.c

index 65efe306a4285ba6c8224c55a885b5de3a32cf22..65a8798a990e812fdb18c25be750db5ef09a048e 100644 (file)
 #      nmake -f Make_mvc.mvc "DEFINES=-DEMACS_TAGS"
 
 RM =           del /f /q
-PS =           powershell.exe
 
-PSFLAGS =      -NoLogo -NoProfile -Command
+# Read MAJOR and MINOR from version.h.
+!IF ![for /f "tokens=2,3" %I in (version.h) do \
+       @if "%I"=="VIM_VERSION_MAJOR" ( echo MAJOR=%J>.\major.tmp ) \
+       else if "%I"=="VIM_VERSION_MINOR" ( echo MINOR=%J>.\minor.tmp )]
+!ENDIF
 
-!IF ![$(PS) $(PSFLAGS) try{Out-File -FilePath '.\major.tmp' -InputObject \
-       \"MAJOR=$$(((Select-String -Pattern 'VIM_VERSION_MAJOR\s+\d{1,2}' \
-       -Path '.\version.h').Line[-2..-1^]-join '').Trim())\"} \
-       catch{exit 1}]
+!IF EXIST(.\major.tmp)
 ! INCLUDE .\major.tmp
 ! IF [$(RM) .\major.tmp]
 ! ENDIF
@@ -179,10 +179,7 @@ PSFLAGS =  -NoLogo -NoProfile -Command
 MAJOR =                9
 !ENDIF
 
-!IF ![$(PS) $(PSFLAGS) try{Out-File -FilePath '.\minor.tmp' -InputObject \
-       \"MINOR=$$(((Select-String -Pattern 'VIM_VERSION_MINOR\s+\d{1,2}' \
-       -Path '.\version.h').Line[-2..-1^]-join '').Trim())\"} \
-       catch{exit 1}]
+!IF EXIST(.\minor.tmp)
 ! INCLUDE .\minor.tmp
 ! IF [$(RM) .\minor.tmp]
 ! ENDIF
@@ -191,24 +188,23 @@ MAJOR =           9
 MINOR =                1
 !ENDIF
 
-!IF ![$(PS) $(PSFLAGS) try{Out-File -FilePath '.\patchlvl.tmp' -InputObject \
-       \"PATCHLEVEL=$$([decimal^]((Get-Content -Path '.\version.c' \
-       -TotalCount ((Select-String -Pattern 'static int included_patches' \
-       -Path '.\version.c').LineNumber+3))[-1^]).Trim().TrimEnd(','))\"} \
-       catch{exit 1}]
+# Read PATCHLEVEL from version.c.
+!IF ![cmd.exe /V:ON /C "echo off && set LINE=0&& set FIND=0&& \
+       for /f "tokens=1,3 delims=,[ " %I in (version.c) do \
+       ( set /A LINE+=1 > NUL && \
+       if "%J"=="included_patches" ( set /A FIND=LINE+3 > NUL ) \
+       else if "!LINE!"=="!FIND!" ( echo PATCHLEVEL=%I>.\patchlvl.tmp && exit ) )"]
+!ENDIF
+!IF EXIST(.\patchlvl.tmp)
 ! INCLUDE .\patchlvl.tmp
 ! IF [$(RM) .\patchlvl.tmp]
 ! ENDIF
 !ENDIF
 
-
-# Build on Windows NT/XP
-
-TARGETOS = WINNT
-
 !IFDEF PATCHLEVEL
 RCFLAGS =      -DVIM_VERSION_PATCHLEVEL=$(PATCHLEVEL)
 !ENDIF
+!message Vim version: $(MAJOR).$(MINOR).$(PATCHLEVEL)
 
 
 !if "$(VIMDLL)" == "yes"
@@ -299,7 +295,9 @@ MAKEFLAGS_GVIMEXT = DEBUG=yes
 LINK = link
 
 # Check VC version.
-!if [echo MSVCVER=_MSC_VER> msvcver.c && $(CC) /EP msvcver.c > msvcver.~ 2> nul]
+!if [echo MSVCVER=_MSC_VER> msvcver.c && \
+       echo MSVC_FULL=_MSC_FULL_VER>> msvcver.c && \
+       $(CC) /EP msvcver.c > msvcver.~ 2> nul]
 ! message *** ERROR
 ! message Cannot run Visual C to determine its version. Make sure cl.exe is in your PATH.
 ! message This can usually be done by running "vcvarsall.bat", located in the bin directory where Visual Studio was installed.
@@ -320,19 +318,6 @@ LINK = link
 MSVC_MAJOR = ($(MSVCVER) / 100 - 5)
 MSVCRT_VER = ($(MSVCVER) / 100 * 10 - 50)
 
-# Calculate MSVC_FULL.
-!if [echo MSVC_FULL=_MSC_FULL_VER> msvcfullver.c && $(CC) /EP msvcfullver.c > msvcfullver.~ 2> nul]
-! message *** ERROR
-! message Cannot run Visual C to determine its version. Make sure cl.exe is in your PATH.
-! message This can usually be done by running "vcvarsall.bat", located in the bin directory where Visual Studio was installed.
-! error Make aborted.
-!else
-! include msvcfullver.~
-! if [del msvcfullver.c msvcfullver.~]
-! endif
-!endif
-
-
 # Calculate MSVCRT_VER
 !if [(set /a MSVCRT_VER="$(MSVCRT_VER)" > nul) && set MSVCRT_VER > msvcrtver.~] == 0
 ! include msvcrtver.~
@@ -340,6 +325,11 @@ MSVCRT_VER = ($(MSVCVER) / 100 * 10 - 50)
 ! endif
 !endif
 
+# Show the versions (for debugging).
+#!message _MSC_VER=$(MSVCVER)
+#!message _MSC_FULL_VER=$(MSVC_FULL)
+#!message MSVCRT_VER=$(MSVCRT_VER)
+
 # Base name of the msvcrXX.dll (vcruntimeXXX.dll)
 MSVCRT_NAME = vcruntime$(MSVCRT_VER)
 
index 4a985b91009fa6c57a3ef30fea8fce55f17ba366..c36aa5119754070976c134d78b970fc8498f2d66 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    657,
 /**/
     656,
 /**/