A software module compilation method, electronic device, medium, and product

By monitoring module modification operations, and using module dependency graphs and binding mapping tables to identify and recompile affected modules, the problem of high time and cost of software module compilation and hot updates is solved, improving development efficiency and code consistency.

CN120631376BActive Publication Date: 2025-11-14HUNDSUN TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202511106472.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-08
Publication Date
2025-11-14
Estimated Expiration
2045-08-08

AI Technical Summary

Technical Problem

In existing technologies, the compilation and hot updating of software modules are time-consuming and computationally resource-intensive, resulting in low development efficiency.

Method used

By monitoring module modifications, and utilizing a pre-generated module dependency graph and binding mapping table, other modules that have dependencies on the modified module are identified, and only these modules whose imported content contains the modified content are recompiled.

Benefits of technology

It optimizes resource utilization, improves development efficiency, ensures code consistency and correctness, reduces the time and computing resources required for software module compilation and hot updates, and enhances the maintainability and scalability of software projects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120631376B_ABST
    Figure CN120631376B_ABST
Patent Text Reader

Abstract

This invention discloses a software module compilation method, electronic device, medium, and product. The method includes: after detecting a modification operation on a first module, determining the first content that has changed in the first module; obtaining a pre-generated module dependency graph and binding mapping table; determining at least one second module that has a dependency relationship with the first module according to the module dependency graph; selecting at least one recompiled module whose imported content contains the first content from the at least one second module according to the binding mapping table; and recompiling the at least one selected recompiled module. This ensures the consistency and correctness of the code, compiles only the affected parts, saves time and computing resources for software module compilation and hot updates, improves development efficiency, optimizes resource utilization, and enhances the maintainability, scalability, and project management efficiency of the software project.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of software systems and web page updating technology, and in particular to a software module compilation method, electronic device, medium and product. Background Technology

[0002] With the rapid development of front-end technology, emerging build tools have gained attention for their lightweight design and optimized development experience.

[0003] For front-end projects with a history of development, blindly migrating build tools can lead to high migration costs and uncontrollable migration risks. In related technologies, to meet the needs of mature products for fixed module division and complex configuration management, as well as to ensure compatibility with different browsers, static module packaging tools are typically used to compile modules as the smallest unit. Based on the module dependency graph, all modules in the entire dependency subtree are recompiled to form a package file for hosting and hot updating.

[0004] However, as the scale of applications expands and the module dependency graph becomes more complex, even with hot updates enabled, the entire module file of the dependency subtree still needs to be regenerated after each code change, which reduces development efficiency and increases the time cost and computing resources required for software module compilation and hot updates. Summary of the Invention

[0005] This invention provides a software module compilation method, electronic device, medium, and product to solve the problems of high time cost, large consumption of computing resources, and low development efficiency in software module compilation and hot updates.

[0006] According to one aspect of the present invention, a software module compilation method is provided, comprising:

[0007] After detecting a modification operation to the first module, the first content that has changed in the first module is determined; wherein, the first module is any module of the software project;

[0008] Obtain the pre-generated module dependency graph and binding mapping table; wherein, the module dependency graph is a dependency graph constructed by the static module packaging tool during the packaging process of each module of the software project; the binding mapping table records the exported and imported content of each module in the software project;

[0009] Based on the module dependency graph, at least one second module that has a dependency relationship with the first module is determined;

[0010] Based on the binding mapping table, at least one recompiled module whose imported content contains the first content is selected from the at least one second module;

[0011] The selected at least one recompiled module is recompiled.

[0012] According to another aspect of the present invention, a software module compilation apparatus is provided, comprising:

[0013] The change determination module is used to determine the first content that has changed in the first module after detecting a modification operation on the first module; wherein, the first module is any module of the software project;

[0014] The module for obtaining graphs is used to obtain a pre-generated module dependency graph and binding mapping table; wherein, the module dependency graph is a dependency graph constructed by the static module packaging tool during the packaging process of each module of the software project; the binding mapping table records the exported and imported content of each module in the software project;

[0015] Determine dependent modules, used to determine at least one second module that has a dependency relationship with the first module based on the module dependency graph;

[0016] A filter recompilation module is used to filter at least one recompilation module whose imported content contains the first content from the at least one second module according to the binding mapping table;

[0017] A recompile module is used to recompile the selected at least one recompile module.

[0018] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0019] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to execute the software module compilation method according to any embodiment of the present invention.

[0020] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the software module compilation method described in any embodiment of the present invention.

[0021] According to another aspect of the present invention, a computer program product is also provided, including a computer program that, when executed by a processor, implements the steps of the method as described in any embodiment of the present invention.

[0022] The technical solution of this invention, after detecting a modification operation on a first module, determines the first content that has changed in the first module; obtains a pre-generated module dependency graph and binding mapping table; determines at least one second module that has a dependency relationship with the first module based on the module dependency graph, thereby identifying other modules that have a dependency relationship with the changed module; filters at least one recompiled module whose imported content contains the first content from at least one second module based on the binding mapping table, thereby filtering modules whose imported content contains the changed content; and recompiles the at least one recompiled module, ensuring the consistency and correctness of the code. Only the affected parts are compiled, saving time and computing resources for software module compilation and hot updates, optimizing resource utilization, improving development efficiency, and enhancing the maintainability, scalability, and project management efficiency of the software project.

