# HG changeset patch # User noe\swadi # Date 1263011652 -19800 # Node ID 509e4801c378d0c861a0ac3efdcc22961b4f036a 1. Copyrights changed to EPL 2. Feature updates mentioned in release notes. diff -r 000000000000 -r 509e4801c378 srcanamdw/appdep/bin/appdep.exe Binary file srcanamdw/appdep/bin/appdep.exe has changed diff -r 000000000000 -r 509e4801c378 srcanamdw/appdep/bin/cfilt.exe Binary file srcanamdw/appdep/bin/cfilt.exe has changed diff -r 000000000000 -r 509e4801c378 srcanamdw/appdep/doc/S60_AppDep_Users_Guide.doc Binary file srcanamdw/appdep/doc/S60_AppDep_Users_Guide.doc has changed diff -r 000000000000 -r 509e4801c378 srcanamdw/appdep/group/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanamdw/appdep/group/Makefile Sat Jan 09 10:04:12 2010 +0530 @@ -0,0 +1,117 @@ +# +# Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: Makefile +# +# + +BOOSTHOME = E:/boost_1_33_1 + +CPP = g++ +CC = gcc +RES = +OBJ = ../obj/appdep.o ../obj/appdep_analysis.o ../obj/appdep_cache.o ../obj/appdep_getters.o ../obj/appdep_otherfunc.o ../obj/appdep_sisfiles.o ../obj/appdep_statdeps.o ../obj/appdep_utils.o ../obj/static_mutex.o ../obj/w32_regex_traits.o ../obj/icu.o ../obj/wc_regex_traits.o ../obj/usinstances.o ../obj/cpp_regex_traits.o ../obj/regex_traits_defaults.o ../obj/wide_posix_api.o ../obj/posix_api.o ../obj/fileiter.o ../obj/cregex.o ../obj/c_regex_traits.o ../obj/winstances.o ../obj/regex_raw_buffer.o ../obj/regex_debug.o ../obj/regex.o ../obj/instances.o $(RES) +LINKOBJ = ../obj/appdep.o ../obj/appdep_analysis.o ../obj/appdep_cache.o ../obj/appdep_getters.o ../obj/appdep_otherfunc.o ../obj/appdep_sisfiles.o ../obj/appdep_statdeps.o ../obj/appdep_utils.o ../obj/static_mutex.o ../obj/w32_regex_traits.o ../obj/icu.o ../obj/wc_regex_traits.o ../obj/usinstances.o ../obj/cpp_regex_traits.o ../obj/regex_traits_defaults.o ../obj/wide_posix_api.o ../obj/posix_api.o ../obj/fileiter.o ../obj/cregex.o ../obj/c_regex_traits.o ../obj/winstances.o ../obj/regex_raw_buffer.o ../obj/regex_debug.o ../obj/regex.o ../obj/instances.o $(RES) +LIBS = +INCS = -I../inc -I$(BOOSTHOME) +CXXINCS = -I../inc -I$(BOOSTHOME) +BIN = ../bin/appdep +CXXFLAGS = $(CXXINCS) -pedantic -Wall -Wextra -Wno-long-long +CFLAGS = $(INCS) -std=c99 -pedantic -Wall -Wextra -Wno-long-long +RM = rm -f + +.PHONY: all all-before all-after clean clean-custom + +all: all-before ../bin/appdep all-after + + +clean: clean-custom + ${RM} $(OBJ) $(BIN) + +$(BIN): $(OBJ) + $(CPP) $(LINKOBJ) -o "../bin/appdep" $(LIBS) + +../obj/appdep.o: ../src/appdep.cpp + $(CPP) -c ../src/appdep.cpp -o ../obj/appdep.o $(CXXFLAGS) + +../obj/appdep_analysis.o: ../src/appdep_analysis.cpp + $(CPP) -c ../src/appdep_analysis.cpp -o ../obj/appdep_analysis.o $(CXXFLAGS) + +../obj/appdep_cache.o: ../src/appdep_cache.cpp + $(CPP) -c ../src/appdep_cache.cpp -o ../obj/appdep_cache.o $(CXXFLAGS) + +../obj/appdep_getters.o: ../src/appdep_getters.cpp + $(CPP) -c ../src/appdep_getters.cpp -o ../obj/appdep_getters.o $(CXXFLAGS) + +../obj/appdep_otherfunc.o: ../src/appdep_otherfunc.cpp + $(CPP) -c ../src/appdep_otherfunc.cpp -o ../obj/appdep_otherfunc.o $(CXXFLAGS) + +../obj/appdep_sisfiles.o: ../src/appdep_sisfiles.cpp + $(CPP) -c ../src/appdep_sisfiles.cpp -o ../obj/appdep_sisfiles.o $(CXXFLAGS) + +../obj/appdep_statdeps.o: ../src/appdep_statdeps.cpp + $(CPP) -c ../src/appdep_statdeps.cpp -o ../obj/appdep_statdeps.o $(CXXFLAGS) + +../obj/appdep_utils.o: ../src/appdep_utils.cpp + $(CPP) -c ../src/appdep_utils.cpp -o ../obj/appdep_utils.o $(CXXFLAGS) + +../obj/static_mutex.o: $(BOOSTHOME)/libs/regex/src/static_mutex.cpp + $(CPP) -c $(BOOSTHOME)/libs/regex/src/static_mutex.cpp -o ../obj/static_mutex.o $(CXXFLAGS) + +../obj/w32_regex_traits.o: $(BOOSTHOME)/libs/regex/src/w32_regex_traits.cpp + $(CPP) -c $(BOOSTHOME)/libs/regex/src/w32_regex_traits.cpp -o ../obj/w32_regex_traits.o $(CXXFLAGS) + +../obj/icu.o: $(BOOSTHOME)/libs/regex/src/icu.cpp + $(CPP) -c $(BOOSTHOME)/libs/regex/src/icu.cpp -o ../obj/icu.o $(CXXFLAGS) + +../obj/wc_regex_traits.o: $(BOOSTHOME)/libs/regex/src/wc_regex_traits.cpp + $(CPP) -c $(BOOSTHOME)/libs/regex/src/wc_regex_traits.cpp -o ../obj/wc_regex_traits.o $(CXXFLAGS) + +../obj/usinstances.o: $(BOOSTHOME)/libs/regex/src/usinstances.cpp + $(CPP) -c $(BOOSTHOME)/libs/regex/src/usinstances.cpp -o ../obj/usinstances.o $(CXXFLAGS) + +../obj/cpp_regex_traits.o: $(BOOSTHOME)/libs/regex/src/cpp_regex_traits.cpp + $(CPP) -c $(BOOSTHOME)/libs/regex/src/cpp_regex_traits.cpp -o ../obj/cpp_regex_traits.o $(CXXFLAGS) + +../obj/regex_traits_defaults.o: $(BOOSTHOME)/libs/regex/src/regex_traits_defaults.cpp + $(CPP) -c $(BOOSTHOME)/libs/regex/src/regex_traits_defaults.cpp -o ../obj/regex_traits_defaults.o $(CXXFLAGS) + +../obj/wide_posix_api.o: $(BOOSTHOME)/libs/regex/src/wide_posix_api.cpp + $(CPP) -c $(BOOSTHOME)/libs/regex/src/wide_posix_api.cpp -o ../obj/wide_posix_api.o $(CXXFLAGS) + +../obj/posix_api.o: $(BOOSTHOME)/libs/regex/src/posix_api.cpp + $(CPP) -c $(BOOSTHOME)/libs/regex/src/posix_api.cpp -o ../obj/posix_api.o $(CXXFLAGS) + +../obj/fileiter.o: $(BOOSTHOME)/libs/regex/src/fileiter.cpp + $(CPP) -c $(BOOSTHOME)/libs/regex/src/fileiter.cpp -o ../obj/fileiter.o $(CXXFLAGS) + +../obj/cregex.o: $(BOOSTHOME)/libs/regex/src/cregex.cpp + $(CPP) -c $(BOOSTHOME)/libs/regex/src/cregex.cpp -o ../obj/cregex.o $(CXXFLAGS) + +../obj/c_regex_traits.o: $(BOOSTHOME)/libs/regex/src/c_regex_traits.cpp + $(CPP) -c $(BOOSTHOME)/libs/regex/src/c_regex_traits.cpp -o ../obj/c_regex_traits.o $(CXXFLAGS) + +../obj/winstances.o: $(BOOSTHOME)/libs/regex/src/winstances.cpp + $(CPP) -c $(BOOSTHOME)/libs/regex/src/winstances.cpp -o ../obj/winstances.o $(CXXFLAGS) + +../obj/regex_raw_buffer.o: $(BOOSTHOME)/libs/regex/src/regex_raw_buffer.cpp + $(CPP) -c $(BOOSTHOME)/libs/regex/src/regex_raw_buffer.cpp -o ../obj/regex_raw_buffer.o $(CXXFLAGS) + +../obj/regex_debug.o: $(BOOSTHOME)/libs/regex/src/regex_debug.cpp + $(CPP) -c $(BOOSTHOME)/libs/regex/src/regex_debug.cpp -o ../obj/regex_debug.o $(CXXFLAGS) + +../obj/regex.o: $(BOOSTHOME)/libs/regex/src/regex.cpp + $(CPP) -c $(BOOSTHOME)/libs/regex/src/regex.cpp -o ../obj/regex.o $(CXXFLAGS) + +../obj/instances.o: $(BOOSTHOME)/libs/regex/src/instances.cpp + $(CPP) -c $(BOOSTHOME)/libs/regex/src/instances.cpp -o ../obj/instances.o $(CXXFLAGS) diff -r 000000000000 -r 509e4801c378 srcanamdw/appdep/group/ReleaseNote.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanamdw/appdep/group/ReleaseNote.txt Sat Jan 09 10:04:12 2010 +0530 @@ -0,0 +1,90 @@ +======================================================================== +RELEASE NOTE FOR APPDEP, 2.2 +======================================================================== + +Product Description: +==================== +AppDep is a command line tool that can be used to resolve static +dependency information of a component within a Symbian OS build (either +platform or custom). The tool generates a cache file by reading the data +from all binaries and import libraries within a release, by using an +external compiler tool set. The use of a cache file is a fast way to make +a dependency review, such as what dependencies a binary has, and functions +and ordinals used in a binary, and to generate dependency lists to a +component or a function. The tool can also be used to view the properties +of a binary. + +Features: +========= +- Generates a cache file appdep-cache-symbol-tables.txt which contain + symbol tables of all import libraries within a release +- Generates a cache file appdep-cache-dependencies.txt which contain + dependency information of all binaries within a release +- Reading data from AppDep generated cache files or from platform + generated StaticDependencies.txt +- Include SIS files under analysis +- Support for defining multiple target types +- Support for reading binaries from a release or a debug build +- Support for reading .lib files or .dso files +- Display properties of a file +- Print all static dependencies of a component +- Print all components that depends on a component +- Print all functions used by a component +- Print all components that are using a function + +Fixed issues: +============= +- Added support for components that include "-" character in the middle of the component name i.e. now + also imported function lines of format '27 imports from libdbus-utils{000a0000}[20010154].dll' are parsed + correctly from dump created by elftran.exe. +- Fixed issue 'command '-showfunctions' may report functions with same ordinal twice' which was due to duplicate + import function instances found from cache file. Now the possible duplicate import function instances are detected + during cache creation and only one import function instance is stored. + +Enhancements: +============= +- Appdep now scans *.agt and *.fxt files as binaries +- Changed tool to use elftran.exe instead petran.exe for GCCE and RVCT toolchains (petran.exe is still used for GCC). + +New Features: +============= + +System Requirements: +==================== +Basic Requirements: +- Windows 2000 +- External RVCT or GCCE tool chain installed when Symbian OS 9.x is + being used +- Symbian OS development environment installed including all related + import libraries (.lib or .dso) + +Compatibility Issues: +===================== +N/A + +Known Issues: +============= + +RVCT toolset slowness +--------------------- +- If your installed RVCT toolset does not have a fixed license, it will + get a license for each import library every time. This may cause the + cache generation become very slow. If this is causing problems, try + --uselibs parameter or use GCCE tool chain instead. + +C++filt location when RVCT toolchain is used +-------------------------------------------- +- When you RVCT toolchain, you must also specify a location to C++filt + tool since RVCT toolchain does not provide that. It is recommended to + use the cfilt.exe provided with AppDep installed since it has been + tested to work correctly. C++filt.exe provided by the platform cannot + be used since it is not compatible. + +Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). +All rights reserved. + +This component and the accompanying materials are made available +under the terms of "Eclipse Public License v1.0" +which accompanies this distribution, and is available +at the URL "http://www.eclipse.org/legal/epl-v10.html". + diff -r 000000000000 -r 509e4801c378 srcanamdw/appdep/inc/appdep.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanamdw/appdep/inc/appdep.hpp Sat Jan 09 10:04:12 2010 +0530 @@ -0,0 +1,335 @@ +/* +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Header file of Appdep +* +*/ + + +#ifndef __APPDEP_HPP__ +#define __APPDEP_HPP__ + + +#if (defined(_MSC_VER) && (_MSC_VER < 1400)) + #error "ERROR: Minimum supported version of Visual C++ is 8.0 (2005)." +#endif + +#ifdef _MSC_VER + #pragma message("IMPORTANT: You can use Visual C++ to aid development, but please compile the releasable executable with MinGW/MSYS !!!") + #pragma warning(disable:4267) // 'var' : conversion from 'size_t' to 'type', possible loss of data + #pragma warning(disable:4996) // 'function': was declared deprecated + #define _CRT_SECURE_NO_DEPRECATE + #ifndef WIN32 + #error "ERROR: Only Win32 target supported!" + #endif +#endif + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _MSC_VER + #include + #define S_ISDIR(m) ((m) & S_IFDIR) +#else + #include +#endif + +using namespace std; + +#define APPDEP_VERSION "2.2" +#define APPDEP_DATE "27th Nov 2009" +#define APPDEP_COPYRIGHT_YEARS "2001-2009" +#define CACHE_ST_FILENAME "appdep-cache_symbol_tables.txt" +#define CACHE_DEP_FILENAME "appdep-cache_dependencies.txt" +#define CACHE_ST_HEADER "appdep symbol tables cache version: 101" +#define CACHE_DEP_HEADER "appdep dependencies cache version: 101" +#define CACHE_FOOTER "#end" +#define CACHE_COMMENT_CHAR '#' +#define CACHE_SEP "|" +#define TEMP_FILENAME "appdep-temp.txt" +#define SIS_TEMP_DIR "sistemp" +#define UNKNOWN "unknown" +#define NOT_VALID "not valid" + +#ifdef WIN32 + #define DIR_SEPARATOR "\\" + #define DIR_SEPARATOR2 '\\' + #define DEFAULT_CACHE_DIR "epoc32\\tools\\s60rndtools\\appdep\\cache\\" + #define DUMPSIS_LOCATION "epoc32\\tools\\dumpsis.exe" + #define PETRAN_LOCATION "epoc32\\tools\\petran.exe" // used for GCC toolchain + #define ELFTRAN_LOCATION "epoc32\\tools\\elftran.exe" // used for other toolchains + #define EPOC32_RELEASE "epoc32\\release\\" + #define GCC_NM_EXE "nm.exe" + #define GCCE_NM_EXE "arm-none-symbianelf-nm.exe" + #define GCCE_READELF_EXE "arm-none-symbianelf-readelf.exe" + #define GCCE_CFILT_EXE "arm-none-symbianelf-c++filt.exe" + #define RVCT_ARMAR_EXE "armar.exe" + #define RVCT_FROMELF_EXE "fromelf.exe" + #define CERR_TO_NULL "2>NUL" + #define DIR_COMMAND "dir /b" + #define DEL_ALL_COMMAND "del /F /S /Q" +#else + #define DIR_SEPARATOR "/" + #define DIR_SEPARATOR2 '/' + #define DEFAULT_CACHE_DIR "epoc32/tools/s60rndtools/appdep/cache/" + #define DUMPSIS_LOCATION "epoc32/tools/dumpsis" + #define PETRAN_LOCATION "epoc32/tools/petran" // used for GCC toolchain + #define ELFTRAN_LOCATION "epoc32/tools/elftran" // used for other toolchains + #define EPOC32_RELEASE "epoc32/release/" + #define GCC_NM_EXE "nm" + #define GCCE_NM_EXE "arm-none-symbianelf-nm" + #define GCCE_READELF_EXE "arm-none-symbianelf-readelf" + #define GCCE_CFILT_EXE "arm-none-symbianelf-c++filt" + #define RVCT_ARMAR_EXE "armar" + #define RVCT_FROMELF_EXE "fromelf" + #define CERR_TO_NULL "2>/dev/null" + #define DIR_COMMAND "ls --format=single-column" + #define DEL_ALL_COMMAND "rm -f -R" + #define _mkdir(X) mkdir(X, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) + #define _rmdir rmdir + #define _unlink unlink + #define _popen popen + #define _pclose pclose +#endif + +enum ExitStates +{ + EXIT_NORMAL = 0, + EXIT_INVALID_ARGUMENT, + EXIT_NO_TARGETS, + EXIT_WRONG_USAGE, + EXIT_CANNOT_CREATE_OUTPUT_FILE, + EXIT_TOOLCHAIN_NOT_FOUND, + EXIT_TARGETDIR_NOT_FOUND, + EXIT_CFILT_NOT_FOUND, + EXIT_PETRAN_NOT_FOUND, + EXIT_TOOLCHAIN_NOT_FOUND_FROM_PATH, + EXIT_PATH_VARIABLE_NOT_FOUND, + EXIT_ONLY_SUPPORTED_IN_WIN32, + EXIT_CANNOT_WRITE_TO_TEMP_FILE, + EXIT_ORDINAL_LIST_CORRUPTED, + EXIT_COMPONENT_NOT_FOUND, + EXIT_INVALID_ORDINAL, + EXIT_CANNOT_WRITE_TO_CACHE_FILE, + EXIT_CANNOT_OPEN_STATIC_DEPENDENCIES_TXT, + EXIT_OPENED_STATIC_DEPENDENCIES_TXT_NOT_SUPPORTED, + EXIT_DUMPSIS_NOT_FOUND, + EXIT_SIS_FILE_NOT_FOUND, + EXIT_SIS_FILE_NOT_SUPPORTED, + EXIT_NOT_SIS_FILE, + EXIT_SIS_FILE_CANNOT_OPEN_FOR_READING, + EXIT_TEMP_SIS_FILE_CANNOT_OPEN_FOR_WRITING, + EXIT_NO_PKG_FILE_FOUND, + EXIT_PKG_FILE_CANNOT_OPEN_FOR_READING, + EXIT_PKG_FORMAT_NOT_SUPPORTED +}; + +struct ordinal +{ + unsigned int funcpos; + string funcname; + + ordinal(unsigned int fp, string fn) + { + funcpos = fp; + funcname = fn; + } +}; + +struct import +{ + unsigned int funcpos; + string funcname; + bool is_vtable; + unsigned int vtable_offset; +}; + +struct dependency +{ + string filename; + vector imports; +}; + +struct binary_info +{ + string directory; + string filename; + string binary_format; + unsigned long file_size; + string uid1; + string uid2; + string uid3; + string secureid; + string vendorid; + unsigned long capabilities; + unsigned long min_heap_size; + unsigned long max_heap_size; + unsigned long stack_size; + time_t mod_time; + vector dependencies; +}; + +struct import_library_info +{ + string directory; + string filename; + time_t mod_time; + vector symbol_table; +}; + +struct target +{ + string name; + string release_dir; + string release_lib_dir; + string release_bin_dir; + string cache_dir; + string st_cache_path; + string dep_cache_path; + bool cache_files_valid; + vector lib_files; + vector bin_files; + vector import_libraries; + vector binaries; +}; + + +// global variables +extern bool _cl_use_gcc; +extern bool _cl_use_gcce; +extern bool _cl_use_rvct; +extern bool _cl_generate_clean_cache; +extern bool _cl_update_cache; +extern bool _cl_use_libs; +extern bool _cl_show_ordinals; +extern bool _cl_use_udeb; +extern bool _cl_print_debug; +extern bool _some_cache_needs_update; + +extern string _cl_toolsdir; +extern string _cl_cachedir; +extern string _cl_releasedir; +extern string _cl_targets; +extern string _cl_cfiltloc; +extern string _cl_outputfile; +extern string _cl_configfile; +extern string _cl_sisfiles; +extern string _cl_usestaticdepstxt; +extern string _cl_properties; +extern string _cl_staticdeps; +extern string _cl_dependson; +extern string _cl_showfunctions; +extern string _cl_usesfunction; + +extern string _gcc_nm_location; +extern string _gcce_nm_location; +extern string _gcce_readelf_location; +extern string _gcce_cfilt_location; +extern string _rvct_armar_location; +extern string _rvct_fromelf_location; +extern string _rvct_cfilt_location; +extern string _petran_location; +extern string _dumpsis_location; +extern string _tempfile_location; +extern string _target_mode; + +extern vector _targets; +extern vector _all_binary_infos; +extern vector _all_import_library_infos; +extern vector _changed_import_libraries; +extern vector _sisfiles; + +extern unsigned int _current_progress; +extern unsigned int _current_progress_percentage; +extern unsigned int _max_progress; + +extern ofstream _outputf; + + +// from appdep_otherfunc.cpp +void ParseCommandLineParameters(int argc, char* argv[]); +void ShowCommandLineOptionsAndExit(); +void DoInitialChecksAndPreparations(); +void ParseTargets(); +void DoCacheGenerationChecksAndPreparations(); +void GetToolsPathFromEnvironmentVariable(); +void FindImportLibrariesAndBinariesFromReleases(); +void GetFileNamesFromDirectory(const string& directory, const string& filter, vector& resultset); +void SetAndCheckPetranPath(); + +// from appdep_utils.cpp +void PrintOutputLn(const string& s); +void MakeSureTrailingDirectoryMarkerExists(string& path); +bool FileExists(const string& path); +bool DirectoryExists(const string& path); +bool RemoveFile(const string& path); +bool RemoveDirectoryWithAllFiles(const string& path); +string LowerCase(const string& s); +string Int2Str(int value); +int Str2Int(const string& s); +void MkDirAll(const string& path); +string& TrimRight(string& s); +string& TrimLeft(string& s); +string& TrimAll(string& s); +int StringICmp(const string& s1, const string& s2); +int StringICmpFileNamesWithoutExtension(const string& s1, const string& s2); +void InsertQuotesToFilePath(string& s); +bool ExecuteCommand(const string& command, vector& resultset); +bool TimestampsMatches(const time_t& orginal_time, const time_t& new_time); +void ShowProgressInfo(unsigned int& current_progress_percentage, unsigned int& current_progress, unsigned int& max_progress, bool print_initial_value); + +// from appdep_getters.cpp +void GetImportTableWithPetran(const string& petran_location, binary_info& b_info); +bool ImportFunctionsHasSameOrdinal(import imp1, import imp2); +void GetSymbolTableWithNM(const string& nm_location, const string& lib_directory, const string& lib_name, vector& symbol_table); +void GetSymbolTableWithReadelf(const string& readelf_location, const string& cfilt_location, const string& lib_directory, const string& lib_name, vector& symbol_table); +void GetSymbolTableWithArmar(const string& armar_location, const string& cfilt_location, const string& lib_directory, const string& lib_name, vector& symbol_table); +void GetSymbolTableWithFromelf(const string& fromelf_location, const string& cfilt_location, const string& lib_directory, const string& lib_name, vector& symbol_table); +void ConvertOrdinalListIntoSymbolTable(const vector& ordinals, vector& symbol_table, const string& lib_path); +void DemangleOrdinalsInSymbolTable(const string& cfilt_location, vector& symbol_table); +bool OrdinalCompare(const ordinal& left, const ordinal& right); + +// from appdep_cache.cpp +void ReadDataFromSymbolTablesCache(target& a_target); +void ReadDataFromDependenciesCache(target& a_target); +void GetDataFromImportTables(target& a_target); +void GetDataFromBinaries(target& a_target); +void WriteDataToSymbolTableCacheFile(const target& a_target); +void WriteDataToDependenciesCacheFile(const target& a_target); + +// from appdep_statdeps.cpp +void GetDataFromStaticDependenciesTxt(); + +// from appdep_sisfiles.cpp +void DoInitialChecksAndPreparationsForSisFiles(); +void AnalyseSisFiles(); + +// from appdep_analysis.cpp +void DisplayProperties(const string& binary_name); +void DisplayStaticDependencies(const string& binary_name); +void DisplayDependents(const string& binary_name); +void DisplayFunctions(const string& binary_name); +void DisplayUsesFunction(const string& function_name); + + +#endif // __APPDEP_HPP__ diff -r 000000000000 -r 509e4801c378 srcanamdw/appdep/src/appdep.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanamdw/appdep/src/appdep.cpp Sat Jan 09 10:04:12 2010 +0530 @@ -0,0 +1,278 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Main entry of Appdep +* +*/ + + +#include "appdep.hpp" + +// init globals +bool _cl_use_gcc = false; +bool _cl_use_gcce = false; +bool _cl_use_rvct = false; +bool _cl_generate_clean_cache = false; +bool _cl_update_cache = false; +bool _cl_use_libs = false; +bool _cl_show_ordinals = false; +bool _cl_use_udeb = false; +bool _cl_print_debug = false; +bool _some_cache_needs_update = false; + +string _cl_toolsdir = ""; +string _cl_cachedir = ""; +string _cl_releasedir = ""; +string _cl_targets = ""; +string _cl_cfiltloc = ""; +string _cl_outputfile = ""; +string _cl_configfile = ""; +string _cl_sisfiles = ""; +string _cl_usestaticdepstxt = ""; +string _cl_properties = ""; +string _cl_staticdeps = ""; +string _cl_dependson = ""; +string _cl_showfunctions = ""; +string _cl_usesfunction = ""; + +string _gcc_nm_location = ""; +string _gcce_nm_location = ""; +string _gcce_readelf_location = ""; +string _gcce_cfilt_location = ""; +string _rvct_armar_location = ""; +string _rvct_fromelf_location = ""; +string _rvct_cfilt_location = ""; +string _petran_location = ""; +string _dumpsis_location = ""; +string _tempfile_location = ""; +string _target_mode = ""; + +vector _targets; +vector _all_binary_infos; +vector _all_import_library_infos; +vector _changed_import_libraries; +vector _sisfiles; + +unsigned int _current_progress = 0; +unsigned int _current_progress_percentage = 0; +unsigned int _max_progress = 0; + +ofstream _outputf; + +int _CRT_glob = 0; // globbing not supported + +// ---------------------------------------------------------------------------------------------------------- + +int main(int argc, char* argv[]) +{ + // parse command line arguments + ParseCommandLineParameters(argc, argv); + + // read from StaticDependencies.txt if in use + if (!_cl_usestaticdepstxt.empty()) + { + GetDataFromStaticDependenciesTxt(); + } + + // otherwise do normal cache operations + else + { + // first do some checks + DoInitialChecksAndPreparations(); + ParseTargets(); + + // checks for sis files if in use + if (!_cl_sisfiles.empty()) + DoInitialChecksAndPreparationsForSisFiles(); + + // try to read data from caches + if (!_cl_generate_clean_cache) + { + for (unsigned int i=0; i<_targets.size(); i++) // loop each target + { + if (_targets.at(i).cache_files_valid) + { + ReadDataFromSymbolTablesCache(_targets.at(i)); + + if (_targets.at(i).cache_files_valid) + ReadDataFromDependenciesCache(_targets.at(i)); + else + _some_cache_needs_update = true; + } + else + { + _some_cache_needs_update = true; + } + } + } + } + + // check if cache needs generation or update + if (_cl_generate_clean_cache || _cl_update_cache || _some_cache_needs_update) + { + // before starting generating cache, we need more checks that user given params are correct + DoCacheGenerationChecksAndPreparations(); + + + if (_cl_generate_clean_cache) + cerr << "Generating cache files at " << _cl_cachedir << " "; + else + cerr << "Updating cache files at " << _cl_cachedir << " "; + + + // get lists of files from the directories + FindImportLibrariesAndBinariesFromReleases(); + + + // init progress values + if (_max_progress == 0) + _max_progress = 1; + + if (_cl_print_debug) + cerr << endl; + else + ShowProgressInfo(_current_progress_percentage, _current_progress, _max_progress, true); + + + // get import libaries of each target and then write that data to the caches + for (unsigned int i=0; i<_targets.size(); i++) // loop each target + { + GetDataFromImportTables(_targets.at(i)); + + // write data only if current file is not valid + if (!_targets.at(i).cache_files_valid) + { + WriteDataToSymbolTableCacheFile(_targets.at(i)); + } + + // append all data to common vector + for (unsigned int j=0; j<_targets.at(i).import_libraries.size(); j++) // loop all binaries in one target + { + _all_import_library_infos.push_back(_targets.at(i).import_libraries.at(j)); + } + + // clear the original vector to save RAM since it is not needed anymore + _targets.at(i).import_libraries.clear(); + } + + // get dependency data and write it to the cache files + for (unsigned int i=0; i<_targets.size(); i++) // loop each target + { + GetDataFromBinaries(_targets.at(i)); + + if (!_targets.at(i).cache_files_valid) // only write cache if it needs updating + { + WriteDataToDependenciesCacheFile(_targets.at(i)); + } + + } + + cerr << endl; + } + + // if sis files in use and not done any previous operations, some things must be done + else if (!_cl_sisfiles.empty()) + { + // check Petran can be found + SetAndCheckPetranPath(); + + for (unsigned int i=0; i<_targets.size(); i++) // loop each target + { + // append all data to common vector + for (unsigned int j=0; j<_targets.at(i).import_libraries.size(); j++) // loop all import libraries in one target + { + // get a binary info data + _all_import_library_infos.push_back(_targets.at(i).import_libraries.at(j)); + } + + // clear the original vector to save RAM since it is not needed anymore + _targets.at(i).import_libraries.clear(); + } + } + + + // include sis files to analysis if in use + if (!_cl_sisfiles.empty()) + AnalyseSisFiles(); + + + // do the analysis + if (_cl_properties.empty() && _cl_staticdeps.empty() && _cl_dependson.empty() && _cl_showfunctions.empty() && _cl_usesfunction.empty()) + { + cerr << "Nothing to do." << endl; + } + else + { + // copy binary_info vectors to a single one + if (_cl_usestaticdepstxt.empty()) + { + for (unsigned int i=0; i<_targets.size(); i++) // loop all targets + { + for (unsigned int j=0; j<_targets.at(i).binaries.size(); j++) // loop all binaries in one target + { + // get a binary info data + _all_binary_infos.push_back(_targets.at(i).binaries.at(j)); + } + + // clear the original vector to save RAM + _targets.at(i).binaries.clear(); + } + } + + if (!_cl_properties.empty()) + { + // show properties of the binary file + DisplayProperties(_cl_properties); + } + + if (!_cl_staticdeps.empty()) + { + // determine all static dependencies of selected component + DisplayStaticDependencies(_cl_staticdeps); + } + + if (!_cl_dependson.empty()) + { + // list all components that depends on selected component + DisplayDependents(_cl_dependson); + } + + if (!_cl_showfunctions.empty()) + { + // determine all functions that are included / supported in selected component + DisplayFunctions(_cl_showfunctions); + } + + if (!_cl_usesfunction.empty()) + { + // list all components that are using selected function + DisplayUsesFunction(_cl_usesfunction); + } + } + + + // close output file + if (_outputf.is_open()) + { + _outputf.close(); + } + + // delete the temporary file + if (!_tempfile_location.empty()) + RemoveFile(_tempfile_location); + + return EXIT_NORMAL; +} + +// ---------------------------------------------------------------------------------------------------------- + diff -r 000000000000 -r 509e4801c378 srcanamdw/appdep/src/appdep_analysis.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanamdw/appdep/src/appdep_analysis.cpp Sat Jan 09 10:04:12 2010 +0530 @@ -0,0 +1,277 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Functionality of analysis +* +*/ + + +#include "appdep.hpp" + + +// ---------------------------------------------------------------------------------------------------------- + +void DisplayProperties(const string& binary_name) +{ + bool match_found = false; + + for (unsigned int i=0; i<_all_binary_infos.size(); i++) + { + if (StringICmp(_all_binary_infos.at(i).filename.c_str(), binary_name.c_str()) == 0) + { + binary_info b_info = _all_binary_infos.at(i); + + PrintOutputLn("Directory: " + b_info.directory); + PrintOutputLn("Filename: " + b_info.filename); + PrintOutputLn("Binary format: " + b_info.binary_format); + PrintOutputLn("UID1: " + b_info.uid1); + PrintOutputLn("UID2: " + b_info.uid2); + PrintOutputLn("UID3: " + b_info.uid3); + + if (b_info.secureid.length() > 2 && b_info.secureid.at(0)=='0' && b_info.secureid.at(1)=='x') + { + PrintOutputLn("Secure ID: " + b_info.secureid); + PrintOutputLn("Vendor ID: " + b_info.vendorid); + + vector symbian_caps; + symbian_caps.push_back("TCB"); + symbian_caps.push_back("CommDD"); + symbian_caps.push_back("PowerMgmt"); + symbian_caps.push_back("MultimediaDD"); + symbian_caps.push_back("ReadDeviceData"); + symbian_caps.push_back("WriteDeviceData"); + symbian_caps.push_back("DRM"); + symbian_caps.push_back("TrustedUI"); + symbian_caps.push_back("ProtServ"); + symbian_caps.push_back("DiskAdmin"); + symbian_caps.push_back("NetworkControl"); + symbian_caps.push_back("AllFiles"); + symbian_caps.push_back("SwEvent"); + symbian_caps.push_back("NetworkServices"); + symbian_caps.push_back("LocalServices"); + symbian_caps.push_back("ReadUserData"); + symbian_caps.push_back("WriteUserData"); + symbian_caps.push_back("Location"); + symbian_caps.push_back("SurroundingsDD"); + symbian_caps.push_back("UserEnvironment"); + + PrintOutputLn("Capabilities:"); + for (unsigned int x=0; x deps = _all_binary_infos.at(i).dependencies; + + for (unsigned int j=0; j deps = _all_binary_infos.at(i).dependencies; + + for (unsigned int j=0; j deps = _all_binary_infos.at(i).dependencies; + + for (unsigned int j=0; j imps = deps.at(j).imports; + + for (unsigned int k=0; k deps = _all_binary_infos.at(i).dependencies; + + for (unsigned int j=0; j imps = deps.at(j).imports; + + for (unsigned int k=0; k 27500) + { + cerr << "Uses function: Given ordinal number is invalid: " << ordinal_number << endl; + exit(EXIT_INVALID_ORDINAL); + } + + PrintOutputLn(function_name + " - is used by:"); + + for (unsigned int i=0; i<_all_binary_infos.size(); i++) + { + string component_name = _all_binary_infos.at(i).filename; + + vector deps = _all_binary_infos.at(i).dependencies; + + for (unsigned int j=0; j imps = deps.at(j).imports; + + for (unsigned int k=0; k 0 && line[0] != CACHE_COMMENT_CHAR) + { + // first entry is the directory|filename|modification_time|symbol_table_size , eg + // x:\epoc32\release\armv5\urel\|avkon.dll|1160666488|178 + string::size_type delim1 = line.find(CACHE_SEP, 0); + string::size_type delim2 = line.find(CACHE_SEP, delim1+1); + string::size_type delim3 = line.find(CACHE_SEP, delim2+1); + + import_library_info lib_info; + lib_info.directory = line.substr(0, delim1); + lib_info.filename = line.substr(delim1+1, delim2-delim1-1); + lib_info.mod_time = Str2Int( line.substr(delim2+1, delim3-delim2-1) ); + unsigned int symbol_table_size = Str2Int( line.substr(delim3+1, line.length()-delim3-1) ); + + // get symbol table + vector symbol_table; + for (unsigned int j=0; j 0 && line[0] != CACHE_COMMENT_CHAR) + { + // first entry is the directory|filename|binary_format|uid1|uid2|uid3|secureid|vendorid|capabilities|min_heap_size|max_heap_size|stack_size|modification_time|number_of_dependencies , eg + // x:\epoc32\release\armv5\urel\|about.exe|EPOC Exe for ARMV4 CPU|0x1000007a|0x100039ce|0x10005a22|0x10005a22|0x101fb657|782384|4096|1048576|8192|1160666488|11 + string::size_type delim1 = line.find(CACHE_SEP, 0); + string::size_type delim2 = line.find(CACHE_SEP, delim1+1); + string::size_type delim3 = line.find(CACHE_SEP, delim2+1); + string::size_type delim4 = line.find(CACHE_SEP, delim3+1); + string::size_type delim5 = line.find(CACHE_SEP, delim4+1); + string::size_type delim6 = line.find(CACHE_SEP, delim5+1); + string::size_type delim7 = line.find(CACHE_SEP, delim6+1); + string::size_type delim8 = line.find(CACHE_SEP, delim7+1); + string::size_type delim9 = line.find(CACHE_SEP, delim8+1); + string::size_type delim10 = line.find(CACHE_SEP, delim9+1); + string::size_type delim11 = line.find(CACHE_SEP, delim10+1); + string::size_type delim12 = line.find(CACHE_SEP, delim11+1); + string::size_type delim13 = line.find(CACHE_SEP, delim12+1); + + binary_info b_info; + b_info.directory = line.substr(0, delim1); + b_info.filename = line.substr(delim1+1, delim2-delim1-1); + b_info.binary_format = line.substr(delim2+1, delim3-delim2-1); + b_info.uid1 = line.substr(delim3+1, delim4-delim3-1); + b_info.uid2 = line.substr(delim4+1, delim5-delim4-1); + b_info.uid3 = line.substr(delim5+1, delim6-delim5-1); + b_info.secureid = line.substr(delim6+1, delim7-delim6-1); + b_info.vendorid = line.substr(delim7+1, delim8-delim7-1); + b_info.capabilities = Str2Int( line.substr(delim8+1, delim9-delim8-1) ); + b_info.min_heap_size = Str2Int( line.substr(delim9+1, delim10-delim9-1) ); + b_info.max_heap_size = Str2Int( line.substr(delim10+1, delim11-delim10-1) ); + b_info.stack_size = Str2Int( line.substr(delim11+1, delim12-delim11-1) ); + b_info.mod_time = Str2Int( line.substr(delim12+1, delim13-delim12-1) ); + unsigned int number_of_deps = Str2Int( line.substr(delim13+1, line.length()-delim13-1) ); + + vector deps; + for (unsigned int j=0; j imps; + for (unsigned int k=0; k symbol_table; + + if (_cl_print_debug) + cerr << "Processing " << a_target.release_lib_dir << a_target.lib_files.at(i) << "..."; + + // if not generating a clean cache, check if this file was already in the cache + if (!_cl_generate_clean_cache) + { + // first try to find existing file + bool update_file = false; + int position = 0; + + for (unsigned int j=0; j symbol_table = a_target.import_libraries.at(i).symbol_table; + + symtabcachef << a_target.import_libraries.at(i).directory << CACHE_SEP << a_target.import_libraries.at(i).filename << CACHE_SEP + << a_target.import_libraries.at(i).mod_time << CACHE_SEP << symbol_table.size() << endl; + + for (unsigned int j=0; j deps = a_target.binaries.at(i).dependencies; + + depcachef << a_target.binaries.at(i).directory << CACHE_SEP << a_target.binaries.at(i).filename << CACHE_SEP + << a_target.binaries.at(i).binary_format << CACHE_SEP << a_target.binaries.at(i).uid1 << CACHE_SEP + << a_target.binaries.at(i).uid2 << CACHE_SEP << a_target.binaries.at(i).uid3 << CACHE_SEP + << a_target.binaries.at(i).secureid << CACHE_SEP << a_target.binaries.at(i).vendorid << CACHE_SEP + << a_target.binaries.at(i).capabilities << CACHE_SEP << a_target.binaries.at(i).min_heap_size << CACHE_SEP + << a_target.binaries.at(i).max_heap_size << CACHE_SEP << a_target.binaries.at(i).stack_size << CACHE_SEP + << a_target.binaries.at(i).mod_time << CACHE_SEP << deps.size() << endl; + + for (unsigned int j=0; j imps = deps.at(j).imports; + + depcachef << deps.at(j).filename << CACHE_SEP << imps.size() << endl; + + for (unsigned int k=0; k deps; + vector tempVector; + + // init defaults + b_info.binary_format = UNKNOWN; + b_info.uid1 = UNKNOWN; + b_info.uid2 = UNKNOWN; + b_info.uid3 = UNKNOWN; + b_info.secureid = NOT_VALID; + b_info.vendorid = NOT_VALID; + b_info.capabilities = 0; + b_info.min_heap_size = 0; + b_info.max_heap_size = 0; + b_info.stack_size = 0; + + // execute petran + string cmd; + + if (_cl_use_gcce || _cl_use_rvct) + cmd = petran_location + " -dump hi \"" + b_info.directory + b_info.filename + "\" " + CERR_TO_NULL; + else + cmd = petran_location + " \"" + b_info.directory + b_info.filename + "\" " + CERR_TO_NULL; + + //cerr << cmd << endl; + ExecuteCommand(cmd, tempVector); + + // get binary format, assuming it's the first line which begings with EPOC + for (unsigned int j=0; j imps; // imports + string filename = ms2+ms3; + + // get position of the filename in import libaries + int lib_pos = -1; + for (unsigned int x=0; x<_all_import_library_infos.size(); x++) + { + if (StringICmpFileNamesWithoutExtension(_all_import_library_infos.at(x).filename, filename) == 0) + { + lib_pos = x; + break; + } + } + + + // read ordinal numbers + for (unsigned int k=0; k= 0) + { + if (imp.funcpos-1 < _all_import_library_infos.at(lib_pos).symbol_table.size()) + imp.funcname = _all_import_library_infos.at(lib_pos).symbol_table.at(imp.funcpos-1); + else + imp.funcname = "BC break: This ordinal position is not in the import library!"; + } + else + { + imp.funcname = "Import library not found!"; + } + + // Checking for possible duplicate imported function ordinals. + import compare[] = { imp }; + vector::iterator it = find_first_of(imps.begin(), imps.end(), compare, compare+1, ImportFunctionsHasSameOrdinal); + if(it == imps.end()) + { + // No duplicate detected. Appending ordinal data to the array. + imps.push_back(imp); + } + + } + + // append to the vector + + dependency dep; + dep.filename = filename; + dep.imports = imps; + + deps.push_back( dep ); + + } + } + + break; //for (int j=0; j& symbol_table) +{ + symbol_table.clear(); + vector tempVector; + vector ordinals; + + // execute nm + string cmd = nm_location + " --demangle \"" + lib_directory + lib_name + "\""; + ExecuteCommand(cmd, tempVector); + + + // parse the results of the command + for (unsigned int j=0; j& symbol_table) +{ + symbol_table.clear(); + vector tempVector; + vector ordinals; + + // execute readelf + // note: 2>NUL is used here to redirect standard error output to NULL since readelf seems to output lots of unwanted warning messages + string cmd = readelf_location + " -s -W \"" + lib_directory + lib_name + "\" " + CERR_TO_NULL; + ExecuteCommand(cmd, tempVector); + + + // parse the results of the command + for (unsigned int j=0; j& symbol_table) +{ + symbol_table.clear(); + vector tempVector; + vector ordinals; + + // execute armar + string cmd = armar_location + " --zs \"" + lib_directory + lib_name + "\""; + ExecuteCommand(cmd, tempVector); + + // parse the results of the command + for (unsigned int j=0; j& symbol_table) +{ + symbol_table.clear(); + vector tempVector; + vector ordinals; + + // execute fromelf + string cmd = fromelf_location + " -s \"" + lib_directory + lib_name + "\""; + ExecuteCommand(cmd, tempVector); + + // parse the results of the command + for (unsigned int j=0; j& ordinals, vector& symbol_table, const string& lib_path) +{ + // remove any invalid ordinals from the list + vector ordinalVectorCopy; + ordinalVectorCopy.reserve(ordinals.size()); + + for (unsigned int i=0; i 32000) + { + cerr << "Error: Invalid ordinal " << ordinals.at(i).funcname << " @ " << Int2Str(ordinals.at(i).funcpos) << endl; + } + else + { + ordinalVectorCopy.push_back(ordinals.at(i)); + } + } + + // sort the ordinal list + sort(ordinalVectorCopy.begin(), ordinalVectorCopy.end(), OrdinalCompare); + + // now check that there are no missing ordinals in the list + unsigned int previous_ordnumber = 0; + unsigned int current_ordnumber = 1; + for (unsigned int i=0; i25000) + { + cerr << endl << "Something went horribly wrong when trying to parse " << lib_path << ". Aborting." << endl; + exit(10); + } + } + + // finally copy data from the ordinal list to the symbol table + if (symbol_table.size() < ordinalVectorCopy.size()) + { + symbol_table.reserve(ordinalVectorCopy.size()); + } + for (unsigned int i=0; i& symbol_table) +{ + ofstream f(_tempfile_location.c_str(), ios::trunc); + if (f.is_open()) + { + // create a temp file which contain all the function names + for (unsigned int k=0; k cfilt_result_set; + string cmd = cfilt_location + " < " + _tempfile_location; + ExecuteCommand(cmd, cfilt_result_set); + + // check that all functions exist and then replace the symbol table with demangled functions + if (cfilt_result_set.size() == symbol_table.size()) + { + symbol_table = cfilt_result_set; + } + } + else + { + f.close(); + } +} + +// ---------------------------------------------------------------------------------------------------------- + +bool OrdinalCompare(const ordinal& left, const ordinal& right) +{ + return left.funcpos < right.funcpos; +} + +// ---------------------------------------------------------------------------------------------------------- + + diff -r 000000000000 -r 509e4801c378 srcanamdw/appdep/src/appdep_otherfunc.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanamdw/appdep/src/appdep_otherfunc.cpp Sat Jan 09 10:04:12 2010 +0530 @@ -0,0 +1,708 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Other non-categorized AppDep functionality +* +*/ + + +#include "appdep.hpp" + +// ---------------------------------------------------------------------------------------------------------- + +void ParseCommandLineParameters(int argc, char* argv[]) +{ + // loop through the command line parameters and check their usage + int i=1; + while (i 0) + _targets.push_back(new_target); + + last_found_plus_pos = plus_pos; + i = last_found_plus_pos; + } + } + + // set more values of targets vector + for (unsigned int i=0; i<_targets.size(); i++) + { + // set path where release the release can be found, eg z:\epoc32\release\armv5\ . + _targets.at(i).release_dir = _cl_releasedir + EPOC32_RELEASE + _targets.at(i).name + DIR_SEPARATOR; + + // set path where the import libraries of the release can be found, eg z:\epoc32\release\armv5\lib\ . + string lib_dir; + if (_cl_use_gcce || _cl_use_rvct) + lib_dir = "lib"; // lib dir used in Symbian OS 9.x + else + lib_dir = _target_mode; + + _targets.at(i).release_lib_dir = _targets.at(i).release_dir + lib_dir + DIR_SEPARATOR; + + // set path where the binaries of the release can be found, eg z:\epoc32\release\armv5\urel\ . + _targets.at(i).release_bin_dir = _targets.at(i).release_dir + _target_mode + DIR_SEPARATOR; + + // set location of the cache files of this target, eg z:\caches\armv5\urel\xxx.txt + _targets.at(i).cache_dir = _cl_cachedir + _targets.at(i).name + DIR_SEPARATOR + _target_mode + DIR_SEPARATOR; + _targets.at(i).st_cache_path = _targets.at(i).cache_dir + CACHE_ST_FILENAME; + _targets.at(i).dep_cache_path = _targets.at(i).cache_dir + CACHE_DEP_FILENAME; + + // check if those cache files exists + _targets.at(i).cache_files_valid = FileExists(_targets.at(i).st_cache_path) && FileExists(_targets.at(i).dep_cache_path); + } +} + +// ---------------------------------------------------------------------------------------------------------- + +void DoCacheGenerationChecksAndPreparations() +{ + if (!_cl_use_gcc && !_cl_use_gcce && !_cl_use_rvct) + { + cerr << "ERROR: No tool chain defined!" << endl; + cerr << "Type appdep -? for help" << endl; + exit(EXIT_WRONG_USAGE); + } + + if (_cl_use_rvct && _cl_cfiltloc.empty()) + { + cerr << "ERROR: Specify -cfilt when RVCT is defined!" << endl; + cerr << "Type appdep -? for help" << endl; + exit(EXIT_WRONG_USAGE); + } + + if ( (_cl_use_gcc && (_cl_use_gcce || _cl_use_rvct)) || (_cl_use_gcce && (_cl_use_gcc || _cl_use_rvct)) || + (_cl_use_rvct && (_cl_use_gcc || _cl_use_gcce)) ) + { + cerr << "ERROR: Specify only one tool chain!" << endl; + cerr << "Type appdep -? for help" << endl; + exit(EXIT_WRONG_USAGE); + } + + // make sure the vectors are empty when generating clean cache + if (_cl_generate_clean_cache) + { + for (unsigned int i=0; i<_targets.size(); i++) // loop each target + { + _targets.at(i).import_libraries.clear(); + _targets.at(i).binaries.clear(); + } + } + + // if tools parameter is empty, try get it from path, otherwise check given parameter + if (_cl_toolsdir.empty()) + { + GetToolsPathFromEnvironmentVariable(); + } + else + { + // check the given tools directory parameter is valid + if (_cl_use_gcc) + { + _gcc_nm_location = _cl_toolsdir + GCC_NM_EXE; + + if (!FileExists(_gcc_nm_location)) + { + cerr << "ERROR: Unable to find " + _gcc_nm_location << ", check -tools parameter" << endl; + cerr << "Tip: GCC is typically installed to \\epoc32\\gcc\\bin directory" << endl; + exit(EXIT_TOOLCHAIN_NOT_FOUND); + } + + // extra quotes needed to prevent white space problems while executing the tool + InsertQuotesToFilePath(_gcc_nm_location); + } + + else if (_cl_use_gcce) + { + _gcce_nm_location = _cl_toolsdir + GCCE_NM_EXE; + _gcce_readelf_location = _cl_toolsdir + GCCE_READELF_EXE; + _gcce_cfilt_location = _cl_toolsdir + GCCE_CFILT_EXE; + + if (!FileExists(_gcce_nm_location)) + { + cerr << "ERROR: Unable to find " + _gcce_nm_location << ", check -tools param" << endl; + cerr << "Tip: GCCE is typically installed to C:\\Program Files\\CSL Arm Toolchain\\bin" << endl; + exit(EXIT_TOOLCHAIN_NOT_FOUND); + } + + if (!FileExists(_gcce_readelf_location)) + { + cerr << "ERROR: Unable to find " + _gcce_readelf_location << ", check -tools param" << endl; + cerr << "Tip: GCCE is typically installed to C:\\Program Files\\CSL Arm Toolchain\\bin" << endl; + exit(EXIT_TOOLCHAIN_NOT_FOUND); + } + + if (!FileExists(_gcce_cfilt_location)) + { + cerr << "ERROR: Unable to find " + _gcce_cfilt_location << ", check -tools param" << endl; + cerr << "Tip: GCCE is typically installed to C:\\Program Files\\CSL Arm Toolchain\\bin" << endl; + exit(EXIT_TOOLCHAIN_NOT_FOUND); + } + + // extra quotes needed to prevent white space problems while executing the tool + InsertQuotesToFilePath(_gcce_nm_location); + InsertQuotesToFilePath(_gcce_readelf_location); + InsertQuotesToFilePath(_gcce_cfilt_location); + + } + + else if (_cl_use_rvct) + { + _rvct_armar_location = _cl_toolsdir + RVCT_ARMAR_EXE; + _rvct_fromelf_location = _cl_toolsdir + RVCT_FROMELF_EXE; + + if (!FileExists(_rvct_armar_location)) + { + cerr << "ERROR: Unable to find " + _rvct_armar_location << ", check -tools param" << endl; + cerr << "Tip: Check your environment variables to see the directory where RVCT has been installed" << endl; + exit(EXIT_TOOLCHAIN_NOT_FOUND); + } + + if (!FileExists(_rvct_fromelf_location)) + { + cerr << "ERROR: Unable to find " + _rvct_fromelf_location << ", check -tools param" << endl; + cerr << "Tip: Check your environment variables to see the directory where RVCT has been installed" << endl; + exit(EXIT_TOOLCHAIN_NOT_FOUND); + } + + // extra quotes needed to prevent white space problems while executing the tool + InsertQuotesToFilePath(_rvct_armar_location); + InsertQuotesToFilePath(_rvct_fromelf_location); + } + } // else of if (!cl_toolsdir) + + + // check path of RVCT's cfilt is correct + if (_cl_use_rvct) + { + _rvct_cfilt_location = _cl_cfiltloc; + + if (!FileExists(_rvct_cfilt_location)) + { + cerr << "ERROR: Unable to find " + _rvct_cfilt_location << ", check -cfilt param" << endl; + cerr << "Tip: Working cfilt.exe can be found from the same directory where appdep has been installed" << endl; + exit(EXIT_CFILT_NOT_FOUND); + } + + // extra quotes needed to prevent white space problems while executing the tool + InsertQuotesToFilePath(_rvct_cfilt_location); + } + + + // check Petran can be found + SetAndCheckPetranPath(); + + // loop all targets + for (unsigned int i=0; i<_targets.size(); i++) + { + // check directories for given targets are valid + if (!DirectoryExists(_targets.at(i).release_dir)) + { + cerr << "ERROR: Directory " << _targets.at(i).release_dir << " not found!" << endl; + cerr << "Please check that -targets parameter is valid and you have a full release environment" << endl; + exit(EXIT_TARGETDIR_NOT_FOUND); + } + else + { + //cerr << "NOTE: " << targets.at(i) << " is a valid target in your release" << endl; + } + + // make sure that the cache directory exists + MkDirAll(_targets.at(i).cache_dir); + } + + // check that it is possible to create the temporary file under the cache directory + _tempfile_location = _cl_cachedir + TEMP_FILENAME; + ofstream tempf(_tempfile_location.c_str(), ios::trunc); + if (!tempf.is_open()) + { + tempf.close(); + cerr << "ERROR: Cannot open " << _tempfile_location << " for writing!" << endl; + cerr << "Please check that the directory exists and there are no write permission problems" << endl; + exit(EXIT_CANNOT_WRITE_TO_TEMP_FILE); + } + else + tempf.close(); + +} + +// ---------------------------------------------------------------------------------------------------------- + +void GetToolsPathFromEnvironmentVariable() +{ + #ifdef WIN32 + // get path environment variable + const char* env_path = getenv("PATH"); + + if (env_path != NULL) + { + string env_path_str = env_path; + + string::size_type previous_delimpos = 0; + bool match_found(false); + string test_path; + + for (unsigned int i=0; i5000) + break; // something went wrong.. + } + + if (!match_found) + { + cerr << "ERROR: Cannot find specified compiler toolset from PATH environment" << endl; + cerr << "Fix PATH environment variable or specify -tools parameter" << endl; + exit(EXIT_TOOLCHAIN_NOT_FOUND_FROM_PATH); + } + + } + else + { + cerr << "ERROR: PATH environment variable not available, please specify -tools parameter" << endl; + exit(EXIT_PATH_VARIABLE_NOT_FOUND); + } + + #else + + cerr << "ERROR: Optional -tools parameter is only supported in Windows environment " << endl; + exit(EXIT_ONLY_SUPPORTED_IN_WIN32); + + #endif + +} + +// ---------------------------------------------------------------------------------------------------------- + +void FindImportLibrariesAndBinariesFromReleases() +{ + // check if analysing .dso or .lib files + string lib_filter; + if (_cl_use_gcc || _cl_use_libs) // for GCC use always .lib files + lib_filter = "*.lib"; + else + lib_filter = "*.dso"; + + for (unsigned int i=0; i<_targets.size(); i++) // loop each target + { + // get import libraries + GetFileNamesFromDirectory(_targets.at(i).release_lib_dir, lib_filter, _targets.at(i).lib_files); + _max_progress += _targets.at(i).lib_files.size(); + + // get binaries + GetFileNamesFromDirectory(_targets.at(i).release_bin_dir, "*.app", _targets.at(i).bin_files); + GetFileNamesFromDirectory(_targets.at(i).release_bin_dir, "*.exe", _targets.at(i).bin_files); + GetFileNamesFromDirectory(_targets.at(i).release_bin_dir, "*.dll", _targets.at(i).bin_files); + GetFileNamesFromDirectory(_targets.at(i).release_bin_dir, "*.prt", _targets.at(i).bin_files); + GetFileNamesFromDirectory(_targets.at(i).release_bin_dir, "*.?sy", _targets.at(i).bin_files); + GetFileNamesFromDirectory(_targets.at(i).release_bin_dir, "*.fep", _targets.at(i).bin_files); + GetFileNamesFromDirectory(_targets.at(i).release_bin_dir, "*.agt", _targets.at(i).bin_files); + GetFileNamesFromDirectory(_targets.at(i).release_bin_dir, "*.fxt", _targets.at(i).bin_files); + + // increase the value of total number of files + _max_progress += _targets.at(i).bin_files.size(); + } +} + +// ---------------------------------------------------------------------------------------------------------- + +void GetFileNamesFromDirectory(const string& directory, const string& filter, vector& resultset) +{ + // get list of files from the directory by executing OS specific dir/ls command + string dir_command = DIR_COMMAND; + string cmd = dir_command + " \"" + directory + "\"" + filter + " " + CERR_TO_NULL; + + vector tempVector; + ExecuteCommand(cmd, tempVector); + + // loop through all returned files + for (unsigned int i=0; i 0) + _sisfiles.push_back(sis_file); + + last_found_semicolon_pos = semicolon_pos; + i = last_found_semicolon_pos; + } + } + + // check that all given sisfiles can be found and it is supported + for (unsigned int i=0; i<_sisfiles.size(); i++) + { + // report an error if the file does not exist + if (!FileExists(_sisfiles.at(i))) + { + cerr << "ERROR: Unable to find " + _sisfiles.at(i) << ", check -sisfiles parameter" << endl; + exit(EXIT_SIS_FILE_NOT_FOUND); + } + + // open the sis file for reading to check if it is supported + ifstream sisf(_sisfiles.at(i).c_str(), ios::binary); + if (sisf.is_open()) + { + int c1, c2, c3, c4; + c1 = sisf.get(); + c2 = sisf.get(); + c3 = sisf.get(); + c4 = sisf.get(); + + // in valid sis first four bytes of the file are 7A1A2010 + if (c1==0x7A && c2==0x1A && c3==0x20 && c4==0x10) + { + //cerr << _sisfiles.at(i) << " is supported" << endl; + } + else + { + // if starting from offset 8, four next bytes are 19040010, the file is + // unsupported SIS file used in previous Symbian OS releases. + sisf.seekg(8, ios::beg); + c1 = sisf.get(); + c2 = sisf.get(); + c3 = sisf.get(); + c4 = sisf.get(); + sisf.close(); + + if (c1==0x19 && c2==0x04 && c3==0x00 && c4==0x10) + { + cerr << "ERROR: " + _sisfiles.at(i) << " is a pre-Symbian OS 9.x" << endl; + cerr << "sisfile which is not supported, check -sisfiles parameter" << endl; + exit(EXIT_SIS_FILE_NOT_SUPPORTED); + } + else + { + cerr << "ERROR: " + _sisfiles.at(i) << " is not a valid sis file," << endl; + cerr << "check -sisfiles parameter" << endl; + exit(EXIT_NOT_SIS_FILE); + } + } + sisf.close(); + } + else + { + cerr << "ERROR: Cannot open " + _sisfiles.at(i) << " for reading, check -sisfiles parameter" << endl; + exit(EXIT_SIS_FILE_CANNOT_OPEN_FOR_READING); + } + } +} + +// ---------------------------------------------------------------------------------------------------------- + +void AnalyseSisFiles() +{ + // create a new target and set some defaults + target sis_target; + sis_target.name = "sis"; + sis_target.cache_dir = _cl_cachedir + sis_target.name + DIR_SEPARATOR; + sis_target.dep_cache_path = sis_target.cache_dir + CACHE_DEP_FILENAME; + + cerr << "Analysing sis files..." << endl; + + // define path to a temp directory where dumpsis will extract the files + const string tempdir = _cl_cachedir + SIS_TEMP_DIR + DIR_SEPARATOR; + const string tempdir2 = _cl_cachedir + SIS_TEMP_DIR; + + // do analysis for each file + for (unsigned int i=0; i<_sisfiles.size(); i++) + { + // create the temporary directory + MkDirAll(tempdir); + + cerr << "Binaries in " << _sisfiles.at(i) << " are:" << endl; + + // due to bugginess of a specific version of dumpsis, we need to copy the source file under the temporary directory + const string new_sis_loc = tempdir + "tempsis.sis"; + + ifstream src_sis_f(_sisfiles.at(i).c_str(), ios::binary); + if (src_sis_f.is_open()) + { + ofstream trgt_sis_f(new_sis_loc.c_str(), ios::binary); + if (trgt_sis_f.is_open()) + { + // read all bytes from source and write to the target + int c1; + + while(!src_sis_f.eof()) + { + c1 = src_sis_f.get(); + trgt_sis_f.put(c1); + } + + trgt_sis_f.close(); + + } + else + { + cerr << "ERROR: Cannot open " + new_sis_loc << " for writing, check write permissions" << endl; + exit(EXIT_TEMP_SIS_FILE_CANNOT_OPEN_FOR_WRITING); + } + + src_sis_f.close(); + + } + else + { + cerr << "ERROR: Cannot open " + _sisfiles.at(i) << " for reading, check -sisfiles parameter" << endl; + exit(EXIT_SIS_FILE_CANNOT_OPEN_FOR_READING); + } + + + + // execute dumpsis + string cmd = _dumpsis_location + " -x -d \"" + tempdir2 + "\" \"" + new_sis_loc + "\" " + CERR_TO_NULL; + + vector tempVector; + ExecuteCommand(cmd, tempVector); + + + // check if pkg file found + string pkgfile_location = tempdir + "tempsis.pkg"; + + if (!FileExists(pkgfile_location)) + { + // try again with an alternative + pkgfile_location = tempdir + "tempsis.sis.pkg"; + + if (!FileExists(pkgfile_location)) + { + RemoveDirectoryWithAllFiles(tempdir); + cerr << "ERROR: Dumpsis failed for " << _sisfiles.at(i) << " since it does not contain a pkg file, check -sisfiles parameter" << endl; + exit(EXIT_NO_PKG_FILE_FOUND); + } + } + + // open the pkg file for reading + ifstream pkgf(pkgfile_location.c_str(), ios::binary); + if (pkgf.is_open()) + { + int c1, c2; + c1 = pkgf.get(); + c2 = pkgf.get(); + + // we only support unicode format + if (c1 == 0xFF && c2 == 0xFE) + { + string line; + + // read more chars + while(!pkgf.eof()) + { + c1 = pkgf.get(); + c2 = pkgf.get(); + + // if (c1 == 0x0D && c2 == 0x00) // new line marker #1 + // { + // c1 = pkgf.get(); + // c2 = pkgf.get(); + + if (c1 == 0x0A && c2 == 0x00) // new line marker #2 + { + // full line is now available, parse it + + boost::regex re1("^\\\"(.+)\\\"-\\\".*\\\\(\\S+)\\\",.*$"); + boost::cmatch matches1; + if (boost::regex_match(line.c_str(), matches1, re1)) + { + // match found + string ms1(matches1[1].first, matches1[1].second); // source name + string ms2(matches1[2].first, matches1[2].second); // target name + + binary_info b_info; + b_info.directory = tempdir; + b_info.filename = ms1; + + GetImportTableWithPetran(_petran_location, b_info); + + // make sure that Petran succeeded for this file since we don't do any file + // extension checks when parsering the file + if (b_info.binary_format != UNKNOWN) + { + // print name of the destination binary + cerr << ms2 << endl; + + b_info.directory = ""; + b_info.filename = ms2; + + // get statistics of the file and set the modification time + struct stat stat_p; + stat((tempdir + ms1).c_str(), &stat_p); + b_info.mod_time = stat_p.st_mtime; + + // create a new entry to list of binary files + sis_target.binaries.push_back( b_info ); + } + + } + + // clear the buffer since we start scanning another line + line = ""; + } + //} + else + { + char c(c1); // simple unicode to ascii conversion, just ignore c2 + line += c; // append the char to end of the line + } + } + } + else + { + pkgf.close(); + RemoveDirectoryWithAllFiles(tempdir); + cerr << "ERROR: Pkg file " + pkgfile_location << " is not supported, check -sisfiles parameter" << endl; + exit(EXIT_PKG_FILE_CANNOT_OPEN_FOR_READING); + } + + } + else + { + RemoveDirectoryWithAllFiles(tempdir); + cerr << "ERROR: Cannot open " + pkgfile_location << " for reading, check -sisfiles parameter" << endl; + exit(EXIT_PKG_FILE_CANNOT_OPEN_FOR_READING); + } + + // close handles and clear any temp files + pkgf.close(); + RemoveDirectoryWithAllFiles(tempdir); + } + + // make sure that the cache directory exists + MkDirAll(sis_target.cache_dir); + + // write the dependencies cache of the sis files + WriteDataToDependenciesCacheFile(sis_target); + + // append to targets + _targets.push_back(sis_target); + + cerr << endl; + +} + +// ---------------------------------------------------------------------------------------------------------- + + diff -r 000000000000 -r 509e4801c378 srcanamdw/appdep/src/appdep_statdeps.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanamdw/appdep/src/appdep_statdeps.cpp Sat Jan 09 10:04:12 2010 +0530 @@ -0,0 +1,189 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Handling of StaticDependencies.txt +* +*/ + + +#include "appdep.hpp" + + +// ---------------------------------------------------------------------------------------------------------- +// Note that in C/C++ code \ has been replaced with \\ and " with \". +// ---------------------------------------------------------------------------------------------------------- + +void GetDataFromStaticDependenciesTxt() +{ + // read cache data from given StaticDependencies.txt + if (!FileExists(_cl_usestaticdepstxt)) + { + cerr << "ERROR: Unable to find " + _cl_usestaticdepstxt << ", check -usestaticdepstxt param" << endl; + cerr << "Please note that this parameter is required only if you use StaticDependencies.txt." << endl; + exit(EXIT_CANNOT_OPEN_STATIC_DEPENDENCIES_TXT); + } + + ifstream staticdepsf(_cl_usestaticdepstxt.c_str()); + string line; + + getline(staticdepsf, line); + if (line != "# Full direct component mapping:") + { + cerr << "ERROR: " << _cl_usestaticdepstxt << " is not a supported StaticDependencies.txt file!" << endl; + staticdepsf.close(); + exit(EXIT_OPENED_STATIC_DEPENDENCIES_TXT_NOT_SUPPORTED); + } + else + { + cerr << "Warning: Use of StaticDependencies.txt may provide incomplete results..." << endl; + + bool line_was_consumed = true; + + // loop through all lines in the file + while(!staticdepsf.eof()) + { + // get a line + if (line_was_consumed) + getline(staticdepsf, line); + + if (line == "# Full inverse component mapping:") + { + // no interesting lines in this file anymore, break the loop + break; + } + + // first line is the executable type, eg + // armv5::screengrabber (exe) + boost::regex re1("^(\\S+)::(\\S+)\\s\\((\\S+)\\).*"); + boost::cmatch matches1; + if (boost::regex_match(line.c_str(), matches1, re1)) + { + // match found + string ms1(matches1[1].first, matches1[1].second); // binary type + string ms2(matches1[2].first, matches1[2].second); // filename + string ms3(matches1[3].first, matches1[3].second); // extension + + line_was_consumed = true; + + binary_info b_info; + b_info.directory = UNKNOWN; + b_info.filename = ms2 + "." + ms3; + b_info.binary_format = ms1 + " " +ms3; + b_info.uid1 = UNKNOWN; + b_info.uid2 = UNKNOWN; + b_info.uid3 = UNKNOWN; + b_info.secureid = UNKNOWN; + b_info.vendorid = UNKNOWN; + b_info.capabilities = 0; + b_info.min_heap_size = 0; + b_info.max_heap_size = 0; + b_info.stack_size = 0; + b_info.mod_time = 0; + + vector deps; + for (;;) + { + // get a line + if (line_was_consumed) + getline(staticdepsf, line); + + // check for dependency line, eg + // screengrabber -> euser + boost::regex re2("^\\s\\s\\s(\\S+)\\s->\\s(\\S+).*"); + boost::cmatch matches2; + if (boost::regex_match(line.c_str(), matches2, re2)) + { + // match found + string ms1(matches2[1].first, matches2[1].second); // filename + string ms2(matches2[2].first, matches2[2].second); // dependency + + line_was_consumed = true; + + dependency dep; + dep.filename = ms2 + ".dll"; // assumming that the file extension is always .dll + + vector imps; + for (;;) + { + if (line_was_consumed) + getline(staticdepsf, line); + + // check for function names, eg + // fref::screengrabber->euser.CActive::Cancel (1) + boost::regex re3("^\\s\\s\\s\\s\\s\\sfref::(\\S+)->(\\S+)\\.(\\S+)\\s\\((\\S+)\\).*"); + boost::cmatch matches3; + if (boost::regex_match(line.c_str(), matches3, re3)) + { + // match found + string ms1(matches3[1].first, matches3[1].second); // filename + string ms2(matches3[2].first, matches3[2].second); // dependency + string ms3(matches3[3].first, matches3[3].second); // functionname + string ms4(matches3[4].first, matches3[4].second); // ??? + + line_was_consumed = true; + + import imp; + imp.funcpos = 0; + imp.funcname = ms3; + imp.is_vtable = false; + imp.vtable_offset = 0; + + // append to the import info vector + imps.push_back( imp ); + } + else + { + // the line does not match, break the loop + line_was_consumed = false; + break; + } + + } // for (;;) + + // now we have import info too + dep.imports = imps; + + // append to the deps info vector + deps.push_back( dep ); + + } + else + { + // the line does not match, break the loop + line_was_consumed = false; + break; + } + } // for (;;) + + // now we have the dep info too + b_info.dependencies = deps; + + // apppend binary info to the vectory + _all_binary_infos.push_back( b_info ); + + } + else + { + // no match found, line was consumed anyway + line_was_consumed = true; + } // else of if (boost::regex_match(tempVector.at(j).c_str(), matches1, re1)) + + } // while(!staticdepsf.eof()) + } // else of if (line != "# Full direct component mapping:") + + // close handle to the cache file + staticdepsf.close(); +} + +// ---------------------------------------------------------------------------------------------------------- + diff -r 000000000000 -r 509e4801c378 srcanamdw/appdep/src/appdep_utils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanamdw/appdep/src/appdep_utils.cpp Sat Jan 09 10:04:12 2010 +0530 @@ -0,0 +1,379 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Misc utility functions +* +*/ + + +#include "appdep.hpp" + +// ---------------------------------------------------------------------------------------------------------- + +void PrintOutputLn(const string& s) +{ + // check if printing to a file or directory to STDOUT + if (!_cl_outputfile.empty()) + { + _outputf << s << endl; + } + else + { + cout << s << endl; + } +} + +// ---------------------------------------------------------------------------------------------------------- + +void MakeSureTrailingDirectoryMarkerExists(string& path) +{ + if (!path.empty() && path.at(path.length()-1) != DIR_SEPARATOR2) + { + path.insert(path.length(), DIR_SEPARATOR); + } +} + +// ---------------------------------------------------------------------------------------------------------- + +bool FileExists(const string& path) +{ + if (!path.empty()) + { + struct stat stat_p; + if (stat(path.c_str(), &stat_p) == 0) + return !S_ISDIR(stat_p.st_mode); // return true if not a directory + else + return false; // cannot find entry + } + else + return false; +} + +// ---------------------------------------------------------------------------------------------------------- + +bool DirectoryExists(const string& path) +{ + if (!path.empty()) + { + string temp_path = path; + + // remove trailing directory marker if exists + if (path.at(path.length()-1) == DIR_SEPARATOR2) + temp_path = path.substr(0, path.length()-1); + + struct stat stat_p; + if (stat(temp_path.c_str(), &stat_p) == 0) + return S_ISDIR(stat_p.st_mode); // return true if a directory + else + return false; // cannot find entry + } + else + return false; +} + +// ---------------------------------------------------------------------------------------------------------- + +bool RemoveFile(const string& path) +{ + return _unlink(path.c_str()) == 0; +} + +// ---------------------------------------------------------------------------------------------------------- + +bool RemoveDirectoryWithAllFiles(const string& path) +{ + string temp_path = path; + MakeSureTrailingDirectoryMarkerExists(temp_path); + + // remove all files in the directory via OS call + string del_command = DEL_ALL_COMMAND; + string cmd = del_command + " " + temp_path + "* " + CERR_TO_NULL; + + vector tempVector; + ExecuteCommand(cmd, tempVector); + + // finally tries to remove the directory, fails if not empty + return _rmdir(path.c_str()) == 0; +} + +// ---------------------------------------------------------------------------------------------------------- + +string LowerCase(const string& s) +{ + char* buf = new char[s.length()]; + s.copy(buf, s.length()); + + for(unsigned int i = 0; i < s.length(); i++) + buf[i] = tolower(buf[i]); + + string r(buf, s.length()); + delete buf; + return r; +} + +// ---------------------------------------------------------------------------------------------------------- + +void MkDirAll(const string& path) +{ + if (!path.empty() && !DirectoryExists(path)) + { + string target_path = path; + + // make sure that the directory has a trailing directory marker + MakeSureTrailingDirectoryMarkerExists(target_path); + + // loop through each character in the string and try to find directory delimeters + for (unsigned int i=0; i& resultset) +{ + // note, cannot use compiler parameters "-std=c++98" because of popen/pclose + // also cannot compile this code is MSVC because usage of popen/pclose + + FILE* fp; + char buffer[1024]; + string tempstr; + + resultset.clear(); + + if ((fp = _popen(command.c_str(), "r")) == NULL) + { + return false; + } + + while (fgets(buffer, sizeof(buffer), fp)) + { + tempstr = buffer; + resultset.push_back(tempstr.substr(0, tempstr.size()-1)); + } + + _pclose(fp); + + return true; +} + +// ---------------------------------------------------------------------------------------------------------- + +string& TrimRight(string& s) +{ + int pos(s.size()); + for (; pos && (s[pos-1]==' ' || s[pos-1]=='\t'); --pos); + s.erase(pos, s.size()-pos); + return s; +} + +// ---------------------------------------------------------------------------------------------------------- + +string& TrimLeft(string& s) +{ + int pos(0); + for (; s[pos]==' ' || s[pos]=='\t'; ++pos); + s.erase(0, pos); + return s; +} + +// ---------------------------------------------------------------------------------------------------------- + +string& TrimAll(string& s) +{ + return TrimLeft(TrimRight(s)); +} + +// ---------------------------------------------------------------------------------------------------------- + +int StringICmp(const string& s1, const string& s2) +{ + string ss1 = LowerCase(s1); + string ss2 = LowerCase(s2); + + return ss1.compare(ss2); +} + +// ---------------------------------------------------------------------------------------------------------- + +int StringICmpFileNamesWithoutExtension(const string& s1, const string& s2) +{ + // remove extension and then compare + string ss1; + string ss2; + + string::size_type dot_pos1 = s1.find_last_of('.'); + if (dot_pos1 == string::npos) + ss1 = s1; + else + ss1 = s1.substr(0, dot_pos1); + + string::size_type dot_pos2 = s2.find_last_of('.'); + if (dot_pos2 == string::npos) + ss2 = s2; + else + ss2 = s2.substr(0, dot_pos2); + + return StringICmp(ss1, ss2); +} + +// ---------------------------------------------------------------------------------------------------------- + +bool TimestampsMatches(const time_t& orginal_time, const time_t& new_time) +{ + // allow two second difference to both directions + if (new_time-2 <= orginal_time && orginal_time <= new_time+2) + return true; + else + return false; +} + +// ---------------------------------------------------------------------------------------------------------- + +string Int2Str(int value) +{ + ostringstream os; + if (os << value) + return os.str(); + else + return ""; +} + +// ---------------------------------------------------------------------------------------------------------- + +int Str2Int(const string& s) +{ + int res(0); + + // return 0 for empty string + if (s.empty()) + { + } + + // hex conversion if the string begings with 0x... + else if (s.length() >= 3 && s.at(0) == '0' && s.at(1) == 'x') + { + istringstream is(s); + is >> hex >> res; + if(!is || !is.eof()) + res = 0; + } + + // normal integer + else + { + istringstream is(s); + is >> res; + if(!is || !is.eof()) + res = 0; + } + + return res; +} + +// ---------------------------------------------------------------------------------------------------------- + +void InsertQuotesToFilePath(string& s) +{ + // example C:\Program Files\do something.exe -> C:\"Program Files"\"do something.exe" + + bool firstBacklashFound = false; + bool anyQuoteInserted = false; + + if (!s.empty()) + { + int s_length = s.length(); + + for (int i=0; i \" + s.insert(pos+1, "\""); + + anyQuoteInserted = true; + firstBacklashFound = true; + s_length++; + i = pos+1; + } + else + { + // replace \ -> "\" + s.insert(pos, "\""); + s.insert(pos+2, "\""); + + anyQuoteInserted = true; + s_length += 2; + i = pos+2; + } + } + + if (i>255) + return; // something went wrong.. + } + + // append extra quote to the end if needed + if (anyQuoteInserted) + s.insert(s.length(), "\""); + } +} + +// ---------------------------------------------------------------------------------------------------------- + +void ShowProgressInfo(unsigned int& current_progress_percentage, unsigned int& current_progress, unsigned int& max_progress, bool print_initial_value) +{ + if (print_initial_value) + { + cerr << "( 0% complete)"; + } + else + { + current_progress++; + + unsigned int temp_percentage = int( (double) current_progress / (double) max_progress * 100 ); + + if (temp_percentage > current_progress_percentage) + { + current_progress_percentage = temp_percentage; + cerr << "\b\b\b\b\b\b\b\b\b\b\b\b\b\b"; + + if (current_progress_percentage < 10) + cerr << " "; + else if (current_progress_percentage < 100) + cerr << " "; + cerr << current_progress_percentage << "% complete)"; + } + } +} + + +// ---------------------------------------------------------------------------------------------------------- diff -r 000000000000 -r 509e4801c378 srcanamdw/appdep/src/building_instructions.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srcanamdw/appdep/src/building_instructions.txt Sat Jan 09 10:04:12 2010 +0530 @@ -0,0 +1,49 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# + + +AppDep building instructions +============================ + +Windows platform +---------------- + +1) Set up MinGW and MSYS compiling environments + - Download MinGW installer 5.0.2 (or newer) from http://www.mingw.org + - Install MinGW including GCC compiler with version number at least 3.4.2 + - Download and install MSYS environment from http://www.mingw.org with + version number at least 1.0.11 + - Set "bin"-directories of both MinGW and MSYS to your path environment, eg + SET PATH=C:\APPS\MinGW\bin;C:\APPS\MSYS\bin;%PATH% + +2) Download Boost v1.33.1 from http://www.boost.org or directly from + http://sourceforge.net/project/showfiles.php?group_id=7586. Install it to any + folder + +3) Modify "BOOSTHOME"-variable in a file "group/MakeFile" in AppDep installation to + point to the directory where you installed Boost. + +4) With command prompt, go to the same "group" directory and type "make". + + + +Any other platform +------------------ + +Set up GCC compiling environment as usually and follow steps 2-4 just like in the +instructions for Windows platform. +