Software compilation optimization method, device and storage medium

By analyzing and optimizing the header and source file reference relationships in software engineering projects, files that affect compilation speed were identified and optimized, thus solving the problem of excessively long compilation cycles and improving development efficiency.

CN118550549BActive Publication Date: 2024-11-08ZHEJIANG DAHUA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411032128.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2024-11-08
Estimated Expiration
2044-07-30

AI Technical Summary

Technical Problem

In software engineering projects, as projects iterate and update, the complexity of the project increases, leading to a longer compilation cycle and impacting development efficiency. In particular, when projects are frequently generated, existing parallel compilation methods have failed to effectively solve the problem of low compilation efficiency.

Method used

By analyzing the reference relationships between header files and source files in a software engineering project, files that affect compilation speed are identified and optimized, including removing redundant and duplicate parts and optimizing the references and dependencies between header files and source files.

Benefits of technology

It improves the compilation efficiency of software engineering projects, shortens the compilation cycle, and enhances development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118550549B_ABST
    Figure CN118550549B_ABST
Patent Text Reader

Abstract

The present application discloses a software compilation optimization method, device and storage medium, the software compilation optimization method comprises: analyzing and processing each header file and each source file of the acquired software engineering project to obtain the reference relationship between each header file and each source file; determining the first header file from each header file and determining the first source file from each source file based on the reference relationship and the preset file screening rule; determining the second source file in each source file and determining the third source file in each source file based on the compilation result of each source file acquired during the compilation process; determining the header file to be optimized and / or the source file to be optimized based on the matching result between the first header file, the first source file, the second source file and the third source file; optimizing the header file to be optimized and / or the source file to be optimized to obtain the optimized software engineering project. The above scheme can improve the compilation efficiency of the software engineering project.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a software compilation optimization method, device and storage medium. Background Art

[0002] In the computer field, software engineering projects become more complex as they are gradually iterated and updated. In addition to the project code itself, many dependent sub-projects will continue to be added, which will gradually lengthen the project compilation and generation cycle.

[0003] Although the use of methods such as parallel compilation of sub-projects can improve the compilation and generation speed of the project, in the process of continuous integration of the project and when the project needs to be generated frequently, it still significantly affects the development cycle of the project and reduces the compilation and generation efficiency of the project.

[0004] Therefore, how to improve development efficiency has become one of the urgent issues to be solved. Summary of the invention

[0005] The present application at least provides a software compilation optimization method, apparatus, device and computer-readable storage medium.

[0006] The first aspect of the present application provides a software compilation optimization method, comprising: analyzing and processing each header file and each source file of an acquired software engineering project to obtain a reference relationship between each header file and each source file; determining a first header file from each header file and determining a first source file from each source file based on the reference relationship and a preset file screening rule; determining a second source file in each source file and determining a third source file in each source file based on the compilation results of each acquired source file during the compilation process; determining a header file to be optimized and / or a source file to be optimized based on a matching result among the first header file, the first source file, the second source file and the third source file; optimizing the header file to be optimized and / or the source file to be optimized to obtain an optimized software engineering project.

[0007] In one embodiment, determining the second source file in each source file and determining the third source file in each source file based on the compilation results of each source file obtained during the compilation process includes: obtaining the file size of the target file generated by each source file during the compilation process and the compilation time of each source file during the compilation process; screening each source file based on the file size of the target file to obtain the second source file; and screening each source file based on the compilation time to obtain the third source file.

[0008] In one embodiment, the filtering of each source file based on the file size of the target file to obtain the second source file; and the filtering of each source file based on the compilation time to obtain the third source file include: performing heap sorting on each source file based on the file size of the target file generated corresponding to each source file and a preset size filtering threshold to obtain the second source file; performing heap sorting on each source file based on the compilation time corresponding to each source file and a preset time filtering threshold to obtain the third source file.

[0009] In one embodiment, the determining of the header file to be optimized and / or the source file to be optimized based on the matching results among the first header file, the first source file, the second source file and the third source file comprises: matching the third source file with the first source file, taking the third source file that successfully matches the first source file as the first matching source file, and taking the third source file that fails to match the first source file as the source file to be optimized; matching the third source file with the second source file, taking the third source file that successfully matches the second source file as the second matching source file; matching the first matching source file with the second matching source file, determining the first header file referenced by the second matching source file that successfully matches as the header file to be optimized, and taking the second matching source file that fails to match as the source file to be optimized.

[0010] In one embodiment, the matching process of the third source file and the first source file includes: performing same-name matching process on the file name of the third source file and the file name of the first source file, so as to obtain a third source file that successfully matches the first source file, and a third source file that fails to match the first source file; the matching process of the third source file and the second source file includes: performing same-name matching process on the file name of the third source file and the file name of the second source file, so as to obtain a third source file that successfully matches the second source file; the matching process of the first matching source file and the second matching source file includes: performing same-name matching process on the file name of the first matching source file and the file name of the second matching source file, so as to obtain a second matching source file that successfully matches and a second matching source file that fails to match.

[0011] In one embodiment, the optimization processing of the header files to be optimized and / or the source files to be optimized to obtain the optimized software engineering project includes: searching for the source files to be processed corresponding to each header file to be optimized based on the reference relationship; obtaining the function types of each header file referenced by each source file to be processed; performing function deduplication processing on the header files with repeated function types in each source file to be processed; and / or extracting the preset code templates in each source file to be optimized, and performing external declaration processing on each preset code template to obtain the optimized source file; obtaining the dependency relationship of each optimized source file; performing dependency deduplication processing on the source files with repeated dependency relationships; and obtaining the optimized software engineering project.

[0012] In one embodiment, determining the first header file from each header file and determining the first source file from each source file based on the reference relationship and a preset file screening rule includes: determining the number of header files referenced by each source file and the number of times each header file is referenced based on the reference relationship; screening each source file based on the number of header files referenced by each source file to obtain the first source file; screening each header file based on the number of times each header file is referenced to obtain the first header file.

[0013] In one embodiment, before the obtained header files and source files of the software engineering project are analyzed and processed to obtain the reference relationship between the header files and the source files, it includes: in response to the compilation event triggering of the software engineering project, the solution included in the software engineering project is parsed to obtain the compilation information of the solution; if it is judged based on the compilation information that the solution has not been updated, the solution product corresponding to the solution is obtained according to a preset reuse list; if it is judged based on the compilation information that the solution has been updated, the solution is compiled.

