0
|
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: Main entry of Appdep
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "appdep.hpp"
|
|
20 |
|
|
21 |
// init globals
|
|
22 |
bool _cl_use_gcc = false;
|
|
23 |
bool _cl_use_gcce = false;
|
|
24 |
bool _cl_use_rvct = false;
|
|
25 |
bool _cl_generate_clean_cache = false;
|
|
26 |
bool _cl_update_cache = false;
|
|
27 |
bool _cl_use_libs = false;
|
|
28 |
bool _cl_show_ordinals = false;
|
|
29 |
bool _cl_use_udeb = false;
|
|
30 |
bool _cl_print_debug = false;
|
|
31 |
bool _some_cache_needs_update = false;
|
|
32 |
|
|
33 |
string _cl_toolsdir = "";
|
|
34 |
string _cl_cachedir = "";
|
|
35 |
string _cl_releasedir = "";
|
|
36 |
string _cl_targets = "";
|
|
37 |
string _cl_cfiltloc = "";
|
|
38 |
string _cl_outputfile = "";
|
|
39 |
string _cl_configfile = "";
|
|
40 |
string _cl_sisfiles = "";
|
|
41 |
string _cl_usestaticdepstxt = "";
|
|
42 |
string _cl_properties = "";
|
|
43 |
string _cl_staticdeps = "";
|
|
44 |
string _cl_dependson = "";
|
|
45 |
string _cl_showfunctions = "";
|
|
46 |
string _cl_usesfunction = "";
|
|
47 |
|
|
48 |
string _gcc_nm_location = "";
|
|
49 |
string _gcce_nm_location = "";
|
|
50 |
string _gcce_readelf_location = "";
|
|
51 |
string _gcce_cfilt_location = "";
|
|
52 |
string _rvct_armar_location = "";
|
|
53 |
string _rvct_fromelf_location = "";
|
|
54 |
string _rvct_cfilt_location = "";
|
|
55 |
string _petran_location = "";
|
|
56 |
string _dumpsis_location = "";
|
|
57 |
string _tempfile_location = "";
|
|
58 |
string _target_mode = "";
|
|
59 |
|
|
60 |
vector<target> _targets;
|
|
61 |
vector<binary_info> _all_binary_infos;
|
|
62 |
vector<import_library_info> _all_import_library_infos;
|
|
63 |
vector<import_library_info> _changed_import_libraries;
|
|
64 |
vector<string> _sisfiles;
|
|
65 |
|
|
66 |
unsigned int _current_progress = 0;
|
|
67 |
unsigned int _current_progress_percentage = 0;
|
|
68 |
unsigned int _max_progress = 0;
|
|
69 |
|
|
70 |
ofstream _outputf;
|
|
71 |
|
|
72 |
int _CRT_glob = 0; // globbing not supported
|
|
73 |
|
|
74 |
// ----------------------------------------------------------------------------------------------------------
|
|
75 |
|
|
76 |
int main(int argc, char* argv[])
|
|
77 |
{
|
|
78 |
// parse command line arguments
|
|
79 |
ParseCommandLineParameters(argc, argv);
|
|
80 |
|
|
81 |
// read from StaticDependencies.txt if in use
|
|
82 |
if (!_cl_usestaticdepstxt.empty())
|
|
83 |
{
|
|
84 |
GetDataFromStaticDependenciesTxt();
|
|
85 |
}
|
|
86 |
|
|
87 |
// otherwise do normal cache operations
|
|
88 |
else
|
|
89 |
{
|
|
90 |
// first do some checks
|
|
91 |
DoInitialChecksAndPreparations();
|
|
92 |
ParseTargets();
|
|
93 |
|
|
94 |
// checks for sis files if in use
|
|
95 |
if (!_cl_sisfiles.empty())
|
|
96 |
DoInitialChecksAndPreparationsForSisFiles();
|
|
97 |
|
|
98 |
// try to read data from caches
|
|
99 |
if (!_cl_generate_clean_cache)
|
|
100 |
{
|
|
101 |
for (unsigned int i=0; i<_targets.size(); i++) // loop each target
|
|
102 |
{
|
|
103 |
if (_targets.at(i).cache_files_valid)
|
|
104 |
{
|
|
105 |
ReadDataFromSymbolTablesCache(_targets.at(i));
|
|
106 |
|
|
107 |
if (_targets.at(i).cache_files_valid)
|
|
108 |
ReadDataFromDependenciesCache(_targets.at(i));
|
|
109 |
else
|
|
110 |
_some_cache_needs_update = true;
|
|
111 |
}
|
|
112 |
else
|
|
113 |
{
|
|
114 |
_some_cache_needs_update = true;
|
|
115 |
}
|
|
116 |
}
|
|
117 |
}
|
|
118 |
}
|
|
119 |
|
|
120 |
// check if cache needs generation or update
|
|
121 |
if (_cl_generate_clean_cache || _cl_update_cache || _some_cache_needs_update)
|
|
122 |
{
|
|
123 |
// before starting generating cache, we need more checks that user given params are correct
|
|
124 |
DoCacheGenerationChecksAndPreparations();
|
|
125 |
|
|
126 |
|
|
127 |
if (_cl_generate_clean_cache)
|
|
128 |
cerr << "Generating cache files at " << _cl_cachedir << " ";
|
|
129 |
else
|
|
130 |
cerr << "Updating cache files at " << _cl_cachedir << " ";
|
|
131 |
|
|
132 |
|
|
133 |
// get lists of files from the directories
|
|
134 |
FindImportLibrariesAndBinariesFromReleases();
|
|
135 |
|
|
136 |
|
|
137 |
// init progress values
|
|
138 |
if (_max_progress == 0)
|
|
139 |
_max_progress = 1;
|
|
140 |
|
|
141 |
if (_cl_print_debug)
|
|
142 |
cerr << endl;
|
|
143 |
else
|
|
144 |
ShowProgressInfo(_current_progress_percentage, _current_progress, _max_progress, true);
|
|
145 |
|
|
146 |
|
|
147 |
// get import libaries of each target and then write that data to the caches
|
|
148 |
for (unsigned int i=0; i<_targets.size(); i++) // loop each target
|
|
149 |
{
|
|
150 |
GetDataFromImportTables(_targets.at(i));
|
|
151 |
|
|
152 |
// write data only if current file is not valid
|
|
153 |
if (!_targets.at(i).cache_files_valid)
|
|
154 |
{
|
|
155 |
WriteDataToSymbolTableCacheFile(_targets.at(i));
|
|
156 |
}
|
|
157 |
|
|
158 |
// append all data to common vector
|
|
159 |
for (unsigned int j=0; j<_targets.at(i).import_libraries.size(); j++) // loop all binaries in one target
|
|
160 |
{
|
|
161 |
_all_import_library_infos.push_back(_targets.at(i).import_libraries.at(j));
|
|
162 |
}
|
|
163 |
|
|
164 |
// clear the original vector to save RAM since it is not needed anymore
|
|
165 |
_targets.at(i).import_libraries.clear();
|
|
166 |
}
|
|
167 |
|
|
168 |
// get dependency data and write it to the cache files
|
|
169 |
for (unsigned int i=0; i<_targets.size(); i++) // loop each target
|
|
170 |
{
|
|
171 |
GetDataFromBinaries(_targets.at(i));
|
|
172 |
|
|
173 |
if (!_targets.at(i).cache_files_valid) // only write cache if it needs updating
|
|
174 |
{
|
|
175 |
WriteDataToDependenciesCacheFile(_targets.at(i));
|
|
176 |
}
|
|
177 |
|
|
178 |
}
|
|
179 |
|
|
180 |
cerr << endl;
|
|
181 |
}
|
|
182 |
|
|
183 |
// if sis files in use and not done any previous operations, some things must be done
|
|
184 |
else if (!_cl_sisfiles.empty())
|
|
185 |
{
|
|
186 |
// check Petran can be found
|
|
187 |
SetAndCheckPetranPath();
|
|
188 |
|
|
189 |
for (unsigned int i=0; i<_targets.size(); i++) // loop each target
|
|
190 |
{
|
|
191 |
// append all data to common vector
|
|
192 |
for (unsigned int j=0; j<_targets.at(i).import_libraries.size(); j++) // loop all import libraries in one target
|
|
193 |
{
|
|
194 |
// get a binary info data
|
|
195 |
_all_import_library_infos.push_back(_targets.at(i).import_libraries.at(j));
|
|
196 |
}
|
|
197 |
|
|
198 |
// clear the original vector to save RAM since it is not needed anymore
|
|
199 |
_targets.at(i).import_libraries.clear();
|
|
200 |
}
|
|
201 |
}
|
|
202 |
|
|
203 |
|
|
204 |
// include sis files to analysis if in use
|
|
205 |
if (!_cl_sisfiles.empty())
|
|
206 |
AnalyseSisFiles();
|
|
207 |
|
|
208 |
|
|
209 |
// do the analysis
|
|
210 |
if (_cl_properties.empty() && _cl_staticdeps.empty() && _cl_dependson.empty() && _cl_showfunctions.empty() && _cl_usesfunction.empty())
|
|
211 |
{
|
|
212 |
cerr << "Nothing to do." << endl;
|
|
213 |
}
|
|
214 |
else
|
|
215 |
{
|
|
216 |
// copy binary_info vectors to a single one
|
|
217 |
if (_cl_usestaticdepstxt.empty())
|
|
218 |
{
|
|
219 |
for (unsigned int i=0; i<_targets.size(); i++) // loop all targets
|
|
220 |
{
|
|
221 |
for (unsigned int j=0; j<_targets.at(i).binaries.size(); j++) // loop all binaries in one target
|
|
222 |
{
|
|
223 |
// get a binary info data
|
|
224 |
_all_binary_infos.push_back(_targets.at(i).binaries.at(j));
|
|
225 |
}
|
|
226 |
|
|
227 |
// clear the original vector to save RAM
|
|
228 |
_targets.at(i).binaries.clear();
|
|
229 |
}
|
|
230 |
}
|
|
231 |
|
|
232 |
if (!_cl_properties.empty())
|
|
233 |
{
|
|
234 |
// show properties of the binary file
|
|
235 |
DisplayProperties(_cl_properties);
|
|
236 |
}
|
|
237 |
|
|
238 |
if (!_cl_staticdeps.empty())
|
|
239 |
{
|
|
240 |
// determine all static dependencies of selected component
|
|
241 |
DisplayStaticDependencies(_cl_staticdeps);
|
|
242 |
}
|
|
243 |
|
|
244 |
if (!_cl_dependson.empty())
|
|
245 |
{
|
|
246 |
// list all components that depends on selected component
|
|
247 |
DisplayDependents(_cl_dependson);
|
|
248 |
}
|
|
249 |
|
|
250 |
if (!_cl_showfunctions.empty())
|
|
251 |
{
|
|
252 |
// determine all functions that are included / supported in selected component
|
|
253 |
DisplayFunctions(_cl_showfunctions);
|
|
254 |
}
|
|
255 |
|
|
256 |
if (!_cl_usesfunction.empty())
|
|
257 |
{
|
|
258 |
// list all components that are using selected function
|
|
259 |
DisplayUsesFunction(_cl_usesfunction);
|
|
260 |
}
|
|
261 |
}
|
|
262 |
|
|
263 |
|
|
264 |
// close output file
|
|
265 |
if (_outputf.is_open())
|
|
266 |
{
|
|
267 |
_outputf.close();
|
|
268 |
}
|
|
269 |
|
|
270 |
// delete the temporary file
|
|
271 |
if (!_tempfile_location.empty())
|
|
272 |
RemoveFile(_tempfile_location);
|
|
273 |
|
|
274 |
return EXIT_NORMAL;
|
|
275 |
}
|
|
276 |
|
|
277 |
// ----------------------------------------------------------------------------------------------------------
|
|
278 |
|