@echo off :: compila el programa PASCAL (freePASCAL) suministrado como argumento :: uso: :: fpc programa :: :: v_1.3 14 Abril 2014 :: Santiago Velilla, Dpto. Informática e Ing. de Sistemas, UNIZAR :: :: %~1 Expands %1 and removes any surrounding quotation marks ("") :: %~f1 Expands %1 to a fully qualified path name. :: %~d1 Expands %1 to a drive letter. :: %~p1 Expands %1 to a path. :: %~n1 Expands %1 to a file name. :: %~x1 Expands %1 to a file extension. set VERFPC=2.6.4 :: eliminar la extension del fichero set PathProg=%~dp1 set NamProg=%~n1 set PROGR=%~dpn1 set libProg=%PathProg%libimp%NamProg%.a :: si no hay extension del fichero, poner extensión por defecto set EXT=.pas if "%~x1"=="" goto :inicio set EXT=%~x1 if "%EXT%"==".p" goto :inicio if "%EXT%"==".pas" goto :inicio if "%EXT%"==".pp" goto :inicio if "%EXT%"==".txt" goto :inicio :: si la extensión no es conocida, no compilar echo extension de fichero no permitida (debe ser .pas, .pp, .p o .txt) pause goto :finERR :inicio ::echo compilar %PROGR%%EXT% ::echo echo ;;; compilar (FreePASCAL %VERFPC%) %PROGR%%EXT% --^> %PROGR%.exe ;;; echo. :: por defecto no hay condición de error set ERROR=0 :: eliminar referencias a versiones anteriores de FPC en el PATH ::set PATH=%PATH:;;=;% ::set PATH=%PATH:;C:\FPC\2.2.4\bin\i386-win32=% ::set PATH=%PATH:;C:\FPC\2.4.0\bin\i386-win32=% set PATH=%PATH:;C:\FPC\2.4.2\bin\i386-win32=% set PATH=%PATH:;C:\FPC\2.6.0\bin\i386-win32=% set PATH=C:\FPC\%VERFPC%\bin\i386-win32\;%PATH% ::path ::pause set FPCDIR=C:\FPC\%VERFPC%\bin\i386-win32\ set FPCbin=C:\FPC\%VERFPC%\bin\i386-win32\ set FPCunit=C:\FPC\%VERFPC%\units\i386-win32\ call %FPCbin%ppc386 "%PROGR%%EXT%" -o"%PROGR%.exe" -S2 -Sg -Un -O1 -OpPENTIUM4 -Fu%FPCunit% -Fu%FPCunit%rtl\ -Fl%FPCunit% -Fl%FPCunit%rtl\ -FD%FPCbin% >"%PROGR%.err" if errorlevel 1 goto :hayErr ::pause echo compilacion correcta ::echo eliminación de ficheros intermedios IF EXIST "%PROGR%.err" del "%PROGR%.err" IF EXIST "%PROGR%.o" del "%PROGR%.o" ::IF EXIST "%libProg%" del "%libProg%" IF EXIST "%PathProg%*%NamProg%.a" del "%PathProg%*%NamProg%.a" goto :fin :hayErr echo ERROR de compilacion :: pause :: mostrar el fichero de errores :: echo. echo. type "%PROGR%.err" pause :: termina la ejecución devolviendo la condición de error set ERROR=1 :fin set FPCdir= set FPCbin= set FPCunit= exit /b %ERROR%