TI XDC工具入门简介

论坛 期权论坛 脚本     
匿名技术用户   2020-12-23 09:52   22   0

http://csharp.usr.cc/forum.php?mod=viewthread&tid=52028&page=1


1.XDC(Express DSP Component)是TI提供的一个命令行工具,它可以生成并使用实时软件组件包,它包括一系列工具,这些工具可以允许你将你的C语言代码组织成类似于java的包管理方式,具有面向对象的特性,因为它还有一个名字,叫做eXpanDed C.





2.以上两图说明了XDC的工作方式:通过相关文件设定操作指令,读入源码、库文件以及已经存在的组件包最终生成可执行文件。

3.Package------XDC工作的基本单元。包括有:源码、库文件以及元数据;元数据这包含有该包的版本信息和依赖信息,以及模块(Module)信息。

4.XDC使用方法:




5.XDC需要的文件:config.bld package.bld package.xdc
Package.xdc -------------描述该包的名称,版本信息,依赖文件,模块信息等

Config.bld --------------描述XDC要使用的编译工具的相关信息,如不同CPU所使用的编译工具目录,每种编译工具的编译选项,连接选项等基本信息;


Package.bld -------------------描述对于该包需要生成的平台,profile(debug,release)。通过Javascript脚本添加源码到生成执行文件的信息中。
Package.mak-------------------由XDC生成的文件,用于最终编译可执行文件。

6.XDC工作流程:



7.使用XDC所需的文件:源码、package.bld、package.xdc、config.bld。同时需要通过shell脚本将DVEVM的安装位置导出为环境变量。
各代码如下:
Config.bld样本代码:
  1. + expand sourceview plaincopy to clipboardprint?
  2. var MVArm9 = xdc.useModule("gnu.targets.MVArm9");
  3. MVArm9.rootDir = "/opt/DVS357/mv_pro_4.0/montavista/pro/devkit/arm/v5t_le";
  4. MVArm9.lnkOpts.suffix = "-lpthread " + MVArm9.lnkOpts.suffix;
  5. var Linux86=xdc.useModule("gnu.targets.Linux86");
  6. Linux86.rootDir = "/usr";
  7. Linux86.lnkOpts.suffix = "-lpthread " + Linux86.lnkOpts.suffix;
  8. Build.targets = [ Linux86,MVArm9,];
  9. var MVArm9 = xdc.useModule("gnu.targets.MVArm9");
  10. MVArm9.rootDir = "/opt/DVS357/mv_pro_4.0/montavista/pro/devkit/arm/v5t_le";
  11. MVArm9.lnkOpts.suffix = "-lpthread " + MVArm9.lnkOpts.suffix;
  12. var Linux86=xdc.useModule("gnu.targets.Linux86");
  13. Linux86.rootDir = "/usr";
  14. Linux86.lnkOpts.suffix = "-lpthread " + Linux86.lnkOpts.suffix;
  15. Build.targets = [ Linux86,MVArm9,];
复制代码
Runxdc.sh样本代码:
  1. view plaincopy to clipboardprint?
  2. #! /bin/sh
  3. # import install paths

  4. # putting the first period before the shell invokation keeps the changes

  5. # to environment variables set here. Otherwise, changes to environment

  6. # are only within the context of the executed script

  7. ./setpaths.sh
  8. # Define search paths for included packages
  9. export XDCPATH="$CE_INSTALL_DIR/packages"
  10. # Define options for execution
  11. export XDCBUILDCFG=$(pwd)"/config.bld

  12. # Execute xdc command to make all packages

  13. /opt/DVS357/dvevm_1_20/xdc_2_94/xdc $@ -P *
  14. #! /bin/sh
  15. # import install paths

  16. # putting the first period before the shell invokation keeps the changes

  17. # to environment variables set here. Otherwise, changes to environment

  18. # are only within the context of the executed script

  19. ./setpaths.sh
  20. # Define search paths for included packages
  21. export XDCPATH="$CE_INSTALL_DIR/packages"
  22. # Define options for execution
  23. export XDCBUILDCFG=$(pwd)"/config.bld

  24. # Execute xdc command to make all packages

  25. /opt/DVS357/dvevm_1_20/xdc_2_94/xdc $@ -P *
