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    package xdc.tools.path;
    13    
    14    /*!
    15     *  ======== xdc.tools.path.Main ========
    16     *  Package Repository Path Display Tool
    17     *
    18     *  This tool displays the packages located along the specified package
    19     *  repository path.  Repositories can be specified by explicitly naming
    20     *  them via the `-Pr` option or implicitly by not passing `-Pr`; in
    21     *  this case, the set of repositories searched corresponds to the set of
    22     *  repositories defined by the current package path:
    23     *  @p(code)
    24     *      $XDCPATH;$XDCROOT/packages;^
    25     *  @p
    26     *
    27     *  where `$XDCPATH` is the value of the the user settable prefix of
    28     *  the package path, `$XDCROOT` is the installation directory of the 
    29     *  XDC tools, and `^` is the repository of the package in the current
    30     *  working directory (if it exists).
    31     * 
    32     *  @a(Examples)
    33     *  
    34     *    1. To display information about the packages on the package path
    35     *    (in this example, the package path is just `C:/xdc-o00/packages`):
    36     *  @p(code)
    37     *    xs xdc.tools.path
    38     *  @p
    39     *
    40     *    Output:
    41     *  @p(code)
    42     *    Package Name:      gnu.gdb.jserver
    43     *    Repository:        C:/xdc-o00/packages
    44     *    Release Name:      gnu_gdb_jserver
    45     *    Label:             default
    46     *    Compatibility Key: 1, 0, 0, 0, 87
    47     *    Date:              11/20/2006  20:38
    48     * 
    49     *    Package Name:      gnu.targets
    50     *    Repository:        C:/xdc-o00/packages
    51     *    Release Name:      gnu_targets
    52     *    Label:             default
    53     *    Compatibility Key: 1, 0, 0, 0, 194
    54     *    Date:              11/20/2006  20:38
    55     *     
    56     *  @p
    57     *
    58     *    2. To display the names of the packages on the package path
    59     *    (in this example, the package path is just `C:/xdc-o00/packages`):
    60     *  @p(code)
    61     *    xs xdc.tools.path -n
    62     *  @p
    63     * 
    64     *    Output:
    65     *  @p(code)
    66     *    gnu.gdb.jserver
    67     *    gnu.targets
    68     *    gnu.targets.rts470MV
    69     *    gnu.targets.rts470uC
    70     *    gnu.targets.rts5
    71     *     
    72     *  @p
    73     *
    74     *    3. To simply, echo the current package path:
    75     *  @p(code)
    76     *    xs xdc.tools.path -p
    77     *  @p
    78     *  
    79     *    Output:
    80     *  @p(code)
    81     *    C:/xdc-o00/packages
    82     *  @p
    83     * 
    84     *    4. To display information about the packages "rooted" in the repository
    85     *    `C:/CCStudio_v3.3/bios_5_31/packages`:
    86     *  @p(code)
    87     *    xs xdc.tools.path -Pr C:/CCStudio_v3.3/bios_5_31/packages
    88     *  @p
    89     *  
    90     *    Output:
    91     *  @p(code)
    92     *    Package Name:      ti.platforms.dsk5402
    93     *    Repository:        C:/CCStudio_v3.3/bios_5_31/packages
    94     *    Release Name:      ti_platforms_dsk5402
    95     *    Label:             default
    96     *    Compatibility Key: 1, 0, 0, 24
    97     *    Date:              05/11/2006  19:10
    98     * 
    99     *    Package Name:      ti.platforms.dsk5416
   100     *    Repository:        C:/CCStudio_v3.3/bios_5_31/packages
   101     *    Release Name:      ti_platforms_dsk5416
   102     *    Label:             default
   103     *    Compatibility Key: 1, 0, 0, 24
   104     *    Date:              05/11/2006  19:10
   105     * 
   106     *    Package Name:      ti.platforms.dsk5510
   107     *    Repository:        C:/CCStudio_v3.3/bios_5_31/packages
   108     *    Release Name:      ti_platforms_dsk5510
   109     *    Label:             default
   110     *    Compatibility Key: 1, 0, 0, 24
   111     *    Date:              05/11/2006  19:10
   112     *     
   113     *  @p
   114     *
   115     *    5. To display the names of all packages in or below the directory
   116     *    `C:/CCStudio_v3.3/bios_5_31/packages`:
   117     *  @p(code)
   118     *    xs xdc.tools.path -n -PR C:/CCStudio_v3.3/bios_5_31/packages
   119     *  @p
   120     * 
   121     *    Output:
   122     *  @p(code)
   123     *    ti.platforms.dsk5402
   124     *    ti.platforms.dsk5416
   125     *    ti.platforms.dsk5510
   126     *    ti.platforms.dsk6211
   127     *     
   128     *  @p
   129     *
   130     *  @see xdc.tools.path
   131     */
   132    metaonly module Main inherits xdc.tools.ICmd {
   133    
   134        override config String usage[] = [
   135           '[-n] [-x] [-v] [-H header] [-p] [-c] [-P package_base_dir ...|-Pr repository ...|-PR directory ...]'
   136        ];
   137    
   138        /*!
   139         *  ======== Pkg ========
   140         *  struct used for xml package info
   141         */
   142        @XmlDtd
   143        metaonly struct Pkg {
   144            String name; 
   145            String repository;
   146            String release;
   147            String label;
   148            String key;
   149            String date;
   150            String providerId;
   151            String originalProviderId;
   152            String producerId;
   153        }
   154    
   155        @XmlDtd
   156        metaonly struct CheckResults {
   157            String repository;
   158            String warnings[];
   159        }
   160    
   161        /*!
   162         *  ======== Results ========
   163         *  return value for xml package info
   164         */
   165        @XmlDtd
   166        metaonly struct Results {
   167            String header;     /*! user-specified header */
   168            String path;       /*! package path */
   169            Pkg pkg[];         /*! array of packages */
   170            CheckResults checkResults[];
   171        }
   172    
   173        /*!
   174         *  ======== NameResults ========
   175         *  return value for xml package names
   176         */
   177        @XmlDtd
   178        metaonly struct NameResults {
   179            String header;     /*! user-specified header */
   180            String path;       /*! package path */
   181            String name[];     /*! array of names */
   182            CheckResults checkResults[];
   183        }
   184    
   185        /*!
   186         *  ======== PathResults ========
   187         *  return value for xml package path
   188         */
   189        @XmlDtd
   190        metaonly struct PathResults {
   191            String header;     /*! user-specified header */
   192            String path;       /*! package path */
   193            CheckResults checkResults[];
   194        }
   195    
   196        /*!
   197         *  ======== DirResults ========
   198         *  return value for xml directory echo
   199         */
   200        @XmlDtd
   201        metaonly struct DirResults {
   202            String header;     /*! user-specified header */
   203            String dir[];      /*! array of package base directories */
   204            CheckResults checkResults[];
   205        }
   206    
   207    instance:
   208    
   209        /*!
   210         * Echo path
   211         */
   212        @CommandOption('p')
   213        config Bool pathFlag = false;
   214    
   215        /*!
   216         * Display package names only
   217         */
   218        @CommandOption('n')
   219        config Bool shortFlag = false;
   220    
   221        /*!
   222         * Return an array of strings
   223         */
   224        @CommandOption('a')
   225        config Bool arrFlag = false;
   226    
   227        /*!
   228         * Return a Results struct as XML
   229         */
   230        @CommandOption('x')
   231        config Bool xmlFlag = false;
   232    
   233        /*!
   234         * Print informative messages during execution
   235         */
   236        @CommandOption('v')
   237        config Bool verboseFlag = false;
   238    
   239        /*!
   240         * Header label
   241         */
   242        @CommandOption('H')
   243        config String header = null;
   244    
   245        /*!
   246         * Use specified directory args instead of xdc.path
   247         */
   248        @CommandOption('-Pr,d')
   249        config Bool repositoriesFlag = false;
   250    
   251        /*!
   252         * Recursively find all packages
   253         *
   254         * Recursively descend into specified directories and find every
   255         * package, including packages whose repository is not one of
   256         * the specified directories.
   257         */
   258        @CommandOption('-PR')
   259        config Bool recurseFlag = false;
   260    
   261        /*!
   262         * Only display information for the package directories
   263         */
   264        @CommandOption('-P')
   265        config Bool directoriesFlag = false;
   266    
   267        /*!
   268         * Check repositories for possible errors
   269         */
   270        @CommandOption('c,--checkpath')
   271        config Bool checkFlag = false;
   272    
   273    }
   274    
   275    /*
   276     *  @(#) xdc.tools.path; 1, 0, 0,189; 10-15-2010 11:41:10; /db/ztree/library/trees/xdctools/xdctools-d45x/src/
   277     */
   278