[0023] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0024] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0025] Figure 1 This is a flowchart of a software module compilation method provided in Embodiment 1 of the present invention;

[0026] Figure 2 This is a flowchart of another software module compilation method provided in Embodiment 2 of the present invention;

[0027] Figure 3 This is a flowchart of another software module compilation method provided in Embodiment 3 of the present invention;

[0028] Figure 4 This is a schematic diagram illustrating a module dependency applicable to an embodiment of the present invention;

[0029] Figure 5 This is a schematic diagram of the structure of a software module compilation device according to Embodiment 4 of the present invention;

[0030] Figure 6 This is a schematic diagram of the structure of an electronic device that implements the software module compilation method of this invention. Detailed Implementation

[0031] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0032] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0033] Example 1

[0034] Figure 1 This is a flowchart of a software module compilation method provided in Embodiment 1 of the present invention. This embodiment is applicable to the recompilation of modified software modules. This method can be executed by a software module compilation device, which can be implemented in hardware and / or software and is generally configured in an electronic device. Figure 1 As shown, the method includes:

[0035] S110. After detecting a modification operation on the first module, determine the first content that has changed in the first module.

[0036] The first module can be any module of the software project.

[0037] In this embodiment of the invention, the first module can be specifically understood as: a module identified as undergoing modification in a software project. In modular programming, a module can be a separate source code file, class, library, framework, or any code unit that can be independently deployed and used. The first content can be specifically understood as: the specific code element that is modified, deleted, or added in the first module. The code element can specifically be: a function or a variable.

[0038] Understandably, in the software development process, software projects are usually composed of many modules, each of which is used to implement a specific function, and one module usually needs to use functions or variables provided by another module, and there are special dependencies between modules.

[0039] Specifically, during the software development process, whenever any module is changed, the system detects the modification operation on the first module through methods such as version control system, file system monitoring, or hot module replacement. Then, it uses methods such as version control system, difference analysis tools, or static code analysis tools to determine the specific content of the change in the first module, i.e., the first content.

[0040] Optionally, based on the above embodiments, determining the first content that has changed in the first module may include:

[0041] Compile the modified first module, compare the compilation result with the compilation result of the first module before the modification, and determine the first content that has changed in the first module based on the comparison result.

[0042] In this embodiment of the invention, the compilation result before the change can be specifically understood as: the compilation result of the first module saved before the first module is changed, which can be: the executable code of the first module after compilation before the change, the intermediate representation generated during the compilation process, or other compilation products.

[0043] Specifically, after the first module is modified, it is recompiled to convert the source code into executable code or intermediate representation, such as bytecode or machine code, consistent with the compilation result before the change. The recompiled result is compared with the compilation result before the change, and based on the comparison result, the first content that has changed in the first module is determined.

[0044] By comparing compilation results, the first change in the first module of the software project can be determined, avoiding the need for repeated processing of unchanged code, saving time and resources, optimizing the change review process, and enhancing the efficiency of change management in software projects. In particular, it improves the development efficiency, operational stability, and maintainability of large-scale projects.

[0045] S120. Obtain the pre-generated module dependency graph and binding mapping table.

[0046] The module dependency graph is a dependency graph built by the static module packaging tool during the packaging process of each module of the software project; the binding mapping table records the exported and imported content of each module in the software project.

[0047] In this embodiment of the invention, the static module packaging tool can be specifically understood as: a tool used to package multiple modules into one or more static files so that they can run in a browser or other environment, such as the webpack module packaging tool.

[0048] A module dependency graph can be understood as a directed graph describing the dependencies between modules in a software project. Nodes represent modules, and directed edges represent dependencies between modules. During the packaging process of a static module packaging tool, the tool analyzes the import and export statements of each module to construct the module dependency graph for the entire project. A binding mapping table can be understood as a table or mapping that records the specific content provided (exported) and required (imported) by each module in the software project. During the packaging process, the static module packaging tool analyzes the code of each module, extracts the module's export and import information, and stores this information in the binding mapping table.

[0049] Exported content can be understood as the parts of a module that can be shared and reused by other modules, including functions or variables. A module exports its content using export statements for other modules to import and use. Imported content can be understood as the parts of content provided by other modules that a module needs. A module imports the required content from other modules using import statements, enabling collaboration and dependencies between modules.

[0050] S130. Determine at least one second module that has a dependency relationship with the first module based on the module dependency graph.

[0051] In this embodiment of the invention, the second module can be specifically understood as: a module that has a dependency relationship with the first module, wherein the dependency relationship includes: direct dependency, indirect dependency and self-dependency.

