EVC用批处理文件——批量编译

EVC用批处理文件——同时批量编译多个工程

1、背景

在用EVC开发一个项目时,可能会有多个exe、多个dll工程,要重新把所有工程的代码都编译一遍,用什么方法来全部编译每个project

◆逐个打开工程编译

如果你有足够多的时间和足够多的耐性,你可以这么做,但这是效率最低的方法。

◆建一workspace,添加所有project

       建一workspace,添加所有project,利用Project Dependencies关联所有要编译的工程。同时编译多个工程。但这不是我今天要描述的。

◆用批处理文件编译多个工程

       不管是什么集成开发工具,包括EVC,我想都应该支持Building Applications on the Command Line”。于是我们可以用批处理文件来同时编译多个工程。本文就是讲述了该方法的使用。

2、学习

打开eMbedded Visual C++ 4.0的帮助文档(EVCHelp菜单Contents即可),在目录Embedded Visual C++ Programmer's Guide –> Building an Application –> Building Applications on the Command Line中可以找到命令行编译的相关说明。先看看“EVC”命令:

evc filename [/MAKE "ProjectConfigName"|"Project ALL"] [/REBUILD /CLEAN /NORECURSE /OUT LogFile /USEENV /EX MacroName /CECONFIG configuration] 
Return Value
The evc return value represents the number of errors that occurred during the build.
The following example demonstrates the syntax for building an emulated "MySDK":
evc Myproject.vcp /make "Myproject - Win32 (WCE emulator) Debug" /ceconfig="MySDK" /rebuild

       evc命令返回编译某个工程时出现的错误个数。参数说明:

Parameter

Description

FileName

A valid workspace or project filename. Must have an extension of .vcp or .vcw. You can also load a source file instead of a project.

Project

The project that contains the configurations to build. If Filename is a workspace file, Project must be a part of that workspace.

ConfigName

Any valid project configuration, or all configurations for a particular project. To build all configurations, simply type ALL for the configuration value (must be uppercase). Corresponds to the choices available from the Settings For drop-down list in the Project Settings dialog box.

LogFile

Name of an optional file used to store the build output information (valid only with the /OUT option).

EVC Options

Option

Operation

/MAKE "projectname1 – configuration1 | projectname1 – configuration2 | projectname2 – configuration1 | ALL"

Builds the specified configurations. The /CLEAN option modifies /MAKE so that the specified configurations are cleaned rather than built. Requires a FileName parameter after evc and a project with at least one configuration.

/?

Displays usage information for the evc command.

/CLEAN

Deletes intermediate files created during the build process for the specified configurations; does not build the project configurations. Requires /MAKE.

/REBUILD

Cleans and builds the specified configurations, including all dependent projects. Requires /MAKE. Takes precedence if both /CLEAN and /REBUILD are specified.

/NORECURSE

Builds the specified project configurations without building any dependent projects. Requires /MAKE.

/OUT logfile

Creates a log file for the build output, which includes such information as syntax errors and warnings. If you don't specify a filename, the build output information is displayed at the command prompt and is not saved to a file.

/USEENV

Directs the build system to use environment variables for the current build session, rather than the directory settings specified on the Directories tab (Tools menu, Options command). The SOURCE, PATH, INCLUDE and LIB paths must be set correctly for the build to succeed when /USEENV is specified.

/EX MacroName

Invokes the named macro (if the associated .dsm file is not loaded, this command will fail).

/CECONFIG configuration

Uses the specified Windows CE platform configuration.

 

3、例子

       例子中涉及到的批处理命令都可以在eMbedded Visual C++ 4.0的帮助文档中找到说明:Embedded Visual C++ Programmer's Guide –> Standard SDK for Windows CE 5.0 –> Shell and User Interface –> Shell –> Shell Application Development –> Command Processor Shell –> Command Processor Commands

       下面我详细的参照一个例子来说明:

 

◆第一行的path命令:指定了批处理文件中用到的exe程序的路径,比如evc.exe。不指定将出现类似错误: "EVC"不是内部或外部命令,也不是可运行的程序或批处理文件。

◆第三行cls命令:清屏。

◆第四行@echo on命令:打开回显功能,即运行批处理命令时,会显示命令(同时显示evc的编译过程)。

◆第六行evc命令:编译指定目录下的制定工程。

这里的目录HelloCE/HelloCE.vew是相对路径(HelloCE文件夹和批处理命令文件*.bat是在同一路径下),当然也可以用绝对路径。

HelloCE - Win32 (WCE emulator) Debug”是你欲编译的EVC工程可支持的配置项,就是打开菜单Build > Set  Active  Configuration的配置。如果你写了一个工程不支持的配置,或者说配置可支持但您没有添加到工程中(菜单Build > Configurations中添加),运行批处理命令时会报错:Error: There are no valid targets to build.

/ceconfig="STANDARDSDK_500"中的STANDARDSDK_500是工程可支持的SDK Platform配置,即菜单Build > Set Active Platform里的配置。同样的,如果你写了一个工程不支持的Platform配置,或者是工程支持但您没有添加(菜单Build > Configurations中添加),运行批处理命令是也会报错。

7@echo off命令:关闭回显。

8IF ERRORLEVEL 1 GOTO ERR命令:如果上一次program运行时返回的结果(即evc返回的错误个数)等于或者大于1,则跳转到ERR去执行,这里的ERR就是结束本批处理的出口。

14echo Rebuild Success!命令:显示“Rebuild Success!”字符串。

15PAUSE命令:This command suspends the processing of a batch program and displays the following message: Press any key to continue

21:EXIT命令:This command exits the command processor shell.

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值