Thanks Graeme, I got your point!
Here is two cmd files for Keil C51 complier and linker, resolve two problem:
1.ERRORLEVEL>=1 when warnings occur, cause build process exit;
2.bl51.exe accept input object file list separated by comma, while file list expaned by "%f" is separated by space.
c51.cmd file for complier:
--------------------------------------
@echo off
@rem usage: c51.cmd "%f" "%bd%n.o"
%KEIL_C%\BIN\c51.exe %1 OBJECT (%2) BROWSE DEBUG OBJECTEXTEND
IF ERRORLEVEL 2 GOTO EXIT_ERROR
EXIT /B 0
:EXIT_ERROR
EXIT /B 2
--------------------------------------
bl51.cmd file for linker:
--------------------------------------
@echo off
@rem usage: bl51.cmd "%f" %bd%rn
@rem save file list to OBJ_FILE_LIST variale, like "a.obj b.obj c.obj "
set OBJ_FILE_LIST=%1
@rem replace space with comma: "a.obj,b.obj,c.obj,"
set OBJ_FILE_LIST=%OBJ_FILE_LIST: =,%
@rem delete the last comma,and surounding "" :a.obj b.obj c.obj
set OBJ_FILE_LIST=%OBJ_FILE_LIST:~1,-2%
%KEIL_C%\BIN\BL51.EXE %OBJ_FILE_LIST% TO %2.abs RAMSIZE(256)
if errorlevel 2 exit /B 1
%KEIL_C%\BIN\oh51.EXE %2.abs HEXFILE(%2.hex)
--------------------------------------