[0052] Direct dependency can be understood as follows: a module directly uses the exported content of another module through an import statement. If the exported content of the first module is imported or used by other modules, then these importing or using modules can be considered as second modules that directly depend on the first module. In the module dependency graph, the second module and the first module are directly connected by a directed edge. Indirect dependency can be understood as follows: a module depends on another module, and this module in turn depends on the first module. That is, the second module can also be a module that indirectly depends on the first module through a series of modules. For example, if module C depends on module B, and module B depends on first module A, then module C is a second module that indirectly depends on first module A. In the module dependency graph, the second module and the first module are indirectly connected by multiple directed edges. When a module internally calls its own public methods or properties, self-references or self-dependencies occur, and the second module is the first module itself.

[0053] Specifically, by using the directed edge connections between modules in the module dependency graph or the internal call information of the modules, at least one second module that depends on the first module can be identified.

[0054] S140. Based on the binding mapping table, at least one recompiled module whose imported content contains the first content is selected from the at least one second module.

[0055] In this embodiment of the invention, the recompilation module can be specifically understood as: the affected module that needs to be recompiled when changes in the first module affect other modules.

[0056] Specifically, by binding the mapping table, modules whose imported content contains the content of the first module are filtered out from all second modules and marked as recompiled modules that need to be recompiled.

[0057] In practice, when HMR (Hot Module Replacement) is triggered, a plugin can intercept the list of modules to be updated. This list of modules to be updated includes each second module that has a dependency relationship with the first module. Then, irrelevant modules are filtered based on the binding mapping table. That is, based on the binding mapping table, at least one recompiled module whose imported content contains the first content is selected from each second module, and the second modules that are not selected are removed.

[0058] S150. Recompile the selected at least one recompiled module.

[0059] Specifically, the selected recompiled modules are recompiled and packaged into a new package file. This new package file is then sent to the client via Hypertext Transfer Protocol (HTP) request, Web Socket Protocol (WSTP) connection, or other network protocols. Upon receiving the new package file, the client replaces the old software modules with hot-update technology. Hot-update can be understood as a method of updating parts of the application in real time without refreshing the entire page.

[0060] The technical solution of this invention, after detecting a modification operation on a first module, determines the first content that has changed in the first module; obtains a pre-generated module dependency graph and binding mapping table; determines at least one second module that has a dependency relationship with the first module based on the module dependency graph, thereby identifying other modules that have a dependency relationship with the changed module; filters at least one recompiled module whose imported content contains the first content from at least one second module based on the binding mapping table, thereby filtering modules whose imported content contains the changed content; and recompiles the at least one recompiled module, ensuring the consistency and correctness of the code. Only the affected parts are compiled, saving time and computing resources for software module compilation and hot updates, optimizing resource utilization, improving development efficiency, and enhancing the maintainability, scalability, and project management efficiency of the software project.

[0061] Example 2

[0062] Figure 2 This is a flowchart of another software module compilation method provided in Embodiment 2 of the present invention. This embodiment is a refinement of the software module compilation method in the above embodiment. Specifically, it may include: before detecting the modification operation on the first module, it may further include: during the process of packaging each module of the software project through a static module packaging tool, the parser used for code parsing in the static module packaging tool constructs the module dependency graph of the software project, and captures the exported and imported content of each module through hook functions; the plugin module of the static module packaging tool constructs the binding mapping table of the software project based on the captured exported and imported content.

[0063] Correspondingly, such as Figure 2 As shown, the method includes:

[0064] S210. During the process of packaging each module of the software project using a static module packaging tool, the parser used for code parsing in the static module packaging tool constructs the module dependency graph of the software project and captures the exported and imported content of each module through hook functions.

[0065] In this embodiment of the invention, the parser can be specifically understood as: a component in a static module packaging tool that converts source code into an abstract syntax tree, parses source code files, and understands the structure and meaning of the code.

[0066] Hook functions can be understood as interfaces that allow developers or development tools to insert custom logic during the compilation phase. For example, during the packaging of various modules in a software project, a hook function can be used to capture the specific execution methods of the exported and imported content of each module based on the abstract syntax tree corresponding to the source code.

[0067] Specifically, during the process of packaging the modules of a software project using a static module packaging tool, the parser analyzes the source code of each module and identifies the dependencies between modules. For example, when a module exports content through an export statement, the parser records the module and its corresponding exported content; when a module imports the exported content of another module through an import statement, the parser records the dependencies between modules, thereby constructing a module dependency graph for the software project.

[0068] During the process of packaging the modules of a software project using a static module packaging tool, the static module packaging tool uses hook functions to capture the exported content (i.e. the content exported by the module through export statements) and imported content (i.e. the content used by the module through import statements) of each module.

[0069] Optionally, based on the above embodiments, the hook function may include: an import statement capture function and an export statement capture function;

[0070] The parameters in the import statement capture function can include: the currently parsed import statement node, the import content path, the import content name, and the import content identifier;

[0071] The parameters in the export statement capture function can include: the currently parsed export statement node, the export content path, the export content name, and the export content identifier;

[0072] Accordingly, the step of retrieving the exported and imported content of each module through hook functions may include:

