xdc应用--hello world

xdc等同于gmake

摘自Davinci Technology Workshop (Rev 0.98) Lab 5
需要的文件:

1 main.c
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
   printf("Hello world/n");
   return 0;
}

2 package.bld
// Define the list of targets to build for in the targs array
var targs = [MVArm9, Linux86];   //生成arm和host的可执行文件
// Define the build profiles to build across the targets
var profiles = ["release"];
// Define the base name for the executable(s) built
var basename = "app";   //可执行文件的名字
// The array of c source files that will be compiled into the final executable
var csources = ["main.c"]; //源文件

// The build phase cycles through the arrays of build targets and profiles
//       and adds an executable for each combination
for (var i = 0; i < targs.length; i++) {
     for(var j = 0; j < profiles.length; j++){
     Pkg.addExecutable( basename + "_" + profiles[j], targs[i],
        targs[i].platform, {
       cfgScript: null,
       profile: profiles[j],
   }
   ).addObjects( csources );
     }
}

3 package.xdc
package app { }

编译配置:
1 脚本runxdc.sh
#! /bin/sh
# import install paths
# putting the first period before the shell invokation keeps the changes
#      to environment variables set here. Otherwise, changes to environment
#      are only within the context of the executed script
. ../setpaths.sh
# Define search paths for included packages
export XDCPATH="$CE_INSTALL_DIR/packages"//搜寻package的路径
# Define options for execution
export XDCBUILDCFG="$(pwd)/../config.bld"//指定config.bld文件
# Execute xdc command to make all packages
xdc $@ -P *
2 其中setpaths.sh 设置环境变量
#! /bin/sh
######## Uncomment the following line for verbose XDC builds##########
#export XDCOPTIONS="-v"
############# Absolute Paths, must be set for each system #############
# The installation directory of the DVEVM software
export DVEVM_INSTALL_DIR="/home/user/dvevm_1_10"
# Installation directory of the software development kit (may be same as above)
export SDK_INSTALL_DIR="/home/user/dvevm_1_10"
# where the BIOS tools are installed
export BIOS_INSTALL_DIR="$SDK_INSTALL_DIR/bios_5_30"
# where the Montavista lsp is installed
export MONTAVISTA_DEVKIT="/opt/montavista/pro/devkit"
# where the C6000 code generation tools are installed
export C6000_CG="$SDK_INSTALL_DIR/cg6x_6_0_3"
###### In most cases, the following do not need modification #########
# Where the Codec Engine package is installed.
export CE_INSTALL_DIR="$DVEVM_INSTALL_DIR/codec_engine_1_02"
# Where the XDAIS package is installed.
export XDAIS_INSTALL_DIR="$DVEVM_INSTALL_DIR/xdais_5_00"
# Where the DSP Link package is installed.
export DSPLINK_INSTALL_DIR="$DVEVM_INSTALL_DIR/dsplink_1_30_08_02"
# Where the CMEM (contiguous memory allocator) package is installed.
export CMEM_INSTALL_DIR="$DVEVM_INSTALL_DIR/cmem_1_01"
# Where the RTSC tools package is installed.
export XDC_INSTALL_DIR="$DVEVM_INSTALL_DIR/xdctools_1_21"
# Where the framework components are installed
export FC_INSTALL_DIR="$SDK_INSTALL_DIR/framework_components_1_00_03"
# The prefix to be added before the GNU compiler tools (optionally including
# path), i.e. "arm_v5t_le-" or "/opt/bin/arm_v5t_le-".
export MVTOOL_PREFIX="$MONTAVISTA_DEVKIT/arm/v5t_le/bin/arm_v5t_le-"
# Where to copy the resulting executables and data to (when executing 'make
# install') in a proper file structure. This EXEC_DIR should either be visible
# from the target, or you will have to copy this (whole) directory onto the
# target filesystem.
export EXEC_DIR="/home/user/workdir/filesys/opt/workshop"
export PATH="$XDC_INSTALL_DIR:$PATH"
3 config.bld
/*
* ======== config.bld ========
* This script is run prior to all build scripts. It sets host-system-
* independent values for targets and platforms, then it attempts to
* find the host-system-specific user.bld script that sets rootDirs.
*
* These settings may be a function of the following global variables:
*
* environment a hash table of environment strings
*
* arguments   an array of string arguments to the config.bld script
*      initialized as follows:
*          arguments[0] - the file name of the config.bld script
*          arguments[1] - the first argument specified in XDCARGS
*              :
*          arguments[n] - the n'th argument in XDCARGS
*
* Build     an alias for xdc.om.xdc.bld.BuildEnvironment
*/
/*
* ======== DSP target ========
*/
var remarks = " " +
//   "-pdr "     + // enable remarks
   "-pden "    + // enumerate remarks