[0014] The second aspect of the present application provides a software compilation optimization device, including: an analysis module, used to analyze and process each header file and each source file of the acquired software engineering project to obtain a reference relationship between each header file and each source file; a first determination module, used to determine a first header file from each header file and a first source file from each source file based on the reference relationship and a preset file screening rule; a second determination module, used to determine a second source file in each source file and a third source file in each source file based on the compilation results of each source file acquired during the compilation process; a matching module, used to determine a header file to be optimized and / or a source file to be optimized based on the matching results between the first header file, the first source file, the second source file and the third source file; an optimization module, used to optimize the header file to be optimized and / or the source file to be optimized to obtain an optimized software engineering project.

[0015] A third aspect of the present application provides an electronic device, including a memory and a processor, wherein the processor is used to execute program instructions stored in the memory to implement the above-mentioned software compilation optimization method.

[0016] A fourth aspect of the present application provides a computer-readable storage medium on which program instructions are stored, and when the program instructions are executed by a processor, the above-mentioned software compilation optimization method is implemented.

[0017] The above scheme obtains the reference relationship between each header file and each source file by analyzing and processing each header file and each source file of the acquired software engineering project; determines the first header file from each header file and determines the first source file from each source file based on the reference relationship and the preset file screening rule, thereby determining the header file and source file that may affect the compilation speed during the compilation process; determines the second source file in each source file and determines the third source file in each source file based on the compilation result of each source file obtained during the compilation process, thereby further determining the header file and source file that affect the compilation speed; therefore, the header file and / or the source file to be optimized can be located through the matching results among the first header file, the first source file, the second source file and the third source file; optimizes the header file and / or the source file to be optimized, optimizes the compilation process, and obtains the optimized software engineering project, thereby improving the compilation and development efficiency of the software project engineering.

[0018] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.

[0020] Figure 1 It is a flowchart of an exemplary embodiment of the software compilation optimization method of the present application;

[0021] Figure 2 It is an exemplary source file optimization schematic diagram in the software compilation optimization method of the present application;

[0022] Figure 3 It is a schematic diagram of an exemplary project multi-scheme continuous integration in the software compilation optimization method of the present application;

[0023] Figure 4 This is an exemplary project multi-scheme implementation flow chart in the software compilation optimization method of the present application;

[0024] Figure 5is a block diagram of a software compilation optimization device shown in an exemplary embodiment of the present application;

[0025] Figure 6 It is a structural schematic diagram of an embodiment of the electronic device of the present application;

[0026] Figure 7 It is a structural diagram of an embodiment of a computer-readable storage medium of the present application. DETAILED DESCRIPTION

[0027] The scheme of the embodiment of the present application is described in detail below in conjunction with the drawings of the specification.

[0028] In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures, interfaces, and technologies are provided to facilitate a thorough understanding of the present application.

[0029] The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the objects associated before and after are in an "or" relationship. In addition, "many" in this article means two or more than two. In addition, the term "at least one" in this article means any combination of at least two of any one or more of a plurality of, for example, including at least one of A, B, and C, can mean including any one or more elements selected from the set consisting of A, B, and C.

[0030] For ease of understanding, the application scenario of the present application is now described exemplarily. In the computer field, after a software engineering project has undergone a gradual iterative update process, the engineering complexity of the project will gradually increase. In addition to the engineering code of the project itself, there will be many dependent sub-projects that need to be added. The ensuing problem is that the compilation and generation cycle of the project will be gradually lengthened. Although the use of methods such as parallel compilation of sub-projects can increase the generation speed of the project, in the process of continuous integration of the project, when the project needs to be generated frequently, it still affects the development cycle of the project and reduces the work efficiency of R&D personnel. Therefore, improving the compilation speed / packaging speed of engineering projects is a problem that needs to be solved urgently.

[0031] Nowadays, with the widespread application and implementation of deep learning technology, algorithm solutions for complex tasks have also been adjusted from the original single algorithm solution to the integration of multiple algorithm solutions. In complex algorithm solutions, this application uses the method of compiling time analysis and positioning to find that the main time consumption of project compilation generation is concentrated in the following parts: the project code compilation time of each project (and sub-project / sub-solution), and the overall packaging time of multiple projects. Therefore, this application optimizes the above key time-consuming locations, saving a lot of manpower and material resources, and facilitating debugging and delivery by R&D personnel, thereby improving development efficiency.

[0032] For example, in the embodiments of the present application, software engineering projects in C or C++ programming languages ​​are mainly used as examples for explanation. For other programming languages ​​such as JAVA, those skilled in the art can still make appropriate improvements to the software compilation optimization of the present application according to their language rules and characteristics and apply them in the same way, which will not be elaborated here.

[0033] See also Figure 1 , Figure 1 This is a flowchart of an exemplary embodiment of the software compilation optimization method of the present application. Specifically, it may include the following steps:

[0034] Step S110 , analyzing and processing each header file and each source file of the acquired software engineering project to obtain a reference relationship between each header file and each source file.

[0035] In the C / C++ compilation scenario, the carrier file containing function and data interface declarations is usually called a header file, which is mainly used to store program declarations and has the file suffix ".h". For example, a header file can be a system header file (including header files in a standard library, or header files provided by a specific operating system. For example, <iostream>is a header file in the standard library, and<windows.h> It is a system header file provided by the Windows operating system), or it can be a custom header file set by R&D personnel for the software engineering project currently being developed, which is not limited here.

[0036] The source file is a collection of related elements with a file name defined by the creator (R&D personnel). Source files generally refer to the result of saving the code written in assembly language or high-level language (such as C or C++) as a file. Source files are relative to object files and executable files. Among them, the object file refers to the file composed of the target code that has been compiled by the compiler of the corresponding language but has not yet been linked by the linker. It is a binary file, and the suffix used by the target file is usually ".obj". The executable file refers to the file formed by linking the target code generated after compilation through the linker.

[0037] Generally speaking, each C / C++ program usually consists of header files and source files. Each header file can be referenced by one or more source files, and each source file can reference one or more header files, so that when the code in each source file is executed, the functions and / or variables in the header file referenced by the source file can be called without rewriting their definitions in the source file.

[0038] Therefore, in this embodiment, by analyzing the header files and source files of each software program in the current software engineering project, the reference relationship between each header file and each source file can be obtained, such as the number of header files and header file names referenced by each source file, and the number of times each header file is referenced, etc. Exemplarily, a python analysis script can be established to analyze and process the source files of the current engineering project to obtain the header files referenced by each source file in the engineering project.