[0073] When the parser in the static module packaging tool parses the import statement of the target module, it calls the import statement capture function to capture the import content of the target module;

[0074] When the parser in the static module packaging tool parses the export statement of the target module, it calls the export statement capture function to capture the exported content of the target module.

[0075] In this embodiment of the invention, the import statement capture function can be specifically understood as: triggered when an import statement of a module is detected, capturing information about other modules that the module depends on. The currently parsed import statement node can be specifically understood as: the specific location and structure of the import statement in the abstract syntax tree. The import content path can be specifically understood as: the path of the imported module used to determine the source of the imported content. The import content name can be specifically understood as: the specific member name being imported, such as a function (func), variable (data), or class. The import content identifier can be specifically understood as: the identifier used in the current module to reference the imported member (such as BA in func BA), generally the same as the exported content identifier.

[0076] The export statement capture function can be understood as follows: it is triggered when an export statement of a module is detected, capturing the function interfaces or variable information provided by the module. The currently parsed export statement node can be understood as the specific location and structure of the export statement in the abstract syntax tree. The export content path can be understood as the path of the exported content, which is the same as the current module. The export content name can be understood as the specific member name exported by the current module, such as functions, variables, or classes. The export content identifier is the identifier of the exported member within the current module.

[0077] Specifically, when the parser parses an import statement of a module, it calls the import statement capture function to capture information about other modules that the module depends on; when the parser parses an export statement of a module, it calls the export statement capture function to capture information about the interfaces or variables that the module provides to the outside world; these are used to construct a module dependency graph based on the dependency relationships between the captured import and export content.

[0078] By using hook functions, including import and export statement fetching functions, to capture the import and export content of the module, the code splitting and lazy loading strategy in the packaging process is optimized, the code modularity is enhanced, making the code easier to maintain and extend. By dynamically handling imports and exports, resource utilization is optimized, especially when dealing with large projects, reducing unnecessary calculations and input / output operations, and improving development efficiency.

[0079] Optionally, based on the above embodiments, the import statement capture function may include: a default import function and a specific import function; the export statement capture function may include: a specific export function;

[0080] Accordingly, the name of the imported content in the default import function is the default import name, and the import content identifier is the default import identifier; wherein, the default import identifier is used to indicate the import of all content exported by other modules;

[0081] The name of the imported content in a specific import function is the specified import name, and the import content identifier is the specified import identifier; wherein, the specified import identifier is used to indicate the import of specified content exported by other modules;

[0082] The exported content name in a specific exported function is the specified exported name, and the exported content identifier is the specified exported identifier; wherein, the specified exported identifier is used to indicate the export of the specified content of this module.

[0083] In this embodiment of the invention, the default import function can be understood as: used to capture the exported content of the import module using the default import method, that is, when importing using the import statement, if no specific import content is specified, all exported content of the corresponding module is imported by default. For example: import default _ from 'lodash', where default represents the default import name (importing all types of exported content, including functions and variables), _ represents the default import identifier, indicating that all exported content of lodash (the export module) is imported. A specific import function can be understood as: used to capture the exported content of a specific name in the import module, that is, when importing using the import statement, specific imported content is specified, for example: import func{ has} from 'lodash', where func represents the specified import name (only importing function class exported content), func can also be data to indicate only importing variable class exported content, and has is the specified import identifier, indicating that the has exported by lodash is imported.

[0084] Export statement capture functions can also include default export functions. Default export functions can be understood as those used to capture the module's default exports. For example, using `export default _{...}` indicates a default export since no export name or identifier is specified, exporting all types of elements in the module, including functions, variables, and classes. Specific export functions can be understood as those used to capture the module's named exports. For example, `export func has() {...}`, where `func` specifies the export name, indicating the export type is a function (it can also be `data`, indicating the export type is a variable), and `has` specifies the export identifier, indicating that `has` is exported.

[0085] For default exports, the name and identifier are usually not explicitly specified because it is the default export of the module. For specific exports, both the name and identifier are explicitly specified. The name refers to the specific member name of the exported function, variable, or class in the module (e.g., func represents a function, data represents a variable), and the corresponding identifier is explicitly specified (e.g., has).

[0086] For default imports, the name and identifier are usually the same because they both point to the default export of the corresponding module. For specific imports, the name is the specific type being imported (such as a function, variable, or class), and the identifier is the name used in the import statement. The name and identifier usually match the name and identifier of the corresponding exported content.

[0087] Understandably, when parsing import statements using an instantiated parser in a static module packaging tool, the hook functions are triggered in two ways: One is that when a specific import identifier (such as `import`) is encountered, the module import statement fetching function (the default import function) is triggered once; when parsing export statements, when a specific export identifier (such as `export`) is encountered, the module export statement fetching function (the default export function) is triggered once. The other is that after encountering a specific import identifier (such as `import`), when a specific import name (`func` or `data`) is encountered, the module import statement fetching function (the specific import function, which imports the function or variable corresponding to the specific identifier) ​​is triggered once; when parsing export statements, after encountering a specific export identifier (such as `export`), when a specific export name (`func` or `data`) is encountered, the module export statement fetching function (the specific export function, which exports the function or variable corresponding to the specific identifier) ​​is triggered once.

