1    /* 
     2     *  Copyright (c) 2009 Texas Instruments and others.
     3     *  All rights reserved. This program and the accompanying materials
     4     *  are made available under the terms of the Eclipse Public License v1.0
     5     *  which accompanies this distribution, and is available at
     6     *  http://www.eclipse.org/legal/epl-v10.html
     7     * 
     8     *  Contributors:
     9     *      Texas Instruments - initial implementation
    10     * 
    11     * */
    12    /*
    13     *  ======== ITarget.xdc ========
    14     *
    15     */
    16    
    17    /*!
    18     *  ======== ITarget ========
    19     *  A TI specific extension to the base `xdc.bld.ITarget3` interface.
    20     */
    21    @TargetHeader("xdc/bld/stddefs.xdt")
    22    metaonly interface ITarget inherits xdc.bld.ITarget3 {
    23    
    24        override readonly config string stdInclude = "ti/targets/std.h";
    25        
    26        /*!
    27         *  ======== binDir ========
    28         *  This parameter controls the location of the target's commands.
    29         *
    30         *  All build commands returned within a command set
    31         *  (`xdc.bld.ITarget.CommandSet.cmds`) are formed by prefixing `binDir`
    32         *  to this target's Command.cmd specification.  For example, the
    33         *  compile command returned is formed as follows:
    34         *  @p(code)
    35         *      $(binDir)$(cc.cmd)
    36         *  @p
    37         *  where, `$(binDir)` is this target's `binDir` value and `$(cc.cmd)` is
    38         *  the value of this target's `cc.cmd` string.
    39         *  
    40         *  If `binDir` is non-empty then it must end with '/'.  If it is empty, 
    41         *  the target's commands (compiler, linker, archiver, etc.) will be
    42         *  located along a path constructed from this target's `pathPrefix`.
    43         */
    44        config string binDir = "$(rootDir)/bin/";
    45    
    46        /*!
    47         *  ======== pathPrefix ========
    48         *  A prefix to the PATH environment variable
    49         *
    50         *  Each target command is executed with C_DIR set to "" and PATH
    51         *  set as follows:
    52         *  @p(code)
    53         *      $(pathPrefix);$(binDir);$(PATH)
    54         *  @p
    55         *  where, `$(pathPrefix)` and `$(binDir)` are the values of the
    56         *  configuration parameters and `$(PATH)` is the value of the `PATH`
    57         *  environment variable set by the `xdc` command (type 'xdc -n' to
    58         *  see this).
    59         *
    60         *  Embedded ';' characters within `pathPrefix` separate directory
    61         *  names.  On UNIX hosts these ';' characters are convered to an
    62         *  appropriate separator; i.e., ':'.
    63         */
    64        config string pathPrefix = "";
    65        
    66        override config String binaryParser = "ti.targets.omf.cof.Coff";
    67    
    68        /*!
    69         *  ======== debugGen ========
    70         *  TI Debugger/IDE file generation support.
    71         *
    72         *  The settings below generate CCS project files that enable one
    73         *  to debug (and even rebuild) Executables from within the CCS GUI.
    74         *
    75         *  To avoid unnecessary build time overhead, these files are not always
    76         *  generated; by default, they are only generated for "debug" profiles.
    77         *  The generation of these files is controlled by the
    78         *  `{@link xdc.cfg.Program#gen}` configuration parameter.  To force these
    79         *  files to be generated for a particular executable, add the following
    80         *  line to the executable's program configuration script:
    81         *  @p(code)
    82         *      Program.gen.debuggerFiles = true;
    83         *  @p
    84         *  It is also possible to control the generation via build options; see
    85         *  `{@link xdc.bld.ITarget#DebugGen}`.
    86         *
    87         *  Note: if you are using CCS 2.x, disable CodeMaestro to prevent
    88         *  instabilities when re-loading project files.  CodeMaestro can be
    89         *  disabled via: Options->"Customize ..."->"CodeMaestro Settings"
    90         *
    91         *  To debug an executable:
    92         *  @p(nlist)
    93         *      - load generated project for the executable:
    94         *             package/cfg/<cfg_name>.pjt
    95         *      - load generated GEL script for the executable:
    96         *             package/cfg/<cfg_name>.gel
    97         *      - load prerequisite packages:
    98         *             GEL->"XDC Package"->open_project
    99         *  @p
   100         *  where <cfg_name> is the name of the executable (foo.x62) with the
   101         *  '.' replaced by and '_' (foo_x62).
   102         *
   103         *  Alternatively, one can use the `ccs_start.pl` script in this package
   104         *  to automate the steps above.  In addition, it is possible to
   105         *  associate `ccs_start.bat` (also in this package) with the generated 
   106         *  `.pjt` files to automate the above by double-clicking on the `.pjt`
   107         *  file.
   108         *
   109         *  To avoid navigation to the executable via file menus, you can load
   110         *  the executable associated with the project via:
   111         *
   112         *      GEL->"XDC Package"->load_executable
   113         *
   114         *  @a(See Also) `xdc.bld.ITarget` contains addition information about
   115         *  how to create and use these templates.
   116         */
   117        override config xdc.bld.ITarget.DebugGen debugGen = {
   118            execTemplate   : "ti/targets/ccs_exec.xdt",
   119            execPattern    : "$(cfgDir)$(cfgName).pjt",
   120            packageTemplate: "ti/targets/ccs_package.xdt",
   121            packagePattern : "package/$(pkgName).pjt"
   122        };
   123        
   124        /*!
   125         *  ======== extensions ========
   126         *  File extensions recognized by TI targets
   127         *
   128         *  @a(TI Specifics)
   129         *  For TI targets, the `typ` string field of an
   130         *  `xdc.bld.ITarget.Extension` structure may be of the form
   131         * `"<cmd>:<langOpt>"` where `<cmd>` is one of `"asm"`, `"c"`, `"cpp"`,
   132         *  and `<langOpt>` is the language option to used to identify the source
   133         *  language of a source file.  This allows one to explicitly control the
   134         *  language flag passed to the compiler based on a source file's
   135         *  extension; in particular, one can define separate source extensions
   136         *  for "linear" and "scheduled" assembly files, or simply cause `".s62"`
   137         *  files to be treated as "linear" assembly rather than "scheduled"
   138         *  assembly.
   139         *
   140         *  For example,
   141         *  @p(code)
   142         *  tiTargets.C62.extensions[".s62"] = {suf: ".s62", typ: "asm:-fl"};
   143         *  @p
   144         *  causes all `".s62"` files to be treated as linear assembly.
   145         *
   146         *  If no ':' appears in the `typ` string, a default will be used:
   147         *  `"-fa"` for `"asm"` files `"-fc"` for `"c"` files, and `"-fp"` for
   148         *  `"cpp"` files.
   149         */
   150        override config xdc.bld.ITarget.Extension extensions[string] =
   151            xdc.bld.ITarget.extensions;
   152    
   153        readonly config Bool splitMap[string];
   154    
   155        /*!
   156         *  ======== profiles ========
   157         *  Standard options profiles for the TI tool-chain.
   158         */
   159        override config xdc.bld.ITarget.OptionSet profiles[string] = [
   160            ["debug", {
   161                compileOpts: {
   162                    copts: "-g",
   163                    defs:  "-D_DEBUG_=1",
   164                }
   165            }],
   166            ["release", {
   167                compileOpts: {
   168                    copts: "-O2",
   169                },
   170            }],
   171            ["whole_program", {
   172                compileOpts: {
   173                    copts: "-oe -O2 -mo",
   174                },
   175            }],
   176            ["whole_program_debug", {
   177                compileOpts: {
   178                    copts: "-oe --symdebug:dwarf -mo",
   179                },
   180            }],
   181        ];
   182    
   183        /*!
   184         *  ======== versionMap ========
   185         *  Map of TI compiler version numbers to compatibility keys.
   186         *
   187         *  This map translates version string information from the compiler
   188         *  into a compatibility key.  The compatibility key is used to validate
   189         *  consistency among a collection of packages used in a configuration.
   190         *
   191         *  TI compiler strings are formed by parsing the output of the
   192         *  compiler's --compiler_revision option and creating a string of the
   193         *  form:
   194         *  @p(code)
   195         *      <comp>_<ver>
   196         *  @p
   197         *  where `<comp>` is the first word of the output and `<ver>` is the
   198         *  version number that appears on this same line.
   199         *
   200         *  There are two forms of version numbers output by the TI code gen
   201         *  tools; an "old" style that is of the form "<major>.<minor>" and a
   202         *  new style of the form "<major>.<minor>.<update>[.<branch>][<qual>],
   203         *  where <major>, <minor>, <update>, and <branch> are non-negative
   204         *  integers and <qual> is of  the form "[IBAP]<yyddd>", and <yyddd>
   205         *  is the last two digits of the year concatenated with the number of
   206         *  the day.
   207         *
   208         *  If a compiler version is not found in this map the default is
   209         *  "1,0,<major>.<minor>" for old style version numbers, and
   210         *  "1,0,<major>.<minor>,<update>[.<branch>][,<yyddd>]" for new style
   211         *  version numbers.
   212         *
   213         *  The user only needs to extend this table when a significant
   214         *  incompatibility occurs (and this package doesn't know about it) or
   215         *  when two versions of the compiler should be treated as 100%
   216         *  compatible.
   217         *
   218         *  @a(Examples)
   219         *  @p(code)
   220         *      var C62 = xdc.useModule('ti.targets.C62');
   221         *
   222         *      // assert that 4.0 is forward compatible with 4.32
   223         *      C62.versionMap["TMS320C6x_4.32"] =  "1,0,4.0,0";
   224         *
   225         *      // assert that 4.28 is incompatible with all other compilers
   226         *      C62.versionMap["TMS320C6x_4.28"] =  "1,1,4.28,0";
   227         */
   228        override config string versionMap[string] = [
   229            ["TMS320C6x_4.32", "1,0,4.32,0"],
   230            ["TMS320C2000_3.07", "1,0,3.07,0"],
   231        ];    
   232        
   233        /*!
   234         *  ======== alignDirectiveSupported ========
   235         *  The compiler supports an align directive.
   236         */
   237        override readonly config Bool alignDirectiveSupported = true;
   238        
   239        /*!
   240         *  ======== ccConfigOpts ========
   241         *  User configurable compiler options for the generated config C file.
   242         */
   243        override config xdc.bld.ITarget2.Options ccConfigOpts = {
   244            prefix: "$(ccOpts.prefix) -mo",
   245            suffix: "$(ccOpts.suffix)"
   246        };
   247    
   248        /*!
   249         *  ======== lnkOpts ========
   250         *  Linker options
   251         *
   252         *  Options:
   253         *  @p(dlist)
   254         *      -`-q`
   255         *          Quite run
   256         *      -`-u`
   257         *          Place unresolved external symbol into symbol table
   258         *      -`-c`
   259         *          ROM autoinitialization model
   260         *      -`-m`
   261         *          create a map file
   262         *      -`-l`
   263         *          archive library file as linker input
   264         */
   265        override config xdc.bld.ITarget2.Options lnkOpts = {
   266            prefix: "-w -q -u _c_int00",
   267            suffix: "-c -m $(XDCCFGDIR)/$@.map -l $(rootDir)/lib/libc.a"
   268        };
   269            
   270        /*!
   271         *  ======== asmName ========
   272         *  The function that converts a C name into an assembly name
   273         */
   274        String asmName(String CName);
   275    
   276        /*!
   277         *  ======== vers ========
   278         *  The command used to get the tool-chain to return a version number.
   279         */
   280        readonly config xdc.bld.ITarget2.Command vers;
   281    
   282        /*!
   283         *  ======== version ========
   284         *  The Compatibility Key associated with this target.
   285         *
   286         *  The first two components of this target Compatibility Key are '1,0'.
   287         *  The rest of the Key represents the compiler version. The third
   288         *  component combines the major and the minor version number in the format
   289         *  Major.Minor. The fourth component is the patch number, and the optional
   290         *  fifth component is the version of an Alpha or Beta release.
   291         *
   292         *  @a(Example)
   293         *  If this target's `rootDir` points to the compiler version 6.0.11, the 
   294         *  Compatibility Key is [1,0,6.0,11]. If this target's `rootDir` points to
   295         *  the compiler version 7.0.0B1, the Compatibility Key is [1,0,7.0,0,1]. 
   296         *  
   297         */
   298        override metaonly config String version;
   299            
   300        /*
   301         *  ======== rawVersion ========
   302         *  The raw version string from the compiler
   303         *
   304         */
   305        override metaonly config String rawVersion;
   306    
   307    }
   308    /*
   309     *  @(#) ti.targets; 1, 0, 3,576; 3-12-2013 15:05:00; /db/ztree/library/trees/xdctargets/xdctargets-g22x/src/ xlibrary
   310    
   311     */
   312