Skip to content

Instantly share code, notes, and snippets.

@yuanliwei
Created December 27, 2015 13:43
Show Gist options
  • Save yuanliwei/4bd6268ff04a669756ce to your computer and use it in GitHub Desktop.
Save yuanliwei/4bd6268ff04a669756ce to your computer and use it in GitHub Desktop.

使用bat编译C51项目

@echo off&setlocal enabledelayedexpansion

set BIN_PATH=E:\Tools\Keil\C51\
set path=%BIN_PATH%BIN;%path%
rem SET TMP=D:\TMP
SET C51INC=%BIN_PATH%INC
SET C51LIB=%BIN_PATH%LIB

rem c51 start.c
for %%a in (%~dp0\src\*.c) do (
    C51.exe %%a
    )

set CLASSPATH="EMP"
for %%a in (%~dp0\src\*.OBJ) do (
      if !CLASSPATH! == "EMP" (
        set CLASSPATH="%%a"
      ) else (
        set CLASSPATH=!CLASSPATH!,"%%a"
      )
    )

if not exist bin mkdir bin
BL51.exe %CLASSPATH% TO "bin\target.tmp" RAMSIZE(256)

OH51.exe bin\target.tmp

for %%a in (%~dp0\src\*.obj) do (
    del %%a
    )
for %%a in (%~dp0\src\*.lst) do (
    del %%a
    )
for %%a in (%~dp0\bin\*.tmp) do (
    del %%a
    )
for %%a in (%~dp0\bin\*.m51) do (
    del %%a
    )

rem pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment