1    /*
     2     *  Copyright 2020 by Texas Instruments Incorporated.
     3     *
     4     */
     5    
     6    /*
     7     * Copyright (c) 2013-2019 Texas Instruments Incorporated
     8     * All rights reserved.
     9     *
    10     * Redistribution and use in source and binary forms, with or without
    11     * modification, are permitted provided that the following conditions
    12     * are met:
    13     *
    14     * *  Redistributions of source code must retain the above copyright
    15     *    notice, this list of conditions and the following disclaimer.
    16     *
    17     * *  Redistributions in binary form must reproduce the above copyright
    18     *    notice, this list of conditions and the following disclaimer in the
    19     *    documentation and/or other materials provided with the distribution.
    20     *
    21     * *  Neither the name of Texas Instruments Incorporated nor the names of
    22     *    its contributors may be used to endorse or promote products derived
    23     *    from this software without specific prior written permission.
    24     *
    25     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    26     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    27     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    28     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    29     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    30     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    31     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    32     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    33     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    34     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    35     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    36     */
    37    
    38    /*!
    39     *  ======== ITarget ========
    40     *  IAR ARM extension to the base `xdc.bld.ITarget3` interface.
    41     */
    42    @TargetHeader("xdc/bld/stddefs.xdt")
    43    metaonly interface ITarget inherits xdc.bld.ITarget3 {
    44    
    45        override readonly config String rts = "iar.targets.arm.rts";
    46    
    47        override config string stdInclude = "iar/targets/arm/std.h";
    48    
    49        /*
    50         *  ======== binDir ========
    51         *  Code gen tools bin directory path
    52         */
    53        config string binDir = "$(rootDir)/bin/";
    54    
    55        /*!
    56         *  ======== model ========
    57         *  Little endian, thumb2 model
    58         */
    59        override readonly config xdc.bld.ITarget.Model model = {
    60            endian: "little",
    61            codeModel: "thumb2",
    62            shortEnums: true
    63        };
    64    
    65        /*!
    66         *  ======== ccOpts ========
    67         *  User configurable compiler options.
    68         */
    69        override config Options ccOpts = {
    70            prefix: "--silent",
    71            suffix: ""
    72        };
    73    
    74        /*!
    75         *  ======== asmOpts ========
    76         *  User configurable assembler options.
    77         */
    78        override config Options asmOpts = {
    79            prefix: "-S",
    80            suffix: ""
    81        };
    82    
    83        /*!
    84         *  ======== ar ========
    85         *  The command used to create an archive
    86         */
    87        override readonly config Command ar = {
    88            cmd: "iarchive",
    89            opts: ""
    90        };
    91    
    92        /*!
    93         *  ======== arOpts ========
    94         *  User configurable archiver options.
    95         */
    96        override config Options arOpts = {
    97            prefix: "--silent",
    98            suffix: ""
    99        };
   100    
   101        /*!
   102         *  ======== lnkOpts ========
   103         *  User configurable linker options.
   104         */
   105        override config xdc.bld.ITarget2.Options lnkOpts = {
   106            prefix: "--silent",
   107            suffix: "--map $(XDCCFGDIR)/$@.map  --redirect _Printf=_PrintfSmall --redirect _Scanf=_ScanfSmall ",
   108        };
   109    
   110        /*!
   111         *  ======== vers ========
   112         *  The command used to get the tool-chain to return a version number.
   113         */
   114        readonly config Command vers = {
   115            cmd: "iccarm",
   116            opts: "-v"
   117        };
   118    
   119        /*!
   120         *  ======== extension ========
   121         *  The IAR assembly file extension recognised by this target.
   122         */
   123        override config Extension extensions[string] = [
   124            [".asm",  {suf: ".asm", typ: "asm"}],
   125            [".c",    {suf: ".c",   typ: "c"  }],
   126            [".cpp",  {suf: ".cpp", typ: "cpp"}],
   127            [".cxx",  {suf: ".cxx", typ: "cpp"}],
   128            [".C",    {suf: ".C",   typ: "cpp"}],
   129            [".cc",   {suf: ".cc",  typ: "cpp"}],
   130            [".s",    {suf: ".s",   typ: "asm"}],
   131            [".sv7M", {suf: ".sv7M",typ: "asm"}],
   132            [".sv8M", {suf: ".sv8M",typ: "asm"}],
   133        ];
   134    
   135        /*!
   136         *  ======== includeOpts ========
   137         *  Additional user configurable target-specific include path options
   138         */
   139        override config String includeOpts = "";
   140    
   141        /*!
   142         *  ======== cmdPrefix ========
   143         *  Prefix to put in front of each command
   144         *
   145         *  This string is put in front of every Command before being passed to
   146         *  the shell for execution.  This string can be used to run the compiler
   147         *  in emulation environments.
   148         *
   149         *  LC_ALL=C must be set for code gen to run on SUSE
   150         */
   151        config String cmdPrefix = "LC_ALL=C ";
   152    
   153        /*!
   154         *  ======== alignDirectiveSupported ========
   155         *  The compiler supports an align directive.
   156         */
   157        override readonly config Bool alignDirectiveSupported = true;
   158    
   159        /*!
   160         *  ======== stdTypes  ========
   161         *  Size and alignment for standard base types
   162         */
   163        override readonly config xdc.bld.ITarget.StdTypes stdTypes = {
   164            t_IArg          : { size: 4, align: 4 },
   165            t_Char          : { size: 1, align: 1 },
   166            t_Double        : { size: 8, align: 8 },
   167            t_Float         : { size: 4, align: 4 },
   168            t_Fxn           : { size: 4, align: 4 },
   169            t_Int           : { size: 4, align: 4 },
   170            t_Int8          : { size: 1, align: 1 },
   171            t_Int16         : { size: 2, align: 2 },
   172            t_Int32         : { size: 4, align: 4 },
   173            t_Long          : { size: 4, align: 4 },
   174            t_LDouble       : { size: 8, align: 8 },
   175            t_LLong         : { size: 8, align: 8 },
   176            t_Ptr           : { size: 4, align: 4 },
   177            t_Short         : { size: 2, align: 2 },
   178            t_Size          : { size: 4, align: 4 },
   179            t_Int64         : { size: 8, align: 8 },
   180        };
   181    
   182        /*!
   183         *  ======== profiles ========
   184         *  Standard options profiles.
   185         */
   186        override config xdc.bld.ITarget.OptionSet profiles[string] = [
   187            ["debug", {
   188                compileOpts: {
   189                    copts: "--debug --dlib_config $(rootDir)/inc/c/DLib_Config_Normal.h",
   190                },
   191                linkOpts: "--semihosting=iar_breakpoint",
   192            }],
   193            ["release", {
   194                compileOpts: {
   195                    copts: "-Ohs --dlib_config $(rootDir)/inc/c/DLib_Config_Normal.h",
   196                },
   197                linkOpts: "--semihosting=iar_breakpoint",
   198            }],
   199            ["debug_full", {
   200                compileOpts: {
   201                    copts: "--debug --dlib_config $(rootDir)/inc/c/DLib_Config_Full.h",
   202                },
   203                linkOpts: "--semihosting=iar_breakpoint",
   204            }],
   205            ["release_full", {
   206                compileOpts: {
   207                    copts: "-Ohs --dlib_config $(rootDir)/inc/c/DLib_Config_Full.h",
   208                },
   209                linkOpts: "--semihosting=iar_breakpoint",
   210            }],
   211        ];
   212    
   213        override config String binaryParser = "xdc.targets.omf.Elf";
   214    }
   215    /*
   216     *  @(#) iar.targets.arm; 1, 0, 0,; 1-17-2020 15:49:08; /db/ztree/library/trees/xdctargets/xdctargets-w07/src/ xlibrary
   217    
   218     */
   219