summaryrefslogtreecommitdiffabout
path: root/lib/component_factory.cc
Side-by-side diff
Diffstat (limited to 'lib/component_factory.cc') (more/less context) (show whitespace changes)
-rw-r--r--lib/component_factory.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/component_factory.cc b/lib/component_factory.cc
index b8f5a16..1253111 100644
--- a/lib/component_factory.cc
+++ b/lib/component_factory.cc
@@ -226,107 +226,107 @@ namespace sitecing {
return;
}catch(utility_no_affix& una) {
// do nothing, not a compiler target
}
}
// preprocessor targets
for(int ppt=0;ppt<sizeof(pp_targets)/sizeof(*pp_targets);ppt++) {
try {
string nos = strip_suffix(dp,pp_targets[ppt]);
string noro = strip_prefix(nos,root_intermediate);
string src = root_source+noro;
if(access(src.c_str(),R_OK))
throw konforka::exception(CODEPOINT,string("can't access component source (")+src+")");
make_path(dir_name(root_intermediate+noro),0755);
file_lock lock(root_intermediate+noro+".lock");
sitecing_parser parser(*this);
config_options *co_skeleton = config.lookup_config(noro,config_options::flag_skeleton);
if(co_skeleton)
parser.skeleton = co_skeleton->skeleton;
static const char *id_chars = "abcdefghijklmnopqrstuvwxyz0123456789_ABCDEFGHIJKLMNOPQRSTUVWXYZ";
parser.class_name = normalize_path(noro,strip_leading_slash|strip_trailing_slash);
for(string::size_type illc = parser.class_name.find_first_not_of(id_chars);illc!=string::npos;illc=parser.class_name.find_first_not_of(id_chars,illc)) {
string::size_type lc = parser.class_name.find_first_of(id_chars,illc);
int n = ((lc==string::npos)?parser.class_name.length():lc)-illc;
parser.class_name.replace(illc,n,n,'_');
}
parser.class_name = "_SCC_"+parser.class_name;
parser.output_basename = nos;
parser.component_basename = noro;
try {
parser.preprocess(src);
string sf = root_intermediate+noro+".pp_stamp";
ofstream sfs(sf.c_str(),ios::trunc|ios::out); // touch .pp_stamp
}catch(preprocessor_error& pe) {
pe.component_name = noro;
pe.see(CODEPOINT);
throw;
}
return;
}catch(utility_no_affix& una) {
// must be a crap from .d file
}
}
cerr << "ignoring build request for " << dp << endl;
}
int component_factory::execute(const string& cmd, const list<string>& args,int stdo,int stde) {
// XXX: is it right that we do stdio/stderr tricks outside of the function?
cerr << "executing: " << cmd;
vector<const char*> argv(args.size()+2);
argv[0]=cmd.c_str();
int an = 1;
for(list<string>::const_iterator i=args.begin();i!=args.end();i++) {
cerr << " " << *i ;
argv[an++] = i->c_str();
}
cerr << endl;
argv[an++]=NULL;
pid_t pid = vfork();
if(pid==-1) {
close(stdo); close(stde);
throw konforka::exception(CODEPOINT,"failed to vfork()");
}
if(!pid) {
// child
if(dup2(stdo,1)!=1)
_exit(-1);
if(dup2(stde,2)!=2)
_exit(-1);
close(0);
execvp(cmd.c_str(),(char**)&argv.front());
_exit(-1);
}
// parent
close(stdo); close(stde);
int rv;
if(waitpid(pid,&rv,0)<0)
throw konforka::exception(CODEPOINT,"failed to waitpid()");
return rv;
}
string component_factory::get_classname(const string& component) {
string cn = root_intermediate+normalize_path(component,strip_trailing_slash|strip_leading_slash)+".classname";
make(cn);
ifstream ifs(cn.c_str());
if(!ifs.good())
throw konforka::exception(CODEPOINT,"failed to access component .classname");
ifs >> cn;
return cn;
}
void component_factory::get_ancestors(const string& component,file_list_t& rv) {
string cn = root_intermediate+normalize_path(component,strip_trailing_slash|strip_leading_slash)+".ancestors";
make(cn);
ifstream ifs(cn.c_str());
if(!ifs.good())
- throw konforka::exception(CODEPOINT,"filed to access component .ancestors");
+ throw konforka::exception(CODEPOINT,string("failed to access component '")+component+"' .ancestors");
rv.clear();
while(!ifs.eof()) {
string a;
ifs >> a;
if(!a.empty())
rv.push_back(a);
}
}
}