Changeset 393
- Timestamp:
- 02/23/07 19:16:00 (2 years ago)
- Files:
-
- trunk/rebuild/compile.c (modified) (4 diffs)
- trunk/rebuild/compile.h (modified) (1 diff)
- trunk/rebuild/config.c (modified) (1 diff)
- trunk/rebuild/link.c (modified) (7 diffs)
- trunk/rebuild/rebuild.conf/dmd-win (modified) (2 diffs)
- trunk/rebuild/rebuild.conf/dmd-win-tango (modified) (3 diffs)
- trunk/rebuild/rebuild.exe (modified) (previous)
- trunk/rebuild/response.c (modified) (1 diff)
- trunk/rebuild/response.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/rebuild/compile.c
r277 r393 18 18 #include "mars.h" 19 19 #include "module.h" 20 #include "response.h" 20 21 21 string compileCommand(const string &i )22 string compileCommand(const string &i, string &response, bool &useresponse) 22 23 { 23 24 int varLoc; … … 29 30 global.errors++; 30 31 return ""; 32 } 33 34 // check if we need to use a response file 35 useresponse = false; 36 if (masterConfig["compile"].find("response") != masterConfig["compile"].end()) { 37 useresponse = true; 38 response = masterConfig["compile"]["response"]; 31 39 } 32 40 … … 49 57 void runCompile(const std::string &files) 50 58 { 51 string cline = compileCommand(files); 59 string response; 60 bool useresponse; 61 string cline = compileCommand(files, response, useresponse); 52 62 53 63 if (global.params.verbose) … … 55 65 56 66 // run it 57 if (cline == "" || 58 system(cline.c_str())) 67 int res = 0; 68 if (cline == "") { 69 res = 1; 70 } else { 71 if (useresponse) 72 res = systemResponse(cline.c_str(), response.c_str(), "rsp"); 73 else 74 res = system(cline.c_str()); 75 } 76 if (res) { 59 77 global.errors++; 78 } 60 79 } trunk/rebuild/compile.h
r277 r393 12 12 #include <string> 13 13 14 std::string compileCommand(const std::string &i );14 std::string compileCommand(const std::string &i, std::string &response, bool &useresponse); 15 15 16 16 void runCompile(const std::string &files); trunk/rebuild/config.c
r332 r393 114 114 115 115 // get the compile line 116 string cline = compileCommand("rebuild_tmp.d"); 116 string response; 117 bool useresponse; 118 string cline = compileCommand("rebuild_tmp.d", response, useresponse); 117 119 118 120 // test it trunk/rebuild/link.c
r366 r393 40 40 #include "mars.h" 41 41 #include "mem.h" 42 #include "response.h" 42 43 #include "root.h" 43 44 … … 51 52 */ 52 53 53 string linkCommand(const string &i, const string &o, char post = 0)54 string linkCommand(const string &i, const string &o, string &response, bool &useresponse, char post) 54 55 { 55 56 int varLoc; … … 77 78 } 78 79 80 // check if we need to use a response file 81 useresponse = false; 82 if (masterConfig.find(linkset) != masterConfig.end() && 83 masterConfig[linkset].find("response") != masterConfig[linkset].end()) { 84 useresponse = true; 85 response = masterConfig[linkset]["response"]; 86 } 87 79 88 // config: compile=[g]dmd -c $i -o $o 80 89 string cline = masterConfig[linkset]["cmd"]; 81 90 82 91 // there are some flags that should be added only on non-darwin 83 92 if (!findCondition(global.params.versionids, new Identifier("darwin", 0))) { … … 123 132 { 124 133 // get the list of input files, as well as the age if they're necessary 125 string inp, out; 134 string inp, out, response; 135 bool useresponse; 126 136 time_t mtime = 0; 127 137 struct stat sbuf, osbuf; … … 177 187 osbuf.st_mtime <= mtime) { 178 188 string cline = linkCommand( 179 inp, out );189 inp, out, response, useresponse, 0); 180 190 181 191 if (global.params.verbose) … … 183 193 184 194 // run it 185 if (cline == "" || 186 system(cline.c_str())) { 195 int res = 0; 196 if (cline == "") { 197 res = 1; 198 } else { 199 if (useresponse) 200 res = systemResponse(cline.c_str(), response.c_str(), "rsp"); 201 else 202 res = system(cline.c_str()); 203 } 204 if (res) { 187 205 global.errors++; 188 206 return -1; … … 191 209 if (global.params.lib) { 192 210 // do postlib link 193 cline = linkCommand(out, "", 1);211 cline = linkCommand(out, "", response, useresponse, 1); 194 212 if (global.params.verbose) 195 213 printf("postlink %s\n", cline.c_str()); 196 if (cline == "" || 197 system(cline.c_str())) { 214 215 res = 0; 216 if (cline == "") { 217 res = 1; 218 } else { 219 if (useresponse) 220 res = systemResponse(cline.c_str(), response.c_str(), "rsp"); 221 else 222 res = system(cline.c_str()); 223 } 224 if (res) { 198 225 global.errors++; 199 226 return -1; trunk/rebuild/rebuild.conf/dmd-win
r391 r393 30 30 [compile] 31 31 cmd=dmd -c $i 32 response=@ 32 33 33 34 flag=$i … … 49 50 safe=yes 50 51 cmd=lib -c -p256 $o $i 52 response=@ 51 53 52 54 libdir= trunk/rebuild/rebuild.conf/dmd-win-tango
r391 r393 31 31 [compile] 32 32 cmd=dmd -version=Tango -c $i 33 response=@ 33 34 34 35 flag=$i … … 41 42 [link] 42 43 cmd=dmd $i -of$o 44 response=@ 43 45 44 46 libdir=-L+$i\ … … 50 52 safe=yes 51 53 cmd=lib -c -p256 $o $i 54 response=@ 52 55 53 56 libdir= trunk/rebuild/response.c
r332 r393 87 87 *argv = nargv; 88 88 } 89 90 int systemResponse(const char *cmd, const char *rflag, const char *rfile) 91 { 92 char *newcmd = mem.strdup(cmd); 93 int res; 94 95 // open the output file 96 FILE *of = fopen(rfile, "w"); 97 if (!of) { 98 perror(rfile); 99 exit(1); 100 } 101 102 // break up the command 103 int i, slen; 104 slen = strlen(newcmd); 105 char *cur = newcmd; 106 for (i = 0; i <= slen; i++) { 107 if (newcmd[i] == ' ' || 108 newcmd[i] == '\0' || 109 newcmd[i] == '\n' || 110 newcmd[i] == '\r') { 111 newcmd[i] = '\0'; 112 113 // add the previous one 114 if (cur != newcmd && 115 *cur != '\0') { 116 fprintf(of, "%s\n", cur); 117 } 118 cur = newcmd + i + 1; 119 } 120 } 121 fclose(of); 122 123 // form the response file line 124 char *newcmdr = (char *) mem.malloc(strlen(newcmd) + strlen(rflag) + strlen(rfile) + 2); 125 sprintf(newcmdr, "%s %s%s", newcmd, rflag, rfile); 126 res = system(newcmdr); 127 remove(rfile); 128 129 mem.free(newcmdr); 130 mem.free(newcmd); 131 132 return res; 133 } trunk/rebuild/response.h
r332 r393 1 1 2 // Component to parse response files2 // Component to parse and generate response files 3 3 // Copyright (c) 2007 Gregor Richards 4 4 // License for redistribution is by either the Artistic License … … 14 14 void parseResponseFile(int *argc, char ***argv, char *rf, int argnum); 15 15 16 int systemResponse(const char *cmd, const char *rflag, const char *rfile); 17 16 18 #endif
