1    /* --COPYRIGHT--,EPL
     2     * Copyright (c) 2018-2019 Texas Instruments Incorporated - http://www.ti.com
     3     * All rights reserved.
     4     *
     5     * Redistribution and use in source and binary forms, with or without
     6     * modification, are permitted provided that the following conditions are met:
     7     *
     8     * *  Redistributions of source code must retain the above copyright
     9     *    notice, this list of conditions and the following disclaimer.
    10     *
    11     * *  Redistributions in binary form must reproduce the above copyright
    12     *    notice, this list of conditions and the following disclaimer in the
    13     *    documentation and/or other materials provided with the distribution.
    14     *
    15     * *  Neither the name of Texas Instruments Incorporated nor the names of
    16     *    its contributors may be used to endorse or promote products derived
    17     *    from this software without specific prior written permission.
    18     *
    19     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    20     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    21     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    22     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    23     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    24     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    25     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    26     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    27     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    28     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    29     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    30     *
    31     * --/COPYRIGHT--*/
    32    /*
    33     *  ======== Win64.xdc ========
    34     */
    35    
    36    /*!
    37     *  ======== Win64 ========
    38     *  Microsoft Windows 64-bit target using the Visual C/C++ compiler
    39     *
    40     *  This target can be configured to be used with different versions of
    41     *  Microsoft Visual C/C++ and different installations of Platform SDK (or a
    42     *  newer equivalent Windows SDK). The optional Platform SDK is needed only
    43     *  for building applications that use Windows API.
    44     *  The target `Win64` contains default configuration for Visual C/C++
    45     *  version 14.0, but in order to support future versions of Visual C/C++ and
    46     *  different Windows SDK installations, there is a parameter {@link #sdkPath},
    47     *  which users can set in their `config.bld` files to enable usage of this
    48     *  target with their installations.
    49     */
    50    metaonly module Win64 inherits microsoft.targets.ITarget {
    51    
    52        override readonly config string name                = "Win64";
    53        override readonly config string os                  = "Windows";
    54        override readonly config string suffix              = "64W";
    55        override readonly config string isa                 = "x64";
    56        override readonly config xdc.bld.ITarget.Model model = {
    57            endian: "little"
    58        };
    59    
    60        override readonly config string rts = "microsoft.targets.rts";
    61    
    62        override config string platform     = "host.platforms.PC";
    63        override config string execExt      = ".exe";
    64    
    65        /*!
    66         *  ======== path ========
    67         *  Path components added during execution of commands
    68         */
    69        readonly config string path =
    70            "$(rootDir)/VC/bin/amd64;$(rootDir)/Common7/IDE";
    71    
    72        /*!
    73         *  ======== SDKPath ========
    74         *
    75         *  A structure type that defines Windows SDK paths to be used for building
    76         *  Windows applications with this target.
    77         *
    78         *  A Windows SDK installation is needed for building programs that use
    79         *  Windows API. However, Windows SDK installations can be anywhere on the
    80         *  disk and also include SDK version numbers (10.0.10586.0 for example).
    81         *  Therefore, these paths can't be derived from the target's rootDir.
    82         *
    83         *  @field(includePath) Absolute path to the Include directory of a Windows
    84         *  SDK installation. Windows SDK is required if the target is used to build
    85         *  executables that use Windows API.
    86         *
    87         *  @field(libraryPath) Absolute path to the Lib directory of a Windows
    88         *  SDK installation.
    89         *
    90         *  @field(libs) List of Windows SDK libraries to be added to the linker
    91         * command line.
    92         */
    93        struct SDKPath {
    94            string includePath[];
    95            string libraryPath[];
    96            string libs;
    97        };
    98    
    99        /*!
   100         *  ======== sdkPath ========
   101         *  Location of the header and library files in a Windows SDK installation
   102         *
   103         *  This parameter contains paths to the optional Windows SDK.
   104         *
   105         *  @a(Examples)
   106         *  If the content of `sdkPath`, set in `config.bld` is
   107         *  @p(code)
   108         *      Win64.sdkPath = {
   109         *          includePath: "C:/PROGRA~2/WI3CF2~1/10/Include/10.0.10586.0/ucrt",
   110         *          libraryPath: "C:/PROGRA~2/WI3CF2~1/10/Lib/10.0.10586.0/um/x64";
   111         *          libs: " libucrt.lib setargv.obj oldnames.lib ole32.lib
   112         * oleaut32.lib olepro32.lib uuid.lib kernel32.lib user32.lib gdi32.lib
   113         * advapi32.lib shell32.lib comctl32.lib mfc70.lib ucrt.lib"
   114         *      };
   115         *  the contents of `includePath`, `libraryPath` and `libs` are added to
   116         *  appropriate command lines.
   117         *
   118         *  If Windows SDK is not installed or needed, sdkPath's `includePath` and
   119         *  `libraryPath` should be empty.
   120         *  @p
   121         *
   122         */
   123        config SDKPath sdkPath = {
   124            includePath: [],
   125            libraryPath: [],
   126            libs: "ole32.lib oleaut32.lib uuid.lib kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib comctl32.lib"
   127        };
   128    
   129        /*!
   130         *  ======== profiles ========
   131         *  Standard options profiles are overwritten because we can't use 'MTs'
   132         *  and -D_DEBUG=1. Both of them added the debug version of the C runtime
   133         *  library to the manifest.
   134         */
   135        override config xdc.bld.ITarget.OptionSet profiles[string] = [
   136            ["debug", {
   137                compileOpts: {
   138                    copts: "-Z7 -Odi -MTd",
   139                    defs:  "",
   140                },
   141                linkOpts: "-debug msvcrtd.lib vcruntimed.lib ucrtd.lib oldnames.lib",
   142            }],
   143    
   144            ["release", {
   145                compileOpts: {
   146                    copts: "-O2 -MT",
   147                    defs:  "",
   148                },
   149                linkOpts: "msvcrt.lib vcruntime.lib ucrt.lib oldnames.lib",
   150            }],
   151        ];
   152    
   153        /*!
   154         *  ======== ar ========
   155         *  The archiver command and all required options
   156         *  @p(dlist)
   157         *      -`-nologo`
   158         *          don't display archiver copyright
   159         */
   160        override readonly config xdc.bld.ITarget2.Command ar = {
   161            cmd: "$(rootDir)/VC/bin/amd64/lib.exe -nologo",
   162            opts: ""
   163        };
   164    
   165        /*!
   166         *  ======== cc ========
   167         *  The compile command and all required options
   168         *  @p(dlist)
   169         *      -`-W3`
   170         *          enable all warnings recommended for production purposes.
   171         *      -`-c`
   172         *          don't link
   173         *      -`-nologo`
   174         *          don't display compiler copyright
   175         *      -`-Zp1`
   176         *          Packs structure members on 1-byte boundry
   177         */
   178        override readonly config xdc.bld.ITarget2.Command cc = {
   179            cmd: "$(rootDir)/VC/bin/amd64/cl.exe -nologo -c",
   180            opts: '-Zp1 -W3 -D_DLL -DWINVER=_WIN32_WINNT_WIN7 -D_WIN32_WINNT=_WIN32_WINNT_WIN7 -DWIN64 -DEXPORT=""'
   181        };
   182    
   183        /*!
   184         *  ======== asm ========
   185         *  The assemble command and all required options
   186         *  @p(dlist)
   187         *      -`-c`
   188         *          don't link
   189         *      -`-nologo`
   190         *          don't display macro assembler copyright
   191         */
   192        override readonly config xdc.bld.ITarget2.Command asm = {
   193            cmd: "$(rootDir)/VC/bin/amd64/ml64 -c",
   194            opts: "-nologo"
   195        };
   196    
   197        /*!
   198         *  ======== lnk ========
   199         *  The linker command and all required options
   200         *  @p(dlist)
   201         *      -`-nologo`
   202         *          Don't display linker copyright
   203         */
   204        override readonly config xdc.bld.ITarget2.Command lnk = {
   205            cmd: "$(rootDir)/VC/bin/amd64/link",
   206            opts: "-nologo"
   207        };
   208    
   209        /*!
   210         *  ======== ccOpts ========
   211         *  User modifiable default options.
   212         *  @p(dlist)
   213         *      -`-Ob1`
   214         *          Expand only functions marked as inline or, in a C++
   215         *          member function, defined within a class declaration
   216         *      -`-Gs`
   217         *          Probe stack to automatically grow stack as necessary
   218         */
   219        override config xdc.bld.ITarget2.Options ccOpts = {
   220            prefix: "-Ob1 -Gs",
   221            suffix: "-Dfar= "
   222        };
   223    
   224        /*!
   225         *  ======== lnkOpts ========
   226         *  User modifiable linker options
   227         *  @p(dlist)
   228         *      -`-libpath`
   229         *              directories to search for toolchain specific libraries
   230         *      -`-nodefaultlib`
   231         *              don't search for default libraries when linking; all
   232         *              libraries used must be explicitly named
   233         *      -`-incremental:no`
   234         *              link for execution (no subsequent link will occur)
   235         *      -`-machine:ix64`
   236         *              link for the 64-bit architecture
   237         *      -`-map:$(XDCCFGDIR)/$@.map`
   238         *              output any link map information to the specified file
   239         *              ($(XDCCFGDIR) is usually package/cfg)
   240         *      -`-pdb:$(XDCCFGDIR)/$@.pdb`
   241         *              output any program debug information to the specified file
   242         *              ($(XDCCFGDIR) is usually package/cfg)
   243         */
   244        override config xdc.bld.ITarget2.Options lnkOpts = {
   245            prefix: "-libpath:$(rootDir)/VC/lib/amd64 -libpath:$(rootDir)/VC/atlmfc/lib/amd64",
   246            suffix: "-map:$(XDCCFGDIR)/$@.map -pdb:$(XDCCFGDIR)/$@.pdb -machine:x64 -nodefaultlib -incremental:no"
   247        };
   248    
   249        /*!
   250         *  ======== includeOpts ========
   251         *  User modifiable include paths
   252         *  @p(dlist)
   253         *      -`-I$(rootDir)/$(compilerDir)/include`
   254         *          include compiler specific headers
   255         */
   256        override config string includeOpts = "-I$(rootDir)/VC/include -I$(rootDir)/VC/atlmfc/include";
   257    
   258        /*!
   259         *  ======== stdTypes ========
   260         */
   261        override readonly config xdc.bld.ITarget.StdTypes stdTypes = {
   262            t_IArg          : { size: 8, align: 1 },
   263            t_Char          : { size: 1, align: 1 },
   264            t_Double        : { size: 8, align: 1 },
   265            t_Float         : { size: 4, align: 1 },
   266            t_Fxn           : { size: 8, align: 1 },
   267            t_Int           : { size: 4, align: 1 },
   268            t_Int8          : { size: 1, align: 1 },
   269            t_Int16         : { size: 2, align: 1 },
   270            t_Int32         : { size: 4, align: 1 },
   271            t_Int64         : { size: 8, align: 1 },
   272            t_Long          : { size: 4, align: 1 },
   273            t_LLong         : { size: 8, align: 1 },
   274            t_LDouble       : { size: 8, align: 1 },
   275            t_Ptr           : { size: 8, align: 1 },
   276            t_Short         : { size: 2, align: 1 },
   277            t_Size          : { size: 8, align: 1 },
   278        };
   279    }