bat

Last-modified: 2013-11-29 (金) 11:06:14
@echo off

set fname=%1
set exec=%~n1
set option=
set CC=

if "%~x1"==".cpp" goto cpp_lang
if "%~x1"==".c" goto c_lang
goto not_suport_lang

:not_suport_lang
echo not support file
goto end

:cpp_lang
echo compile cpp file.
set CC=g++
set option=-o %exec% -std=c++0x
goto build

:c_lang
echo compile c file.
set CC=gcc
set option=-o %exec%
goto build

:build
echo %CC% %option% %fname%
%CC% %option% %fname%

if "%ERRORLEVEL%"=="0" if not "%exec%"=="" (
	echo ---EXEC---------------------------
	%exec%
)

:end
pause