Font Size: a A A

Study And Implementation Of Source Code Analysis Method For Large-scale CMake Projects

Posted on:2020-04-02Degree:MasterType:Thesis
Country:ChinaCandidate:M M HanFull Text:PDF
GTID:2428330578457345Subject:Computer technology
Abstract/Summary:PDF Full Text Request
CMake is one of the mainstream compiler tools,which has the characteristics of open source,automation and cross-platform.The main configuration file for CMake is CMakeLists.txt,in which the compilation process of all platforms can be described by writing simple statements.CMake projects refer to projects that contain CMakeLists.txt files in each directory,which can be compiled and managed by CMake commands.CMake differs from other compiler tools in its cross-platform nature.Its cross-platform nature is mainly reflected in the fact that as long as there is a set of CMake compiler scripts,the executable project scripts can be compiled on each major platform,and developers can use the native build system of each platform to manage the project.However,at present,the design documents of CMake configuration files and the description documents of the compilation process are scarce,which make it difficult to develop and maintain CMake projects.Especially with the increasing scale and complexity of software systems,the above problems become more and more obvious.Only by understanding the construction process of a CMake project,can we better analyze its configuration files and the source codes of the whole project,so as to facilitate the development of CMake projects.Therefore,according to the characteristics of CMake configuration files,the research on source code analysis method of CMake project discussed in this paper has important practical significance and application value.Firstly,the basic knowledge of CMake project source code,CMakeLists.txt files,CMake tool and other related basic knowledge are briefly introduced.Then,the grammatical rules of the embedded functions provided by CMake for its configuration files,the organizational structure of the files and the processing methods of various statements in the files are described in detail.It focuses on the embedded functions called by the CMakeLists.txt file and the detailed parsing scheme of various statements in the file,as well as the analysis of all CMakeLists.txt files in each directory level by recursive processing.Based on the results of manual analysis program,integrated with the characteristic of the CMake project configuration files describe the compilation of the project,a source code analysis method of simulating the source code compilation and construction process of CMake projects is proposed.A prototype of CMake configuration file analysis based on embedded function invocations is constructed,and a complete program for simulating the compilation process of CMake project is designed and implemented.On this basis,the prototype is used to analyze and test the source codes of large-scale CMake projects with different functions,and verify the availability of the method and the accuracy of the results.In the meantime,the path of the source code of the project to be analyzed is obtained firstly;then,putting the top-level CMakeLists.txt file as a starting point,the whole project analysis is carried out,and the complete analysis process of the whole project is obtained;finally,the required information is extracted from the analysis process.The prototype test results of source code analysis method for CMake projects show that the method can accurately obtain the complete analysis process of the project.From the analysis process,we can easily get relevant information(for example the invocation relationship between functions).Compared with the relevant information obtained by manually analyzing the source codes,the accuracy rate is higher.Because of the high efficiency of the analysis process,it has a strong usa'bility,which is more helpful to understand the compilation and construction process of CMake projects and improve the comprehensibility of source codes.
Keywords/Search Tags:CMake, Configuration files for CMake, Compilation, Program analysis, Understandability
PDF Full Text Request
Related items