// Pass input file through the chain until we bump into a Join node or // a node that says that it is the last. void CompilationGraph::PassThroughGraph (const sys::Path& InFile, const Node* StartNode, const InputLanguagesSet& InLangs, const sys::Path& TempDir) const { bool Last = false; sys::Path In = InFile; const Node* CurNode = StartNode; while(!Last) { sys::Path Out; Tool* CurTool = CurNode->ToolPtr.getPtr(); if (CurTool->IsJoin()) { JoinTool& JT = dynamic_cast<JoinTool&>(*CurTool); JT.AddToJoinList(In); break; } // Since toolchains do not have to end with a Join node, we should // check if this Node is the last. if (!CurNode->HasChildren() || CurTool->IsLast()) { if (!OutputFilename.empty()) { Out.set(OutputFilename); } else { Out.set(In.getBasename()); Out.appendSuffix(CurTool->OutputSuffix()); } Last = true; } else { Out = MakeTempFile(TempDir, In.getBasename(), CurTool->OutputSuffix()); } if (CurTool->GenerateAction(In, Out).Execute() != 0) throw std::runtime_error("Tool returned error code!"); if (Last) return; CurNode = &getNode(ChooseEdge(CurNode->OutEdges, InLangs, CurNode->Name())->ToolName()); In = Out; Out.clear(); } }
// Pass input file through the chain until we bump into a Join node or // a node that says that it is the last. int CompilationGraph::PassThroughGraph (const sys::Path& InFile, const Node* StartNode, const InputLanguagesSet& InLangs, const sys::Path& TempDir, const LanguageMap& LangMap) const { sys::Path In = InFile; const Node* CurNode = StartNode; while(true) { Tool* CurTool = CurNode->ToolPtr.getPtr(); if (CurTool->IsJoin()) { JoinTool& JT = static_cast<JoinTool&>(*CurTool); JT.AddToJoinList(In); break; } Action CurAction; if (int ret = CurTool->GenerateAction(CurAction, In, CurNode->HasChildren(), TempDir, InLangs, LangMap)) { return ret; } if (int ret = CurAction.Execute()) return ret; if (CurAction.StopCompilation()) return 0; const Edge* Edg = ChooseEdge(CurNode->OutEdges, InLangs, CurNode->Name()); if (Edg == 0) return 1; CurNode = getNode(Edg->ToolName()); if (CurNode == 0) return 1; In = CurAction.OutFile(); } return 0; }