[0039] Step S120 , determining a first header file from each header file and determining a first source file from each source file based on the reference relationship and a preset file screening rule.

[0040] The preset file screening rules may include one or more preset sorting algorithms, such as a heap sort algorithm, a bubble sort algorithm, an insertion sort algorithm or a quick sort algorithm, and then the sorted files are screened according to one or more preset thresholds to obtain the results, which will not be elaborated here.

[0041] Combined with the above steps, for complex software engineering projects, the number of header files and source files is very large. Optimizing some header files and source files does not bring obvious optimization effects, and system header files are usually not modified and optimized.

[0042] Therefore, in order to improve data processing efficiency, header files and source files can also be screened in this step. For example, header files and source files with complex reference relationships are screened out. Usually, due to the complex reference relationships between these header files and source files, they will become performance bottlenecks during code compilation and affect compilation efficiency.

[0043] Exemplarily, the current software engineering project to be optimized includes an initial header file and an initial source file, and the initial header file includes a system header file and a custom header file preset by the R&D personnel. In the process of using the analysis script to analyze each header file and each source file, N1 first source files can be screened out from each source file through the reference relationship between the header file and the source file (for example, the number of header files referenced by the source file, the number of times the header file is referenced by the source file, etc.) and the preset screening rules, and N2 first header files can be determined from each header file. It should be noted that the system header file can be ignored in the screening process, that is, only the reference relationship between the source file and the custom header file in the engineering project can be analyzed and processed, and the first header file and the first source file can be determined.

[0044] Step S130 , determining the second source file in each source file and determining the third source file in each source file based on the obtained compilation results of each source file in the compilation process.

[0045] Among them, the compilation results at least include the compilation time of each source file in the compilation process, and the file size of the target file generated after each source file is compiled. This can reflect the size of each source file to a certain extent, that is, it can characterize the degree of impact on the compilation efficiency during the compilation process.

[0046] Specifically, the second source file is determined from each source file according to the compilation time of each source file and the preset file screening rules (for example, the source file with a longer compilation time is screened out from each source file as the second source file), and the third source file is determined from each source file according to the size of the target file generated corresponding to each source file and the preset file screening rules (for example, the source file with a larger corresponding target file size in each source file is used as the third source file). It should be noted that there may be one or more file screening rules in the present application, that is, the file screening rules for determining the second source file and the file screening rules for determining the third source file in this step may be the same or different, which will not be elaborated here. Similarly, the file screening rules of this step may also be the same or different from the file screening rules of the previous step.

[0047] Step S140: determining a header file to be optimized and / or a source file to be optimized based on the matching results among the first header file, the first source file, the second source file, and the third source file.

[0048] In order to further determine the performance bottleneck position of the current software engineering project in the compilation process, the three factors of reference relationship, compilation time and target file size can be combined and analyzed in this step. Specifically, based on the matching results between the first header file, the first source file, the second source file and the third source file, the header file to be optimized and / or the source file to be optimized can be determined from these files, thereby determining the source file to be optimized that has a complex reference relationship, a long compilation time and a correspondingly generated target file is large, and the correspondingly screened header file can also be used as the header file to be optimized.

[0049] Step S150, optimizing the header file to be optimized and / or the source file to be optimized to obtain an optimized software engineering project.

[0050] The optimization process may include, but is not limited to, processing redundant parts and / or repeated parts in the header file to be optimized, and / or processing redundant parts and / or repeated parts in the source file to be optimized.

[0051] For example, each header file has a corresponding header file function. Therefore, in a complex software engineering project, there may be repeated function types between different header files (for example, between header file A and header file B). If a source file references these header files (header file A and header file B) at the same time, the contents of these header files will be called separately during the process of compiling the source file, resulting in repeated functions and thus reducing compilation efficiency.

[0052] Therefore, the present application optimizes the obtained header files to be optimized and / or source files to be optimized, which can reduce the redundancy of the software engineering project and thereby improve the subsequent compilation efficiency and development efficiency of the software engineering project.

[0053] It can be seen that the present application obtains the reference relationship between each header file and each source file by analyzing and processing the obtained header files and source files of the software engineering project; determines the first header file from each header file and the first source file from each source file based on the reference relationship and the preset file screening rules, thereby determining the header files and source files that may affect the compilation speed during the compilation process; determines the second source file in each source file and the third source file in each source file based on the compilation results of the obtained source files during the compilation process, and then further determines the header files and source files that affect the compilation speed; therefore, the header file to be optimized and / or the source file to be optimized can be located through the matching results between the first header file, the first source file, the second source file and the third source file; optimizes the header file to be optimized and / or the source file to be optimized, optimizes the compilation process, and obtains the optimized software engineering project, thereby improving the compilation and development efficiency of the software project engineering.

[0054] Based on the above embodiment, the embodiment of the present application describes the steps of determining the second source file in each source file and determining the third source file in each source file based on the compilation results of each source file obtained during the compilation process. Specifically, the method of this embodiment includes the following steps:

[0055] Obtain the file size of the target file generated by each source file during the compilation process and the compilation time of each source file during the compilation process; filter each source file based on the target file size to obtain a second source file; and filter each source file based on the compilation time to obtain a third source file.

[0056] In conjunction with the above-mentioned embodiment, the target file is a compilation product obtained after the source file is compiled and assembled (collectively referred to as the compilation process). Therefore, the compilation result at least includes the target file (target file size) corresponding to each source file and the compilation time corresponding to each source file. The second source file and the third source file are selected from each source file based on the target file size and the compilation time.

[0057] It should be noted that the specific screening method may include but is not limited to a sorting screening method, such as using an existing sorting algorithm to sort each source file based on the target file size, and to sort each source file based on the compilation time; and then filtering out the second source file from each source file sorted based on the target file size, and filtering out the second source file from each source file sorted based on the compilation time.

[0058] Among them, it can be to filter out a preset number of second source files and third source files; it can also be to filter out source files whose target file size is greater than or equal to a preset file size threshold as the second source files and filter out source files whose compilation time is greater than or equal to a preset time threshold as the third source files; or it can be another combination of the two screening methods, which is not limited here. In this way, N3 second source files filtered out based on the target file size and N4 third source files filtered out based on the compilation time can be obtained.

