Changeset 1219
- Timestamp:
- 07/05/09 10:57:37 (3 years ago)
- Files:
-
- trunk/tools/rdmd.d (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/tools/rdmd.d
r1126 r1219 34 34 // add a trailing path separator to clarify it's a dir 35 35 exe = std.path.join(value[1 .. $], ""); 36 assert(std. string.endsWith(exe, std.path.sep));36 assert(std.algorithm.endsWith(exe, std.path.sep[])); 37 37 } 38 38 else if (value[0] == '-') … … 90 90 ~ ";\n} }"); 91 91 } 92 else 93 { 94 return .eval(importWorld ~ "void main(char[][] args) {\n" 95 ~ join(eval, "\n") ~ ";\n}"); 96 } 92 return .eval(importWorld ~ "void main(char[][] args) {\n" 93 ~ join(eval, "\n") ~ ";\n}"); 97 94 } 98 95 … … 111 108 root = /*rel2abs*/(chomp(args[programPos], ".d") ~ ".d"), 112 109 exeBasename = basename(root, ".d"), 110 exeDirname = dirname(root), 113 111 programArgs = args[programPos + 1 .. $]; 114 112 args = args[0 .. programPos]; 115 113 const compilerFlags = args[1 .. programPos]; 114 115 // Change to the main module's directory; all searches will be 116 // relative to that directory 117 // auto initialDir = getcwd; 118 // chdir(exeDirname); 119 // scope(exit) chdir(initialDir); 116 120 117 121 // Compute the object directory and ensure it exists … … 132 136 { 133 137 // user-specified exe name 134 if (std. string.endsWith(exe, std.path.sep))138 if (std.algorithm.endsWith(exe, std.path.sep[])) 135 139 { 136 140 // user specified a directory, complete it to a file … … 277 281 return std.path.join(objDir, chomp(basename(dfile), ".d")~".o"); 278 282 } 283 284 immutable depsFilename = rootModule~".deps"; 285 immutable rootDir = dirname(rootModule); 279 286 280 287 // myModules maps module source paths to corresponding .o names 281 288 string[string] myModules;// = [ rootModule : d2obj(rootModule) ]; 282 289 // Must collect dependencies 283 invariant depsGetter = compiler~" "~join(compilerFlags, " ") 284 ~" -v -o- "~shellQuote(rootModule); 290 invariant depsGetter = "chdir "~shellQuote(rootDir)~" && " 291 ~compiler~" "~join(compilerFlags, " ") 292 ~" -v -o- "~shellQuote(rootModule) 293 ~" >"~depsFilename; 285 294 if (chatty) writeln(depsGetter); 286 File depsReader; 287 depsReader.popen(depsGetter); 295 immutable depsExitCode = system(depsGetter); 296 if (depsExitCode) exit(depsExitCode); 297 auto depsReader = File(depsFilename); 288 298 scope(exit) collectException(depsReader.close); // we don't care for errors 289 299 … … 296 306 if (inALibrary(moduleName, moduleSrc)) continue; 297 307 invariant moduleObj = d2obj(moduleSrc); 298 myModules[/*rel2abs*/ (moduleSrc)] = moduleObj;308 myModules[/*rel2abs*/join(rootDir, moduleSrc)] = moduleObj; 299 309 } 300 310
