1    /* 
     2     *  Copyright (c) 2011 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    /*!
    14     *  ======== google.targets.ITarget ========
    15     *  Interface to Google's GCC compatible compilers (e.g. Bionic)
    16     */
    17    @TargetHeader("xdc/bld/stddefs.xdt")
    18    metaonly interface ITarget inherits xdc.bld.ITarget2 {
    19    
    20        override readonly config string stdInclude = "google/targets/std.h";
    21        override config string dllExt     = ".so";
    22    
    23        /*!
    24         *  ======== GCCVERS ========
    25         *  Version number of the GCC compiler; e.g., "3.2".
    26         *
    27         *  This string can be supplied by the user, otherwise it is obtained
    28         *  by running "gcc -dumpversion".
    29         */
    30        config string GCCVERS = null;
    31    
    32        /*!
    33         *  ======== BINVERS ========
    34         *  Version number of binutils used with the compiler; e.g., "2.19".
    35         *
    36         *  This string can be supplied by the user, otherwise it is obtained
    37         *  by running "ld -v".
    38         */
    39        config string BINVERS = null;
    40    
    41        /*!
    42         *  ======== version ========
    43         *  The Compatibility Key associated with this target.
    44         *
    45         *  The first two components of this target's Compatibility Key are '1,0'.
    46         *  The rest of the Key represents the compiler version. The third
    47         *  component combines the major and the minor version number in the format
    48         *  Major.Minor. The fourth component is the patch number.
    49         *
    50         *  @a(Example)
    51         *  If this target's `rootDir` points to the compiler version 3.4.6, the
    52         *  Compatibility Key is [1,0,3.4,6].
    53         *
    54         */
    55        override metaonly config String version;
    56    
    57        /*!
    58         *  ======== GCCTARG ========
    59         *  The name of the platform executing programs produced by this target
    60         *
    61         *  This string can be supplied by the user, otherwise is is obtained
    62         *  from the compiler and follows the GNU standard format
    63         *  (<cpu>-<manufacturer>-<os> or <cpu>-<manufacturer>-<kernel>-<os>);
    64         *  e.g., "sparc-sun-solaris2.6" or "i586-pc-linux-gnu".
    65         *
    66         *  When building a GCC compiler, there are three different execution
    67         *  platforms to consider: the platform used to "build" the compiler, the
    68         *  "host" platform that runs the compiler, and the "target" platform
    69         *  that runs the executables produced by the compiler. All three
    70         *  platforms are identified using a
    71         *  {@link http://sources.redhat.com/autobook/autobook/autobook_17.html configuration name}
    72         *  defined by GNU Autotools.  `GCCTARG` is the name of the "target"
    73         *  platform.
    74         */
    75        config string GCCTARG = null;
    76    
    77        /*!
    78         *  ======== LONGNAME ========
    79         *  The "long name" of the gcc compiler
    80         *
    81         *  This name is used (in conjunction with rootDir) to find the compiler
    82         *  and linker for this target. The format of `LONGNAME` is always
    83         *  "/bin/<machine>-gcc". For majority of the targets, the default value
    84         *  for `LONGNAME` does not ever need to be changed. But, there are
    85         *  targets where the different but compatible compilers may have
    86         *  different `LONGNAME` parameters. For such targets and compilers,
    87         *  `LONGNAME` can be set in `config.bld`.
    88         *
    89         *  @a(Example)
    90         *  If a version 2010q1 of the CodeSourcery GNU toolchain for Arm is
    91         *  installed in C:/CodeSourcery/arm-2010q1, the following settings in
    92         *  `config.bld` configure `google.targets.arm.Bionic` target to use that
    93         *  toolchain:
    94         *  @p(code)
    95         *  var Bionic = xdc.module("google.targets.arm.Bionic");
    96         *  Bionic.rootDir = "C:/CodeSourcery/arm-2010q1";
    97         *  Bionic.LONGNAME = "bin/arm-none-linux-gnueabi-gcc";
    98         *  Bionic.libcDir = "C:/android-rowboat/bionic";
    99         *  Bionic.fsDir = "C:/android-rowboat/out/target/product/ti814xevm/obj";
   100         *  @p
   101         *
   102         */
   103        config string LONGNAME = "/bin/gcc";
   104    
   105        /*!
   106         *  ======== libcDir ========
   107         *  The libc of the gcc compiler
   108         *
   109         *  This name is used to find the libc libraries.
   110         *
   111         *  @a(Example)
   112         *  If the libc files are installed in C:/android-rowboat/bionic, the
   113         *  following settings in `config.bld` configure the
   114         *  `google.targets.arm.Binoic` target to use that libc installation:
   115         *  @p(code)
   116         *  var Bionic = xdc.module("google.targets.arm.Bionic");
   117         *  Bionic.rootDir = "C:/CodeSourcery/arm-2010q1";
   118         *  Bionic.LONGNAME = "bin/arm-none-linux-gnueabi-gcc";
   119         *  Bionic.libcDir = "C:/android-rowboat/bionic";
   120         *  Bionic.fsDir = "C:/android-rowboat/out/target/product/ti814xevm/obj";
   121         *  @p
   122         *
   123         */
   124        config string libcDir;
   125    
   126        /*!
   127         *  ======== fsDir ========
   128         *  The bionic file system
   129         *
   130         *  This name is used to find the file system libraries.
   131         *
   132         *  @a(Example)
   133         *  If the file system is installed in
   134         *  C:/android-rowboat/out/target/product/ti814xevm/obj, the
   135         *  following settings in `config.bld` configure the
   136         *  `google.targets.arm.Binoic` target to use that file system:
   137         *  @p(code)
   138         *  var Bionic = xdc.module("google.targets.arm.Bionic");
   139         *  Bionic.rootDir = "C:/CodeSourcery/arm-2010q1";
   140         *  Bionic.LONGNAME = "bin/arm-none-linux-gnueabi-gcc";
   141         *  Bionic.fsDir = "C:/android-rowboat/out/target/product/ti814xevm/obj";
   142         *  @p
   143         *
   144         */
   145        config string fsDir;
   146    
   147        /*!
   148         *  ======== CYGWIN ========
   149         *  Is the target's compiler a cygwin executable
   150         *
   151         *  Since file names produced by cygwin-based tools differ from the
   152         *  names understood by other Windows executables, it is important
   153         *  to avoid using the names output by cygwin tools as input to
   154         *  non-cygwin programs.  This property tells the target whether
   155         *  or not it's possible to use the output from `gcc -MD -MF`, for
   156         *  example.
   157         */
   158        readonly config Bool CYGWIN = false;
   159    
   160        /*!
   161         *  ======== noStdLinkScript ========
   162         *  Don't use the standard linker script
   163         *
   164         *  If `true`, add a `-T` flag before the generated `package/cfg/*.xdl`
   165         *  file passed to the linker.  This flag suppresses use of the
   166         *  standard linker script implicit in the GCC flow, which effectively
   167         *  says the generated `.xdl` file assumes total control for all
   168         *  `MEMORY` and `SECTION` directives.
   169         *
   170         */
   171        config Bool noStdLinkScript = false;
   172    
   173        /*
   174         *  ======== profiles ========
   175         */
   176        override config xdc.bld.ITarget.OptionSet profiles[string] = [
   177            ["debug", {
   178                compileOpts: {
   179                    copts: "-g",
   180                    defs:  "-D_DEBUG_=1",
   181                },
   182                linkOpts: "-g",
   183            }],
   184    
   185            ["release", {
   186                compileOpts: {
   187                    copts: "-O2 -ffunction-sections -fdata-sections",
   188                },
   189                linkOpts: "-Wl,--gc-sections",
   190            }],
   191    
   192            ["profile", {
   193                compileOpts: {
   194                    copts: "-g -pg",
   195                },
   196                linkOpts: "-pg"     /* can't use -static here */
   197            }],
   198    
   199            ["coverage", {
   200                compileOpts: {
   201                    copts: "-fprofile-arcs -ftest-coverage",
   202                },
   203                linkOpts: "-fprofile-arcs -ftest-coverage",
   204            }],
   205        ];
   206    
   207        /*!
   208         *  ======== versionMap ========
   209         *  Map of GCC compiler version numbers to compatibility keys.
   210         *
   211         *  This map translates version string information from the compiler
   212         *  into a compatibility key.  The compatibilty key is used to
   213         *  validate consistency among a collection of packages used in
   214         *  a configuration.
   215         *
   216         *  The compiler version string is "gcc<ver>", where <ver> is
   217         *  GCCVERS.
   218         *
   219         *  If a compiler version is not found in this map the default is
   220         *  "1,0,<ver>", where <ver> is the compiler version number.  Thus,
   221         *  the user only needs to extend this table when a significant
   222         *  incompatibility occurs or when two versions of the compiler should
   223         *  be treated as 100% compatible.
   224         */
   225        override config string versionMap[string] = [
   226            ["gcc3.2", "1,0,3.2,0"],
   227        ];
   228    
   229        /*!
   230         *  ======== remoteHost ========
   231         *  Remote host used to run compiler, linker, and archiver tools
   232         *
   233         *  If `remoteHost` is `null` (or `undefined`), the configured compiler
   234         *  is run locally; otherwise, `remoteHost` is taken to be the host name
   235         *  of the machine that that should be used to run the specified compiler.
   236         *
   237         *  All target commands are prefixed with a command that uses `rsh` to run
   238         *  the commands on the specified host.  Thus, in order to use this
   239         *  setting, the remote machine must be support `rsh` and the user must
   240         *  have permission to run commands from the local machine on the remote
   241         *  host named `remoteHost`.  This usually involves adding a line to the
   242         *  user's `~/.rhosts` file on the remote machine of the form:
   243         *  @p(code)
   244         *      local-machine-name user-name
   245         *  @p
   246         *  where `local-machine-name` is the name of the local machine and
   247         * `user-name` is the user's login name on the local machine.
   248         */
   249        config string remoteHost;
   250    
   251        /*!
   252         *  ======== ar ========
   253         *  The command used to create an archive
   254         */
   255        override readonly config xdc.bld.ITarget2.Command ar = {
   256            cmd: "$(rootDir)/$(GCCTARG)/bin/ar",
   257            opts: "cr"
   258        };
   259    
   260        /*!
   261         *  ======== lnk ========
   262         *  The command used to link executables.
   263         */
   264        override readonly config xdc.bld.ITarget2.Command lnk = {
   265            cmd: "$(rootDir)/$(LONGNAME)",
   266            opts: ""
   267        };
   268    
   269        /*!
   270         *  ======== cc ========
   271         *  The command used to compile C/C++ source files into object files
   272         */
   273        override readonly config xdc.bld.ITarget2.Command cc = {
   274            cmd: "$(rootDir)/$(LONGNAME) -c -MD -MF $@.dep",
   275            opts: ""
   276        };
   277    
   278        /*!
   279         *  ======== asm ========
   280         *  The command used to assembles assembly source files into object files
   281         */
   282        override readonly config xdc.bld.ITarget2.Command asm = {
   283            cmd: "$(rootDir)/$(LONGNAME) -c -x assembler",
   284            opts: ""
   285        };
   286    
   287        /*!
   288         *  ======== includeOpts ========
   289         *  Additional user configurable target-specific include path options
   290         */
   291        override config string includeOpts = "";
   292    }
   293    /*
   294     *  @(#) google.targets; 1, 0, 0,22; 2-10-2012 11:27:35; /db/ztree/library/trees/xdctargets/xdctargets-f18x/src/ xlibrary
   295    
   296     */
   297