I tried building vim and gvim with MinGW according to this instruction. For convenience I'm posting them here
#echo off
REM Run this batch file from any directory to build gvim.exe and vim.exe.
REM But first edit the paths and Python version number.
REM --- Specify Vim /src folder ---
set VIMSRC=C:\Downloads\vim\src
REM --- Add MinGW /bin directory to PATH ---
PATH = C:\MinGW\bin;%PATH%
REM --- Also make sure that PYTHON, PYTHON_VER below are correct. ---
REM get location of this batch file
set WORKDIR=%~dp0
set LOGFILE=%WORKDIR%log.txt
echo Work directory: %WORKDIR%
echo Vim source directory: %VIMSRC%
REM change to Vim /src folder
cd /d %VIMSRC%
REM --- Build GUI version (gvim.exe) ---
echo Building gvim.exe ...
REM The following command will compile with both Python 2.7 and Python 3.3
mingw32-make.exe -f Make_ming.mak PYTHON="C:/Python27" PYTHON_VER=27 DYNAMIC_PYTHON=yes PYTHON3="C:/Python35" PYTHON3_VER=35 DYNAMIC_PYTHON3=yes FEATURES=HUGE GUI=yes gvim.exe > "%LOGFILE%"
REM --- Build console version (vim.exe) ---
echo Building vim.exe ...
REM The following command will compile with both Python 2.7 and Python 3.3
mingw32-make.exe -f Make_ming.mak PYTHON="C:/Python27" PYTHON_VER=27 DYNAMIC_PYTHON=yes PYTHON3="C:/Python35" PYTHON3_VER=35 DYNAMIC_PYTHON3=yes FEATURES=HUGE GUI=no vim.exe >> "%LOGFILE%"
echo Moving files ...
move gvim.exe "%WORKDIR%"
move vim.exe "%WORKDIR%"
echo Cleaning Vim source directory ...
REM NOTE: "mingw32-make.exe -f Make_ming.mak clean" does not finish the job
IF NOT %CD%==%VIMSRC% GOTO THEEND
IF NOT EXIST vim.h GOTO THEEND
IF EXIST pathdef.c DEL pathdef.c
IF EXIST obj\NUL RMDIR /S /Q obj
IF EXIST obji386\NUL RMDIR /S /Q obji386
IF EXIST gobj\NUL RMDIR /S /Q gobj
IF EXIST gobji386\NUL RMDIR /S /Q gobji386
IF EXIST gvim.exe DEL gvim.exe
IF EXIST vim.exe DEL vim.exe
:THEEND
pause
I'm getting the following error during a build process:
Building gvim.exe ...
diff.c: In function 'ex_diffpatch':
diff.c:891:12: error: storage size of 'st' isn't known
stat_T st;
^
diff.c:891:12: warning: unused variable 'st' [-Wunused-variable]
mingw32-make.exe: *** [gobjx86-64/diff.o] Error 1
Building vim.exe ...
diff.c: In function 'ex_diffpatch':
diff.c:891:12: error: storage size of 'st' isn't known
stat_T st;
^
diff.c:891:12: warning: unused variable 'st' [-Wunused-variable]
mingw32-make.exe: *** [objx86-64/diff.o] Error 1
Does anyone know what could be the problem?
I figured out what was the problem. I was using a 32 bit MinGW instead of the one for 64 bit system. In other words I needed to download MinGW-w64 from https://mingw-w64.org/doku.php instead of downloading MinGW from http://www.mingw.org/.
I don't know what this problem is; but if I were you I would follow the instructions by Antoine Mechelynck, which are very detailed. I've used his guide for building at Unix/Linux guide and they are very good.
You could consider downloading the binary from vim.org if you still have problems to build it. There is also a portable version (from PortableApps), which doesn't requires privileges to install and even run from USB stick.
Related
I need to know how to write bat script to unzip file in a location and save the extracted file to a different location, also I need to delete the original file after the extraction is done.
For example suppose my .gz file are in location C:\Users\jibin\Desktop\CDR\ and I need to extract all the files in this location to C:\Users\jibin\Desktop\CDR\CDR_Extract(destination).
This can easily be achieved using 7-zip, combined with forfiles, something like (not tested, don't kill me if it doesn't work immediately):
forfiles /M *.gz /C "cmd /c 7z x #path -oC:\Users\jibin\Desktop\CDR\CDR_Extract *.* -r"
Where:
x means "extract"
-o means "output directory"
*.* means "filename inside can be anything, extract every file"
-r means "recursive subdirectories"
Deleting the zipfile afterwards is obvious.
Without need to install third party software - you can use gzipjs.bat:
md "C:\Users\jibin\Desktop\CDR\CDR_Extract\" >nul 2>&1
for %%# in ("C:\Users\jibin\Desktop\CDR\*.gz") do (
call gzipjs.bat -u "%%~f#" "C:\Users\jibin\Desktop\CDR\CDR_Extract\%%~n#"
rem del "%%~f#" /q /f
)
Check if this is what you need and delete the rem word in the last file in order to activate deletion of the source files as you requested.
If you are using windows 10 with all the latest updates (from build 17063 and above) you can use TAR.
If you're using windows-10, version 1803+, (December 2017 to April 2018 - minimum 10.0.17063), then you may be better advised to use the built-in tar executable:
#If Exist "C:\Users\jibin\Desktop\CDR\*.gz" (
If Not Exist "%__AppDir__%tar.exe" Exit /B 1
PushD "C:\Users\jibin\Desktop\CDR"
If Not Exist "CDR_Extract\" MD "CDR_Extract" 2>NUL || Exit /B 1
For %%G In (*.gz) Do #("%__AppDir__%tar.exe" -xf "%%G" -C "CDR_Extract"
If Not ErrorLevel 1 Del "%%G")
PopD)
I have a batch file as below:
#echo off
REM <--Fetching installed service pack version and storing it in var-->
FOR /f "tokens=* " %%a in ('findstr /I "install.servicepack" ^< "C:\A\B\C\D.properties" ') DO SET temp=%%a
SET var=%temp:~22%
REM <-- I tested, correct value is getting assigned to var say 1.2.3-->
REM <--Next, I am changing the directory using CD, in which X, Y and Z is a fixed directory path and after that it is variable based upon %var% value
cd c:\X\Y\Z\%var%
echo %cd%
REM <-- I tested and directory is correctly set against cd c:\X\Y\Z\1.2.3
REM <--With in c:\X\Y\Z\%var% (c:\X\Y\Z\1.2.3), there is an exe called uninstaller.exe and I am executing it is below:
dir
ECHO MESSAGE: Starting Silent Uninstallation of ABC Package
uninstaller.exe -options -silent
ECHO MESSAGE: Finished Silent Uninstallation of ABC Package
Set-up: I have Jenkins installed on windows and via sshexec task in ANT, I am calling the above batch file in a remote windows machine using cygwin openssh.
Issue: The above script when called from Jenkins job using above set-up, it is returning “Remote command failed with exit status 127”. However, if I am hard coding the value of %var% in cd as cd c:\X\Y\Z\a.b.c rather than passing as cd c:\X\Y\Z\%var%, script is executing fine, i.e.; directly changing the directory with the exact path (cd C:\X.Y.Z.\1.2.3).
I tried couple of ways to call uninstaller.exe after changing the directory but no success.
Please help.
Do NOT change value of TEMP variable: this is a special system variable holding the temporary directory env. variable.
Please choose another variable name.
FOR /f "tokens=* " %%a in ('findstr /I "install.servicepack" ^< "C:\A\B\C\D.properties" ') DO SET t=%%a
SET var=%t:~22%
If you change temporary directory, programs relying on it may crash (and there are a lot of them).
I made an exe that has embedded files in it like a portable 7zip (7za.exe) and I want to call to it in the batch script that I am compiling into an exe but when I do it just gives me "7za.exe" is not recognized as an internal or external command. If I left anything out just ask.
(Sorry if this is an easy fix I am just messing around with some basic code)
This is the code I am working with and exe is in releases tab.
https://github.com/iamtis/mass-extract
Let us look on batch file with some additional lines at top:
#echo off
echo Current working directory is: %CD%
echo Directory of batch file is: %~dp0
pause
echo Files in current working directory:
dir /A-D /B
pause
echo Files in directory of batch file:
dir /A-D /B "%~dp0"
pause
I suppose that the current working directory is not equal the directory of the batch file and the tools are in the directory of the batch file. I suppose the batch file directory is a subdirectory with random name in %TEMP%.
So what you most likely need is:
#echo off
set "ToolPath=%~dp0"
if not exist "%CD%\archive\*" md "%CD%\archive"
"%ToolPath%7za.exe" x "%CD%\*.zip" "%CD%\archive\"
"%ToolPath%7za.exe" x "%CD%\*.7z" "%CD%\archive\"
"%ToolPath%unrar.exe" x "%CD%\*.rar" "%CD%\archive\"
"%ToolPath%7za.exe" a -mx9 archive.7z "%CD%\archive\"
rd /S /Q "%CD%\archive"
set "ToolPath="
I write a .bat to automate generating and compiling a cmake project. The batch file will
optional rmdir build
mkdir build if not exist
cd build
cmake .. generate a nmake project from upper folder
nmake compile project
the source:
#ECHO OFF
set "OpenCV_LIB=C:\Program Files (x86)\OpenCV2.1"
echo !! OpenCV Library: [ %OpenCV_LIB% ]
IF NOT EXIST "%OpenCV_LIB%" (
echo Can't find OpenCV Library, please change OpenCV_LIB setting
GOTO END
)
if %PROCESSOR_ARCHITECTURE%==x86 set BUILD_ARCH=x86
if %PROCESSOR_ARCHITECTURE%==AMD64 set BUILD_ARCH=x86_amd64
if %PROCESSOR_ARCHITECTURE%==IA64 set BUILD_ARCH=x86_IPF
echo !! Target architecture [ %BUILD_ARCH% ]
call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" %BUILD_ARCH%
cd "sikuli-script"
set /p answer=Do you want to make clean first? (Y/N):
if %answer% == Y ( IF EXIST build rmdir /s /q build )
if %answer% == y ( IF EXIST build rmdir /s /q build )
IF NOT EXIST build mkdir build
cd build
IF NOT EXIST CMakeCache.txt ( cmake -G "NMake Makefiles" -D CMAKE_BUILD_TYPE=Release -D "OpenCV_DIR=%OpenCV_LIB%" .. )
nmake
:END
pause
After i run this .bat over and over, i notice that cd build failed sometimes, so i change my code to test it:
#ECHO ON
set /p answer=Do you want to make clean first? (Y/N):
if %answer% == Y ( IF EXIST build rmdir /s /q build )
if %answer% == y ( IF EXIST build rmdir /s /q build )
:DO_MKDIR_CD
IF NOT EXIST build mkdir build
cd build
if errorlevel 1 (
pause
GOTO DO_MKDIR_CD
)
It comes out the error happens every time choose to clean up build, even the build is at small size (e.g. after interrupted compiling, size 3.08 MB, 183 files, 67 dirs).
!! OpenCV Library: [ C:\Program Files (x86)\OpenCV2.1 ]
!! Target architecture [ x86_amd64 ]
Setting environment for using Microsoft Visual Studio 2010 x64 cross tools.
D:\repo\sikuli>cd "sikuli-script"
D:\repo\sikuli\sikuli-script>set /p answer=Do you want to make clean first? (Y/N):
Do you want to make clean first? (Y/N):y
D:\repo\sikuli\sikuli-script>if y == Y (IF EXIST build rmdir /s /q build )
D:\repo\sikuli\sikuli-script>if y == y (IF EXIST build rmdir /s /q build )
D:\repo\sikuli\sikuli-script>IF NOT EXIST build mkdir build
D:\repo\sikuli\sikuli-script>cd build
Access is denied.
D:\repo\sikuli\sikuli-script>if errorlevel 1 (
pause
GOTO DO_MKDIR_CD
)
Press any key to continue . . .
So every time after remove and recreate build, the cd build fails, then cmake start messing up my source tree.
The error check and loop trying could fix this problem, but why is the file system not stable? or am i writing it in a wrong way?
That build directory check:
IF NOT EXIST build mkdir build
Will create the directory if both directory and file named "build" are not exist.
One way to check a directoy existence is:
if exist build\nul echo directory exist
If you want to make sure a directory exist use:
if not exist build\nul mkdir build
or better:
if not exist build\nul (
mkdir build
if not exist build\nul (
echo mkdir failed
goto :eof
)
)
This is my first batch file, and also my first time with batch language (I usually use UNIX and don't know a lot about Windows commands).
I'm creating a batch file called install.bat which does all the work to install a Java application from source files. Here a snapshot of the install section:
#ECHO off
SET INSTALL_DIR=%1\
SET SRC_DIR=sources\
SET LIB_DIR=lib\
SET IMG_DIR=img\
SET BIN_DIR=bin\
SET INIT_DIR=%CD%
SET MAIN_CLASS=%SRC_DIR%\main\Main.java
SET CLASS_PATH=%LIB_DIR%log4j.jar;%LIB_DIR%jdom.jar;
SET JAR_NOM=myApp.jar
SET JAR_MF=MANIFEST.MF
:BEGIN
CLS
ECHO Checking directory...
IF EXIST %INSTALL_DIR% (
GOTO Ask_Overwrite
) ELSE (
GOTO Install
)
:Ask_overwrite
SET OVERW=Y
SET /P OVERW="The program is already installed. Overwrite? ([Y]/N): "
IF %OVERW%==N GOTO Cancel
IF %OVERW%==n GOTO Cancel
IF %OVERW%==Y (
RD /S /Q %INSTALL_DIR% <--- Here was the error
GOTO Install
)
IF %OVERW%==y (
RD /S /Q %INSTALL_DIR% <--- Here was the error
GOTO Install
)
GOTO Ask_overwrite
:Install
MD %INSTALL_DIR%
XCOPY . %INSTALL_DIR% /E
CD /D %INSTALL_DIR%
MD %BIN_DIR%
ECHO Compiling...
javac -cp %CLASS_PATH% -sourcepath %SRC_DIR% %MAIN_CLASS% -d %BIN_DIR%
ECHO Creating JAR file...
jar cfm %JAR_NOM% %JAR_MF% -C %BIN_DIR% .
ECHO Succes! The application has been installed in %INSTALL_DIR%
GOTO CleanUp
:Abort
ECHO Abort! The application has not been installed.
GOTO CleanUp
:Cancel
ECHO Canceled by user. The application has not been installed.
GOTO END
:Cleanup
REM Code for clean up
GOTO END
:END
CD /D %INIT_DIR%
PAUSE
NOTE: The javac and jar commands are correct, at least work in my machine.
Well, the script works correctly when I test it with the INSTALL_DIR belonging to the same drive where I execute it, but if I use a target directory out of the drive where I'm executing, I have problems.
Executions without problems (called in a cmd.exe session):
C:\Users\TC\testInstall> install.bat .\..\installTarget
C:\Users\TC\testInstall> install.bat C:\Users\TC\installTarget
Execution with problems (called in a cmd.exe session):
C:\Users\TC\testInstall> install.bat D:\Documents\installTarget
The problems happen when I try to copy files specially, but also making and removing directories.
I hope someone can tell to me which options I must use in order to fix the problems.
Regards!
Well, I have two mistakes that I fixed and then the script work correctly.
The first was that I didn't use the /d option in cd command in order to change also the drive unit. It means, C:Users\TC> cd D:\Documents is wrong, the correct command is the following: C:Users\TC> cd /d D:\Documents as well as the MS-DOS manual page indicates.
The second error, it wasn't actually an error, I put rm -rf %INSTALL_DIR% (like in Linux) instead of the correct Windows command rd /s/q %INSTALL_DIR%
Now all the problems have been fixed and the script works properly :)
It has to do with batch files not accessing other drives than the C:\ drive by default. Even if you open up your command line, you shouldn't be able to CD D:\. Try this (not sure if this will work as I have never tried it)
PUSHD D:\
C:\Users\TC\testInstall> install.bat D:\Documents\installTarget
Or else, use PUSHD D:\ then move the install file to D:\ temporarily and install. Only solutions I can think of.