1
2
3
4
5
6 #include <cpp2cm/cpp2cm/System.hpp>
7 #include <cpp2cm/cpp2cm/Project.hpp>
8 #include <sngxml/dom/Document.hpp>
9 #include <sngxml/dom/Element.hpp>
10 #include <sngxml/dom/Parser.hpp>
11 #include <sngxml/xpath/XPathEvaluate.hpp>
12 #include <soulng/util/Path.hpp>
13 #include <soulng/util/Unicode.hpp>
14
15 namespace cpp2cm {
16
17 using namespace soulng::util;
18 using namespace soulng::unicode;
19
20 void ProcessSystemXml(const std::string& systemXmlFilePath, bool verbose)
21 {
22 std::string systemRootDir = Path::GetDirectoryName(systemXmlFilePath);
23 std::unique_ptr<sngxml::dom::Document> systemXmlDoc = sngxml::dom::ReadDocument(systemXmlFilePath);
24 std::unique_ptr<sngxml::xpath::XPathObject> result = sngxml::xpath::Evaluate(U"/cpp2cm/projects/project", systemXmlDoc.get());
25 if (result)
26 {
27 if (result->Type() == sngxml::xpath::XPathObjectType::nodeSet)
28 {
29 sngxml::xpath::XPathNodeSet* nodeSet = static_cast<sngxml::xpath::XPathNodeSet*>(result.get());
30 int n = nodeSet->Length();
31 for (int i = 0; i < n; ++i)
32 {
33 sngxml::dom::Node* node = (*nodeSet)[i];
34 if (node->GetNodeType() == sngxml::dom::NodeType::elementNode)
35 {
36 sngxml::dom::Element* element = static_cast<sngxml::dom::Element*>(node);
37 std::u32string fileAttr = element->GetAttribute(U"file");
38 if (!fileAttr.empty())
39 {
40 std::string projectXmlFilePath = GetFullPath(Path::Combine(systemRootDir, ToUtf8(fileAttr)));
41 Project project(systemXmlFilePath, projectXmlFilePath, false);
42 project.SetSystem();
43 project.Process(verbose, ProcessType::stage);
44 }
45 }
46 }
47 }
48 }
49 }
50
51 }