[0059] Based on the above embodiment, the embodiment of the present application describes the steps of filtering each source file based on the target file size to obtain a second source file; and filtering each source file based on the compilation time to obtain a third source file. Specifically, the method of this embodiment includes the following steps:

[0060] Based on the file size of the target file generated by each source file and a preset size screening threshold, each source file is heap sorted to obtain a second source file; based on the compilation time corresponding to each source file and a preset time screening threshold, each source file is heap sorted to obtain a third source file.

[0061] In combination with the foregoing embodiments, in this embodiment, the TopN algorithm in the heap sort algorithm is mainly used as an example for explanation. Among them, N refers to finding the largest (or smallest) top N elements from the acquired data (array), that is, the number of files that need to be screened out. It can be understood that if N3 second source files need to be screened out, the TopN3 algorithm is executed, and if N4 third source files need to be screened out, the TopN4 algorithm is executed. The specific algorithm principle and algorithm execution process can refer to the existing TopN algorithm or TopK algorithm, etc., which will not be repeated here.

[0062] Exemplarily, in this embodiment, the TopN algorithm can be used to screen source files. For example, in the code compilation stage, a tool "compile save option" can be added accordingly to enable the compilation intermediate product (target file) of each source file to be saved, so as to facilitate the subsequent analysis of the target file size corresponding to each source file. Then, according to the target file size corresponding to each source file, the preset TopN3 algorithm is used to sort and output each source file from large to small according to the corresponding target file size, and the outputted N3 source files with the top sorting are obtained as the second source file (for the convenience of distinction, they are also referred to as TopN3 source files in the future). It should also be noted that one or more file size thresholds (for example, 10KB bytes) can be preset, and the source files whose corresponding target file size in the N3 source files is less than the file size threshold are further trimmed, and the source files whose corresponding target file size in the N3 source files is greater than or equal to the file size threshold are retained, so that the file size of the target file generated by the second source file finally obtained is relatively large.

[0063] Similarly, the method for selecting the third source file from each source file in this embodiment can also refer to the above-mentioned real-time method. Exemplarily, in the complete compilation stage of the code, the tool "compilation time statistics option" is added to separately count the compilation time of each source file, so as to facilitate the subsequent analysis of the compilation time corresponding to each source file. Then, according to the compilation time corresponding to each source file, the analysis script is used according to the preset TopN4 algorithm, so that each source file is sorted and output from large to small according to the corresponding compilation time, and the N4 source files with the top sorting after output are obtained as the third source file (for the convenience of distinction, it is also referred to as the TopN4 source file later). It should also be noted that, in the same way, one or more time-consuming thresholds can be preset, and the source files whose compilation time in the N4 source files is less than the time-consuming threshold are further trimmed, and the source files whose compilation time in the N4 source files is greater than or equal to the time-consuming threshold are retained, so that the compilation time of the third source file finally obtained is relatively long.

[0064] Based on the above embodiments, the embodiment of the present application describes the steps of determining the header file to be optimized and / or the source file to be optimized based on the matching results between the first header file, the first source file, the second source file, and the third source file. Specifically, the method of this embodiment includes the following steps:

[0065] The third source file and the first source file are matched, and the third source file that successfully matches the first source file is used as the first matching source file, and the third source file that fails to match the first source file is used as the source file to be optimized; the third source file and the second source file are matched, and the third source file that successfully matches the second source file is used as the second matching source file; the first matching source file and the second matching source file are matched, and the first header file referenced by the second matching source file that successfully matches is determined as the header file to be optimized, and the second matching source file that fails to match is determined as the source file to be optimized.

[0066] In conjunction with the foregoing embodiment, the first source file and the first header file represent source files and header files with complex reference relationships, the second source file represents a source file with a large intermediate product (target file) in the compilation process, and the third source file represents a source file that takes a long time to compile the source file in the entire compilation process. It is understandable that these source files and header files are all likely to cause the efficiency of the compilation process to be limited, and the same source files may exist between the first source file and the second source file, between the first source file and the third source file, and between the second source file and the third source file. Therefore, the first header file, the first source file, the second source file, and the third source file can be matched, and the priority of each type of file to be optimized can be determined according to the matching result, and then the header file to be optimized and / or the source file to be optimized can be obtained.

[0067] Exemplarily, the third source file (TopN4 source file) and the first source file (TopN1 source file) are matched (based on the TopN4 source file), and the third source file that successfully matches the first source file is used as the first matching source file (identified as the M1 source file), that is, the source file with complex reference relationship and long compilation time is determined from the third source file (such source files are mainly due to complex reference relationship, which leads to long compilation time, and may also be due to file factors (such as file content)). And the third source file that fails to match the first source file is used as a source file to be optimized (identified as an M2 source file), that is, the source file with simple reference relationship but long compilation time is determined from the third source file (such source files are usually due to file factors that lead to long compilation time, so they are source files to be optimized that need to be optimized). Among them, the matching processing method may include but is not limited to matching based on file name, and / or each file is preset with a file identifier and matching is performed based on the file identifier, and / or matching is performed based on the entire file content or part of the file content of each file, etc.

[0068] Similarly, the third source file (TopN4 source file) and the second source file (TopN3 source file) are matched (the TopN4 source file can still be used as a benchmark), and the third source file that successfully matches the second source file is used as the second matching source file (identified as the M3 source file), that is, the source file that takes a long time to compile and has a larger intermediate product (target file) is determined from the third source file.

[0069] Further, the first matching source file (M1 source file) and the second matching source file (M3 source file) are matched (based on the M3 source file), and the first header file referenced by the successfully matched second matching source file is determined as the header file to be optimized, that is, the source file that is time-consuming, has a large target file, and has a complex reference relationship is determined from the second matching source file (identified as the M4 source file), and such source files are usually time-consuming and inefficient to compile because they reference a large number of header files. Therefore, the header files referenced by the M4 source file are searched. Such header files significantly affect the compilation efficiency, so they are used as header files to be optimized. Among them, before searching for the header files referenced by the M4 source file, a reference relationship topology table map1 can be established based on the reference relationship between the first source file and the first header file; after obtaining the M4 source file, the M4 source file can be quickly obtained through the map1 topological relationship. The header file with a large number of references (identified as the M6 ​​header file), that is, the first header file referenced by the M4 source file.

