#include "idep_linkdep.h"#include <iostream>Go to the source code of this file.
Defines | |
| #define | NL "\n" |
Enumerations | |
| enum | { IOERROR = -1, SUCCESS = 0, DESIGN_ERROR = 1 } |
Functions | |
| const char * | help () |
| ostream & | err () |
| int | missing (const char *argName, char option) |
| int | extra (const char *text, char option) |
| int | unreadable (const char *dirFile, char option) |
| int | incorrect (const char *file, char option) |
| const char * | getArg (int *i, int argc, const char *argv[]) |
| int | main (int argc, const char *argv[]) |
Variables | |
| enum { ... } | s_status |
|
|
|
|
|
Definition at line 37 of file ldep.cc. 00037 { IOERROR = -1, SUCCESS = 0, DESIGN_ERROR = 1 } s_status = SUCCESS;
|
|
|
Definition at line 39 of file ldep.cc. References s_status. 00040 {
00041 s_status = IOERROR;
00042 return cerr << "Error: ";
00043 }
|
|
||||||||||||
|
Definition at line 52 of file ldep.cc. Referenced by main(), and RotoClient::SendCommand(). 00053 {
00054 err() << "extra text \"" << text << "\" encountered after -"
00055 << option << " option." << endl;
00056 return s_status;
00057 }
|
|
||||||||||||||||
|
Definition at line 73 of file ldep.cc. Referenced by main(). 00074 {
00075 return 0 != argv[*i][2] ? argv[*i] + 2 :
00076 ++*i >= argc || '-' == argv[*i][0] ? "" : argv[*i];
00077 }
|
|
|
Definition at line 9 of file ldep.cc. References NL. 00010 {
00011 return NL
00012 "ldep: Analyze the link-time dependencies among a collection of components." NL
00013 "" NL
00014 " The following command line interface is supported:" NL
00015 "" NL
00016 " ldep [-U<dir>] [-u<un>] [-a<aliases>] [-d<deps>] [-l|-L] [-x|-X] [-s]" NL
00017 "" NL
00018 " -U<dir> Specify directory not to group as a package." NL
00019 " -u<un> Specify file containing directories not to group." NL
00020 " -a<aliases> Specify file containg list of component name aliases." NL
00021 " -d<deps> Specify file containg list of compile-time dependencies." NL
00022 " -l Long listing: provide non-redundant list of dependencies."NL
00023 " -L Long listing: provide complete list of dependencies." NL
00024 " -x Suppress printing any alias/unalias information." NL
00025 " -X Suppress printing all but the levelized component names." NL
00026 " -s Do _not_ remove suffixes; consider each file separately." NL
00027 "" NL
00028 " This command takes no arguments. The dependencies themselves will" NL
00029 " come from standard input unless the -d option has been invoked." NL
00030 "" NL
00031 " TYPICAL USAGE:" NL
00032 "" NL
00033 " ldep -aaliases -ddependencies" NL
00034 NL;
00035 }
|
|
||||||||||||
|
Definition at line 66 of file ldep.cc. Referenced by main(). 00067 {
00068 err() << "file \"" << file << "\" contained invalid contents for -"
00069 << option << " option." << endl;
00070 return s_status;
00071 }
|
|
||||||||||||
|
Definition at line 79 of file ldep.cc. References idep_LinkDep::addDependencyFile(), idep_LinkDep::addUnaliasDirectory(), idep_LinkDep::calculate(), DESIGN_ERROR, err(), extra(), getArg(), help(), incorrect(), missing(), option, idep_LinkDep::printAliases(), idep_LinkDep::printCycles(), idep_LinkDep::printLevels(), idep_LinkDep::printSummary(), idep_LinkDep::printUnaliases(), idep_LinkDep::readAliases(), idep_LinkDep::readUnaliasDirectories(), s(), s_status, and unreadable(). 00080 {
00081 int fileFlag = 0; // -d<file> sets this to 1
00082 int longListingFlag = 0; // both -l and -L set this to 1
00083 int canonicalFlag = 1; // -L sets this to 0 and -l sets it back to 1
00084 int suffixFlag = 1; // -s sets this to 1
00085 int suppression = 0; // -x sets this to 1; -X sets it to 2.
00086 idep_LinkDep environment;
00087 for (int i = 1; i < argc; ++i) {
00088 const char *word = argv[i];
00089 if ('-' == word[0]) {
00090 char option = word[1];
00091 switch(option) {
00092 case 'U': {
00093 const char *arg = getArg(&i, argc, argv);
00094 if (!*arg) {
00095 return missing("dir", option);
00096 }
00097 environment.addUnaliasDirectory(arg);
00098 } break;
00099 case 'u': {
00100 const char *arg = getArg(&i, argc, argv);
00101 if (!*arg) {
00102 return missing("file", option);
00103 }
00104 if (0 != environment.readUnaliasDirectories(arg)) {
00105 return unreadable(arg, option);
00106 }
00107 } break;
00108 case 'a': {
00109 const char *arg = getArg(&i, argc, argv);
00110 if (!*arg) {
00111 return missing("file", option);
00112 }
00113 int s = environment.readAliases(cerr, arg);
00114 if (s < 0) {
00115 return unreadable(arg, option);
00116 }
00117 if (s > 0) {
00118 return incorrect(arg, option);
00119 }
00120 } break;
00121 case 'd': {
00122 const char *arg = getArg(&i, argc, argv);
00123 if (!*arg) {
00124 return missing("file", option);
00125 }
00126 environment.addDependencyFile(arg);
00127 fileFlag = 1;
00128 } break;
00129 case 'l': {
00130 const char *arg = word + 2;
00131 if (*arg) {
00132 return extra(arg, option);
00133 }
00134 canonicalFlag = 1;
00135 longListingFlag = 1;
00136 } break;
00137 case 'L': {
00138 const char *arg = word + 2;
00139 if (*arg) {
00140 return extra(arg, option);
00141 }
00142 longListingFlag = 1;
00143 canonicalFlag = 0;
00144 } break;
00145 case 's': {
00146 const char *arg = word + 2;
00147 if (*arg) {
00148 return extra(arg, option);
00149 }
00150 suffixFlag = 0;
00151 } break;
00152 case 'x': {
00153 const char *arg = word + 2;
00154 if (*arg) {
00155 return extra(arg, option);
00156 }
00157 suppression = 1;
00158 } break;
00159 case 'X': {
00160 const char *arg = word + 2;
00161 if (*arg) {
00162 return extra(arg, option);
00163 }
00164 suppression = 2;
00165 } break;
00166 default: {
00167 err() << "unknown option \"" << word << "\"." << endl
00168 << help();
00169 return s_status;
00170 } break;
00171 }
00172 }
00173 else {
00174 err() << "illegal argument \"" << word << "\"." << endl
00175 << help();
00176 return s_status;
00177 }
00178 }
00179
00180 if (!fileFlag) {
00181 environment.addDependencyFile(""); // "" is synonym for standard input
00182 }
00183
00184 int result = environment.calculate(cerr, canonicalFlag, suffixFlag);
00185
00186 s_status = result < 0 ? IOERROR : result > 0 ? DESIGN_ERROR : SUCCESS;
00187
00188 if (s_status >= 0) {
00189 if (0 == suppression) {
00190 environment.printAliases(cout);
00191 environment.printUnaliases(cout);
00192 }
00193 environment.printCycles(cerr);
00194 environment.printLevels(cout, longListingFlag, suppression >= 2);
00195 if (suppression <= 1) {
00196 environment.printSummary(cout);
00197 }
00198 }
00199
00200 return s_status;
00201 }
|
|
||||||||||||
|
Definition at line 45 of file ldep.cc. Referenced by main(). 00046 {
00047 err() << "missing `" << argName << "' argument for -"
00048 << option << " option." << endl;
00049 return s_status;
00050 }
|
|
||||||||||||
|
Definition at line 59 of file ldep.cc. Referenced by main(). 00060 {
00061 err() << "unable to read \"" << dirFile << "\" for -"
00062 << option << " option." << endl;
00063 return s_status;
00064 }
|
|
|
|
1.3.9.1