Code generation method and system for customized derivative project

By using predefined configurations and code preprocessing in the main code to generate code for customized derivative projects, the problems of time-consuming code configuration and difficult synchronization in the existing technology are solved, and efficient and flexible customized code generation is achieved.

CN120653294APending Publication Date: 2025-09-16BEIJING ZHAOXUN HENGDA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510715136.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-30
Publication Date
2025-09-16

AI Technical Summary

Technical Problem

In software development, during the code generation process of customized derivative projects, existing configuration management tools cause code configuration to take a long time, debugging to be difficult, and synchronization back to the main code to be difficult, making it difficult to effectively utilize main code resources, increasing maintenance costs and code fragmentation.

Method used

Ensure consistency in development and testing by using predefined configurations and code preprocessing in the main code, blocking code functions, creating predefined configurations for derivative projects, optimizing and adjusting difference functions, and using preprocessing generation tools to generate release projects that only contain necessary code.

Benefits of technology

It enables the generation of multiple customized software versions without modifying the main code, improving development efficiency, reducing maintenance costs, enhancing software flexibility and scalability, and reducing code fragmentation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120653294A_ABST
    Figure CN120653294A_ABST
Patent Text Reader

Abstract

The invention discloses a code generation method and system for customized derivative items. The method comprises the following steps: acquiring a trunk code; creating a predefined configuration of the derivative project, and creating a development project of the derivative project by taking the predefined configuration as a basis of the main code derivative project; developing, debugging and iterating specific functions, which are different from the trunk code, of the derivative project; performing optimization adjustment on the predefined configuration; adding or modifying the trunk codes to add or optimize functions, and increasing or decreasing configuration items of the trunk codes as required; and after the derivative project is tested and verified, generating a derivative project release project. Derivative engineering development is carried out by using different predefined configurations, so that the development efficiency is effectively improved, the maintenance cost is reduced, and the flexibility and expandability of software are enhanced.
Need to check novelty before this filing date? Find Prior Art

Claims

1. A code generation method for a customized derivative project, characterized in that The following steps are involved: S1: Get the main code; S2: Create a predefined configuration for the derivative project, use the predefined configuration as the basis for the main code derivative project, and create a development project for the derivative project; S3: In the development of the derivative project, develop, debug, and iterate on features that are unique to the derivative project and differ from the main code; optimize and adjust the predefined configurations in step S2; add or modify the main code to add or optimize features, and increase or decrease configuration items in the main code as needed; S4: After the derivative project is tested and verified, the derivative project is input into the preprocessing generation tool, and the preprocessing generation tool generates the derivative project release project, retaining only the necessary code for the derivative project.

2. The method for generating code for a customized derivative project according to claim 1, wherein: The code block refers to the use of macro definition marks to divide the configurable and configurable code blocks in the code, which include at least functions, interfaces, and functions, into blocks as needed during the development process of the main code; When using macro definitions to segment code blocks, select logical operations and numerical operations that support macro expansion.

3. The method for generating code for a customized derivative project according to claim 2, wherein The pre-processing further comprises: Inject predefined configuration items into the code through pre-agreed code comments in a special format.

4. The method for generating code for a customized derivative project according to claim 3, wherein The predefined configuration items include one or more of the following: 1) The header files of the example codes are included by macro definitions, so that one or more of these example code header files can be selectively included by modifying the configuration items; 2) Using a series of conditional compilation instructions to aggregate different static parameter combinations under different conditions, so as to select different static parameter combinations by modifying the configuration items; 3) The configuration project contains different function interfaces and interface instance variables that can be referenced externally. Specific functions or variables can be selectively included through the configuration project; 4) The default instruction #include CONFIG_SYSTEM_HEADER is agreed upon, where CONFIG_SYSTEM_HEADER represents a configuration item that modifies the reference of the system header file to adapt to the header files of different systems that the derived project depends on.

5. The method for generating code for a customized derivative project according to any one of claims 1 to 4, characterized in that The code preprocessing in step S1 is implemented by a preprocessing generation tool, which includes the following sub-steps: Read the file and process the file encoding, unifying the encoding format within the preprocessing generation tool; Clean up characters that are irrelevant to the code logic or text markup logic, merge lines, remove redundant line breaks, and unify the smallest line unit of merged code or text markup to standardize the file content; Perform static analysis on code and text files, parsing the code into an abstract syntax tree; Perform all preprocessing operations on the abstract syntax tree after code parsing; During the execution of the preprocessing process, a processing queue is created and the minimum unit of the operation to be processed is filled into the preprocessing task queue; The merged and simplified preprocessing task queue is used to process the code syntax tree level by level. The processed abstract syntax tree is then restored to human-readable code or text through a code reverse restoration algorithm.

6. The method for generating code for a customized derivative project according to claim 1, wherein In step S1, the main code is designed to support configuration of code functions through code preprocessing.

7. The method for generating code for a customized derivative project according to claim 1, wherein In step S1, the code preprocessing at least includes code segmentation and macro definition replacement of code-configurable references or text resources.

8. The method for generating code for a customized derivative project according to claim 1, wherein: After step S4, step S5 is also included: constructing the release project of the derivative project and performing comparative testing and verification on the functional performance of the construction results of the development project to ensure that the requirements of the release project are consistent with those of the development project.

9. The method for generating code for a customized derivative project according to claim 8, wherein: After step S5, the method further includes step S6: merging newly added functional code modules that can be merged into the main code during the development of the derivative project to increase the functions of the main code; Merge the main code problem fixes or performance optimization codes during the development of derivative projects, and regenerate the previously generated derivative projects after this step so that other derivative projects can obtain the main code problem fixes and performance optimization updates in a transitive manner.

10. A code generation system for customized derivative projects, characterized by The invention comprises a processor and a memory; wherein the memory is coupled to the processor and is used to store a computer program, and when the computer program is executed by the processor, the processor implements the code generation method according to any one of claims 1 to 9.