Source code compiling method and device, computer equipment and readable storage medium
By using source code compilation methods in tools such as MonoRepo, we obtain code library identification information, generate code storage warehouses and modify information storage areas, the problem of component version information is solved, and high-precision version control and flexible code library management are achieved.
Patent Information
- Application Number
- CN202411756823.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-03-14
AI Technical Summary
In tools such as MonoRepo, since there is no independent submission record for component modification, component version information is lost, and it is impossible to determine whether each modification is compatible with the current modification, resulting in confusion in version management.
Provide a source code compilation method, by obtaining the identification information of multiple code libraries, generating code storage warehouses and modification information storage areas, automatically capturing modification information and generating binary components, ensuring that each modification has detailed records and version information.
Improves version control accuracy, enhances flexibility in codebase management, improves team collaboration efficiency, simplifies the continuous integration/continuous deployment process, and reduces error rates and maintenance costs.
Smart Images

Figure CN119621136A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of research and development frameworks, and in particular to a source code compilation method, apparatus, computer equipment, and readable storage medium. Background Art
[0002] In the wave of componentization, all projects or modules are stored in the same code base by using tools such as MonoRepo, which have dependencies on each other and can share code and resources. Code and resources can be easily shared, code duplication can be reduced, and maintenance and upgrades can be facilitated. However, if the code base is too large, it will increase the compilation and building time, and more stringent code management specifications are also required to avoid code conflicts and errors.
[0003] To solve the problem of overly large code bases, different projects or modules are currently stored in different code bases. Each code base is managed independently and has no dependencies on each other. Modifying one code base will not affect other code bases, and version control and release can be flexibly performed. However, in components such as MonoRepo, since there is no independent submission record for modification, component version information will be lost. It is impossible to determine whether each modification is compatible with the current modification, resulting in very confusing version management of the code base.
[0004] Therefore, there is an urgent need for a source code compilation method for multiple code bases to ensure that each modification is compatible with the current modification. Summary of the invention
[0005] The present application provides a source code compilation method, device, computer equipment and readable storage medium, which aims to solve the current problem that different projects or modules are stored in different code bases, each code base is managed independently, and there is no dependency between each other. Modifying one code base will not affect other code bases, and version control and release can be flexibly performed. However, in components such as MonoRepo, since there is no independent submission record for modification, the component version information will be lost. It is impossible to determine whether each modification is compatible with the current modification, resulting in a very confusing version management of the code base.
[0006] In a first aspect, the present application provides a source code compilation method, comprising:
[0007] Obtain identification information corresponding to multiple code bases to be managed;
[0008] Generate code storage bins and modification information storage areas corresponding to multiple code libraries according to the identification information, each code library runs in the code storage bin, and the modification information storage area is stored in the code storage bin;
[0009] Upon receiving first modification information of at least one code repository in the code storage repository, generating a corresponding binary component according to the first modification information;
[0010] The binary component is added to the modification information storage area according to the identification information of the code library corresponding to the first modification information, and the compilation of the source code in the code storage bin is completed.
[0011] In some embodiments, the identification information includes at least the name, URL and path of the code repository; the code storage repository is a Git storage repository; and code storage repositories and modification information storage areas corresponding to multiple code repositories are generated based on the identification information, including: creating a blank Git storage repository; adding each code repository and the corresponding identification information to the Git storage repository, with each code repository as a submodule in the Git storage repository; cloning the Git storage repository and each submodule in a preset development environment to ensure that all submodules can be accessed and used in the local development environment; generating a modification information storage area in the Git storage repository based on the identification information corresponding to each submodule for storing modification records.
[0012] In some embodiments, after adding the binary component to the modification information storage area according to the identification information of the code library corresponding to the first modification information, the binary component generates a historical modification component corresponding to the identification information; after completing the compilation of the source code in the code storage warehouse, it also includes: when receiving new second modification information, generating a corresponding binary component according to the second modification information; searching in the code storage warehouse according to the identification information of the code library corresponding to the second modification information, if the identification information corresponding to the second modification information has a corresponding historical modification component in the code storage warehouse, adding the binary component corresponding to the second modification information to the historical modification component.
[0013] Exemplarily, before adding the binary component corresponding to the second modification information to the historical modification component, it also includes: performing a legitimacy check on the modification content corresponding to the second modification information and the modification content corresponding to the historical modification component to obtain a check result; if it is determined according to the check result that the legitimacy check fails, the check result is returned to the terminal device corresponding to the second modification information to prompt adjustment of the second modification information.
[0014] It should be noted that, in some embodiments, the legality of the modified content corresponding to the second modification information is verified with the modified content corresponding to the historical modification component, including: comparing the modified content corresponding to the second modification information with the modified content corresponding to the historical modification component to obtain the code structure similarity score, interface change impact score and dependency consistency score; obtaining the code quality score of the modified content corresponding to the second modification information; and completing the legality verification based on the code structure similarity score, interface change impact score, dependency consistency score and code quality score.
[0015] It should be noted that, in some embodiments, if it is determined based on the verification result that the legality check fails, the method also includes: determining the corresponding target code that fails the legality check in the second modification information based on the verification result; and canceling the modification corresponding to the target code in the code library corresponding to the second modification information.
[0016] In some embodiments, if the first modification information corresponds to multiple code bases in the code storage bin, generating a corresponding binary component according to the first modification information, and adding the binary component to the modification information storage area according to the identification information of the code base corresponding to the first modification information, including: parsing the first modification information, obtaining multiple sub-modification information and identification information of the code base corresponding to each sub-modification information; the sub-modification information at least includes a version number, a compilation time, and a compiler identifier; generating a sub-binary component according to each sub-modification information and the corresponding identification information; generating a binary component corresponding to the first modification information according to each sub-binary component. Adding each sub-binary component to the modification information storage area according to the identification information corresponding to each sub-binary component.
[0017] In a second aspect, the present application provides a source code compiling device, comprising:
[0018] An information acquisition unit, used to acquire identification information corresponding to a plurality of code libraries to be managed;
[0019] A storage generation unit, configured to generate a plurality of code storage bins and modification information storage areas corresponding to the code libraries according to the identification information, wherein each code library is run in the code storage bin, and the modification information storage area is stored in the code storage bin;
[0020] a modification receiving unit, configured to generate a corresponding binary component according to the first modification information upon receiving first modification information of at least one of the code libraries in the code storage bin;
[0021] The compilation completion unit is used to add the binary component to the modification information storage area according to the identification information of the code library corresponding to the first modification information, and complete the compilation of the source code in the code storage warehouse.
[0022] In a third aspect, the present application further provides a computer device, including:
[0023] Memory and processor;
[0024] The memory is used to store computer programs;
[0025] The processor is used to execute the computer program and implement the steps of the source code compiling method described in the first aspect above when executing the computer program.
[0026] In a fourth aspect, the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the steps of the source code compilation method described in the first aspect above.
[0027] The embodiments of the present application provide a source code compilation method, apparatus, computer device, and readable storage medium, which are intended to solve the problems existing in the management and compilation of multiple code repositories, especially when it comes to the management of components within a single code repository (MonoRepo), while maintaining clear tracking of component modification records and versions without destroying component independence.
[0028] First, the system used in the method can identify and obtain the unique identifier of each code base that needs to be managed (such as the name, ID, or URL of the code base, etc.), so that subsequent operations can effectively manage and distinguish each code base. The collection of this identification information allows the system to dynamically adapt to the needs of different code bases.
[0029] Then, the code repository is a space for storing the source code of each code base, while the modification information storage area is an area dedicated to recording the modification information that has occurred in the code base. The creation of these two storage spaces ensures a clear separation of the code and its modification history, which is conducive to subsequent version control and problem tracking. Each code base has its own independent code repository, which means that it can be run, built, and tested independently without interfering with the workflow of other code bases.
[0030] Then, when the developer modifies the code in any code base, the method can automatically capture the modification information. The "first modification information" here refers to the detailed information of any modification operation, including but not limited to the time of modification, modification content, modifier, etc. By compiling the modified source code, a binary component that can run independently is generated. This step is the key to ensuring that the source code can be transformed into a practical software product or service. Every time the code is modified, a new binary component version will theoretically be generated, ensuring that each modification has a corresponding executable version.
[0031] Finally, the generated binary components and their related modification information (such as version number, modification time, modifier, etc.) are added to the modification information storage area corresponding to the code base. Doing so not only preserves the version information of the components, but also enables the development team to easily trace back to the build status at any specific point in time, providing a solid foundation for code review, problem troubleshooting, and subsequent continuous integration and continuous deployment (CI / CD).
[0032] The provided method has the following beneficial effects:
[0033] 1. Improve the accuracy of version control: By binding the modification information of each code base to the binary component, this method greatly improves the accuracy of version control, ensures that every code change can be traced, and helps maintain code quality and stability.
[0034] 2. Enhanced flexibility of code base management: It supports parallel development of multiple code bases and allows fine-grained component management in MonoRepo, providing more flexibility for different development scenarios.
[0035] 3. Improve team collaboration efficiency: Clear modification records and version information make it easier for team members to understand each other's work progress, reduce communication costs, and improve development efficiency.
[0036] 4. Simplify the continuous integration / continuous deployment process: Since each modification generates a new binary component and its detailed information is recorded, this greatly simplifies the build, test, and release steps in the CI / CD process and accelerates the software delivery cycle.
[0037] 5. Reduce error rates and maintenance costs: Through automated compilation and version management, the possibility of human errors is reduced, and long-term maintenance work is simplified, especially when multiple versions need to be supported at the same time.
[0038] In summary, this source code compilation method provides an efficient solution for concurrent development in complex multiple code bases or a single large code base by cleverly combining code storage and modification information recording. It significantly improves the version management accuracy, development flexibility, team collaboration efficiency and automation level in the software development process, which is of great significance to improving the quality of software products and accelerating development speed.
[0039] It should 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
[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0041] Figure 1 This is a schematic flow chart of the steps of a source code compilation method provided by an embodiment of the present application;
[0042] Figure 2 is a schematic diagram of a Git storage repository provided by an embodiment of the present application;
[0043] Figure 3 It is a flow chart of a source code compilation method provided by an embodiment of the present application;
[0044] Figure 4 It is a schematic diagram of the structure of a source code compiling device provided in one embodiment of the present application;
[0045] Figure 5 It is a schematic block diagram of the structure of a computer device provided in one embodiment of the present application.
[0046] It should 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. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0048] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0049] It should be understood that, in order to facilitate the clear description of the technical solutions of the embodiments of the present invention, in the embodiments of the present invention, the words "first", "second", etc. are used to distinguish the same items or similar items with substantially the same functions and effects. Those skilled in the art can understand that the words "first", "second", etc. do not limit the quantity and execution order, and the words "first", "second", etc. do not necessarily limit the difference.
[0050] It should be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0051] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0052] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0053] In the wave of componentization, all projects or modules are stored in the same code base by using tools such as MonoRepo, which have dependencies on each other and can share code and resources. Code and resources can be easily shared, code duplication can be reduced, and maintenance and upgrades can be facilitated. However, if the code base is too large, it will increase the compilation and building time, and more stringent code management specifications are also required to avoid code conflicts and errors.
[0054] To solve the problem of the code base being too large, different projects or modules are currently stored in different code bases. Each code base is managed independently and has no dependencies on each other. Modifying one code base will not affect other code bases, and version control and release can be flexibly performed. However, in components such as MonoRepo, since there is no independent submission record for modification, component version information will be lost. It is impossible to determine whether each modification is compatible with the current modification, resulting in very confusing version management of the code base. The official Bazel solution not only requires distributed server support, but also requires Hook IDE build process, which increases the difficulty of implementing the solution.
[0055] Therefore, there is an urgent need for a source code compilation method for multiple code bases to ensure that each modification is compatible with the current modification.
[0056] To solve the above problems, please refer to Figure 1 , Figure 1 This is a schematic flow chart of a source code compilation method provided by an embodiment of the present application. The source code compilation method can be implemented by a computer device, and the computer device can be deployed on a single server or a server cluster. It can also be deployed on a handheld terminal, a laptop computer, a wearable device or a robot, etc.
[0057] It should be noted that the acquisition of any code and information mentioned in the provided method is in compliance with relevant regulations and is carried out with the user's consent, and will not infringe on the user's privacy or violate relevant laws and regulations.
[0058] At the same time, the method provided by this application can be applied to scenarios such as the financial field, which has a large number of code bases and requires frequent code modifications. At the same time, it can also achieve good application effects in other scenarios that require the application and modification of a large number of code bases. Therefore, the financial field is only a specific example of this application, and the specific application scope of the method provided by this application is not limited.
[0059] To solve the above problems, please refer to Figure 1 Specifically, Figure 1 As shown, the provided source code compilation method includes steps S101 to S104. The details are as follows:
[0060] Step S101: Obtain identification information corresponding to multiple code libraries to be managed.
[0061] Specifically, the system (hereinafter referred to as the system) used by the method obtains unique identification information of each code base through a unified interface or tool. Such identification information may include the name, ID, URL, version number, etc. of the code base. The identification information may be obtained through API calls, database queries, metadata reading of version control systems (such as Git), etc.
[0062] The unique identification information of each code base ensures that the system can accurately manage multiple code bases to avoid confusion and omissions. The system can dynamically adjust the management strategy according to the newly added or deleted code bases to improve flexibility.
[0063] Assume that a financial institution has multiple different departments, each with its own code base for developing different application systems (such as trading systems, risk management systems, customer service systems, etc.). By obtaining the identification information of these code bases, the system can dynamically manage these code bases to ensure that the development work of each department is independent and orderly.
[0064] Step S102: Generate code storage bins and modification information storage areas corresponding to multiple code libraries according to the identification information, each code library runs in the code storage bin, and the modification information storage area is stored in the code storage bin.
[0065] Specifically, based on the collected identification information, the system generates an independent code storage warehouse for each code base to store source code. At the same time, a modification information storage area is generated for each code base to record all modification information in the code base (such as submission logs, version numbers, modifiers, etc.). The code storage warehouse and the modification information storage area can be stored in different databases or file systems to ensure data separation and security.
[0066] Separate storage of code and modification information makes data management clearer and easier to query and analyze. Each code base runs in an independent code storage warehouse, reducing interference between different code bases and improving system stability and reliability.
[0067] For example, if multiple departments of a financial institution develop different application systems, each system has an independent code base. The system generates an independent code storage warehouse and modification information storage area for each code base to ensure that the development work of each department does not affect each other, and facilitates version control and auditing.
[0068] Step S103: upon receiving first modification information of at least one code library in the code storage repository, generating a corresponding binary component according to the first modification information.
[0069] Specifically, the system monitors the code storage warehouse, and when it detects new submission information (i.e., the first modification information) in a code repository, it automatically triggers the compilation process. The compilation process compiles the modified source code into binary components, which can be directly run or integrated into other systems. Different compilation parameters and configurations can be applied during the compilation process to adapt to different development and production environments.
[0070] The automated compilation process reduces human intervention, improves development efficiency, and reduces the error rate. Each modification generates a new binary component, ensuring the traceability and compatibility of each modification.
[0071] For example, a department of a financial institution is responsible for developing a trading system. When there is a new submission in the code base of the trading system, the system automatically triggers the compilation process to generate new binary components. These binary components can be directly deployed to the test server or production environment to ensure that each modification can be quickly verified and launched.
[0072] Step S104: Add the binary component to the modification information storage area according to the identification information of the code library corresponding to the first modification information, and complete the compilation of the source code in the code storage bin.
[0073] Specifically, the system stores the generated binary components and their related modification information (such as version number, submission time, modifier, etc.) in the corresponding modification information storage area. The modification information storage area can be a database table, a log file in the file system, or other storage medium to record the detailed information of each compilation. The integrity and accuracy of the modification information must be ensured during storage to facilitate subsequent version management and troubleshooting.
[0074] Detailed records of each compilation make version management and troubleshooting more efficient. By recording modification information, you can easily trace back to the build status at any specific point in time, which helps to understand historical changes and solve compatibility issues.
[0075] For example, when a financial institution develops a new risk management module, whenever a new code is submitted, the system automatically generates a new binary component and stores its detailed information (such as version number, submission log, build time, etc.) in the modification information storage area. This information can provide a detailed change history during the audit process, helping to ensure the stability and compliance of the system.
[0076] The following example illustrates the specific application of steps S101 to S104 in a financial scenario:
[0077] Suppose a financial institution is using MonoRepo to manage its multiple application systems, including trading systems, risk management systems, and customer service systems. These systems have complex dependencies, but the traditional MonoRepo management method causes component version information to be lost, which brings troubles to version management and maintenance.
[0078] The system obtains the unique identification information of each application system (such as warehouse name, branch, etc.) through the Git API. The system generates an independent code storage repository and modification information storage area for each application system. For example, the trading system has an independent code storage repository trading-system-code and a modification information storage area trading-system-modifications. When a developer submits a new code modification to the code base of the trading system, the system automatically detects the change and triggers the compilation process. A new binary component trading-system-v1.2.3.jar is generated during the compilation process. The generated binary component and its related modification information (such as version number 1.2.3, submission time, modifier, etc.) are stored in trading-system-modifications. This information can include:
[0079] Version number: 1.2.3;
[0080] Submission time: 2024-11-2510:00:00;
[0081] Modified by: Zhang San;
[0082] Submit log: Fixed performance issues in the trading system;
[0083] Through the above steps, financial institutions can better manage the codes and versions of their multiple application systems, ensure that each modification is recorded in detail, and improve the code quality and system stability. In addition, automated compilation and version management also significantly reduce the workload of development and operation and maintenance, and speed up the software delivery cycle.
[0084] In some embodiments, the identification information includes at least the name, URL and path of the code repository; the code storage repository is a Git storage repository; and code storage repositories and modification information storage areas corresponding to multiple code repositories are generated based on the identification information, including: creating a blank Git storage repository; adding each code repository and the corresponding identification information to the Git storage repository, with each code repository as a submodule in the Git storage repository; cloning the Git storage repository and each submodule in a preset development environment to ensure that all submodules can be accessed and used in the local development environment; generating a modification information storage area in the Git storage repository based on the identification information corresponding to each submodule for storing modification records.
[0085] The identification information includes at least the name, URL, and path of the code repository. This information can be obtained through the API of the version control system (such as Git), or through the configuration files or database records of the development team. The system can obtain this identification information by calling the Git API, reading the configuration files, or querying the database. For example, the system can call the API of code hosting platforms such as GitHub and GitLab to obtain the name, URL, and path of each code repository. Generate code storage repositories and modification information storage areas corresponding to multiple code repositories based on the identification information The system creates a blank Git storage repository on the preset code hosting platform (such as GitHub, GitLab) as the main repository. When creating the main repository, you can specify the name, path, and related permission settings of the repository to ensure the security and accessibility of the repository. Add each code repository and the corresponding identification information to the Git storage repository, and each code repository as a submodule in the Git storage repository: The system uses the submodule function of Git to add each code repository to be managed as a submodule to the main repository. Submodules can be added by executing gitsubmodule add <url><path> command to complete, where <url>is the remote repository URL of the submodule, and <path> is the local path of the submodule in the main repository. The system clones the main repository in the preset development environment. The cloning command can be gitclone--recurse-submodules<main repository URL>. The --recurse-submodules parameter ensures that all submodules are also cloned into the local development environment. The system creates an independent modification information storage area for each submodule to record the detailed information of each modification. The modification information storage area can be an independent branch, tag, or a special file (such as changelog.txt) to record the version number, submission time, modifier, and submission log of each submission.
[0086] The identification information including name, URL and path enables the system to manage each code base more accurately to avoid confusion and omissions. Through the hierarchical structure of the main warehouse and submodules, the system can better organize multiple code bases, ensure the independence of each code base, and facilitate centralized management. The system can dynamically add new submodules according to needs, which is convenient for expansion and management. At the same time, by cloning the main warehouse and all submodules, developers can fully access and use all codes locally, which improves the flexibility and efficiency of development. The modification information storage area of each submodule ensures that each modification is recorded in detail, which is convenient for version management and auditing. Through the record of modification information, it is easy to trace back to the build status at any specific point in time, which helps to understand historical changes and solve compatibility issues.
[0087] From the creation of the main repository to the addition of submodules, to the cloning and compilation of the code, the entire process can be automated, reducing the possibility of human intervention and errors. The hierarchical structure of the main repository and submodules enables team members to understand the organizational structure of the code more clearly, reducing communication costs. All submodules are concentrated in one main repository, making it easier for team members to collaborate and share code.
[0088] In some embodiments, after adding the binary component to the modification information storage area according to the identification information of the code library corresponding to the first modification information, the binary component generates a historical modification component corresponding to the identification information; after completing the compilation of the source code in the code storage warehouse, it also includes: when receiving new second modification information, generating a corresponding binary component according to the second modification information; searching in the code storage warehouse according to the identification information of the code library corresponding to the second modification information, if the identification information corresponding to the second modification information has a corresponding historical modification component in the code storage warehouse, adding the binary component corresponding to the second modification information to the historical modification component.
[0089] When receiving new second modification information, a corresponding binary component is generated according to the second modification information; the code storage warehouse is searched according to the identification information of the code library corresponding to the second modification information, and if the identification information corresponding to the second modification information has a corresponding historical modification component in the code storage warehouse, the binary component corresponding to the second modification information is added to the historical modification component. The system continues to monitor the code storage warehouse, and automatically triggers a new compilation process when new submission information (i.e., the second modification information) is detected. The system searches the code storage warehouse for corresponding historical modification component records according to the identification information of the code library corresponding to the second modification information. If there is a corresponding historical modification component record, the system adds the new binary component to the record. If not, a new historical modification component record is created and the new binary component is added to the record. The system records the new modification information (version number, submission time, modifier, submission log, etc.) in the corresponding modification information storage area.
[0090] By generating and maintaining historical modification component records, the system can record in detail all versions of each code base and their modification information. This helps team members quickly trace back to the build status at any specific point in time when needed, understand historical changes, and resolve compatibility issues. Detailed historical records make version backtracking easier. Developers can quickly find and use old versions of binary components through historical modification component records, improving the reliability and security of version management. Historical modification component records can be used to verify whether new modifications are compatible with historical versions, reducing problems caused by version upgrades.
[0091] The system automatically detects new submission information, automatically generates new binary components and records them in the historical modification component record, reducing the duplication of work for developers and operation and maintenance personnel and improving the efficiency of development and operation and maintenance. The new second modification information triggers the compilation process and automatically adds the new binary components to the historical record, supporting continuous integration and continuous deployment (CI / CD).
[0092] At the same time, the historical modification component records provide the team with transparent version management information, which facilitates collaboration and communication among team members. Through automated processes, it ensures that the modification and compilation operations of each code base follow consistent specifications, reducing the inconsistency caused by human intervention. Detailed historical records make audit work simpler and more efficient, in line with the compliance requirements of the financial industry.
[0093] Exemplarily, before adding the binary component corresponding to the second modification information to the historical modification component, it also includes: performing a legitimacy check on the modification content corresponding to the second modification information and the modification content corresponding to the historical modification component to obtain a check result; if it is determined according to the check result that the legitimacy check fails, the check result is returned to the terminal device corresponding to the second modification information to prompt adjustment of the second modification information.
[0094] Before adding the binary component corresponding to the second modification information to the historical modification component, the system needs to perform a validity check on the modification content of the second modification information. Through the validity check, non-compliant code submissions can be discovered and prevented in a timely manner, reducing system failures caused by erroneous codes. Improve code quality: The verification process can help developers discover potential problems and improve the quality and stability of the code. Transparency: Returning the verification results enables developers to understand the problems with the submission in a timely manner, facilitating adjustments and optimizations.
[0095] It should be noted that, in some embodiments, the legality of the modified content corresponding to the second modification information is verified with the modified content corresponding to the historical modification component, including: comparing the modified content corresponding to the second modification information with the modified content corresponding to the historical modification component to obtain the code structure similarity score, interface change impact score and dependency consistency score; obtaining the code quality score of the modified content corresponding to the second modification information; and completing the legality verification based on the code structure similarity score, interface change impact score, dependency consistency score and code quality score.
[0096] Developer submits code: Li Si submits a new code modification in the code base of the risk management subsystem, adding a new risk assessment model. The system obtains the name, URL, and path of the risk management subsystem through the GitHub API. The system adds the risk management subsystem as a submodule to the main repository composite-trading-platform. The development environment automatically clones the main repository and its submodules. Generate a modification information storage area: Create a changelog.txt file in the / src / risk-management directory. Monitoring and compilation: The system detects new submission information, automatically triggers the compilation process, and generates a new binary component risk-management-v2.1.0.jar. Generate historical modification component records: The system creates a file or directory in the / src / risk-management / historical-components directory to record all versions of the risk-management binary component and its modification information. Zhao Liu submits a new code modification in the code base of the risk management subsystem, adjusting the algorithm of the risk assessment model. The system obtains the name, URL, and path of the risk management subsystem through the GitHub API. The system compares the code structure of the new modification with the historical version and generates a similarity score. The system analyzes the impact of the new interface changes on the historical components and generates an impact score. The system checks whether the new dependencies are consistent with the dependencies of the historical version and generates a consistency score. The system performs a quality assessment on the new code and generates a quality score. The system completes the legality check based on the above four scores. If the new modification passes the verification, the system generates a new binary component risk-management-v2.1.1.jar, records its detailed modification information in changelog.txt, and pushes it to the Maven repository. The system adds the new binary component risk-management-v2.1.1.jar and its modification information to the / src / risk-management / historical-components directory.
[0097] It should be noted that, in some embodiments, if it is determined based on the verification result that the legality check fails, the method also includes: determining the corresponding target code that fails the legality check in the second modification information based on the verification result; and canceling the modification corresponding to the target code in the code library corresponding to the second modification information.
[0098] For example, Sun Qi submitted a new code modification in the code base of the customer service subsystem, adding a new customer support function. The system obtains the name, URL, and path of the customer service subsystem through the GitHub API. The system adds the customer service subsystem as a submodule to the main repository composite-trading-platform. The development environment automatically clones the main repository and its submodules. Create a changelog.txt file in the / src / customer-service directory. The system detects the new submission information, automatically triggers the compilation process, and generates a new binary component customer-service-v1.0.1.jar. The system creates a file or directory in the / src / customer-service / historical-components directory to record all versions of the customer-service binary component and its modification information. For example, Zhou Ba submitted a new code modification in the code base of the customer service subsystem, but this modification introduced a serious performance problem. The system obtains the name, URL, and path of the customer service subsystem through the GitHub API.
[0099] The system verifies the legality of the new modification content and generates a verification result. If the verification result shows that the performance problem is serious, the system returns the verification result to Zhou Ba's terminal device and prompts him to make adjustments. Determine the target code: The system determines the specific code part that does not pass in the new modification information, that is, the target code. The system cancels the modification corresponding to the target code to ensure that only legal modifications are compiled and recorded. If the code adjusted by Zhou Ba passes the verification, the system triggers the compilation process again and generates a new binary component customer-service-v1.0.2.jar. The generated binary component and its detailed modification information are recorded in changelog.txt and pushed to the Maven repository.
[0100] The system adds the new binary component customer-service-v1.0.2.jar and its modification information to the / src / customer-service / historical-components directory.
[0101] In some embodiments, if the first modification information corresponds to multiple code bases in the code storage bin, generating a corresponding binary component according to the first modification information, and adding the binary component to the modification information storage area according to the identification information of the code base corresponding to the first modification information, including: parsing the first modification information, obtaining multiple sub-modification information and identification information of the code base corresponding to each sub-modification information; the sub-modification information at least includes a version number, a compilation time, and a compiler identifier; generating a sub-binary component according to each sub-modification information and the corresponding identification information; generating a binary component corresponding to the first modification information according to each sub-binary component. Adding each sub-binary component to the modification information storage area according to the identification information corresponding to each sub-binary component.
[0102] The system parses the first modification information, obtains multiple sub-modification information and identification information of the code base corresponding to each sub-modification information. The sub-modification information includes at least the version number, compilation time and compiler identification. The system generates sub-binary components according to each sub-modification information and the corresponding identification information. The process of generating sub-binary components includes the steps of compilation, testing and packaging to ensure the quality of each sub-binary component. The system merges all sub-binary components into a binary component corresponding to the first modification information. The merging process can be packaging into a large binary file or building a distribution package containing all sub-components.
[0103] According to the identification information corresponding to each sub-binary component, each sub-binary component and its related modification information are stored in the corresponding modification information storage area. For example, the system records the generated sub-binary component transaction-management-v1.2.3.jar and its modification information in / src / transaction-management / changelog.txt. Store the binary component corresponding to the first modification information: Record the overall binary component corresponding to the first modification information and its detailed modification information in the modification information storage area of the main warehouse.
[0104] For example, the system will record the generated overall binary component composite-trading-platform-v1.2.3.jar and its modification information in / src / composite-trading-platform / changelog.txt. After the compilation is completed, the system will push the binary component to the preset component repository (such as Maven repository) for subsequent integration and deployment.
[0105] By parsing the first modification information, the system can accurately obtain each sub-modification information and the corresponding code base identification information, ensuring that each sub-modification information is correctly processed. The system generates a sub-binary component according to each sub-modification information, improving the accuracy and reliability of the compilation process.
[0106] Each sub-binary component undergoes an independent compilation, testing, and packaging process, ensuring the quality of each sub-component. By merging all sub-binary components into an overall binary component, the system can generate a high-quality, compliant final product.
[0107] By parsing the first modification information, multiple sub-modification information and corresponding code base identification information are obtained, sub-binary components are generated respectively, and then all sub-binary components are merged into an overall binary component. This method not only improves the accuracy and reliability of multi-code base management, but also ensures that the final binary components generated are of high quality and strong compliance. In financial scenarios, this source code compilation method can significantly improve the quality of code base management, protect the integrity and stability of the system, reduce the workload of development and operation and maintenance, and accelerate the software delivery cycle.
[0108] In some embodiments, Figure 2 As shown, Figure 2 This is a schematic diagram of a Git storage warehouse. In view of the unique feature of the MonoRepo warehouse, a component binary package description file (Project_Binary.lock) is added here and added to the git warehouse. The Project_Binary.lock file is used to record the build timing, realize the one-to-one correspondence between binary packages and source code changes, and prevent errors in the correspondence between binary packages after the code needs to be changed. The version number is no longer used here. Instead, commitID is used as the component binary package identifier to prevent version conflicts during multiple simultaneous developments. Taking commitID 239e2df09fb submitted at 2023-01-02 10:00 as an example, this commit modified the source code files of the two components ProjectA and ProjectB, and the binary packages of ProjectA and ProjectB need to be rebuilt to accelerate the build. The specific process is as follows:
[0109] 1. The developer completes the code modification and creates a commit with commitID 239e2df09fb.
[0110] 2. Build the corresponding component binary package based on the commit modification, and upload it to CDN with commitID239e2df09fb and component name as key.
[0111] 3. Modify the Project_Binary.lock file and update the binary package of the corresponding component to commitID239e2df09fb.
[0112] 4. Create a buildcommit in the following format: build(239e2df09fb):ProjectA,ProjectBchecksum2, where checksum2 is the MD5 value of all commitID strings from the previous build commit to the current build commit, which is used to verify its legitimacy and increase accuracy.
[0113] 5. Push code to the remote end.
[0114] Steps 2, 3, and 4 can be combined using a script to detect changed components based on commits and build, upload, and update Project_Binary.lock to achieve atomic operations and greatly improve operational efficiency and accuracy.
[0115] like Figure 3 As shown, the detection process is as follows:
[0116] Description of the component change detection process:
[0117] 1. Create a component set X that needs to be built, which is used to record the components modified by each commit and completed by the build commit.
[0118] 2. Scan the latest 100 commits in the code repository (this value can be optimized according to actual conditions to increase detection accuracy).
[0119] 3. All commits have been sorted in reverse chronological order.
[0120] 4. Start traversing from the earliest commit.
[0121] 5. If the commit is not a build commit, check the source code changes of the commit, find the corresponding component according to the file directory, and add it to set X.
[0122] 6. If the commit is a build commit, check its validity.
[0123] 7. If it is legal, take out the building component corresponding to the commit and delete it from the set X.
[0124] 8. If it is illegal, skip the current build commit.
[0125] 9. Until the traversal is completed, the final component set X that needs to be built is obtained and the result is returned.
[0126] This process can help developers discover changes in the code repository in a timely manner, build and test in a timely manner, and ensure the quality and stability of the project.
[0127] The merged process only requires three steps, which is much simpler than the original MultiRepo. Each repository does not need to be released independently:
[0128] 1. The developer completes the code modification and creates a commit with commitID 239e2df09fb.
[0129] 2. Use scripts to automatically compile, upload, and update modified components.
[0130] 3. Push code to the remote end.
[0131] The provided method has the following beneficial effects:
[0132] 1. Improve the accuracy of version control: By binding the modification information of each code base to the binary component, this method greatly improves the accuracy of version control, ensures that every code change can be traced, and helps maintain code quality and stability.
[0133] 2. Enhanced flexibility of code base management: It supports parallel development of multiple code bases and allows fine-grained component management in MonoRepo, providing more flexibility for different development scenarios.
[0134] 3. Improve team collaboration efficiency: Clear modification records and version information make it easier for team members to understand each other's work progress, reduce communication costs, and improve development efficiency.
[0135] 4. Simplify the continuous integration / continuous deployment process: Since each modification generates a new binary component and its detailed information is recorded, this greatly simplifies the build, test, and release steps in the CI / CD process and accelerates the software delivery cycle.
[0136] 5. Reduce error rates and maintenance costs: Through automated compilation and version management, the possibility of human errors is reduced, and long-term maintenance work is simplified, especially when multiple versions need to be supported at the same time.
[0137] In summary, this source code compilation method provides an efficient solution for concurrent development in complex multiple code bases or a single large code base by cleverly combining code storage and modification information recording. It significantly improves the version management accuracy, development flexibility, team collaboration efficiency and automation level in the software development process, which is of great significance to improving the quality of software products and accelerating development speed.
[0138] See also Figure 4 As shown, Figure 4 1 is a schematic diagram of the structure of a source code compiling device 200 provided in an embodiment of the present application. The source code compiling device 200 is used to execute the steps of the source code compiling method shown in the above embodiments. The source code compiling device 200 can be a single server or a server cluster, or the source code compiling device 200 can be a terminal, which can be a handheld terminal, a laptop computer, a wearable device or a robot, etc.
[0139] like Figure 4 As shown, the source code compiling device 200 includes:
[0140] An information acquisition unit 201 is used to acquire identification information corresponding to a plurality of code libraries to be managed;
[0141] A storage generation unit 202, configured to generate a plurality of code storage bins and modification information storage areas corresponding to the code libraries according to the identification information, wherein each code library is run in the code storage bin, and the modification information storage area is stored in the code storage bin;
[0142] A modification receiving unit 203, configured to generate a corresponding binary component according to the first modification information upon receiving first modification information of at least one of the code libraries in the code storage bin;
[0143] The compilation completion unit 204 is used to add the binary component to the modification information storage area according to the identification information of the code library corresponding to the first modification information, and complete the compilation of the source code in the code storage bin.
[0144] It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the source code compilation device and each module described above can refer to the corresponding processes in the source code compilation method embodiments described in the above embodiments, and will not be repeated here.
[0145] The above-mentioned source code compilation method can be implemented in the form of a computer program. The computer program can be Figure 4 Run on the device shown.
[0146] See also Figure 5 , Figure 5 1 is a schematic block diagram of the structure of a computer device provided in an embodiment of the present application. The computer device includes a processor, a memory and a network interface connected via a device bus, wherein the memory may include a storage medium and an internal memory.
[0147] The storage medium can store an operating device and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute any source code compilation method.
[0148] The processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.
[0149] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor, the processor can execute any source code compilation method.
[0150] The network interface is used for network communication, such as sending assigned tasks, etc. Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the scheme of the present application, and does not constitute a limitation on the terminal to which the scheme of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0151] It should be understood that the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0152] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0153] Obtain identification information corresponding to multiple code bases to be managed;
[0154] Generate code storage bins and modification information storage areas corresponding to multiple code libraries according to the identification information, each code library runs in the code storage bin, and the modification information storage area is stored in the code storage bin;
[0155] Upon receiving first modification information of at least one code repository in the code storage repository, generating a corresponding binary component according to the first modification information;
[0156] The binary component is added to the modification information storage area according to the identification information of the code library corresponding to the first modification information, and the compilation of the source code in the code storage bin is completed.
[0157] In some embodiments, the identification information includes at least the name, URL and path of the code repository; the code storage repository is a Git storage repository; and code storage repositories and modification information storage areas corresponding to multiple code repositories are generated based on the identification information, including: creating a blank Git storage repository; adding each code repository and the corresponding identification information to the Git storage repository, with each code repository as a submodule in the Git storage repository; cloning the Git storage repository and each submodule in a preset development environment to ensure that all submodules can be accessed and used in the local development environment; generating a modification information storage area in the Git storage repository based on the identification information corresponding to each submodule for storing modification records.
[0158] In some embodiments, after adding the binary component to the modification information storage area according to the identification information of the code library corresponding to the first modification information, the binary component generates a historical modification component corresponding to the identification information; after completing the compilation of the source code in the code storage warehouse, it also includes: when receiving new second modification information, generating a corresponding binary component according to the second modification information; searching in the code storage warehouse according to the identification information of the code library corresponding to the second modification information, if the identification information corresponding to the second modification information has a corresponding historical modification component in the code storage warehouse, adding the binary component corresponding to the second modification information to the historical modification component.
[0159] Exemplarily, before adding the binary component corresponding to the second modification information to the historical modification component, it also includes: performing a legitimacy check on the modification content corresponding to the second modification information and the modification content corresponding to the historical modification component to obtain a check result; if it is determined according to the check result that the legitimacy check fails, the check result is returned to the terminal device corresponding to the second modification information to prompt adjustment of the second modification information.
[0160] It should be noted that, in some embodiments, the legality of the modified content corresponding to the second modification information is verified with the modified content corresponding to the historical modification component, including: comparing the modified content corresponding to the second modification information with the modified content corresponding to the historical modification component to obtain the code structure similarity score, interface change impact score and dependency consistency score; obtaining the code quality score of the modified content corresponding to the second modification information; and completing the legality verification based on the code structure similarity score, interface change impact score, dependency consistency score and code quality score.
[0161] It should be noted that, in some embodiments, if it is determined based on the verification result that the legality check fails, the method also includes: determining the corresponding target code that fails the legality check in the second modification information based on the verification result; and canceling the modification corresponding to the target code in the code library corresponding to the second modification information.
[0162] In some embodiments, if the first modification information corresponds to multiple code bases in the code storage bin, generating a corresponding binary component according to the first modification information, and adding the binary component to the modification information storage area according to the identification information of the code base corresponding to the first modification information, including: parsing the first modification information, obtaining multiple sub-modification information and identification information of the code base corresponding to each sub-modification information; the sub-modification information at least includes a version number, a compilation time, and a compiler identifier; generating a sub-binary component according to each sub-modification information and the corresponding identification information; generating a binary component corresponding to the first modification information according to each sub-binary component. Adding each sub-binary component to the modification information storage area according to the identification information corresponding to each sub-binary component.
[0163] The present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the processor implements the steps of the source code compilation method described in the first aspect above.
[0164] The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiment, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc., equipped on the computer device.
[0165] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.< / url> < / url>
Claims
1. A source code compiling method, characterized in that: include: Obtain identification information corresponding to multiple code bases to be managed; Generate a plurality of code storage bins and modification information storage areas corresponding to the code libraries according to the identification information, each of the code libraries is run in the code storage bin, and the modification information storage area is stored in the code storage bin; Upon receiving first modification information of at least one of the code libraries in the code storage bin, generating a corresponding binary component according to the first modification information; The binary component is added to the modification information storage area according to the identification information of the code library corresponding to the first modification information, and the source code in the code storage bin is compiled.
2. The method according to claim 1, characterized in that The identification information includes at least the name, URL and path of the code library; The code storage repository is a Git storage repository; The step of generating a plurality of code storage bins and modification information storage areas corresponding to the code libraries according to the identification information includes: Create a blank Git repository; Add each of the code libraries and the corresponding identification information to the Git storage repository, with each of the code libraries serving as a submodule in the Git storage repository; Clone the Git repository and each of the submodules in a preset development environment to ensure that all submodules can be accessed and used in the local development environment; The modification information storage area is generated in the Git storage repository according to the identification information corresponding to each of the submodules, and is used to store modification records.
3. The method according to claim 1, characterized in that After adding the binary component to the modification information storage area according to the identification information of the code base corresponding to the first modification information, the binary component generates a historical modification component corresponding to the identification information; After the source code in the code storage bin is compiled, the method further includes: When receiving the new second modification information, generating a corresponding binary component according to the second modification information; The code storage repository is searched according to the identification information of the code library corresponding to the second modification information. If a corresponding historical modification component exists in the code storage repository for the identification information corresponding to the second modification information, the binary component corresponding to the second modification information is added to the historical modification component.
4. The method according to claim 3, characterized in that Before adding the binary component corresponding to the second modification information to the historical modification component, the method further includes: Performing a validity check on the modification content corresponding to the second modification information and the modification content corresponding to the historical modification component to obtain a verification result; If it is determined according to the verification result that the legality verification fails, the verification result is returned to the terminal device corresponding to the second modification information to prompt adjustment of the second modification information.
5. The method according to claim 4, characterized in that The performing a legality check on the modification content corresponding to the second modification information and the modification content corresponding to the historical modification component, includes: Compare the modification content corresponding to the second modification information with the modification content corresponding to the historical modification component to obtain a code structure similarity score, an interface change impact score, and a dependency consistency score; Obtain a code quality score of the modified content corresponding to the second modification information; The legality check is completed according to the code structure similarity score, interface change impact score, dependency consistency score and code quality score.
6. The method according to claim 4, characterized in that If it is determined according to the verification result that the legality verification fails, the method further includes: Determine, in the second modification information, a target code corresponding to the failure of the legality check according to the check result; The modification corresponding to the target code in the code library corresponding to the second modification information is cancelled.
7. The method according to claim 1, characterized in that If the first modification information corresponds to a plurality of the code libraries in the code storage bin, generating a corresponding binary component according to the first modification information, and adding the binary component to the modification information storage area according to identification information of the code library corresponding to the first modification information, comprising: Parsing the first modification information to obtain a plurality of sub-modification information and identification information of a code base corresponding to each of the sub-modification information; the sub-modification information at least includes a version number, a compilation time, and a compiler identification; Generate a sub-binary component according to each sub-modification information and the corresponding identification information; Generate a binary component corresponding to the first modification information according to each of the sub-binary components; Each of the sub-binary components is added to the modification information storage area according to the identification information corresponding to each of the sub-binary components.
8. A source code compiling device, characterized in that: include: An information acquisition unit, used to acquire identification information corresponding to a plurality of code libraries to be managed; A storage generation unit, configured to generate a plurality of code storage bins and modification information storage areas corresponding to the code libraries according to the identification information, wherein each code library is run in the code storage bin, and the modification information storage area is stored in the code storage bin; a modification receiving unit, configured to generate a corresponding binary component according to the first modification information upon receiving first modification information of at least one of the code libraries in the code storage bin; The compilation completion unit is used to add the binary component to the modification information storage area according to the identification information of the code library corresponding to the first modification information, and complete the compilation of the source code in the code storage warehouse.
9. A computer device, characterized in that: The computer device includes a memory and a processor; The memory is used to store computer programs; The processor is configured to execute the computer program and implement the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, causes the processor to implement the method according to any one of claims 1 to 7.
Citation Information
Cited By
Document data processing method and device, medium, electronic equipment and program product
CN121212097A