[0088] By differentiating between default imports and specific imports, as well as default exports and specific exports, in static module packaging tools, more accurate dependency tracking can be achieved, packaging efficiency can be optimized, code modularity and maintainability can be enhanced, more detailed module dependency graphs can be built, more effective code splitting and lazy loading strategies can be implemented, the size of the final packaged file can be reduced, the application loading speed can be accelerated, and the running efficiency can be improved.

[0089] S220. The plugin module of the static module packaging tool constructs the binding mapping table of the software project based on the captured exported and imported content.

[0090] Specifically, developers create custom plugins that subscribe to hook functions provided by the plugin resolver. When a plugin's subscribed hook function is triggered, the plugin collects detailed information about exports and imports, such as module paths, exported function or variable identifiers, and imported function or variable identifiers. Based on the correspondence between the exported and imported content of each module, the plugin constructs a binding mapping table for the software project.

[0091] S230. After detecting a modification operation on the first module, determine the first content that has changed in the first module.

[0092] The first module can be any module of the software project.

[0093] S240. Obtain the pre-generated module dependency graph and binding mapping table.

[0094] The module dependency graph is a dependency graph built by the static module packaging tool during the packaging process of each module of the software project; the binding mapping table records the exported and imported content of each module in the software project.

[0095] S250. Determine at least one second module that has a dependency relationship with the first module based on the module dependency graph.

[0096] S260. Based on the binding mapping table, at least one recompiled module whose imported content contains the first content is selected from the at least one second module.

[0097] S270. Recompile the selected at least one recompiled module.

[0098] The technical solution of this invention, during the packaging of each module of the software project using a static module packaging tool, constructs a module dependency graph of the software project through a parser used for code parsing in the static module packaging tool, and captures the exported and imported content of each module through hook functions; based on the captured exported and imported content, the plugin module of the static module packaging tool constructs a binding mapping table of the software project, achieving accurate identification of the interfaces of each module, providing basic data for subsequent dependency analysis and management, and the created binding mapping table records the exported and imported content of each module, improving the location of dependencies between modules. The system improves efficiency; after detecting modifications to the first module, it identifies the first content that has changed in the first module; it obtains the pre-generated module dependency graph and binding mapping table, identifies other modules that have dependencies on the changed module, and filters out recompiled modules whose imported content contains the changed content. The recompiled modules are then recompiled, optimizing the compilation and update process, improving development efficiency, ensuring code consistency and correctness, optimizing resource utilization, compiling only the affected parts, saving time and computing resources for software module compilation and hot updates, and improving the maintainability, scalability, and project management efficiency of the software project.

[0099] Example 3

[0100] Figure 3 This is a flowchart of another software module compilation method provided in Embodiment 3 of the present invention. This embodiment is a refinement of the software module compilation method in the above embodiments. Specifically, the software module compilation method may further include: when the first content involves adding exported or imported content, adding the corresponding exported or imported content of the first module in the binding mapping table; when the first content involves deleting exported content, removing the corresponding exported content of the first module from the binding mapping table and updating the imported content of the recompiled module that imported the exported content; when the first content involves modifying the internal code logic of the exported content, and the modification involves the structure or type of the exported content, converting the structure or type of the corresponding exported content of the first module into the target structure or target type in the binding mapping table and updating the imported content of the recompiled module that imported the exported content.

[0101] Correspondingly, such as Figure 3 As shown, the method includes:

[0102] S310. After detecting a modification operation on the first module, determine the first content that has changed in the first module.

[0103] The first module can be any module of the software project.

[0104] S320. Obtain the pre-generated module dependency graph and binding mapping table.

[0105] The module dependency graph is a dependency graph built by the static module packaging tool during the packaging process of each module of the software project; the binding mapping table records the exported and imported content of each module in the software project.

[0106] S330. Determine at least one second module that has a dependency relationship with the first module based on the module dependency graph.

[0107] S340. Based on the binding mapping table, at least one recompiled module whose imported content contains the first content is selected from the at least one second module.

[0108] S350. Recompile the selected at least one recompiled module.

[0109] S360. When the first content involves adding exported or imported content, add the corresponding exported or imported content of the first module to the binding mapping table.

[0110] Specifically, when the first content only involves adding export or import, add the newly added export or import content of the first module to the binding mapping table, and record the specific information of the new export or import of the first module, such as name and identifier, to complete the update of the binding mapping table.

[0111] S370. When the first content involves the deletion of exported content, remove the corresponding exported content of the first module from the binding mapping table and update the import content of the recompiled module that imported the exported content.

[0112] Specifically, when the first content involves the deletion of exported content, the deleted exported content in the first module is removed from the binding mapping table, it is determined which recompiled modules imported the deleted exported content, and their imported content is updated, such as removing references to the deleted exported content or updating it to other exported content.

