|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Handling of StaticDependencies.txt |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "appdep.hpp" |
|
20 |
|
21 |
|
22 // ---------------------------------------------------------------------------------------------------------- |
|
23 // Note that in C/C++ code \ has been replaced with \\ and " with \". |
|
24 // ---------------------------------------------------------------------------------------------------------- |
|
25 |
|
26 void GetDataFromStaticDependenciesTxt() |
|
27 { |
|
28 // read cache data from given StaticDependencies.txt |
|
29 if (!FileExists(_cl_usestaticdepstxt)) |
|
30 { |
|
31 cerr << "ERROR: Unable to find " + _cl_usestaticdepstxt << ", check -usestaticdepstxt param" << endl; |
|
32 cerr << "Please note that this parameter is required only if you use StaticDependencies.txt." << endl; |
|
33 exit(EXIT_CANNOT_OPEN_STATIC_DEPENDENCIES_TXT); |
|
34 } |
|
35 |
|
36 ifstream staticdepsf(_cl_usestaticdepstxt.c_str()); |
|
37 string line; |
|
38 |
|
39 getline(staticdepsf, line); |
|
40 if (line != "# Full direct component mapping:") |
|
41 { |
|
42 cerr << "ERROR: " << _cl_usestaticdepstxt << " is not a supported StaticDependencies.txt file!" << endl; |
|
43 staticdepsf.close(); |
|
44 exit(EXIT_OPENED_STATIC_DEPENDENCIES_TXT_NOT_SUPPORTED); |
|
45 } |
|
46 else |
|
47 { |
|
48 cerr << "Warning: Use of StaticDependencies.txt may provide incomplete results..." << endl; |
|
49 |
|
50 bool line_was_consumed = true; |
|
51 |
|
52 // loop through all lines in the file |
|
53 while(!staticdepsf.eof()) |
|
54 { |
|
55 // get a line |
|
56 if (line_was_consumed) |
|
57 getline(staticdepsf, line); |
|
58 |
|
59 if (line == "# Full inverse component mapping:") |
|
60 { |
|
61 // no interesting lines in this file anymore, break the loop |
|
62 break; |
|
63 } |
|
64 |
|
65 // first line is the executable type, eg |
|
66 // armv5::screengrabber (exe) |
|
67 boost::regex re1("^(\\S+)::(\\S+)\\s\\((\\S+)\\).*"); |
|
68 boost::cmatch matches1; |
|
69 if (boost::regex_match(line.c_str(), matches1, re1)) |
|
70 { |
|
71 // match found |
|
72 string ms1(matches1[1].first, matches1[1].second); // binary type |
|
73 string ms2(matches1[2].first, matches1[2].second); // filename |
|
74 string ms3(matches1[3].first, matches1[3].second); // extension |
|
75 |
|
76 line_was_consumed = true; |
|
77 |
|
78 binary_info b_info; |
|
79 b_info.directory = UNKNOWN; |
|
80 b_info.filename = ms2 + "." + ms3; |
|
81 b_info.binary_format = ms1 + " " +ms3; |
|
82 b_info.uid1 = UNKNOWN; |
|
83 b_info.uid2 = UNKNOWN; |
|
84 b_info.uid3 = UNKNOWN; |
|
85 b_info.secureid = UNKNOWN; |
|
86 b_info.vendorid = UNKNOWN; |
|
87 b_info.capabilities = 0; |
|
88 b_info.min_heap_size = 0; |
|
89 b_info.max_heap_size = 0; |
|
90 b_info.stack_size = 0; |
|
91 b_info.mod_time = 0; |
|
92 |
|
93 vector<dependency> deps; |
|
94 for (;;) |
|
95 { |
|
96 // get a line |
|
97 if (line_was_consumed) |
|
98 getline(staticdepsf, line); |
|
99 |
|
100 // check for dependency line, eg |
|
101 // screengrabber -> euser |
|
102 boost::regex re2("^\\s\\s\\s(\\S+)\\s->\\s(\\S+).*"); |
|
103 boost::cmatch matches2; |
|
104 if (boost::regex_match(line.c_str(), matches2, re2)) |
|
105 { |
|
106 // match found |
|
107 string ms1(matches2[1].first, matches2[1].second); // filename |
|
108 string ms2(matches2[2].first, matches2[2].second); // dependency |
|
109 |
|
110 line_was_consumed = true; |
|
111 |
|
112 dependency dep; |
|
113 dep.filename = ms2 + ".dll"; // assumming that the file extension is always .dll |
|
114 |
|
115 vector<import> imps; |
|
116 for (;;) |
|
117 { |
|
118 if (line_was_consumed) |
|
119 getline(staticdepsf, line); |
|
120 |
|
121 // check for function names, eg |
|
122 // fref::screengrabber->euser.CActive::Cancel (1) |
|
123 boost::regex re3("^\\s\\s\\s\\s\\s\\sfref::(\\S+)->(\\S+)\\.(\\S+)\\s\\((\\S+)\\).*"); |
|
124 boost::cmatch matches3; |
|
125 if (boost::regex_match(line.c_str(), matches3, re3)) |
|
126 { |
|
127 // match found |
|
128 string ms1(matches3[1].first, matches3[1].second); // filename |
|
129 string ms2(matches3[2].first, matches3[2].second); // dependency |
|
130 string ms3(matches3[3].first, matches3[3].second); // functionname |
|
131 string ms4(matches3[4].first, matches3[4].second); // ??? |
|
132 |
|
133 line_was_consumed = true; |
|
134 |
|
135 import imp; |
|
136 imp.funcpos = 0; |
|
137 imp.funcname = ms3; |
|
138 imp.is_vtable = false; |
|
139 imp.vtable_offset = 0; |
|
140 |
|
141 // append to the import info vector |
|
142 imps.push_back( imp ); |
|
143 } |
|
144 else |
|
145 { |
|
146 // the line does not match, break the loop |
|
147 line_was_consumed = false; |
|
148 break; |
|
149 } |
|
150 |
|
151 } // for (;;) |
|
152 |
|
153 // now we have import info too |
|
154 dep.imports = imps; |
|
155 |
|
156 // append to the deps info vector |
|
157 deps.push_back( dep ); |
|
158 |
|
159 } |
|
160 else |
|
161 { |
|
162 // the line does not match, break the loop |
|
163 line_was_consumed = false; |
|
164 break; |
|
165 } |
|
166 } // for (;;) |
|
167 |
|
168 // now we have the dep info too |
|
169 b_info.dependencies = deps; |
|
170 |
|
171 // apppend binary info to the vectory |
|
172 _all_binary_infos.push_back( b_info ); |
|
173 |
|
174 } |
|
175 else |
|
176 { |
|
177 // no match found, line was consumed anyway |
|
178 line_was_consumed = true; |
|
179 } // else of if (boost::regex_match(tempVector.at(j).c_str(), matches1, re1)) |
|
180 |
|
181 } // while(!staticdepsf.eof()) |
|
182 } // else of if (line != "# Full direct component mapping:") |
|
183 |
|
184 // close handle to the cache file |
|
185 staticdepsf.close(); |
|
186 } |
|
187 |
|
188 // ---------------------------------------------------------------------------------------------------------- |
|
189 |