[0070] In addition, the second matching source file that failed to match (identified as M5 source file) is used as the source file to be optimized. The M5 source file represents a source file that takes a long time to compile and has a large intermediate product, but does not reference a small number of header files. The reason for the compilation efficiency of such source files is usually due to factors of the file itself, so the M5 source file is used as the source file to be optimized.

[0071] In addition, all header files referenced by the M4 source file can be filtered according to the obtained M6 header file. Specifically, the M6 ​​header file refers to the first header file referenced by the M4 source file. Such header files are usually public and have a large number of references. Among all header files referenced by the M4 source file, in addition to the M6 ​​header file, there are other header files (identified as M7 header files). Such header files are usually non-public, but they will also affect the compilation efficiency. Therefore, the M7 header file can also be used as a header file to be optimized.

[0072] In summary, the file information of the files to be optimized that are recommended for optimization can be obtained and output as follows: Priority 1: M6 header files (public, most referenced, and actual header files that affect time consumption); Priority 2: M7 header files (non-public, but some header files that affect time consumption); Priority 3: M5 source files (source files that are time-consuming and have large intermediate products, but the number of referenced header files is not large); Priority 4: M2 source files (source files that are time-consuming, but have almost nothing to do with the number of referenced header files). Therefore, when optimizing the header files to be optimized and / or the source files to be optimized, you can refer to the above file priorities and select all or part of the files for optimization, which will not be elaborated here.

[0073] Based on the above embodiment, the embodiment of the present application will illustrate the steps of matching the third source file with the first source file, matching the third source file with the second source file, and matching the first matching source file with the second matching source file. Specifically, the method of this embodiment includes the following steps:

[0074] The file name of the third source file and the file name of the first source file are matched by the same name to obtain a third source file that successfully matches the first source file, and a third source file that fails to match the first source file; the file name of the third source file and the file name of the second source file are matched by the same name to obtain a third source file that successfully matches the second source file; the file name of the first matching source file and the file name of the second matching source file are matched by the same name to obtain a second matching source file that successfully matches and a second matching source file that fails to match.

[0075] In combination with the above-mentioned embodiment, this embodiment mainly describes that the matching process among the first header file, the first source file, the second source file, and the third source file can adopt the method of same-name matching.

[0076] Specifically, same-name matching refers to matching based on the file names of header files and / or source files. If two files have the same file name, it is determined that the match is successful; if the two files do not have the same file name, it is determined that the match fails.

[0077] Exemplarily, the file name of each third source file is matched with the file name of each first source file, and the third source file that successfully matches is used as the first matching source file (identified as the M1 source file), and the third source file that fails to match is used as the source file to be optimized (identified as the M2 source file). The same name matching process for the remaining files is similar and will not be described in detail here.

[0078] Based on the above embodiments, the present embodiment will illustrate the steps of optimizing the header file to be optimized and / or the source file to be optimized to obtain the optimized software engineering project. Specifically, the method of this embodiment includes the following steps:

[0079] Based on the reference relationship, search for the source files to be processed corresponding to each header file to be optimized; obtain the function types of each header file referenced by each source file to be processed; perform function deduplication processing on the header files with repeated function types in each source file to be processed; and / or extract the preset code templates in each source file to be optimized, and perform external declaration processing on each preset code template to obtain the optimized source file; obtain the dependency relationship of each optimized source file; perform dependency deduplication processing on the source files with repeated dependency relationships; and obtain the optimized software engineering project.

[0080] In combination with the above-mentioned embodiments, this embodiment mainly describes the optimization process of the present application. It should be noted that the optimization process of the present application may at least include optimization of header files and / or optimization of source files.

[0081] Specifically, the reference relationship refers to the reference relationship between the header file and the source file, such as the reference relationship topology table map1 established in the aforementioned embodiment, so the source file to be processed that references the header file to be optimized can be found in map1 (such source files may be source files to be optimized or other source files). For each source file to be processed, the functional type of the header file referenced in each source file to be processed is obtained. It should be noted that the functional types may include but are not limited to common basic modules, business modules, third-party dependent modules, etc., and the functions of each header file can be divided according to the functions provided by each header file and whether it changes frequently. Among them, the common basic module represents a module whose file content remains basically unchanged and provides basic functions, the business module represents a module that involves business changes and provides business functions, and the third-party module represents a module that depends on other third-party developers.

[0082] Furthermore, after obtaining the function type of the header file referenced by each source file to be processed, it is possible to determine whether there are header files with duplicate function types in each source file to be processed, and perform deduplication processing on the header files with duplicate function types in each source file to be processed, for example, trimming the header files of duplicate functions used in each source file to be processed, or trimming the header files of invalid references in each source file to be processed. The specific trimming method can refer to the existing method, which will not be described here.

[0083] It should also be noted that, in this embodiment, before searching for the source file to be processed based on the header file to be optimized and map1, other optimization processing operations can be performed on the header file to be optimized. For example, after receiving the header file optimization instruction input by the user, for the common basic module in each header file to be optimized, the optimization method of the precompiled header file can be adopted, and the compilation result of the header file whose file content is basically unchanged can be saved, so that the precompiled header file compilation result can be directly used in the subsequent code compilation process, without the need to compile the header file referenced by it every time the code in the source file is compiled. For the business module, the optimization method of pre-type declaration can be adopted, and the members (including member functions and / or member variables) required by various businesses are only pre-declared, and the corresponding header file is automatically introduced only when the actual code runs to the corresponding member. Therefore, it is not necessary to introduce all header files when each source file is initially compiled, thereby increasing the compilation time, and avoiding invalid references caused by some wrong settings. For third-party dependent modules, the optimization method of function replacement can be adopted, such as modules in the form of hpp for function implementation, which can be tailored in a targeted manner or the function can be realized by itself to reduce the module engineering level.

[0084] In addition, in addition to optimizing the header file to be optimized, the source file to be optimized can also be optimized. Specifically, after receiving the source file optimization instruction input by the user, the preset code templates in each source file to be optimized are extracted, and each preset code template is externally declared to obtain the optimized source file. Among them, the template is a general programming tool that allows programmers to write general code to process multiple data types or data structures without having to write repeated code for each specific type. The preset code template can be used to achieve code reuse and generalization, thereby improving the flexibility and maintainability of the code. However, when the compiler encounters template code, each template needs to be instantiated. Especially in large projects, if multiple source files contain the same preset code template, the compiler will generate a code instantiated with the preset code template for each source file, which will cause a large amount of redundant code to be generated in the subsequent compilation and linking process, increasing the compilation time. Therefore, an analysis tool can be established to extract the preset code templates involved in each source file to be optimized, and after analyzing it, it can be optimized by using an external template based on the received source file optimization instruction to avoid code redundancy. Among them, external template refers to separating the declaration and definition of the template into different files. The advantage of this is that the definition of the template can be placed in an independent source file, thereby achieving modularity and reusability of the code template. It is equivalent to if one or more preset code templates have been instantiated, the external template declaration can be used to prevent the template from being instantiated multiple times, thereby reducing the time cost of the compilation and linking process.

