author | Michael Krelin <hacker@klever.net> | 2005-04-03 13:07:33 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2005-04-03 13:07:33 (UTC) |
commit | 197174ead5e273bd0c8684d92752e1e8599d6656 (patch) (unidiff) | |
tree | 7f464c0fd17593e723b13766307c54ceb0ee326f /lib | |
parent | f2ddc6833252f106cf9aa589bc13216ba25ee4e6 (diff) | |
download | sitecing-197174ead5e273bd0c8684d92752e1e8599d6656.zip sitecing-197174ead5e273bd0c8684d92752e1e8599d6656.tar.gz sitecing-197174ead5e273bd0c8684d92752e1e8599d6656.tar.bz2 |
yet another fix to handling dependencies
-rw-r--r-- | lib/component_factory.cc | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/component_factory.cc b/lib/component_factory.cc index 5c18bb7..b5e95af 100644 --- a/lib/component_factory.cc +++ b/lib/component_factory.cc | |||
@@ -110,28 +110,28 @@ namespace sitecing { | |||
110 | } | 110 | } |
111 | }catch(utility_no_suffix& uns) { } | 111 | }catch(utility_no_suffix& uns) { } |
112 | } | 112 | } |
113 | }catch(utility_no_prefix& unp) { } | 113 | }catch(utility_no_prefix& unp) { } |
114 | } | 114 | } |
115 | 115 | ||
116 | bool component_factory::is_uptodate(const string& dst,file_list_t *deps) { | 116 | bool component_factory::is_uptodate(const string& dst,file_list_t *deps) { |
117 | string dp = normalize_path(dst,strip_trailing_slash); | 117 | string dp = normalize_path(dst,strip_trailing_slash); |
118 | // XXX: or just compare it off, instead of throwing things around. | ||
119 | try { | 118 | try { |
120 | string noro = strip_prefix(dp,root_intermediate); | 119 | string noro = strip_prefix(dp,root_intermediate); |
121 | for(int ppt=0;(ppt+1)<sizeof(pp_targets)/sizeof(*pp_targets);ppt++) { | 120 | for(int ppt=0;(ppt+1)<sizeof(pp_targets)/sizeof(*pp_targets);ppt++) { |
122 | try { | 121 | try { |
123 | string nos = strip_suffix(noro,pp_targets[ppt]); | 122 | string nos = strip_suffix(noro,pp_targets[ppt]); |
124 | return file_factory::is_uptodate(root_intermediate+nos+".pp_stamp",deps); | 123 | return file_factory::is_uptodate(root_intermediate+nos+".pp_stamp",deps); |
125 | }catch(utility_no_suffix& uns) { } | 124 | }catch(utility_no_suffix& uns) { } |
126 | } | 125 | } |
127 | bool rv = file_factory::is_uptodate(dst,deps); | 126 | bool rv = file_factory::is_uptodate(dst,deps); |
128 | return rv; | 127 | return rv; |
129 | }catch(utility_no_prefix& unp) { } | 128 | }catch(utility_no_prefix& unp) { } |
129 | // XXX: or just compare it off, instead of throwing things around. | ||
130 | try { | 130 | try { |
131 | strip_prefix(dp,root_so); | 131 | strip_prefix(dp,root_so); |
132 | return file_factory::is_uptodate(dst,deps); | 132 | return file_factory::is_uptodate(dst,deps); |
133 | }catch(utility_no_prefix& unp) { } | 133 | }catch(utility_no_prefix& unp) { } |
134 | return true; | 134 | return true; |
135 | } | 135 | } |
136 | 136 | ||
137 | void component_factory::build(const string& dst) { | 137 | void component_factory::build(const string& dst) { |
@@ -142,16 +142,17 @@ namespace sitecing { | |||
142 | // building the sources is left up to developer | 142 | // building the sources is left up to developer |
143 | return; | 143 | return; |
144 | }catch(utility_no_prefix& unp) { } | 144 | }catch(utility_no_prefix& unp) { } |
145 | // .so files | 145 | // .so files |
146 | try { | 146 | try { |
147 | string noso = strip_suffix(dp,".so"); | 147 | string noso = strip_suffix(dp,".so"); |
148 | string noro = strip_prefix(noso,root_so); | 148 | string noro = strip_prefix(noso,root_so); |
149 | string o = root_intermediate+noro+".o"; | 149 | string o = root_intermediate+noro+".o"; |
150 | cerr << "Linking " << noro << endl; | ||
150 | if(access(o.c_str(),R_OK)) | 151 | if(access(o.c_str(),R_OK)) |
151 | throw konforka::exception(CODEPOINT,string("can't access compiled component code (")+o+")"); | 152 | throw konforka::exception(CODEPOINT,string("can't access compiled component code (")+o+")"); |
152 | make_path(dir_name(root_so+noro),0755); | 153 | make_path(dir_name(root_so+noro),0755); |
153 | file_lock lock_cc(root_intermediate+noro+".o.lock"); | 154 | file_lock lock_cc(root_intermediate+noro+".o.lock"); |
154 | file_lock lock_so(root_so+noro+".so.lock"); | 155 | file_lock lock_so(root_so+noro+".so.lock"); |
155 | int stdO = open((root_intermediate+noro+".ld.stdout").c_str(),O_CREAT|O_TRUNC|O_WRONLY,0664); | 156 | int stdO = open((root_intermediate+noro+".ld.stdout").c_str(),O_CREAT|O_TRUNC|O_WRONLY,0664); |
156 | if(stdO<0) | 157 | if(stdO<0) |
157 | throw konforka::exception(CODEPOINT,"failed to open/create linker stdout"); | 158 | throw konforka::exception(CODEPOINT,"failed to open/create linker stdout"); |
@@ -186,16 +187,17 @@ namespace sitecing { | |||
186 | try { | 187 | try { |
187 | string noro = strip_prefix(dp,root_intermediate); | 188 | string noro = strip_prefix(dp,root_intermediate); |
188 | // compiler targets | 189 | // compiler targets |
189 | for(int cct=0;cct<sizeof(cc_targets)/sizeof(*cc_targets);cct++) { | 190 | for(int cct=0;cct<sizeof(cc_targets)/sizeof(*cc_targets);cct++) { |
190 | try { | 191 | try { |
191 | string nos = strip_suffix(noro,cc_targets[cct]); | 192 | string nos = strip_suffix(noro,cc_targets[cct]); |
192 | string cc = root_intermediate+nos+".cc"; | 193 | string cc = root_intermediate+nos+".cc"; |
193 | string o = root_intermediate+nos+".o"; | 194 | string o = root_intermediate+nos+".o"; |
195 | cerr << "Compiling " << nos << endl; | ||
194 | if(access(cc.c_str(),R_OK)) | 196 | if(access(cc.c_str(),R_OK)) |
195 | throw konforka::exception(CODEPOINT,string("can't access preprocessed component code (")+cc+")"); | 197 | throw konforka::exception(CODEPOINT,string("can't access preprocessed component code (")+cc+")"); |
196 | make_path(dir_name(cc),0755); | 198 | make_path(dir_name(cc),0755); |
197 | string pwd = dir_name(root_source+nos); | 199 | string pwd = dir_name(root_source+nos); |
198 | auto_chdir dir_changer(pwd); | 200 | auto_chdir dir_changer(pwd); |
199 | file_lock lock_source(root_intermediate+nos+".lock"); | 201 | file_lock lock_source(root_intermediate+nos+".lock"); |
200 | file_lock lock_cc(root_intermediate+nos+".o.lock"); | 202 | file_lock lock_cc(root_intermediate+nos+".o.lock"); |
201 | int stdO = open((root_intermediate+nos+".stdout").c_str(),O_CREAT|O_TRUNC|O_WRONLY,0664); | 203 | int stdO = open((root_intermediate+nos+".stdout").c_str(),O_CREAT|O_TRUNC|O_WRONLY,0664); |
@@ -225,16 +227,17 @@ namespace sitecing { | |||
225 | return; | 227 | return; |
226 | }catch(utility_no_suffix& uns) { } | 228 | }catch(utility_no_suffix& uns) { } |
227 | } | 229 | } |
228 | // preprocessor targets | 230 | // preprocessor targets |
229 | for(int ppt=0;ppt<sizeof(pp_targets)/sizeof(*pp_targets);ppt++) { | 231 | for(int ppt=0;ppt<sizeof(pp_targets)/sizeof(*pp_targets);ppt++) { |
230 | try { | 232 | try { |
231 | string nos = strip_suffix(noro,pp_targets[ppt]); | 233 | string nos = strip_suffix(noro,pp_targets[ppt]); |
232 | string src = root_source+nos; | 234 | string src = root_source+nos; |
235 | cerr << "Preprocessing " << nos << endl; | ||
233 | if(access(src.c_str(),R_OK)) | 236 | if(access(src.c_str(),R_OK)) |
234 | throw konforka::exception(CODEPOINT,string("can't access component source (")+src+")"); | 237 | throw konforka::exception(CODEPOINT,string("can't access component source (")+src+")"); |
235 | make_path(dir_name(root_intermediate+nos),0755); | 238 | make_path(dir_name(root_intermediate+nos),0755); |
236 | file_lock lock(root_intermediate+nos+".lock"); | 239 | file_lock lock(root_intermediate+nos+".lock"); |
237 | sitecing_parser parser(*this); | 240 | sitecing_parser parser(*this); |
238 | config_options *co_skeleton = config.lookup_config(nos,config_options::flag_skeleton); | 241 | config_options *co_skeleton = config.lookup_config(nos,config_options::flag_skeleton); |
239 | if(co_skeleton) | 242 | if(co_skeleton) |
240 | parser.skeleton = co_skeleton->skeleton; | 243 | parser.skeleton = co_skeleton->skeleton; |
@@ -259,27 +262,41 @@ namespace sitecing { | |||
259 | } | 262 | } |
260 | return; | 263 | return; |
261 | }catch(utility_no_suffix& uns) { } | 264 | }catch(utility_no_suffix& uns) { } |
262 | } | 265 | } |
263 | }catch(utility_no_prefix& unp) { } | 266 | }catch(utility_no_prefix& unp) { } |
264 | cerr << "ignoring build request for " << dp << endl; | 267 | cerr << "ignoring build request for " << dp << endl; |
265 | } | 268 | } |
266 | 269 | ||
270 | void component_factory::make(const string& dst) { | ||
271 | string dp = normalize_path(dst,strip_trailing_slash); | ||
272 | try { | ||
273 | string noso = strip_suffix(dp,".so"); | ||
274 | string noro = strip_prefix(noso,root_so); | ||
275 | file_list_t a; | ||
276 | get_ancestors(noro,a); | ||
277 | for(file_list_t::const_iterator i=a.begin();i!=a.end();++i) { | ||
278 | make(root_so+*i+".so"); | ||
279 | } | ||
280 | }catch(utility_no_affix& una) { } | ||
281 | file_factory::make(dst); | ||
282 | } | ||
283 | |||
267 | int component_factory::execute(const string& cmd, const list<string>& args,int stdo,int stde) { | 284 | int component_factory::execute(const string& cmd, const list<string>& args,int stdo,int stde) { |
268 | // XXX: is it right that we do stdio/stderr tricks outside of the function? | 285 | // XXX: is it right that we do stdio/stderr tricks outside of the function? |
269 | cerr << "executing: " << cmd; | 286 | // cerr << "executing: " << cmd; |
270 | vector<const char*> argv(args.size()+2); | 287 | vector<const char*> argv(args.size()+2); |
271 | argv[0]=cmd.c_str(); | 288 | argv[0]=cmd.c_str(); |
272 | int an = 1; | 289 | int an = 1; |
273 | for(list<string>::const_iterator i=args.begin();i!=args.end();i++) { | 290 | for(list<string>::const_iterator i=args.begin();i!=args.end();i++) { |
274 | cerr << " " << *i ; | 291 | // cerr << " " << *i ; |
275 | argv[an++] = i->c_str(); | 292 | argv[an++] = i->c_str(); |
276 | } | 293 | } |
277 | cerr << endl; | 294 | // cerr << endl; |
278 | argv[an++]=NULL; | 295 | argv[an++]=NULL; |
279 | pid_t pid = vfork(); | 296 | pid_t pid = vfork(); |
280 | if(pid==-1) { | 297 | if(pid==-1) { |
281 | close(stdo); close(stde); | 298 | close(stdo); close(stde); |
282 | throw konforka::exception(CODEPOINT,"failed to vfork()"); | 299 | throw konforka::exception(CODEPOINT,"failed to vfork()"); |
283 | } | 300 | } |
284 | if(!pid) { | 301 | if(!pid) { |
285 | // child | 302 | // child |