[0113] S380. When the first content involves modification of the internal code logic of the exported content, and the modification involves the structure or type of the exported content, the structure or type of the corresponding exported content of the first module is converted into the target structure or target type in the binding mapping table, and the import content of the recompiled module that imported the exported content is updated.

[0114] Specifically, when the first module involves modifications to the internal code logic of exported content, and these modifications affect the structure or type of the exported content (e.g., a change in the exported name, such as an exported function becoming an exported variable or vice versa), the addition of new parameters to an exported function, or a change in the type of an exported variable (e.g., from character to string), if the second module still uses these exported contents based on the old structure or type, this change will affect the second module that depends on these exported contents. Therefore, in the binding mapping table, the structure or type of the corresponding exported content of the first module needs to be updated to the new target structure or type. All recompiled modules that have imported the changed exported content need to be identified, and their import content needs to be updated to match the new exported content structure or type.

[0115] When the internal code logic of the exported content in the first module is modified, but this modification does not affect the structure or type of the exported content, it indicates that these changes are superficial and will not affect existing business logic, that is, they will not affect other modules' use of these exported contents or the dependencies between modules. Therefore, there is no need to update the binding mapping table.

[0116] Figure 4 This is a schematic diagram illustrating a module dependency applicable to an embodiment of the present invention, such as... Figure 4 As shown, the project entry module is the first module executed when the application starts. Modules A, B, C, D, E, F, and G are other modules in the project; each module may contain one or more functions or variables. Functions BA, BB, CA, CB, EA, GA, and GB are specific functions within their respective modules. Variable BA is a data variable in module B. Arrows represent dependencies between modules, i.e., directed edges in the module dependency graph. For example, module C depends on functions BA and BB provided by module B.

[0117] In a specific example, the binding mapping table content can take the form of:

[0118] {"Utiles module B":{

[0119] "exports":["func BA","func BB","data BA"],

[0120] "consumers":{

[0121] "Module C":["func BA","func BB"]}}}

[0122] The binding mapping table records the module's exported and imported content. Here, `Utils` represents exporting modules. `exports` represents the content exported by the module, which can be functions (`func`), variables (`data`), classes, etc. `consumers` represents other modules that import the exported content of a given module, along with their imported content. For example, module B exports functions `BA` and `BB`, and module C imports functions `BA` and `BB`. Figure 4 Corresponding to the dependencies in the text, module C depends on functions BA and BB provided by module B.

[0123] Correspondingly, when the exported content of module B is added (such as function BC), the exports section of the binding mapping table needs to be updated (add func BC).

[0124] When module B imports new content (module C imports variable BA), the consumers section of the binding mapping table needs to be updated (data BA is added in module C).

[0125] When the exported content of module B is deleted, such as canceling the exported function BA, removing func BA from exports and func BA from consumers of module C.

[0126] When the internal code logic of the export content function BA of module B is modified, but the structure or type of the exported content is not involved, the binding mapping table is not modified.

[0127] When the internal code logic of the exported content function BB of module B is modified, involving the structure or type of the exported content (such as changing function BB to variable BB), the exports part (changing func BB to DATABB) and consumers part (changing funcBB to DATABB) in the binding mapping table need to be updated.

[0128] During software development, updating the binding mapping table to reflect changes in module export and import content, combined with module dependency graph analysis, ensures the accuracy of dependencies between modules in the software project, optimizes the build and packaging process, improves application loading speed, helps to quickly diagnose and resolve dependency-related issues, improves development efficiency, and enhances code maintainability and project scalability.

[0129] The technical solution of this invention, after detecting a modification operation on a first module, determines the first content that has changed in the first module; obtains a pre-generated module dependency graph and binding mapping table, identifies other modules that have dependencies on the changed module, and filters out recompiled modules whose imported content contains the changed content, recompiles the recompiled modules, optimizes the compilation and update process, improves development efficiency, ensures code consistency and correctness, optimizes resource utilization, only compiles the affected parts, saves time and computing resources for software module compilation and hot updates, and improves the scalability of software projects and the efficiency of project management. When the exported or imported content of a module changes, the corresponding exported or imported content is added to the binding mapping table to ensure the real-time updating of the mapping table. This improves the accuracy of dependency analysis for subsequent modification operations and simplifies the module update process. When exported content is deleted, it is removed from the mapping table, and the imported content of the relevant modules is updated to avoid errors caused by invalid dependencies and maintain project stability. When the internal logic of exported content is modified, affecting its structure or type, the mapping table is updated to reflect these changes, and the imported content of the relevant modules is adjusted to ensure the compatibility and correctness of the mapping relationship between modules. This improves the adaptability and flexibility of the project, further optimizes the software module compilation and development process, and enhances the stability, reliability, and maintainability of the software project.

[0130] Example 4

[0131] Figure 5 This is a schematic diagram of a software module compilation device provided in Embodiment 4 of the present invention. Figure 5 As shown, the device includes: a change determination module 510, a chart acquisition module 520, a dependency determination module 530, a filtering and recompilation module 540, and a recompilation module 550, wherein:

[0132] The change determination module 510 is used to determine the first content that has changed in the first module after detecting a modification operation on the first module; wherein, the first module is any module of the software project;

[0133] The graph acquisition module 520 is used to acquire a pre-generated module dependency graph and binding mapping table; wherein, the module dependency graph is a dependency graph constructed by the static module packaging tool during the packaging process of each module of the software project; the binding mapping table records the exported and imported content of each module in the software project;

[0134] Dependency determination module 530 is used to determine at least one second module that has a dependency relationship with the first module based on the module dependency graph;

[0135] The filtering recompilation module 540 is used to filter at least one recompilation module whose imported content contains the first content from the at least one second module according to the binding mapping table;

[0136] Recompile module 550 is used to recompile the selected at least one recompile module.

[0137] The technical solution of this invention improves development efficiency, ensures code consistency and correctness, optimizes resource utilization, saves time and computing resources for software module compilation and hot updates, and enhances the maintainability, scalability, and project management efficiency of software projects by detecting modifications to a first module; obtaining a pre-generated module dependency graph and binding mapping table; determining at least one second module that has a dependency relationship with the first module based on the module dependency graph, thereby identifying other modules that have a dependency relationship with the modified module; selecting at least one recompiled module whose imported content contains the first content from at least one second module based on the binding mapping table, thereby selecting modules whose imported content contains the modified content; and recompiling the selected at least one recompiled module.

[0138] Based on the above embodiments, the variation determination module 510 is specifically used for:

[0139] Compile the modified first module, compare the compilation result with the compilation result of the first module before the modification, and determine the first content that has changed in the first module based on the comparison result.

[0140] Furthermore, based on the above embodiments, the software module compilation apparatus may further include: a dependency graph construction module and a mapping table construction module, wherein:

[0141] The dependency graph construction module is used to construct the module dependency graph of the software project by the parser used for code parsing in the static module packaging tool during the packaging process of each module of the software project before the modification operation of the first module is detected, and to capture the exported and imported contents of each module through hook functions.

[0142] The mapping table construction module is used to construct the binding mapping table of the software project based on the captured exported and imported content through the plugin module of the static module packaging tool.

[0143] Based on the above embodiments, hook functions may include: import statement capture functions and export statement capture functions;

[0144] The parameters in the import statement capture function can include: the currently parsed import statement node, the import content path, the import content name, and the import content identifier;

[0145] The parameters in the export statement capture function can include: the currently parsed export statement node, the export content path, the export content name, and the export content identifier;

[0146] Accordingly, based on the above embodiments, a dependency graph module is constructed, specifically used for:

[0147] When the parser in the static module packaging tool parses the import statement of the target module, it calls the import statement capture function to capture the import content of the target module;

[0148] When the parser in the static module packaging tool parses the export statement of the target module, it calls the export statement capture function to capture the exported content of the target module.

[0149] Based on the above embodiments, the import statement capture function may include: a default import function and a specific import function; the export statement capture function may include: a specific export function;

[0150] Accordingly, the name of the imported content in the default import function is the default import name, and the import content identifier is the default import identifier; wherein, the default import identifier is used to indicate the import of all content exported by other modules;

[0151] The name of the imported content in a specific import function is the specified import name, and the import content identifier is the specified import identifier; wherein, the specified import identifier is used to indicate the import of specified content exported by other modules;

[0152] The exported content name in a specific exported function is the specified exported name, and the exported content identifier is the specified exported identifier; wherein, the specified exported identifier is used to indicate the export of the specified content of this module.

[0153] Furthermore, based on the above embodiments, the software module compilation apparatus may further include: a first update table module, a second update table module, and a third update table module, wherein:

[0154] The first update table module is used to add the corresponding exported or imported content of the first module to the binding mapping table when the first content involves the addition of exported or imported content.

[0155] The second update table module is used to remove the corresponding exported content of the first module from the binding mapping table when the first content involves the deletion of exported content, and update the imported content of the recompiled module that imported the exported content.

[0156] The third update table module is used to convert the structure or type of the corresponding exported content of the first module into the target structure or type in the binding mapping table when the first content involves internal code logic modification of the exported content, and the modification involves the structure or type of the exported content, and update the import content of the recompiled module that imported the exported content.

[0157] The software module compilation apparatus provided in the embodiments of the present invention can execute the software module compilation method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0158] The collection, storage, use, processing, transmission, provision, and disclosure of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0159] Example 5

[0160] Figure 6 A schematic diagram of an electronic device 10, which can be used to implement embodiments of the present invention, is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0161] like Figure 6 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0162] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0163] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as software module compilation methods, i.e.:

[0164] After detecting a modification operation to the first module, the first content that has changed in the first module is determined; wherein, the first module is any module of the software project;

[0165] Obtain the pre-generated module dependency graph and binding mapping table; wherein, the module dependency graph is a dependency graph constructed by the static module packaging tool during the packaging process of each module of the software project; the binding mapping table records the exported and imported content of each module in the software project;

[0166] Based on the module dependency graph, at least one second module that has a dependency relationship with the first module is determined;