[0085] In addition to optimizing the template part in the source file, you can also extract the part of each source file with less file content changes and optimize it by pre-compiling a dynamic library. Pre-compiling the part of the file with less file content changes into a dynamic library can reduce the compilation time of this part in the subsequent compilation process.

[0086] After the source files to be optimized have been optimized as described above, the dependency relationships of the optimized source files can also be obtained; and the source files with duplicate dependencies can be deduplicated. Among them, the dependency relationship of the source files is similar to the reference relationship between the source files and the header files in the aforementioned embodiment. If module 2 in the source file depends on its module 1, then module 1 usually needs to be compiled before module 2 can be compiled, that is, since there is a dependency relationship between module 1 and module 2, module 1 and module 2 are compiled serially. It should be noted that the dependency relationship can be the dependency of one source file on another source file (cross-file dependency), or the dependency of one function on another function in the same source file (same-file dependency), or other common dependency relationships, etc., which are not limited here.

[0087] Therefore, you can use analysis tools to obtain the dependencies of each optimized source file, and then use parallel compilation to further optimize the compilation speed. Figure 2 , Figure 2 It is an exemplary source file optimization schematic diagram in the software compilation optimization method of the present application, which shows the conventional compilation process for each module in the source file, and the optimized parallel compilation process. Exemplarily, in the source file compilation process, 1. the CPU multi-core capability can be used to compile the source file in parallel; 2. the dependency relationship of the source file is adjusted, and some or all modules in each source file are subjected to dependency deduplication processing, and parallel compilation can be performed during subsequent compilation. Dependency deduplication processing, for example: if module 2 and module 3 both depend on module 1, and module 4 depends on module 1 in addition to module 2 and module 3, so it can be seen from analysis that module 4 and modules 2 and 3 all depend on module 1, and in fact, modules 2 and 3 that depend on module 1 can continue to compile module 4 after successful compilation, so the dependency relationship between module 4 and module 1 is a duplicate dependency relationship, so this layer of duplicate dependencies can be removed.

[0088] In summary, in the specific process of file optimization, you can choose to optimize the header file to be optimized and / or optimize the source file to be optimized, and then get the optimized software engineering project. When you subsequently compile the optimized software engineering project, the compilation efficiency will be improved compared to the previous unoptimized software engineering project.

[0089] Based on the above embodiment, the embodiment of the present application describes the steps of determining the first header file from each header file and determining the first source file from each source file based on the reference relationship and the preset file screening rule. Specifically, the method of this embodiment includes the following steps:

[0090] Based on the reference relationship, the number of header files referenced by each source file and the number of times each header file is referenced are determined; based on the number of header files referenced by each source file, each source file is screened to obtain a first source file; based on the number of times each header file is referenced, each header file is screened to obtain a first header file.

[0091] In conjunction with the above-mentioned embodiment, all source files of the current software project can be analyzed through an analysis script to obtain the number of header files referenced by each source file (since system header files are usually not changed, the number of header files here can exclude the number of system header files). Then, each source file is screened and processed according to the number of header files referenced by each source file. For details, please refer to the TopN algorithm (setting the N1 value) described in the above-mentioned embodiment. According to the number of header files corresponding to each source file and the TopN1 algorithm, each source file is sorted from large to small based on the number of header files and N1 source files are output, and the first source file is obtained, that is, the source file that references more header files is represented by the first source file.

[0092] Similarly, use the analysis script to analyze the header files of the current software project. The header files here can also refer to all header files of the current software project except the system header files, and obtain the number of times each header file is cited. Then, according to the preset N2 value, based on the number of times each header file is cited and the TopN2 algorithm, each header file is sorted from large to small based on the number of times it is cited, and N2 header files are output, and the first header file is obtained, that is, the header file with a large number of citations is represented by the first header file.

[0093] In summary, there is a complex reference relationship between the first source file and the first header file. Further, based on the first source file determined by the TopN1 algorithm and the first header file determined by the TopN2 algorithm, a reference relationship topology table map1 is generated, which can represent the complex reference relationship between the first source file and the first header file, and is also convenient for subsequent file search in the problem analysis and location process.

[0094] Based on the above embodiment, the embodiment of the present application describes the steps before analyzing and processing each header file and each source file of the acquired software engineering project to obtain the reference relationship between each header file and each source file. Specifically, the method of this embodiment includes the following steps:

[0095] In response to a compilation event triggering a software engineering project, the solution included in the software engineering project is parsed to obtain the compilation information of the solution; if it is determined based on the compilation information that the solution has not been updated, the solution product corresponding to the solution is obtained according to a preset reuse list; if it is determined based on the compilation information that the solution has been updated, the solution is compiled.

[0096] It is understandable that after compiling the solution, the reference relationship between each source file and each header file in the solution, the compilation time of each source file, the size of the target file generated by each source file, etc. can be obtained. Then, the optimization method of the above embodiment can be used to optimize the solution.

[0097] It should be noted that the aforementioned embodiments are mainly for the purpose of defect location and file optimization of the source files and header files of a single solution in the project. However, in general, a software project may include multiple solutions, so it is necessary to analyze and optimize the source files and header files in each solution separately, and then package the final results. Among them, the solution refers to the corresponding supporting software or hardware and software solution for a certain aspect or type of problem in the project requirements, which is mostly a complete information solution. For example, the multiple functions that need to be implemented in a software can be regarded as multiple problems, and the relevant information and / or related files required to implement each function (i.e., solve each problem) can be regarded as a solution.

[0098] Therefore, when facing a large project including multiple solutions, in addition to performing the optimization method of the aforementioned embodiment on each solution in the project, time-consuming optimization can also be performed during the packaging process of multiple solutions.

