Method and device for automatically generating compiling configuration file
By querying the target compilation option collection in the compilation rule library, the compilation configuration files are automatically generated, which solves the problems of low manual configuration efficiency and poor performance compatibility, and realizes efficient compilation configuration file generation.
Patent Information
- Application Number
- CN202510349570.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2025-08-15
AI Technical Summary
Manually configuring the compiled files in the prior art leads to low compilation efficiency and poor performance or poor compatibility of compiled programs.
By obtaining the project attributes and attribute values of the software development project, query the target compilation option collection in the preset compilation rule library, generate a compilation configuration file. There are multiple matching rules and compilation options collections stored in the compilation rule library, and use a tree structure to store matching rules and perform rule matching to automatically generate compilation configuration files.
Improves the configuration efficiency of compiling configuration files, avoiding the problems of poor program performance or poor compatibility due to manual negligence or lack of experience in choosing inappropriate compilation options.
Smart Images

Figure CN120491963A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for automatically generating a compilation configuration file. Background Art
[0002] In the software development process, compilation is a key step in converting source code into executable programs. In different software development projects, due to differences in programming language, target platform, performance requirements, code size and other factors, different compilation parameters are required to achieve optimal compilation performance.
[0003] However, the current compilation configuration process mostly relies on manual configuration by developers. Manually configuring compilation options requires a deep understanding of the compiler's various parameters and the need to adjust them based on the specific circumstances of the software development project. For complex software development projects, the number of possible compilation option combinations is enormous, and manually selecting the appropriate options requires significant time and effort, resulting in low compilation efficiency. Furthermore, due to negligence or lack of experience, developers may select inappropriate compilation options, leading to poor performance or poor compatibility of the compiled program. Summary of the Invention
[0004] The present invention provides a method and device for automatically generating a compilation configuration file, which is used to solve the problems in the prior art of manually configuring compilation files, resulting in low compilation efficiency, and poor performance or compatibility of compiled programs.
[0005] The present invention provides a method for automatically generating a compilation configuration file, comprising the following steps: Obtain each project attribute and corresponding attribute value of the software development project; Searching a preset compilation rule library for a target compilation option set that matches the attribute value of each project attribute; Generate a compilation configuration file based on the target compilation option set; The compilation rule library stores a plurality of matching rules and a compilation option set corresponding to each matching rule, and each matching rule corresponds to a combination of attribute value permutations of all project attributes.
[0006] According to a method for automatically generating a compilation configuration file provided by the present invention, obtaining various project attributes and corresponding attribute values of a software development project includes: Reading a project file related to a software development project, and extracting each of the project attributes and corresponding attribute values from the project file based on a keyword of each of the project attributes; And / or, sending a project attribute inquiry request to a developer terminal, receiving a response result returned by the developer terminal, and extracting each of the project attributes and corresponding attribute values from the response result.
[0007] According to a method for automatically generating a compilation configuration file provided by the present invention, different project attributes have different priorities. The compilation rule base stores the matching rules in a tree structure. The compilation rule base is generated as follows: Creating first-level nodes of a tree structure with each attribute value of the first-priority item attribute, where each first-level node corresponds to an attribute value of the first-priority item attribute; For any i-1th layer node, create an i-th layer node corresponding to each attribute value of the i-th priority project attribute, and use each i-1th layer node as a child node of the i-1th layer node until the Nth layer node is created, where N is the total number of project attributes, and i is greater than or equal to 2 and less than or equal to N; The corresponding compilation option set is associated with the matching rule corresponding to each first-layer node to each leaf node of the Nth layer to complete the creation of the compilation rule base.
[0008] According to a method for automatically generating a compilation configuration file provided by the present invention, searching a preset compilation rule library for a target compilation option set that matches the attribute values of each project attribute, comprising: Assign default attribute values to project attributes that are missing; According to the priority of each item attribute in the tree-structured compilation rule base, rule matching is performed starting from the first layer node until the last layer leaf node is matched; The compilation option set corresponding to the leaf node of the last layer is determined as the target compilation option set.
[0009] A method for automatically generating a compilation configuration file according to the present invention further includes: if a target compilation option set matching the attribute values of each project attribute cannot be found in a preset compilation rule library, prompting a user to manually configure the compilation option set, generating a compilation configuration file based on the manually configured compilation option set, and using the combination of the attribute values of each project attribute as a new matching rule and adding the corresponding manually configured compilation option set to the compilation rule library.
[0010] According to the present invention, a method for automatically generating a compilation configuration file, after generating the compilation configuration file based on the target compilation option set, further includes: Verifying the syntax of the compilation configuration file and the compatibility of each compilation option in the compilation option set, and generating corresponding prompt information if the verification fails; The prompt information is sent to the developer terminal, and adjustment information sent by the developer terminal is received, and the compilation configuration file is adjusted according to the adjustment information.
[0011] According to a method for automatically generating a compilation configuration file provided by the present invention, after adjusting the compilation configuration file, the method further includes: Compile the source files of the software development project based on the compilation configuration file; Report error information when the compiler detects errors in the source code or the compilation environment; When the compiler detects an error in the compilation options, the compilation rule base is adjusted based on the error in the compilation options.
[0012] The present invention also provides a device for automatically generating a compilation configuration file, comprising: The attribute acquisition module is used to obtain the project attributes and corresponding attribute values of the software development project; A query matching module, configured to search a preset compilation rule library for a target compilation option set that matches the attribute value of each project attribute; A file generation module, configured to generate a compilation configuration file based on the target compilation option set; The compilation rule library stores a plurality of matching rules and a compilation option set corresponding to each matching rule, and each matching rule corresponds to a combination of attribute value permutations of all project attributes.
[0013] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein when the processor executes the program, the method for automatically generating a compiled configuration file as described above is implemented.
[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method for automatically generating a compilation configuration file as described above is implemented.
[0015] The present invention provides a method and device for automatically generating a compilation configuration file. A compilation rule library stores multiple matching rules and a compilation option set corresponding to each matching rule. Each matching rule corresponds to a combination of attribute value permutations of all project attributes. After obtaining the project attributes and corresponding attribute values of a software development project, the compilation rule library is queried for a target compilation option set that matches the attribute values of each project attribute. A compilation configuration file is then generated based on the target compilation option set, thereby achieving automatic generation of the compilation configuration file. Compared with manual configuration, the configuration efficiency of the compilation configuration file is improved, and the problem of poor performance or poor compatibility of the compiled program caused by selecting inappropriate compilation options due to human negligence or lack of experience is avoided. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0017] Figure 1 This is one of the flow charts of the method for automatically generating a compilation configuration file provided by the present invention.
[0018] Figure 2 This is a schematic diagram of the tree-structured compilation rule base structure in the method for automatically generating a compilation configuration file provided by the present invention.
[0019] Figure 3 This is the second flow chart of the method for automatically generating a compilation configuration file provided by the present invention.
[0020] Figure 4 It is a structural diagram of the device for automatically generating a compiled configuration file provided by the present invention.
[0021] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0022] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0023] The method for automatically generating a compiled configuration file according to an embodiment of the present invention is as follows: Figure 1 As shown, the following steps are included: Step S110: Obtain the project attributes and corresponding attribute values of the software development project. Specifically, the project attributes include but are not limited to: programming language, target platform, performance requirements and code scale. The attribute values of programming languages include: C / C++, JAVA and Python, etc. The target platform includes: operating system and hardware architecture, etc., and its attribute values include: Linux, Windows and iOS, etc. Performance requirements include: whether high throughput, low latency and real-time performance are required, etc., and its attribute values can be: high throughput, low throughput, high latency, low latency, high real-time performance and low real-time performance, etc., or the comprehensive performance can be: high, medium and low, or high and low, etc. The code scale includes the number of code files and the number of lines of code, etc., and its attribute values are large scale and small scale.
[0024] Step S120: Querying a preset compilation rule library for a target compilation option set that matches the attribute values of each project attribute. The compilation rule library stores a plurality of matching rules and a compilation option set corresponding to each matching rule. Each matching rule corresponds to one of the permutations and combinations of attribute values of all project attributes, i.e., each attribute value combination of each project attribute corresponds to a compilation option set.
[0025] Step S130: Generate a compilation configuration file based on the target compilation option set. The compilation configuration file can be a common compiler configuration file (e.g., a .gccrc file for gcc) or a configuration file for a project build tool (e.g., a Makefile, CMakeLists.txt, etc.). Specifically, the compilation configuration file can be automatically generated according to the compilation configuration file format. The generated compilation configuration file includes the compilation options determined by rule matching and their corresponding property values.
[0026] In the method for automatically generating a compilation configuration file of this embodiment, a compilation rule library stores multiple matching rules and a compilation option set corresponding to each matching rule, each matching rule corresponding to a combination of attribute values of all project attributes. After obtaining the project attributes and corresponding attribute values of the software development project, the compilation rule library is queried for a target compilation option set that matches the attribute values of each project attribute, and then a compilation configuration file is generated based on the target compilation option set, thereby achieving automatic generation of the compilation configuration file. Compared with manual configuration, the configuration efficiency of the compilation configuration file is improved, and the problem of poor performance or poor compatibility of the compiled program caused by selecting inappropriate compilation options due to human negligence or lack of experience is avoided.
[0027] In some embodiments, step S110 specifically includes: reading a project file related to the software development project, extracting each project attribute and the corresponding attribute value from the project file based on the keywords of each project attribute; and / or sending a project attribute consultation request to the developer terminal, and receiving a response result returned by the developer terminal, and extracting each project attribute and the corresponding attribute value from the response result.
[0028] Specifically, relevant files of the software development project, such as Makefile, CMakeLists.txt and other files, are read, and keywords of each project attribute (such as programming language, programming language, language, etc.) are extracted from them to obtain at least one of the attribute values of the project's programming language, target platform, performance requirements and code size.
[0029] It should be noted that a software development project is generally divided into multiple program modules, each of which also has its own compilation configuration file, such as a Makefile. In this embodiment, not only the overall Makefile for the software development project is generated, but also the Makefiles for each program module. However, if the developer provides Makefiles for certain program modules or uses some open source sub-repositories (which include Makefiles), then in step S110 of this embodiment, relevant project properties will also be obtained based on the compilation configuration files provided by the developer or the compilation configuration files in the open source sub-repository to generate compilation configuration files for other program modules, as well as the overall compilation configuration file.
[0030] In this embodiment, the system will also interact with the developer to obtain the attribute information of the project attributes. Specifically, a project attribute inquiry request is sent to the developer terminal, and a response result is received from the developer terminal. The project attributes and corresponding attribute values are extracted from the response result. In particular, when it is impossible to obtain sufficient attribute information from the project file, for example, only the attribute values of the programming language and target platform are obtained from the project file, a prompt message is sent to the developer terminal to inquire about the attribute values of attributes such as the performance requirements, code size, and whether debugging is required for the software development project. For example, if the programming language is C++, the target platform is Linux, and the performance requirement is high, the project attributes and attribute values obtained are as follows: language: C++; target_platform: Linux; performance_requirement: high; debug_mode: debug.
[0031] In this embodiment, project attributes and their corresponding attribute values can be obtained efficiently and accurately by reading the project file and interacting with the developer.
[0032] In some embodiments, different project attributes have different priorities, which can be set according to the actual situation of the software development project. For example, the four project attributes of programming language, target platform, performance requirements, and code size are prioritized in descending order: programming language, target platform, performance requirements, and code size. The compilation rule base stores the matching rules in a tree structure, and the compilation rule base is generated as follows: Create the first-level nodes of the tree structure with the attribute values of the first-priority project attributes, and each first-level node corresponds to an attribute value of the first-priority project attributes. Figure 2As shown, programming language has the highest priority, and its three attribute values c / c++, java and python are used as the first-level nodes.
[0033] For any i-1th level node, create an i-th level node corresponding to each attribute value of the i-th priority project attribute, and use each i-1th level node as a child node of the i-1th level node, until the Nth level node is created. Where N is the total number of project attributes, and i is greater than or equal to 2 and less than or equal to N. For example, for each programming language attribute value node, there are three child nodes: linux, win, and ios.
[0034] The compilation rule base is created by associating the matching rules corresponding to each first-level node through each leaf node in the Nth level with the corresponding compilation option set. This allows the project attributes and attribute values to be used as matching conditions, matching the corresponding rules in the tree-structured compilation rule base to obtain the corresponding compilation option set. Specifically, the matching rules and the corresponding compilation option set are stored as key-value pairs. Each matching rule (matching condition) and the corresponding compilation option set are as follows: { "match_conditions": { "language": "C++", "target_platform": "Linux", "performance_requirement": "high" }; "compile_options": { "optimization_level": "-O3", "enable_multithreading": true }; "match_conditions": { "language": "C++", "target_platform": "Linux", "debug_mode": "debug" }; "compile_options": { "debug_mode": "-g", }; }.
[0035] Taking the four project attributes of programming language, target platform, performance requirements and code size as an example, the generated tree-structured compilation rule library is as follows: Figure 2 As shown in the figure, each path from the first-level node to the last-level leaf node is a matching rule, and each matching rule corresponds to a set of compilation options. For example, a rule might be defined as follows: When the project's programming language is C++, the target platform is Linux, performance requirements are high, and the code size is large, the compilation option set includes optimization level -O3 and enabling multi-threaded compilation.
[0036] Figure 2 Preferably, an index node can be established for the first-layer node, and the index node serves as the root node of the tree structure so as to match the attribute value corresponding to the first-layer node more quickly. The index node can be a mapping structure of attribute value and address, and the storage address of the first-layer node in the tree structure is found through the attribute value so as to traverse and match backward.
[0037] In this embodiment, the tree-structured compilation rule base can effectively store matching rules and corresponding compilation option sets, and can quickly and accurately match corresponding target compilation option sets to relevant source files corresponding to the current software development project.
[0038] In some embodiments, based on the tree-structured compilation rule base, step S120 specifically includes: Step 1: Assign default attribute values to the project attributes with missing attribute values. In order to match the corresponding rules in the tree-structured compilation rule base, assign corresponding default attribute values to the project attributes whose attribute values are not obtained in step S110. For example: there are no special requirements for performance and code size, so the corresponding attribute values may not be obtained in step S110. You can choose low performance requirements as the default attribute value and small code size as the default attribute value. For project attributes whose attribute values can be defaulted, their default attribute values can be determined in advance. In step S110, when the attribute values of project attributes whose attribute values can be defaulted are not obtained, the corresponding default attribute values can be used to fill them.
[0039] It should be noted that before matching rules, project attributes and attribute values are preprocessed. Specifically, they are converted to a unified format recognizable by the compilation rule base, and useless information is removed. For example, programming language names are uniformly converted to lowercase format recognizable by the compilation rule base, and target platform names are converted to standard identifiers.
[0040] Step 2: According to the priority of each project attribute, rule matching starts from the first-level node in the compilation rule library of the tree structure until the last-level leaf node is matched. That is, the project attributes and attribute values are used as matching conditions, and the corresponding rules are matched in the compilation rule library of the tree structure to obtain the corresponding compilation option set.
[0041] For example, if the project attributes and attribute values are: programming language is C++, target platform is Linux, performance requirements are high and code size is large, first Figure 2 The first-level node in the tree matches the c / c++ node, and then matches the three child nodes of the c / c++ node, matching the linux node, and matching the corresponding child nodes backward in sequence until the last leaf node.
[0042] Step 3: Determine the compilation option set corresponding to the last leaf node as the target compilation option set. For example, if the project attributes and attribute values are: programming language is C++, target platform is Linux, performance requirements are high and code size is large, press Figure 2 In the tree-structured compilation rule base, the compilation option set 1 is finally obtained as the target compilation option set, which includes compilation options such as optimization level -O3 and enabling multi-threaded compilation.
[0043] In some embodiments, the method for automatically generating a compilation configuration file further includes: when no target compilation option set matching the attribute values of the project attributes can be found in a preset compilation rule library, prompting the user to manually configure the compilation option set, so as to generate a compilation configuration file according to the manually configured compilation option set, and using the combination of attribute values of the project attributes as a new matching rule, and adding the corresponding manually configured compilation option set to the compilation rule library.
[0044] In this embodiment, manually configured compilation option sets are added to the compilation rule library, thereby continuously updating and maintaining the compilation rule library to adapt to new programming languages, target platforms, and compilation requirements. In this embodiment, project compilation data can also be regularly collected and analyzed to adjust and optimize the rules in the rule library based on actual conditions. At the same time, rule editing and management tools can also be provided to allow developers to easily add, delete, and modify rules in the compilation rule library.
[0045] In some embodiments, after step S130, a step of verifying the compiled configuration file is further included, specifically including: The syntax of the compilation configuration file and the compatibility of each compilation option in the compilation option set are verified, and if the verification fails, a corresponding prompt message is generated. The compilation configuration file is a file read by the compiler. Different programming languages have different compilers and different compilation configuration files. Different compilation configuration files have different syntax formats. In this embodiment, the compilation configuration file can be verified according to the corresponding syntax format. For the compatibility problem of compilation options (i.e., semantic problem), the compatibility rules between different compilation options are determined based on the compiler. Therefore, the compatibility between the compilation options in the compilation option set can be verified according to the compatibility rules between the different compilation options.
[0046] The prompt information is sent to the developer terminal, and the adjustment information sent by the developer terminal is received. The compiled configuration file is adjusted according to the adjustment information, that is, the compiled configuration file is adjusted according to the developer's instruction.
[0047] Taking the matching rules (matching conditions) and the corresponding compilation option set shown in the above code as an example, the generated compilation configuration file (such as Makefile file) is as follows: CC = g++ CFLAGS = -O3 –pthread -g all: my_program $(CC) $(CFLAGS) -o my_program main.cpp clean: rm -f my_program.
[0048] Verifying the generated compilation configuration revealed compatibility issues with the compilation options. -O3 is the highest level optimization option, while -g is used to generate debug information. High optimization levels can affect debug information generation, potentially preventing certain debugging features from functioning properly. The presence of both can cause issues. Therefore, adjustments to the compilation configuration were necessary. Because of the conflicting compilation options, interaction with the developer was necessary. The developer chose not to prioritize performance, resulting in the following compilation configuration adjustments: CC = g++ CFLAGS = -O0 –pthread -g all: my_program $(CC) $(CFLAGS) -o my_program main.cpp clean: rm -f my_program.
[0049] In some embodiments, after adjusting the compiled configuration file, the following steps are further included: The source files of the software development project are compiled based on the compilation configuration file, and the compiler reads the compilation configuration file to compile the source files.
[0050] When the compiler detects an error in the source code or the compilation environment, it reports the error information. That is, when the compiler compiles the source code, if the source code or the compilation environment is wrong, it only needs to report the corresponding error information, which has nothing to do with the compilation configuration file.
[0051] When the compiler detects an error in the compilation options, it prompts the compiler to adjust the compilation rule base based on the incorrect compilation options. When the compiler detects an error in the compilation options, it means that there is an error in the compilation options in the compilation configuration file. The compilation options are obtained by matching the compilation rule base, so the compilation rule base needs to be adjusted. Therefore, the compilation rule base is adjusted based on the incorrect compilation options prompt.
[0052] In some embodiments, the method for automatically generating a compiled configuration file is as follows: Figure 3 As shown, the process is as follows: obtain the project attributes and corresponding attribute values of the software development project; perform rule matching based on the compilation rule base, if the match is successful, generate the corresponding compilation configuration file, otherwise, adjust the compilation rule base (that is, the combination of the attribute values of each project attribute is used as a new matching rule, and the corresponding manually configured compilation option set is added to the compilation rule base); after generating the compilation configuration file, perform syntax and compilation option compatibility verification on the generated compilation configuration file, if the verification fails, adjust the compilation configuration file, if the verification passes, use the compiler to compile the source code based on the compilation configuration file to determine whether the compilation passes, if it passes, the entire compilation configuration file generation process is completed, if it fails, analyze the compiler's error report, if there is an error in the source code or the compilation environment, report the error information, and determine that the entire compilation configuration file generation process is completed, if there is an error in the compilation option, prompt to adjust the compilation rule base, re-match the new compilation option set based on the adjusted compilation rule base, enter the generation of a new compilation configuration file, and then undergo subsequent verification until the entire compilation configuration process is completed.
[0053] The following describes the automatic generation device for a compilation configuration file provided by the present invention. The automatic generation device for a compilation configuration file described below and the automatic generation method for a compilation configuration file described above can refer to each other.
[0054] The automatic generation device of the compilation configuration file according to the embodiment of the present invention is as follows: Figure 4 As shown, it includes the following modules: The attribute acquisition module 410 is used to acquire various project attributes of the software development project and corresponding attribute values.
[0055] The query matching module 420 is configured to query a preset compilation rule library for a target compilation option set that matches the attribute value of each project attribute.
[0056] The file generation module 430 is configured to generate a compilation configuration file based on the target compilation option set.
[0057] The compilation rule library stores a plurality of matching rules and a compilation option set corresponding to each matching rule, and each matching rule corresponds to a combination of attribute value permutations of all project attributes.
[0058] In the apparatus for automatically generating a compilation configuration file of this embodiment, a compilation rule library stores a plurality of matching rules and a compilation option set corresponding to each matching rule, wherein each matching rule corresponds to a combination of attribute value permutations of all project attributes. After obtaining the project attributes and corresponding attribute values of a software development project, the compilation rule library is queried for a target compilation option set that matches the attribute values of each project attribute, and a compilation configuration file is generated based on the target compilation option set, thereby achieving automatic generation of the compilation configuration file. Compared with manual configuration, the configuration efficiency of the compilation configuration file is improved, and the problem of poor performance or poor compatibility of the compiled program caused by selection of inappropriate compilation options due to human negligence or lack of experience is avoided.
[0059] In some embodiments, the attribute acquisition module 410 is specifically used to read project files related to the software development project, and extract each project attribute and the corresponding attribute value from the project file based on the keywords of each project attribute; and / or, send a project attribute consultation request to the developer terminal, and receive a response result returned by the developer terminal, and extract each project attribute and the corresponding attribute value from the response result.
[0060] In some embodiments, different project attributes have different priorities. The compilation rule base stores the matching rules in a tree structure. The compilation rule base is generated as follows: A first-level node of a tree structure is created with each attribute value of the first-priority item attribute, and each first-level node corresponds to an attribute value of the first-priority item attribute.
[0061] For any i-1th layer node, create an i-th layer node corresponding to each attribute value of the project attribute of the i-th priority, and use each i-1th layer node as a child node of the said any i-1th layer node until the Nth layer node is created, where N is the total number of project attributes, i is greater than or equal to 2, and less than or equal to N.
[0062] The corresponding compilation option set is associated with the matching rule corresponding to each first-layer node to each leaf node of the Nth layer to complete the creation of the compilation rule base.
[0063] In some embodiments, the query matching module 420 is specifically used to assign default attribute values to project attributes with missing attribute values; according to the priority of each project attribute, rule matching is started from the first layer node in the compilation rule library of the tree structure until the last layer leaf node is matched; and the compilation option set corresponding to the last layer leaf node is determined as the target compilation option set.
[0064] In some embodiments, the automatic compilation configuration file generation device further includes: a rule adding module for prompting a user to manually configure a compilation option set when no target compilation option set matching the attribute values of the project attributes is found in a preset compilation rule library, so as to generate a compilation configuration file according to the manually configured compilation option set, and adding the combination of the attribute values of the project attributes as a new matching rule and the corresponding manually configured compilation option set to the compilation rule library.
[0065] In some embodiments, the automatic compilation configuration file generation device also includes: a configuration file verification module, which is used to verify the syntax of the compilation configuration file and the compatibility of each compilation option in the compilation option set after generating the compilation configuration file based on the target compilation option set, and generate corresponding prompt information if the verification fails; send the prompt information to the developer terminal, receive adjustment information sent by the developer terminal, and adjust the compilation configuration file according to the adjustment information.
[0066] In some embodiments, the compilation configuration file automatic generation device also includes: a compilation verification module, which is used to compile the source files of the software development project based on the compilation configuration file after adjusting the compilation configuration file; report error information when the compiler detects an error in the source code or the compilation environment; and adjust the compilation rule base based on the erroneous compilation option prompt when the compiler detects an error in the compilation option.
[0067] Figure 5 An example of a physical structure diagram of an electronic device is shown below. Figure 5As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530, and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 communicate with each other via the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the method for automatically generating a compiled configuration file, which includes: Get each project attribute and corresponding attribute value of the software development project.
[0068] A target compilation option set matching the attribute value of each project attribute is searched in a preset compilation rule library.
[0069] A compilation configuration file is generated based on the target compilation option set.
[0070] The compilation rule library stores a plurality of matching rules and a compilation option set corresponding to each matching rule, and each matching rule corresponds to a combination of attribute value permutations of all project attributes.
[0071] Furthermore, the logic instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0072] On the other hand, the present invention further provides a computer program product, comprising a computer program, which may be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can perform the method for automatically generating a compilation configuration file provided by each of the above methods, the method comprising: Get each project attribute and corresponding attribute value of the software development project.
[0073] A target compilation option set matching the attribute value of each project attribute is searched in a preset compilation rule library.
[0074] A compilation configuration file is generated based on the target compilation option set.
[0075] The compilation rule library stores a plurality of matching rules and a compilation option set corresponding to each matching rule, and each matching rule corresponds to a combination of attribute value permutations of all project attributes.
[0076] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method for automatically generating a compilation configuration file provided by the above methods is implemented, and the method includes: Get each project attribute and corresponding attribute value of the software development project.
[0077] A target compilation option set matching the attribute value of each project attribute is searched in a preset compilation rule library.
[0078] A compilation configuration file is generated based on the target compilation option set.
[0079] The compilation rule library stores a plurality of matching rules and a compilation option set corresponding to each matching rule, and each matching rule corresponds to a combination of attribute value permutations of all project attributes.
[0080] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0081] Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented using software plus a necessary general-purpose hardware platform, or of course, hardware. Based on this understanding, the essence of the above technical solution, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, or an optical disk, and includes a number of instructions for causing a computer device (such as a personal computer, server, or network device) to execute the methods described in each embodiment or certain portions of the embodiments.
[0082] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A method for automatically generating a compilation configuration file, characterized in that: include: Obtain each project attribute and corresponding attribute value of the software development project; Searching a preset compilation rule library for a target compilation option set that matches the attribute value of each project attribute; Generate a compilation configuration file based on the target compilation option set; The compilation rule library stores a plurality of matching rules and a compilation option set corresponding to each matching rule, and each matching rule corresponds to a combination of attribute value permutations of all project attributes.
2. The method for automatically generating a compilation configuration file according to claim 1, wherein: Get the project attributes and corresponding attribute values of the software development project, including: Reading a project file related to a software development project, and extracting each of the project attributes and corresponding attribute values from the project file based on a keyword of each of the project attributes; And / or, sending a project attribute inquiry request to a developer terminal, receiving a response result returned by the developer terminal, and extracting each of the project attributes and corresponding attribute values from the response result.
3. The method for automatically generating a compilation configuration file according to claim 1, wherein: Different project attributes have different priorities. The compilation rule base stores the matching rules in a tree structure. The compilation rule base is generated as follows: Creating first-level nodes of a tree structure with each attribute value of the first-priority item attribute, where each first-level node corresponds to an attribute value of the first-priority item attribute; For any i-1th layer node, create an i-th layer node corresponding to each attribute value of the i-th priority project attribute, and use each i-1th layer node as a child node of the i-1th layer node until the Nth layer node is created, where N is the total number of project attributes, and i is greater than or equal to 2 and less than or equal to N; The corresponding compilation option set is associated with the matching rule corresponding to each first-layer node to each leaf node of the Nth layer to complete the creation of the compilation rule base.
4. The method for automatically generating a compilation configuration file according to claim 3, wherein: Searching a preset compilation rule library for a target compilation option set that matches the attribute value of each project attribute includes: Assign default attribute values to project attributes that are missing; According to the priority of each item attribute in the tree-structured compilation rule base, rule matching is performed starting from the first layer node until the last layer leaf node is matched; The compilation option set corresponding to the leaf node of the last layer is determined as the target compilation option set.
5. The method for automatically generating a compilation configuration file according to claim 1, wherein: Also includes: If a target compilation option set that matches the attribute values of the project attributes cannot be found in the preset compilation rule library, the user is prompted to manually configure the compilation option set, so as to generate a compilation configuration file based on the manually configured compilation option set, and the combination of the attribute values of the project attributes is used as a new matching rule, and the corresponding manually configured compilation option set is added to the compilation rule library.
6. The method for automatically generating a compilation configuration file according to any one of claims 1 to 5, characterized in that: After generating a compilation configuration file based on the target compilation option set, the method further includes: Verifying the syntax of the compilation configuration file and the compatibility of each compilation option in the compilation option set, and generating corresponding prompt information if the verification fails; The prompt information is sent to the developer terminal, and adjustment information sent by the developer terminal is received, and the compilation configuration file is adjusted according to the adjustment information.
7. The method for automatically generating a compilation configuration file according to claim 6, wherein: After adjusting the compilation configuration file, the following steps are also included: Compile the source files of the software development project based on the compilation configuration file; Report error information when the compiler detects errors in the source code or the compilation environment; When the compiler detects an error in the compilation options, the compilation rule base is adjusted based on the error in the compilation options.
8. A device for automatically generating a compilation configuration file, characterized in that: include: The attribute acquisition module is used to obtain the project attributes and corresponding attribute values of the software development project; A query matching module, configured to search a preset compilation rule library for a target compilation option set that matches the attribute value of each project attribute; A file generation module, configured to generate a compilation configuration file based on the target compilation option set; The compilation rule library stores a plurality of matching rules and a compilation option set corresponding to each matching rule, and each matching rule corresponds to a combination of attribute value permutations of all project attributes.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the method for automatically generating a compilation configuration file according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for automatically generating a compilation configuration file according to any one of claims 1 to 7 is implemented.