[0167] Based on the binding mapping table, at least one recompiled module whose imported content contains the first content is selected from the at least one second module;

[0168] The selected at least one recompiled module is recompiled.

[0169] In some embodiments, the software module compilation method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the software module compilation method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to execute the software module compilation method by any other suitable means (e.g., by means of firmware).

[0170] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0171] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0172] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0173] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0174] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0175] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0176] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0177] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A method for compiling software modules, characterized in that, include: After detecting a modification operation to the first module, the first content that has changed in the first module is determined; wherein, the first module is any module of the software project; Obtain the pre-generated module dependency graph and binding mapping table; wherein, the module dependency graph is a dependency graph constructed by the static module packaging tool during the packaging process of each module of the software project; the binding mapping table records the exported and imported content of each module in the software project; Based on the module dependency graph, at least one second module that has a dependency relationship with the first module is determined; Based on the binding mapping table, at least one recompiled module whose imported content contains the first content is selected from the at least one second module; Recompile the at least one selected recompiled module; This includes, before detecting any modification to the first module, the following: During the process of packaging each module of the software project using a static module packaging tool, the parser used for code parsing in the static module packaging tool constructs the module dependency graph of the software project and captures the exported and imported content of each module through hook functions. The plugin module of the static module packaging tool constructs the binding mapping table of the software project based on the captured exported and imported content; The hook functions include: an import statement capture function and an export statement capture function; Accordingly, the process of retrieving the exported and imported content of each module through hook functions includes: When the parser in the static module packaging tool parses the import statement of the target module, it calls the import statement capture function to capture the import content of the target module; When the parser in the static module packaging tool parses the export statement of the target module, it calls the export statement capture function to capture the exported content of the target module.

2. The method according to claim 1, characterized in that, The first content that has changed in the first module includes: Compile the modified first module, compare the compilation result with the compilation result of the first module before the modification, and determine the first content that has changed in the first module based on the comparison result.

3. The method according to claim 1, characterized in that, The parameters in the import statement capture function include: the currently parsed import statement node, the import content path, the import content name, and the import content identifier; The parameters in the export statement fetching function include: the currently parsed export statement node, the export content path, the export content name, and the import content identifier.

4. The method according to claim 3, characterized in that, Import statement capture functions include: default import functions and specific import functions; export statement capture functions include: specific export functions; Accordingly, the name of the imported content in the default import function is the default import name, and the import content identifier is the default import identifier; wherein, the default import identifier is used to indicate the import of all content exported by other modules; The name of the imported content in a specific import function is the specified import name, and the import content identifier is the specified import identifier; wherein, the specified import identifier is used to indicate the import of specified content exported by other modules; The exported content name in a specific exported function is the specified exported name, and the exported content identifier is the specified exported identifier; wherein, the specified exported identifier is used to indicate the export of the specified content of this module.

5. The method according to claim 1, characterized in that, Also includes: When the first content involves adding exported or imported content, add the corresponding exported or imported content of the first module to the binding mapping table; When the first content involves the deletion of exported content, remove the corresponding exported content of the first module from the binding mapping table and update the import content of the recompiled module that imported the exported content. When the first content involves modifying the internal code logic of the exported content, and the modification involves the structure or type of the exported content, the structure or type of the corresponding exported content of the first module is converted to the target structure or target type in the binding mapping table, and the import content of the recompiled module that imported the exported content is updated.

6. A software module compilation apparatus, characterized in that, include: The change determination module is used to determine the first content that has changed in the first module after detecting a modification operation on the first module; wherein, the first module is any module of the software project; The module for obtaining graphs is used to obtain a pre-generated module dependency graph and binding mapping table; wherein, the module dependency graph is a dependency graph constructed by the static module packaging tool during the packaging process of each module of the software project; the binding mapping table records the exported and imported content of each module in the software project; Determine dependent modules, used to determine at least one second module that has a dependency relationship with the first module based on the module dependency graph; A filter recompilation module is used to filter at least one recompilation module whose imported content contains the first content from the at least one second module according to the binding mapping table; A recompile module, used to recompile the selected at least one recompile module; The software module compilation device further includes: The dependency graph construction module is used to construct the module dependency graph of the software project by the parser used for code parsing in the static module packaging tool during the packaging process of each module of the software project before the modification operation of the first module is detected, and to capture the exported and imported contents of each module through hook functions. A mapping table construction module is used to construct the binding mapping table of the software project based on the captured export and import content through the plugin module of the static module packaging tool; The hook functions include: an import statement capture function and an export statement capture function; Accordingly, a dependency graph construction module is specifically used for: When the parser in the static module packaging tool parses the import statement of the target module, it calls the import statement capture function to capture the import content of the target module; When the parser in the static module packaging tool parses the export statement of the target module, it calls the export statement capture function to capture the exported content of the target module.

7. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the software module compilation method according to any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the software module compilation method according to any one of claims 1-5.

9. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the software module compilation method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Incremental compiling processing method and device, electronic equipment and storage medium

    CN117616387A