原文地址:http://alphamailpost.blog.163.com/blog/static/20111808120127219102039/
这个文件夹是示例代码,目录下有user.bld xdcpaths.mk 和config.bld三个文件,xdcpaths.mk里面保存了编译代码所需的所有工具和库所在的路径,没什么好说的.
config.bld:
NOTE FOR THE USER:
* 用户注意
* 1) Generally there is no need to edit this file
* 2) It is best to keep it in the same directory where the file "user.bld" is
* 通常没必要修改这个文件,最好把这个文件放到和user.bld同一级的文件夹里.
* In more details:
*
* This file controls compiler options for the Arm and the DSP when
* building programs with XDC. It affects only the binaries that are built
* through "package.bld" XDC files. The XDC tools pick up this file along
* the package path; this file then finds "user.bld" file with further options
* that are specific for the user's build environment.
*这个文件控制ARM和DSP的编译器使用XDC编译程序时的选项,它只影响通过package.bld文件编译的*的二进制文件.XDC工具顺着包的路径找到这个文件,这个文件再找到user.bld文件,添加进一步的选项来*指定用户编译环境的选项(因为它会包含user.bld,所以要改什么在user.bld里改就可以,不用改这个文件).* The contents of this file usually doesn't change, but having it in your
* ownership allows you to tweak your compler options. If you do change
* this file, however, on the next upgrade to Codec Engine we recommend
* that you take "config.bld" file as supplied by the upgrade and then merge
* your changes with it.
*这个文件的内容通常不变,但是你是文件的主人,改不改随你的意.如果你改了这个文件.*在升级CE时,建议你使用升级的config.bld文件,并把你的改变merge到里面.
* Also note that the XDC tools pick up the first config.bld file they find
* along the package path; to make sure it is this file that gets picked,
* make the directory where this file is the first in the package path.
* You can verify that this file is being included by checking that
* the build process for each package prints the "Running the version
* from Codec Engine Examples" message.*注间:XDC工具只沿着路径找第一个config.bld文件,为了保证这个文件能被找到,把这个文件所在的路径*放在第一个包路径的位置上.要查看这个文件有没有被包含,可以查看编译过程中的"Running*the version from Comdec Engine Examples"消息.*/
所以说这个文件不用管.然后看 user.bld,这个文件是要修改的:
/*
* ======== user.bld ========
*
* User note: YOU MUST MODIFY THIS FILE TO SPECIFY THE COMPILER TOOL PATHS.*用户注意:你必须修改这个来件来指定编译器路径.
*/
// This table list the targets for which to build libraries and programs, and for
// each target it lists where the compiler tools are and for what platforms
// the programs should be built. For all build variants where you specify
// that "doBuild" is "true", you must specify the compiler tools, and it is
// desirable to comment out unwanted platforms.
// Example: if you are only interested in building Arm-side examples for
// evmDM6446 running Montavista Arm Linux, set doBuild: false everywhere
// except for the first Arm "doBuild"; then, specify your Montavista Arm
// tools directory, and comment out all platforms for that build except
// for '{ platform: "evmDM6446" }'.//下面的表列出了库和程序编译运行的目标,每个目标都指明了其编译器所在路径和程序编译的平台.//对于每一个构架变体,你都必须指定其编译器,并注释掉不需要的平台.//例如:如果你只关心编译DM6446上跑Montavista linux的ARM端的示例程序,则在除第一个Arm外的每//一处设定doBuild为false.然后指定你的montavista arm 编译器的路径,注释掉除{//platform:"evmDM6446"}以外的所有平台.
下面我们为DM6446修改后的buildtabe变量的值:
var buildTable = { "Arm": [{doBuild: true, // standard build for Linux这里doBuild为true,因为DM6446上有ARM target: "gnu.targets.arm.GCArmv5T", //DM6446上的ARM是ARVv5核的 // Arm tools. NOTE: make sure the directory you specify has a "bin" subdirectory cgtoolsRootDir: "/usr/local/montavista/pro/devkit/arm/v5t_le", //ARM编译器路径在这里设 platforms: [ // NOTE: comment out platforms (boards) below for which you don't want to build
上一节中指定了编译器的路径,但编译器的具体文件名叫什么呢?对arm平台来说是不一样的,这里要指定你所有的名字是什么,比如arm-linux-gcc,但montavista自带的编译器gcc名字是arm_v5t_le-gcc在这里指定.var targets = []; //这里通过脚本,从buildTable里面提取信息,赋值给targets和userbldBuildPlatforms变量. var userbldBuildPlatforms = {}; for each (var cpu in buildTable) {//对于buildTable中的每一个cpu表项, for (var t = 0; t < cpu.length; t++) { if (cpu[t].doBuild) {//如果某个cpu的doBuild值为true, var targ = xdc.useModule(cpu[t].target); targets.push(targ); //targets里就加上cpu[t].target项通过xdc.useModule转化的内容. targ.rootDir = cpu[t].cgtoolsRootDir; userbldBuildPlatforms[targ.name] = cpu[t].platforms;//这里加上平台信息. } } } Build.targets = targets;