Changeset 1402:1311dabc6a1f
- Timestamp:
- 05/20/09 15:13:41
(3 years ago)
- Author:
- Christian Kamm <kamm incasoftware de>
- branch:
- default
- Message:
Merged xfBuild patch for dependency tree generation. See #286.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r1358 |
r1402 |
|
| 117 | 117 | } |
|---|
| 118 | 118 | |
|---|
| | 119 | char* escapePath(char* fname, char* buffer, int bufLen) { |
|---|
| | 120 | char* res = buffer; |
|---|
| | 121 | bufLen -= 2; // for \0 and an occasional escape char |
|---|
| | 122 | int dst = 0; |
|---|
| | 123 | for (; dst < bufLen && *fname; ++dst, ++fname) { |
|---|
| | 124 | switch (*fname) { |
|---|
| | 125 | case '(': |
|---|
| | 126 | case ')': |
|---|
| | 127 | case '\\': |
|---|
| | 128 | buffer[dst++] = '\\'; |
|---|
| | 129 | // fall through |
|---|
| | 130 | |
|---|
| | 131 | default: |
|---|
| | 132 | buffer[dst] = *fname; |
|---|
| | 133 | } |
|---|
| | 134 | } |
|---|
| | 135 | buffer[dst] = '\0'; |
|---|
| | 136 | return buffer; |
|---|
| | 137 | } |
|---|
| 119 | 138 | |
|---|
| 120 | 139 | void Import::semantic(Scope *sc) |
|---|
| … | … | |
| 170 | 189 | } |
|---|
| 171 | 190 | //printf("-Import::semantic('%s'), pkg = %p\n", toChars(), pkg); |
|---|
| | 191 | |
|---|
| | 192 | |
|---|
| | 193 | if (global.params.moduleDeps != NULL) { |
|---|
| | 194 | char fnameBuf[262]; // MAX_PATH+2 |
|---|
| | 195 | |
|---|
| | 196 | OutBuffer *const ob = global.params.moduleDeps; |
|---|
| | 197 | ob->printf("%s (%s) : ", |
|---|
| | 198 | sc->module->toPrettyChars(), |
|---|
| | 199 | escapePath(sc->module->srcfile->toChars(), fnameBuf, sizeof(fnameBuf) / sizeof(*fnameBuf)) |
|---|
| | 200 | ); |
|---|
| | 201 | |
|---|
| | 202 | char* protStr = ""; |
|---|
| | 203 | switch (sc->protection) { |
|---|
| | 204 | case PROTpublic: protStr = "public"; break; |
|---|
| | 205 | case PROTprivate: protStr = "private"; break; |
|---|
| | 206 | case PROTpackage: protStr = "package"; break; |
|---|
| | 207 | default: break; |
|---|
| | 208 | } |
|---|
| | 209 | ob->writestring(protStr); |
|---|
| | 210 | if (isstatic) { |
|---|
| | 211 | ob->writestring(" static"); |
|---|
| | 212 | } |
|---|
| | 213 | ob->writestring(" : "); |
|---|
| | 214 | |
|---|
| | 215 | if (this->packages) { |
|---|
| | 216 | for (size_t i = 0; i < this->packages->dim; i++) { |
|---|
| | 217 | Identifier *pid = (Identifier *)this->packages->data[i]; |
|---|
| | 218 | ob->printf("%s.", pid->toChars()); |
|---|
| | 219 | } |
|---|
| | 220 | } |
|---|
| | 221 | |
|---|
| | 222 | ob->printf("%s (%s)", |
|---|
| | 223 | this->id->toChars(), |
|---|
| | 224 | mod ? escapePath(mod->srcfile->toChars(), fnameBuf, sizeof(fnameBuf) / sizeof(*fnameBuf)) : "???" |
|---|
| | 225 | ); |
|---|
| | 226 | |
|---|
| | 227 | if (aliasId) { |
|---|
| | 228 | ob->printf(" -> %s", aliasId->toChars()); |
|---|
| | 229 | } else { |
|---|
| | 230 | if (names.dim > 0) { |
|---|
| | 231 | ob->writestring(" : "); |
|---|
| | 232 | for (size_t i = 0; i < names.dim; i++) |
|---|
| | 233 | { |
|---|
| | 234 | if (i > 0) { |
|---|
| | 235 | ob->writebyte(','); |
|---|
| | 236 | } |
|---|
| | 237 | |
|---|
| | 238 | Identifier *name = (Identifier *)names.data[i]; |
|---|
| | 239 | Identifier *alias = (Identifier *)aliases.data[i]; |
|---|
| | 240 | |
|---|
| | 241 | if (!alias) { |
|---|
| | 242 | ob->printf("%s", name->toChars()); |
|---|
| | 243 | alias = name; |
|---|
| | 244 | } else { |
|---|
| | 245 | ob->printf("%s=%s", alias->toChars(), name->toChars()); |
|---|
| | 246 | } |
|---|
| | 247 | } |
|---|
| | 248 | } |
|---|
| | 249 | } |
|---|
| | 250 | |
|---|
| | 251 | ob->writenl(); |
|---|
| | 252 | } |
|---|
| 172 | 253 | } |
|---|
| 173 | 254 | |
|---|
| … | … | |
| 261 | 342 | } |
|---|
| 262 | 343 | } |
|---|
| 263 | | buf->printf("%s;", id->toChars()); |
|---|
| | 344 | buf->printf("%s", id->toChars()); |
|---|
| | 345 | if (names.dim > 0) { |
|---|
| | 346 | buf->writebyte(':'); |
|---|
| | 347 | for (size_t i = 0; i < names.dim; i++) |
|---|
| | 348 | { |
|---|
| | 349 | if (i > 0) { |
|---|
| | 350 | buf->writebyte(','); |
|---|
| | 351 | } |
|---|
| | 352 | |
|---|
| | 353 | Identifier *name = (Identifier *)names.data[i]; |
|---|
| | 354 | Identifier *alias = (Identifier *)aliases.data[i]; |
|---|
| | 355 | |
|---|
| | 356 | if (!alias) { |
|---|
| | 357 | buf->printf("%s", name->toChars()); |
|---|
| | 358 | alias = name; |
|---|
| | 359 | } else { |
|---|
| | 360 | buf->printf("%s=%s", alias->toChars(), name->toChars()); |
|---|
| | 361 | } |
|---|
| | 362 | } |
|---|
| | 363 | } |
|---|
| | 364 | buf->writebyte(';'); |
|---|
| 264 | 365 | buf->writenl(); |
|---|
| 265 | 366 | } |
|---|
| r1372 |
r1402 |
|
| 118 | 118 | |
|---|
| 119 | 119 | struct Array; |
|---|
| | 120 | struct OutBuffer; |
|---|
| 120 | 121 | |
|---|
| 121 | 122 | // LDC |
|---|
| … | … | |
| 205 | 206 | |
|---|
| 206 | 207 | const char *xmlname; // filename for XML output |
|---|
| 207 | | |
|---|
| | 208 | |
|---|
| | 209 | OutBuffer *moduleDeps; // buffer and filename for emitting module deps |
|---|
| | 210 | char *moduleDepsFile; |
|---|
| | 211 | |
|---|
| 208 | 212 | // Hidden debug switches |
|---|
| 209 | 213 | bool debuga; |
|---|
| r1364 |
r1402 |
|
| 201 | 201 | |
|---|
| 202 | 202 | |
|---|
| | 203 | cl::opt<std::string> moduleDepsFile("deps", |
|---|
| | 204 | cl::desc("Write module dependencies to filename"), |
|---|
| | 205 | cl::value_desc("filename")); |
|---|
| | 206 | |
|---|
| | 207 | |
|---|
| 203 | 208 | cl::opt<const llvm::TargetMachineRegistry::entry*, false, |
|---|
| 204 | 209 | llvm::RegistryParser<llvm::TargetMachine> > mArch("march", |
|---|
| r1067 |
r1402 |
|
| 36 | 36 | #endif |
|---|
| 37 | 37 | extern cl::list<std::string> versions; |
|---|
| | 38 | extern cl::opt<std::string> moduleDepsFile; |
|---|
| 38 | 39 | |
|---|
| 39 | 40 | extern cl::opt<const llvm::TargetMachineRegistry::entry*, false, |
|---|
| r1390 |
r1402 |
|
| 144 | 144 | global.params.objfiles = new Array(); |
|---|
| 145 | 145 | global.params.ddocfiles = new Array(); |
|---|
| 146 | | |
|---|
| | 146 | |
|---|
| | 147 | global.params.moduleDeps = NULL; |
|---|
| | 148 | global.params.moduleDepsFile = NULL; |
|---|
| 147 | 149 | |
|---|
| 148 | 150 | // Set predefined version identifiers |
|---|
| … | … | |
| 222 | 224 | global.params.hdrdir || global.params.hdrname; |
|---|
| 223 | 225 | #endif |
|---|
| | 226 | |
|---|
| | 227 | initFromString(global.params.moduleDepsFile, moduleDepsFile); |
|---|
| | 228 | if (global.params.moduleDepsFile != NULL) |
|---|
| | 229 | { |
|---|
| | 230 | global.params.moduleDeps = new OutBuffer; |
|---|
| | 231 | } |
|---|
| 224 | 232 | |
|---|
| 225 | 233 | processVersions(debugArgs, "debug", |
|---|
| … | … | |
| 831 | 839 | fatal(); |
|---|
| 832 | 840 | |
|---|
| | 841 | // write module dependencies to file if requested |
|---|
| | 842 | if (global.params.moduleDepsFile != NULL) |
|---|
| | 843 | { |
|---|
| | 844 | assert (global.params.moduleDepsFile != NULL); |
|---|
| | 845 | |
|---|
| | 846 | File deps(global.params.moduleDepsFile); |
|---|
| | 847 | OutBuffer* ob = global.params.moduleDeps; |
|---|
| | 848 | deps.setbuffer((void*)ob->data, ob->offset); |
|---|
| | 849 | deps.write(); |
|---|
| | 850 | } |
|---|
| | 851 | |
|---|
| 833 | 852 | // collects llvm modules to be linked if singleobj is passed |
|---|
| 834 | 853 | std::vector<llvm::Module*> llvmModules; |
|---|