[0099] For details, please refer to Figure 3 , Figure 3 This is an exemplary schematic diagram of continuous integration of multiple solutions for a project in the software compilation optimization method of the present application. The steps for analyzing and optimizing the source files and header files of the solution in the aforementioned embodiment are integrated into this process. For example, the analysis and optimization method in the aforementioned embodiment is integrated into an automated analysis tool, which supports the output of an optimization report (which may include header files to be optimized, source files to be optimized, and corresponding recommended optimization methods) after analyzing and processing the code of the solution. The tool is also integrated into the compilation phase of the project (which can be used as a debugging function, and options are used to determine whether to turn on and use the tool) so that the corresponding optimization information can be obtained after the project is compiled and packaged.

[0100] For example, reference may also be made to Figure 4 , Figure 4 This is an exemplary project multi-solution implementation flow chart in the software compilation optimization method of this application. Among them, 1. The compilation information of each solution included in the project can be recorded in XML format, which may include but is not limited to: module name, module warehouse path, module version, module compilation method, module dependency, etc.

[0101] 2. When the project is compiled, each solution recorded in the XML is parsed. For each solution, it is matched in the reuse list according to its module name and warehouse path, which is equivalent to detecting whether the version of the current solution has been updated. Among them, the reuse list means that the compilation results of each module can be stored in the reuse list after each successful project compilation. In the subsequent compilation process, the solution products in the reuse list can be directly called without the need to complete the compilation process again, thereby improving the compilation speed. If the match is not successful, it means that the current solution is different from the solution corresponding to the solution product previously stored in the reuse list. It may be that the solution has been updated. Therefore, the solution product in the reuse list cannot be called, and the current new solution needs to be compiled. If the match is successful, the relevant solution products in the reuse list can be called.

[0102] 3. For solutions that need to be compiled, you can use multi-threading or multi-process technology (the number of threads or processes is determined by the compilation environment and the number of tasks) in combination with the current computer equipment or server load, and concurrently download each algorithm module repository that needs to be compiled to a temporarily generated temporary compilation path. In the temporary compilation path, execute the compilation parameters of each algorithm model to compile the algorithm module, copy the generated product to the temporary compilation path, and add its product information to the reuse list.

[0103] 4. Process each compilation module according to the tool generated by the compilation optimization method of the above embodiment. If optimization analysis is required, use the analysis and optimization tool to analyze and optimize the current project and output an optimization report (the report may include relevant information of the header file to be optimized and the source file to be optimized, as well as some optimization measures automatically executed by the computer device or server, etc.). In addition, the developer can also issue optimization instructions according to the optimization report to optimize the current project.

[0104] 5. Package the solution products of each solution in the temporary compilation path uniformly.

[0105] From the above, it can be seen that if the current software project is compiled for the first time, an optimization report can be generated according to the above solution; after the current project is optimized according to the optimization report, the various solutions can be continuously updated and optimized during the subsequent continuous integration process of the project, further reducing the time consumed in compilation and packaging during the project life cycle.

[0106] It should be further explained that the execution subject of the software compilation optimization method may be a software compilation optimization device, for example, the software compilation optimization method may be executed by a terminal device or a server or other processing device, wherein the terminal device may be a user equipment (UE), a computer, a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. In some possible implementations, the software compilation optimization method may be implemented by a processor calling a computer-readable instruction stored in a memory.

[0107] Figure 5 FIG. 1 is a block diagram of a software compilation optimization device shown in an exemplary embodiment of the present application. Figure 5 As shown, the exemplary software compilation optimization device 500 at least includes an analysis module 510, a first determination module 520, a second determination module 530, a matching module 540 and an optimization module 550. Specifically:

[0108] The analysis module 510 is used to analyze and process each header file and each source file of the acquired software engineering project to obtain the reference relationship between each header file and each source file.

[0109] The first determining module 520 is used to determine the first header file from each header file and determine the first source file from each source file based on the reference relationship and a preset file screening rule.

[0110] The second determining module 530 is used to determine the second source file in each source file and determine the third source file in each source file based on the obtained compilation results of each source file in the compilation process.

[0111] The matching module 540 is used to determine the header file to be optimized and / or the source file to be optimized based on the matching results among the first header file, the first source file, the second source file and the third source file.

[0112] The optimization module 550 is used to optimize the header file to be optimized and / or the source file to be optimized to obtain an optimized software engineering project.

[0113] In this exemplary software compilation optimization device, by analyzing and processing each header file and each source file of the acquired software engineering project, the reference relationship between each header file and each source file is obtained; based on the reference relationship and the preset file screening rules, the first header file is determined from each header file and the first source file is determined from each source file, thereby determining the header files and source files that may affect the compilation speed during the compilation process; based on the compilation results of each source file acquired during the compilation process, the second source file in each source file and the third source file in each source file are determined, and the header files and source files that affect the compilation speed can be further determined; therefore, the header file to be optimized and / or the source file to be optimized can be located through the matching results between the first header file, the first source file, the second source file and the third source file; the header file to be optimized and / or the source file to be optimized are optimized, so that the compilation process can be optimized and the optimized software engineering project can be obtained, thereby improving the compilation and development efficiency of the software project engineering.

[0114] It should be noted that the device provided in the above embodiment and the method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment, and will not be repeated here. In practical applications, the device provided in the above embodiment can distribute the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.

[0115] Among them, the functions of each module can be found in the embodiment of the software compilation optimization method, which will not be repeated here.

[0116] See also Figure 6 , Figure 6 6 is a schematic diagram of the structure of an embodiment of an electronic device of the present application. The electronic device 600 includes a memory 601 and a processor 602, and the processor 602 is used to execute the program instructions stored in the memory 601 to implement the steps in any of the above software compilation optimization method embodiments. In a specific implementation scenario, the electronic device 600 may include but is not limited to: a microcomputer, a server, and in addition, the electronic device 600 may also include a mobile device such as a laptop computer and a tablet computer, which is not limited here.

[0117] Specifically, the processor 602 is used to control itself and the memory 601 to implement the steps in any of the above-mentioned software compilation optimization method embodiments. The processor 602 can also be called a CPU (Central Processing Unit). The processor 602 may be an integrated circuit chip with signal processing capabilities. The processor 602 can also be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field-programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 602 can be implemented by an integrated circuit chip.

[0118] In this exemplary electronic device, each header file and each source file of the acquired software engineering project are analyzed and processed to obtain the reference relationship between each header file and each source file; based on the reference relationship and the preset file screening rules, the first header file is determined from each header file and the first source file is determined from each source file, thereby determining the header files and source files that may affect the compilation speed during the compilation process; based on the compilation results of each source file acquired during the compilation process, the second source file in each source file and the third source file in each source file are determined, and the header files and source files that affect the compilation speed can be further determined; therefore, the header file to be optimized and / or the source file to be optimized can be located through the matching results between the first header file, the first source file, the second source file and the third source file; the header file to be optimized and / or the source file to be optimized are optimized, so that the compilation process can be optimized and the optimized software engineering project can be obtained, thereby improving the compilation and development efficiency of the software project engineering.

[0119] See also Figure 7 , Figure 7 The computer-readable storage medium 710 stores program instructions 711 that can be executed by a processor, and the program instructions 711 are used to implement the steps in any of the above software compilation optimization method embodiments.

[0120] In this exemplary storage medium, each header file and each source file of the acquired software engineering project are analyzed and processed by running the program instructions in the storage medium to obtain the reference relationship between each header file and each source file; based on the reference relationship and the preset file screening rules, the first header file is determined from each header file and the first source file is determined from each source file, thereby determining the header files and source files that may affect the compilation speed during the compilation process; based on the compilation results of each source file acquired during the compilation process, the second source file in each source file and the third source file in each source file are determined, and the header files and source files that affect the compilation speed can be further determined; therefore, the header file to be optimized and / or the source file to be optimized can be located through the matching results between the first header file, the first source file, the second source file and the third source file; the header file to be optimized and / or the source file to be optimized are optimized, so that the compilation process can be optimized and the optimized software engineering project can be obtained, thereby improving the compilation and development efficiency of the software project engineering.

[0121] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.

[0122] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.

[0123] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0124] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or part of the contribution to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.< / iostream>

Claims

1. A software compilation optimization method, characterized in that: The method comprises: Analyze and process each header file and each source file of the acquired software engineering project to obtain the reference relationship between each header file and each source file; Determine a first header file from each header file and determine a first source file from each source file based on the reference relationship and a preset file screening rule; Determine the second source file in each source file and determine the third source file in each source file based on the obtained compilation results of each source file in the compilation process; The step of determining the second source file in each source file based on the obtained compilation results of each source file in the compilation process and determining the third source file in each source file includes: obtaining the file size of the target file generated by each source file in the compilation process and the compilation time of each source file in the compilation process; screening each source file based on the file size of the target file to obtain the second source file; and screening each source file based on the compilation time to obtain the third source file; The steps of screening each source file based on the file size of the target file to obtain the second source file; and screening each source file based on the compilation time to obtain the third source file include: performing heap sorting on each source file based on the file size of the target file generated corresponding to each source file and a preset size screening threshold to obtain the second source file; performing heap sorting on each source file based on the compilation time corresponding to each source file and a preset time screening threshold to obtain the third source file; Determine a file to be optimized and a file priority of the file to be optimized based on a matching result among the first header file, the first source file, the second source file, and the third source file, wherein the file to be optimized includes a header file to be optimized and / or a source file to be optimized; The step of determining the file to be optimized and the file priority of the file to be optimized based on the matching results among the first header file, the first source file, the second source file and the third source file comprises: matching the third source file and the first source file to obtain the M1 source file that successfully matches and the M2 source file that fails to match in the third source file, and using the M2 source file as the source file to be optimized; matching the third source file and the second source file to obtain the M3 source file that successfully matches in the third source file; matching the M1 source file and the M3 source file to obtain the M4 source file that successfully matches and the M5 source file that fails to match in the M3 source file, and determining the M6 ​​header file referenced by the M4 source file as the header file to be optimized, and using the M5 source file as the source file to be optimized; According to the M6 ​​header file, all header files referenced by the M4 source file are filtered to obtain an M7 header file, and the M7 header file is determined as the header file to be optimized; Set the M6 ​​header file to priority 1, the M7 header file to priority 2, the M5 source file to priority 3, and the M2 source file to priority 4 to obtain the file priority of the file to be optimized; The header file to be optimized and / or the source file to be optimized are fully or partially optimized according to the file priority to obtain an optimized software engineering project.

2. The method according to claim 1, characterized in that The matching process of the third source file and the first source file includes: Perform same-name matching processing on the file name of the third source file and the file name of the first source file to obtain a third source file that successfully matches the first source file and a third source file that fails to match the first source file; The matching process of the third source file and the second source file includes: matching the file name of the third source file with the file name of the second source file to obtain a third source file that successfully matches the second source file; The matching process of the M1 source file and the M3 source file includes: matching the file name of the M1 source file with the file name of the M3 source file to obtain a successfully matched M3 source file and an unmatched M3 source file.

3. The method according to claim 1, characterized in that The step of optimizing the header file to be optimized and / or the source file to be optimized to obtain an optimized software engineering project includes: Searching for a source file to be processed corresponding to each header file to be optimized based on the reference relationship; Get the function type of each header file referenced by each source file to be processed; Perform function deduplication processing on header files with duplicate function types in each source file to be processed; and / or, extracting preset code templates from each source file to be optimized, and performing external declaration processing on each preset code template to obtain an optimized source file; Get the dependencies of each optimized source file; De-duplicate source files with duplicate dependencies; The optimized software engineering project is obtained.

4. The method according to claim 1, characterized in that: The determining the first header file from each header file and the determining the first source file from each source file based on the reference relationship and the preset file screening rule includes: Determine the number of header files referenced by each source file and the number of times each header file is referenced based on the reference relationship; Filtering each source file based on the number of header files referenced by each source file to obtain the first source file; The header files are screened based on the number of times each header file is cited to obtain the first header file.

5. The method according to claim 1, characterized in that Before analyzing and processing the header files and source files of the acquired software engineering project to obtain the reference relationship between the header files and the source files, the following steps are included: In response to a compilation event triggering the software engineering project, a solution included in the software engineering project is parsed to obtain compilation information of the solution; If it is determined based on the compilation information that the solution has not been updated, obtaining a solution product corresponding to the solution according to a preset reuse list; If it is determined based on the compilation information that the solution has been updated, the solution is compiled.

6. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the processor is used to execute program instructions stored in the memory to implement the method according to any one of claims 1 to 5.

7. A computer-readable storage medium having program instructions stored thereon, characterized in that: When the program instructions are executed by a processor, the method according to any one of claims 1 to 5 is implemented.