复制代码
Setpaths.sh样本代码:
  1. #!/bin/sh

  2. export DVEVM_INSTALL_DIR="/opt/DVS357/dvevm_1_20/"
  3. export BIOS_INSTALL_DIR=$DVEVM_INSTALL_DIR/bios_5_31_01
  4. export CG_INSTALL_DIR=$DVEVM_INSTALL_DIR/cg6x_6_0_14
  5. export CMEM_INSTALL_DIR=$DVEVM_INSTALL_DIR/cmem_1_02
  6. export CE_INSTALL_DIR=$DVEVM_INSTALL_DIR/codec_engine_1_10_01
  7. export CS_INSTALL_DIR=$DVEVM_INSTALL_DIR/codec_servers_1_23
  8. export DSPLINK_INSTALL_DIR=$DVEVM_INSTALL_DIR/dsplink_1_30_08_02
  9. export FMWK_INSTALL_DIR=$DVEVM_INSTALL_DIR/framework_components_1_10_04
  10. export XDAIS_INSTALL_DIR=$DVEVM_INSTALL_DIR/xdais_5_10
  11. export XDC_INSTALL_DIR=$DVEVM_INSTALL_DIR/xdc_2_94

  12. export PATH=$XDC_INSTALL_DIR:$PATH
  13. #!/bin/sh

  14. export DVEVM_INSTALL_DIR="/opt/DVS357/dvevm_1_20/"
  15. export BIOS_INSTALL_DIR=$DVEVM_INSTALL_DIR/bios_5_31_01
  16. export CG_INSTALL_DIR=$DVEVM_INSTALL_DIR/cg6x_6_0_14
  17. export CMEM_INSTALL_DIR=$DVEVM_INSTALL_DIR/cmem_1_02
  18. export CE_INSTALL_DIR=$DVEVM_INSTALL_DIR/codec_engine_1_10_01
  19. export CS_INSTALL_DIR=$DVEVM_INSTALL_DIR/codec_servers_1_23
  20. export DSPLINK_INSTALL_DIR=$DVEVM_INSTALL_DIR/dsplink_1_30_08_02
  21. export FMWK_INSTALL_DIR=$DVEVM_INSTALL_DIR/framework_components_1_10_04
  22. export XDAIS_INSTALL_DIR=$DVEVM_INSTALL_DIR/xdais_5_10
  23. export XDC_INSTALL_DIR=$DVEVM_INSTALL_DIR/xdc_2_94

  24. export PATH=$XDC_INSTALL_DIR:$PATH
复制代码
package.bld样本代码:
  1. + expand sourceview plaincopy to clipboardprint?
  2. var targs = [MVArm9, Linux86];
  3. var profiles = ["debug", "release"];
  4. // Define the base name for the executable(s) built
  5. var basename = "app";
  6. // The following code uses the java.io.File.list() method to generate an array
  7. // of all files in the current directory ('.') and then sorts out .c files
  8. var sources = java.io.File('.').list();
  9. var csources = [];
  10. for (var i = 0; i < sources.length; i++){
  11. if(String(sources[i]).match(/.*\.c$/))
  12. csources.push(sources[i]);
  13. }

  14. // The build phase cycles through the arrays of build targets and profiles
  15. // and adds an executable for each combination

  16. for (var i = 0; i < targs.length; i++) {
  17. for(var j = 0; j < profiles.length; j++){
  18. Pkg.addExecutable( basename + "_" + profiles[j], targs[i],
  19. targs[i].platform, {
  20. cfgScript: null,
  21. profile: profiles[j],
  22. }
  23. ).addObjects( csources );
  24. }
  25. }
  26. var targs = [MVArm9, Linux86];
  27. var profiles = ["debug", "release"];
  28. // Define the base name for the executable(s) built
  29. var basename = "app";
  30. // The following code uses the java.io.File.list() method to generate an array
  31. // of all files in the current directory ('.') and then sorts out .c files
  32. var sources = java.io.File('.').list();
  33. var csources = [];
  34. for (var i = 0; i < sources.length; i++){
  35. if(String(sources[i]).match(/.*\.c$/))
  36. csources.push(sources[i]);
  37. }

  38. // The build phase cycles through the arrays of build targets and profiles
  39. // and adds an executable for each combination

  40. for (var i = 0; i < targs.length; i++) {
  41. for(var j = 0; j < profiles.length; j++){
  42. Pkg.addExecutable( basename + "_" + profiles[j], targs[i],
  43. targs[i].platform, {
  44. cfgScript: null,
  45. profile: profiles[j],
  46. }
  47. ).addObjects( csources );
  48. }
  49. }
复制代码
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP