1    /* 
     2     *  Copyright (c) 2008 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    package microsoft.targets;
    16    
    17    /*!
    18     *  ======== ITarget ========
    19     *  A Microsoft-specific extension to the base xdc.bld.ITarget interface.
    20     */
    21    @TargetHeader("xdc/bld/stddefs.xdt")
    22    metaonly interface ITarget inherits xdc.bld.ITarget {
    23    
    24        override readonly config string stdInclude = "microsoft/targets/std.h";
    25        override config string dllExt     = ".dll";
    26    
    27        /*!
    28         *  ======== debugGen ========
    29         *  Debugger/IDE project file generation support.
    30         * 
    31         *  The settings below generate VC project files that enable one
    32         *  to debug (and even rebuild) Executables from within the VC GUI.
    33         *
    34         *  To avoid unnecessary build time overhead, these files are not always
    35         *  generated; by default, they are only generated for "debug" profiles.
    36         *  The generation of these files is controlled by the
    37         *  `{@link xdc.cfg.Program#gen}` configuration parameter.  To force these
    38         *  files to be generated for a particular executable, add the following
    39         *  line to the executable's program configuration script:
    40         *  @p(code)
    41         *      Program.gen.debuggerFiles = true;
    42         *  @p
    43         *  It is also possible to control the generation via build options; see
    44         *  `{@link xdc.bld.ITarget#DebugGen}`.
    45         *
    46         *  To debug an executable: double click on the generated *.vcproj file,
    47         *      when the debugger comes up, type F11 (step into).
    48         *
    49         *  The first time you debug an executable, the VC debugger may prompt
    50         *  you for a "solution file" to save.  Click OK (accepting the solution
    51         *  file name), and you will be at the first statement of your
    52         *  executable.
    53         *
    54         *  To set command line arguments prior to debugging: open the
    55         *  executable's "Project Properties" dialog (select the
    56         *  executable in the "Solution Explorer" window and pull-down
    57         *  View->"Property Pages" or type shift-F4), select "Debugging"
    58         *  in the left-most pane of the executable's "Property Pages", and
    59         *  enter command line arguments in the "Command Arguments" text box.
    60         *
    61         *  @see  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtskdebugginganexecreatedwithoutvisualstudioproject.asp
    62         */
    63        override config xdc.bld.ITarget.DebugGen debugGen = {
    64            execTemplate: "microsoft/targets/vc_exec.xdt",
    65            execPattern: "$(cfgName).vcproj"
    66        };
    67    
    68        /*!
    69         *  ======== profiles ========
    70         *  Standard options profiles for the microsoft tool-chain.
    71         */
    72        override config xdc.bld.ITarget.OptionSet profiles[string] = [
    73            ["debug", {
    74                compileOpts: {
    75                    copts: "-Z7 -Odi -MTd",
    76                    defs:  "-D_DEBUG=1",
    77                },
    78                linkOpts: "-debug msvcrt.lib setargv.obj oldnames.lib ole32.lib oleaut32.lib olepro32.lib uuid.lib kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib comctl32.lib",
    79            }],
    80    
    81            ["release", {
    82                compileOpts: {
    83                    copts: "-O2 -MT",
    84                    defs:  "",
    85                },
    86                linkOpts: "msvcrt.lib setargv.obj oldnames.lib ole32.lib oleaut32.lib olepro32.lib uuid.lib kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib comctl32.lib",
    87            }],
    88        ];
    89    
    90        /*!
    91         *  ======== Command ========
    92         *  Required command and options.
    93         *
    94         *  The compile, link, and archive functions in this interface are
    95         *  implemented by expanding the strings specified in this structure
    96         *  and inserting strings from the Options structure to form a single
    97         *  command.  The strings in this structure can not be changed by
    98         *  the user (they are fixed by the target), but the string in the
    99         *  Options structure may be changed by the user.
   100         *
   101         *  The final command is:
   102         *      Command.cmd Options.prefix Command.opts Options.suffix
   103         *
   104         *  @field(cmd)     name of a tool-chain executable without any path
   105         *                  information.  The location of this executable is
   106         *                  specified by the binDir (or pathPrefix) 
   107         *                  configuration parameter.
   108         *
   109         *  @field(opts)    required options passed to the command; these options
   110         *                  can not be changed or eliminated by user's
   111         *                  configuration script.
   112         */
   113        struct Command {
   114            string cmd;     /*! the command to run */
   115            string opts;    /*! required options for the command */
   116        }
   117    
   118        /*!
   119         *  ======== Options ========
   120         *  User configurable command options.
   121         *
   122         *  The option strings allow the user to pass additional parameters to the
   123         *  executable that is responsible for compiling, linker, or archiving.
   124         *
   125         *  @a(see)
   126         *  microsoft.targets.ITarget.Command
   127         */
   128        struct Options {
   129            string prefix;  //! options placed before required command options
   130            string suffix;  //! options placed after required command options
   131        }
   132    
   133        /*!
   134         *  ======== ar ========
   135         *  The command used to create an archive (i.e., library)
   136         */
   137        readonly config Command ar;
   138    
   139        /*!
   140         *  ======== arOpts ========
   141         *  User configurable archiver options.
   142         */
   143        config Options arOpts = {
   144            prefix: "",
   145            suffix: ""
   146        };
   147    
   148        /*!
   149         *  ======== lnk ========
   150         *  The command used to link executables.
   151         */
   152        readonly config Command lnk;
   153    
   154        /*!
   155         *  ======== lnkOpts ========
   156         *  User configurable linker options.
   157         */
   158        config Options lnkOpts = {
   159            prefix: "",
   160            suffix: ""
   161        };
   162    
   163        /*!
   164         *  ======== cc ========
   165         *  The command used to compile C/C++ source files into object files
   166         */
   167        readonly config Command cc;
   168    
   169        /*!
   170         *  ======== ccOpts ========
   171         *  User configurable compiler options.
   172         */
   173        config Options ccOpts = {
   174            prefix: "",
   175            suffix: ""
   176        };
   177    
   178        /*!
   179         *  ======== asm ========
   180         *  The command used to assembles assembly source files into object files
   181         */
   182        readonly config Command asm;
   183    
   184        /*!
   185         *  ======== setPath ========
   186         *  Return path needed to find necessary DLLS
   187         *
   188         *  The microsoft compilers often require one or more directories to
   189         *  be in the PATH; this allows the compiler to find necessary DLLs.
   190         *  A target implementing this function returns a string with path
   191         *  components separated by ";".
   192         */
   193        function setPath();
   194    
   195        /*!
   196         *  ======== cmdPrefix ========
   197         *  Prefix to put in front of each command
   198         *
   199         *  This string is put in front of every Command before being passed to
   200         *  the shell for execution.  This string can be used to run the compiler
   201         *  in emulation environments.  
   202         */
   203        config String cmdPrefix = "";
   204        
   205        /*!
   206         *  ======== strictANSI ========
   207         *  Disable Microsoft C/C++ language extensions
   208         *
   209         *  Set to true if you plan to port your program to other environments.
   210         *  The compiler treats extended keywords as simple identifiers, disables
   211         *  the other Microsoft extensions, and automatically defines the
   212         *  `__STDC__` predefined macro for C programs. This option shows up
   213         *  as `"-Za"` on the command line when strictANSI is set to `true`.
   214         */
   215        config bool strictANSI = true;
   216        
   217        /*!
   218         *  ======== version ========
   219         *  The Compatibility Key associated with this target.
   220         *
   221         *  The first two components of this target Compatibility Key are '1,0'.
   222         *  The rest of the Key represents the compiler version. The third
   223         *  component combines the major and the minor version number in the format
   224         *  Major.Minor. The fourth component is the build number.
   225         *
   226         *  @a(Example)
   227         *  If this target's `rootDir` points to the Visual C++ 2005 Express 
   228         *  Edition, the output of the command `cl` may contains the compiler
   229         *  version string 14.00.50727.42. The Compatibility Key is
   230         *  [1,0,14.00,50727].
   231         *  
   232         */
   233        override metaonly config String version;
   234    
   235        /*!
   236         *  ======== asmOpts ========
   237         *  User configurable assembler options.
   238         */
   239        config Options asmOpts = {
   240            prefix: "",
   241            suffix: ""
   242        };
   243    
   244        /*!
   245         *  ======== includeOpts ========
   246         *  Additional user configurable target-specific include path options
   247         */
   248        config string includeOpts;
   249    
   250        /*!
   251         *  ======== stdTypes ========
   252         *  @_nodoc
   253         */
   254        override readonly config xdc.bld.ITarget.StdTypes stdTypes = {
   255            t_IArg          : { size: 4, align: 1 },
   256            t_Char          : { size: 1, align: 1 },
   257            t_Double        : { size: 8, align: 1 },
   258            t_Float         : { size: 4, align: 1 },
   259            t_Fxn           : { size: 4, align: 1 },
   260            t_Int           : { size: 4, align: 1 },
   261            t_Int8          : { size: 1, align: 1 },
   262            t_Int16         : { size: 2, align: 1 },
   263            t_Int32         : { size: 4, align: 1 },
   264            t_Int64         : { size: 8, align: 1 },
   265            t_Long          : { size: 4, align: 1 },
   266            t_LDouble       : { size: 8, align: 1 },
   267            t_Ptr           : { size: 4, align: 1 },
   268            t_Short         : { size: 2, align: 1 },
   269        };
   270    }
   271    /*
   272     *  @(#) microsoft.targets; 1, 0, 2, 0,391; 6-9-2010 16:19:56; /db/ztree/library/trees/xdctargets/xdctargets-b37x/src/
   273     */
   274