Files
Nim/tools/niminst/buildbat.tmpl
apense 80d6b0e9ca Fixed gcc batch issue
See #18 on csources. Basically, some Windows system have gcc as a gcc.bat file. This isn't an issue unless you're calling from another batch file (like here). The call chain will follow to gcc.bat and end there, meaning only one command is processed. Using "CALL" before the other batch command will keep the calls in the main batch file after completion, meaning the compilation will actually succeed this way [see technet](https://technet.microsoft.com/en-us/library/bb490873.aspx). Otherwise you have to hope there is a gcc.exe somewhere instead
2015-06-17 13:07:38 -04:00

42 lines
1.2 KiB
Cheetah

#! stdtmpl(subsChar='?') | standard
#proc generateBuildBatchScript(c: ConfigData, winIndex, cpuIndex: int): string =
# result = "@echo off\nREM Generated by niminst\n"
SET CC=gcc
SET LINKER=gcc
SET COMP_FLAGS=?{c.ccompiler.flags}
SET LINK_FLAGS=?{c.linker.flags}
SET BIN_DIR=?{firstBinPath(c).toWin}
if EXIST ..\koch.nim SET BIN_DIR=..\bin
if NOT EXIST %BIN_DIR%\nul mkdir %BIN_DIR%
REM call the compiler:
# block win32:
# var linkCmd = ""
# for ff in items(c.cfiles[winIndex][cpuIndex]):
# let f = ff.toWin
ECHO %CC% %COMP_FLAGS% -Ic_code -c ?{f} -o ?{changeFileExt(f, "o")}
CALL %CC% %COMP_FLAGS% -Ic_code -c ?{f} -o ?{changeFileExt(f, "o")}
# linkCmd.add(" " & changeFileExt(f, "o"))
IF ERRORLEVEL 1 (GOTO:END)
# end for
ECHO %LINKER% -o ?{"%BIN_DIR%"\toLower(c.name)}.exe ?linkCmd %LINK_FLAGS%
CALL %LINKER% -o ?{"%BIN_DIR%"\toLower(c.name)}.exe ?linkCmd %LINK_FLAGS%
# end block
:END
IF ERRORLEVEL 1 (
ECHO FAILURE
ECHO.
ECHO CSource compilation failed. Please check that the gcc compiler is in
ECHO the PATH environment variable, and that you are calling the batch script
ECHO that matches the target architecture of the compiler.
) ELSE (
ECHO SUCCESS
)
exit /b %ERRORLEVEL%