//   "-pds=880 " + // variable never referenced
//   "-pds=552 " + // variable set but not used
//   "-pds=238 " + // controlling expression is constant
   "-pds=681 " + // call cannot be inlined
   "-pds=452 " + // long long type is not standard
   "-pds=195 " + // zero used for undefined preprocessing id (setjmp.h)
   // check for -pds=452 -pds=238 -pds=681
   "";
var C64P = xdc.useModule('ti.targets.C64P');
C64P.platform       = "ti.platforms.evmDM6446";
C64P.ccOpts.prefix += " --no_compress --mem_model:data=far --disable:sploop " + remarks;
/*
* ======== Linux host target ========
*/
var Linux86 = xdc.useModule('gnu.targets.Linux86');
Linux86.lnkOpts.suffix = "-lpthread " + Linux86.lnkOpts.suffix;
Linux86.rootDir = "/usr";
Linux86.ccOpts.prefix += " -Wall";
Linux86.includeOpts += " -isystem /usr/lib/gcc/i386-redhat-linux/$(GCCVERS)/include ";
/*
* ======== Arm target ========
* [dm]TODO:H double-check all these options! Decide what to add or remove.
*/
var MVArm9 = xdc.useModule('gnu.targets.MVArm9');
MVArm9.ccOpts.prefix += " "
    // options that check quality/strictness of code
    + "-Wall "
    // supress some warnings caused by .xdc.h files
    + "-fno-strict-aliasing "
    ;
MVArm9.platform = "ti.platforms.evmDM6446";
/* remove reference to C++ from opts */
MVArm9.lnkOpts.suffix = MVArm9.lnkOpts.suffix.replace("-lstdc++", "");
/* add pthreads */
MVArm9.lnkOpts.suffix = "-lpthread " + MVArm9.lnkOpts.suffix;
/* add search path for DaVinci lsp driver header files */
MVArm9.includeOpts = "-isystem $(rootdir)/../../../lsp/ti-davinci_evm-arm_v5t_le/linux-2.6.10_mvl401/include " + MVArm9.includeOpts;
/*
* ======== Pkg.attrs.profile ========
*/
Pkg.attrs.profile = "release";
/*
* ======== Pkg.libTemplate ========
* Set default library version template to be used by all packages
*/
Pkg.libTemplate = "ti/sdo/ce/utils/libvers.xdt";
/*
* ======== Tool Locations =========
*/
/* location of your C6000 codegen tools (C64P is target name for C64x+ DSP)*/
//C64P.rootDir = "/home/user/dvevm_1_10/cg6x_6_0_3";
C64P.rootDir = java.lang.System.getenv("C6000_CG");
/* location of your Montavista Arm9 tools */
//MVArm9.rootDir = "/opt/montavista/pro/devkit/arm/v5t_le/armv5tl-montavista-linuxeabi";
MVArm9.rootDir = java.lang.System.getenv("MONTAVISTA_DEVKIT") + "/arm/v5t_le/armv5tl-montavista-linuxeabi";

/*
* ======== Build.targets ========
* list of targets (ISAs + compilers) to build for
*/
Build.targets = [
    C64P,
    MVArm9,
    Linux86
];

var paths = [];
// Where to copy the resulting executables and data to (when executing 'make
// install') in a proper file structure. This EXEC_DIR should either be visible
// from the target, or you will have to copy this (whole) directory onto the
// target filesystem.
//paths["EXEC_DIR"]="/home/user/workdir/filesys/opt/workshop";
paths["EXEC_DIR"]=java.lang.System.getenv("EXEC_DIR");
setpaths.shconfig.bld需要根据本机环境修改

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值