/* * Manual page at function.def */ INT16 CGEN_PROTECTED CFunction::OnList() { FNC_DELEGATE OnList(); // Delegate to running function if (CDlpObject_OfKind("function",m_iAi)) // Is active instance a function return ((CFunction*)m_iAi)->List(GetNextToken(TRUE)); // Do listing for active function return List(GetNextToken(TRUE)); // Do the listing }
bool Maker::CreateDependencyTree() { if (goals.size() == 0) { Variable *dg = VariableContainer::Instance()->Lookup(".DEFAULT_GOAL"); std::string value; if (dg && dg->GetValue().size() != 0) { value = dg->GetValue(); if (dg->GetFlavor() == Variable::f_recursive) { Eval r(value, false); value = r.Evaluate(); } } else { value = firstGoal; } if (value.size() == 0) return true; // nothing to do AddGoal(value); } EnterSuffixTerminals(); std::string intermediate; Variable *v = VariableContainer::Instance()->Lookup(".INTERMEDIATE"); if (v) { intermediate = v->GetValue(); } for (std::deque<std::string>::iterator it = goals.begin(); it != goals.end(); ++it) { Time tv1, tv2; Depends *t = Dependencies(*it, "", tv1); if (t || OnList(*it,".PHONY")) { depends.push_back(t); } else if (t) delete t; } v = VariableContainer::Instance()->Lookup(".INTERMEDIATE"); if (v) { v->SetValue(intermediate); } return !missingTarget; }
int Maker::RunOne(Depends *depend, Environment &env, bool keepGoing) { int rv = 0; if (depend->GetRuleList()->IsBuilt()) return 0; RuleList *rl = depend->GetRuleList(); Eval::PushruleStack(rl); bool stop = false; bool cantbuild = false; for (Depends::iterator it = depend->begin(); it != depend->end(); ++it) { // if (!(*it)->GetOrdered()) { if (rv = RunOne(*it, env, keepGoing)) { stop = true; if (!keepGoing) { Eval::PopruleStack(); return rv; } } } // else // cantbuild |= !(*it)->GetRuleList()->IsBuilt(); } if (stop) { Eval::PopruleStack(); return -1; } if (cantbuild || rl->IsBuilt()) { Eval::PopruleStack(); return 0; } rl->SetBuilt(); if (touch) { rl->Touch(OS::GetCurrentTime()); } bool sil = silent; bool ig = ignoreResults; if (!sil) sil = OnList(depend->GetGoal(), ".SILENT"); if (!ig) ig = OnList(depend->GetGoal(), ".IGNORE"); Spawner sp(env, ig, sil, displayOnly); if (depend->GetRule() && depend->GetRule()->GetCommands()) rv = sp.Run(*depend->GetRule()->GetCommands(), rl, NULL); if (rv) { std::strstream a; a << rv; std::string b; a >> b; if (RuleContainer::Instance()->Lookup(".DELETE_ON_ERROR")) { OS::RemoveFile(depend->GetGoal()); std::cout << std::endl; Eval::error("commands returned error code " + b + " '" + depend->GetGoal() + "' removed"); } else { std::cout << std::endl; Eval::error("commands returned error code " + b); } } Eval::PopruleStack(); return rv; }
Maker::Depends *Maker::Dependencies(const std::string &goal, const std::string &preferredPath, Time &timeval) { Time goalTime; Time dependsTime; Depends *rv = Depends::Lookup(goal); bool intermediate = OnList(goal, ".INTERMEDIATE"); bool secondary = OnList(goal, ".SECONDARY"); bool precious = OnList(goal, ".PRECIOUS"); if (!rv) { Time xx; RuleList *ruleList = RuleContainer::Instance()->Lookup(goal); bool remake = false; if (ruleList) { RuleList::iterator it; for (it = ruleList->begin(); it != ruleList->end(); ++it) { if ((*it)->HasCommands()) break; } if (it == ruleList->end()) { Time xx; SearchImplicitRules(goal, preferredPath, true, false, xx); } std::string foundPath = GetFileTime(goal ,preferredPath, goalTime); bool exists = ! !goalTime; rv = new Depends(goal, xx, intermediate && !precious && !secondary); Rule *executionRule = NULL; std::string newerPrereqs; for (RuleList::iterator it = ruleList->begin(); it != ruleList->end(); ++it) { std::string working = (*it)->GetPrerequisites(); bool remakeThis = false; while (working.size()) { Time current; std::string thisOne = Eval::ExtractFirst(working, " "); Depends *dp = Dependencies(thisOne, foundPath, current); if (current > dependsTime) { dependsTime = current; } if (dp) { *rv += (dp); } if (current > goalTime || rebuildAll) { if (newerPrereqs.size()) newerPrereqs += " "; newerPrereqs += thisOne; remakeThis = true; } } working = (*it)->GetOrderPrerequisites(); while (working.size()) { Time current; std::string thisOne = Eval::ExtractFirst(working, " "); Depends *dp = Dependencies(thisOne, preferredPath, current); if (dp) { dp->SetOrdered(true); (*rv) += dp; } } if ((*it)->HasCommands()) if (ruleList->GetDoubleColon() && remakeThis || !ruleList->GetDoubleColon()) if (executionRule) Eval::warning("Conflicting command lists for goal '" + goal + "'"); else executionRule = *it; } if (executionRule) { rv->SetRuleList(ruleList); rv->SetRule(executionRule); ruleList->SetNewerPrerequisites(newerPrereqs); } else { rv->SetRuleList(ruleList); } } else { if (SearchImplicitRules(goal, preferredPath, true, true, timeval)) rv = Dependencies(goal, preferredPath, timeval); } } if (rv && !rebuildAll) { if (goalTime > dependsTime) { if (!rv->size()) { delete rv; rv = NULL; } else { bool check = true; for (Depends::iterator it = rv->begin(); check && it != rv->end(); ++it) { check &= (*it)->IsSecondary(); } if (check) { delete rv; rv = NULL; } } } } if (rv) { rv->SetSecondary(secondary || intermediate); } if (dependsTime > goalTime) { if (dependsTime > timeval) timeval = dependsTime; } else { if (goalTime > timeval) timeval = goalTime; } return rv; }