Software module compiling method, electronic equipment, medium and product

By monitoring module modification operations and using module dependency graphs and binding mapping tables to identify and recompile affected modules, the high time cost of software module compilation and hot updates is solved, efficient resource utilization and code consistency are achieved, and development efficiency and project management efficiency are improved.

CN120631376AActive Publication Date: 2025-09-12HUNDSUN TECH
View PDF 8 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In the existing technology, software module compilation and hot update have high time costs and consume large computing resources, resulting in low development efficiency.

Method used

By monitoring module modification operations and using pre-generated module dependency graphs and binding mapping tables, other modules that have dependencies on the changed module are identified, and only these modules are recompiled to avoid repeated processing of unchanged code.

Benefits of technology

It optimizes resource utilization, improves development efficiency, ensures code consistency and correctness, and enhances the maintainability and scalability of software projects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120631376A_ABST
    Figure CN120631376A_ABST
Patent Text Reader

Abstract

The invention discloses a software module compiling method, electronic equipment, a medium and a product, and the method comprises the following steps: after a modification operation on a first module is monitored, determining changed first content in the first module; obtaining a pre-generated module dependency graph and a binding mapping table; determining at least one second module having a dependency relationship with the first module according to the module dependency graph; according to the binding mapping table, screening out at least one recompiling module of which the imported content comprises the first content from the at least one second module; according to the method, at least one screened recompilation module is recompiled, so that the consistency and correctness of codes are ensured, only the affected part is compiled, the time and computing resources for software module compiling and hot updating are saved, the development efficiency is improved, the resource utilization is optimized, and the development cost is reduced. And the maintainability, the expandability and the project management efficiency of the software project are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software systems and network page updating, and in particular to a software module compilation method, electronic equipment, medium and product. Background Art

[0002] With the rapid development of technological iteration in the front-end field, emerging construction tools have attracted attention due to their lightweight and optimized development experience.

[0003] For historically developed front-end projects, blindly migrating build tools can result in high migration costs and uncontrollable migration risks. To meet the rigid module division and complex configuration management requirements of mature products, as well as compatibility with different browsers, static module bundling tools are often used to compile modules as the smallest unit. These tools then recompile all modules in the entire dependency subtree based on the module dependency graph, creating a bundled file for hosting and hot-updating.

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

[0005] The present invention provides a software module compilation method, electronic equipment, medium and product to solve the problems of high time cost, large computing resource consumption and low development efficiency in software module compilation and hot update.

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

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

[0008] Obtaining a pre-generated module dependency graph and binding mapping table; wherein the module dependency graph is a dependency graph constructed by a static module packaging tool during the packaging of the modules of the software project; and the binding mapping table records the export content and import content of each module in the software project;

[0009] Determine at least one second module having a dependency relationship with the first module according to the module dependency graph;

[0010] Filtering, from the at least one second module according to the binding mapping table, at least one recompilation module whose imported content includes the first content;

[0011] Recompile the at least one filtered recompilation module.

[0012] According to another aspect of an embodiment of the present invention, a software module compiling device is provided, comprising:

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

[0014] A graph acquisition module is used to obtain a pre-generated module dependency graph and a binding mapping table; wherein the module dependency graph is a dependency graph constructed by a static module packaging tool during the packaging of the modules of the software project; and the binding mapping table records the export content and import content of each module in the software project;

[0015] Determining a dependent module, for determining at least one second module having a dependency relationship with the first module according to the module dependency graph;

[0016] a screening recompilation module, configured to screen out, from the at least one second module according to the binding mapping table, at least one recompilation module whose imported content includes the first content;

[0017] The recompiling module is configured to recompile the at least one selected recompiling module.

[0018] According to another aspect of an embodiment 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, and the computer program is executed by the at least one processor to enable the at least one processor to perform the software module compilation method described in any embodiment of the present invention.

[0020] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the software module compilation method described in any embodiment of the present invention when executed.

[0021] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the steps of the method according to any embodiment of the present invention are implemented.

[0022] The technical solution of the embodiment of the present invention determines the first content that has changed in the first module after monitoring the modification operation on 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 according to the module dependency graph, thereby identifying other modules that have a dependency relationship with the changed module; filters out at least one recompiled module whose imported content contains the first content from at least one second module according to the binding mapping table, thereby filtering out modules whose imported content contains the changed content; recompiles the at least one filtered recompiled module to ensure the consistency and correctness of the code, and only compiles the affected parts, saving time and computing resources for software module compilation and hot update, 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 content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

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

[0026] Figure 2 is a flowchart of another software module compiling method provided according to the second embodiment of the present invention;

[0027] Figure 3 is a flowchart of another software module compiling method provided according to the third embodiment of the present invention;

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

[0029] Figure 5 2 is a schematic structural diagram of a software module compiling device provided according to a fourth embodiment of the present invention;

[0030] Figure 6 It is a structural diagram of an electronic device for implementing the software module compiling method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0031] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.

[0032] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0033] Example 1

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

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

[0036] The first module is any module of a software project.

[0037] In the embodiments of the present invention, the first module can be specifically understood as a module identified as being modified in a software project. In modular programming, a module can be a separate source code file, class, library, framework, or any independently deployable and usable code unit. The first content can be specifically understood as a specific code element that is modified, deleted, or added in the first module. The code element can specifically be a function or variable.

[0038] It is understandable that in the software development process, a software project is usually composed of many modules, each module is used to implement a specific function, and a module usually needs to use functions or variables provided by another module, and there is a special dependency relationship between modules.

[0039] Specifically, during the software development process, whenever any module changes, the system monitors the modification operation on the first module through the version control system, file system monitoring or hot module replacement, and then determines the specific content of the change in the first module, i.e., the first content, through the version control system, difference analysis tools or static code analysis tools.

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

[0041] Compile the changed first module, compare the obtained compilation result with the compilation result of the first module before the change, and determine the changed first content in the first module according to the comparison result.

[0042] In an embodiment of the present 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 specifically be: the executable code compiled by the first module before the change, the intermediate representation generated during the compilation process, or other compilation products.

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

[0044] By comparing the compilation results, the first content that has changed in the first module of the software project is determined, which avoids the subsequent repeated processing of unchanged code, saves time and resources, optimizes the change review process, and enhances the change management efficiency of the software project, especially improving the development efficiency, operational stability and maintainability of large projects.

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

[0046] The module dependency graph is a dependency graph constructed when a static module packaging tool is used to package the modules of the software project; the binding mapping table records the export content and import content of each module in the software project.

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

[0048] A module dependency graph can be understood as a directed graph used to describe the dependencies between modules in a software project. A node represents a module, and a directed edge indicates the dependency of one module on another. When a static module packaging tool packages a software project, it analyzes the import and export statements of each module to construct a module dependency graph for the entire project. A binding map can be understood as a table or map 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 map.

[0049] Exports can be understood as the content within a module that can be shared and reused by other modules. This can include functions, variables, and other content. A module uses export statements to export its content, allowing other modules to import and use it. Imports can be understood as the content provided by other modules that a module needs to use. Modules use import statements to import content from other modules, enabling collaboration and inter-module dependencies.

[0050] S130. Determine at least one second module having a dependency relationship with the first module according to the module dependency graph.

[0051] In the embodiment of the present 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-dependence.

[0052] A direct dependency can be understood as one module directly using the exports of another module through an import statement. If the exports of the first module are imported or used by other modules, these modules can be considered second modules that directly depend on the first module. In a module dependency graph, the second module is directly connected to the first module via a directed edge. An indirect dependency can be understood as one module depending on another module, which in turn depends on the first module. This means that the second module can also indirectly depend on the first module through a series of modules. For example, if module C depends on module B, and module B depends on module A, then module C is the second module that indirectly depends on module A. In a module dependency graph, the second module is indirectly connected to the first module via multiple directed edges. When a module internally calls its own public methods or properties, a self-reference or self-dependence occurs, and the second module is the first module itself.

[0053] Specifically, at least one second module that depends on the first module is identified through the connection relationship of the directed edges between the modules in the module dependency graph or the internal calling information of the modules.

[0054] S140: Filter out, from the at least one second module according to the binding mapping table, at least one recompilation module whose imported content includes the first content.

[0055] In the embodiment of the present invention, recompiling a module may be specifically understood as: when a change in a first module affects other modules, an affected module needs to be recompiled.

[0056] Specifically, modules whose imported content includes the first content are screened out from all second modules through the binding mapping table and marked as recompiled modules that need to be recompiled.

[0057] In specific implementation, when HMR (Hot Module Replacement) is triggered, the list of modules to be updated can be intercepted by the plug-in. The list of modules to be updated includes each second module that has a dependency relationship with the first module, and then irrelevant modules are filtered out based on the binding mapping table. That is, based on the binding mapping table, at least one recompiled module whose imported content includes the first content is filtered out from each second module, and the second modules that are not filtered out are eliminated.

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

[0059] Specifically, the selected recompiled modules are recompiled and packaged into a new package file. This new package file is sent to the client via a Hypertext Transfer Protocol (HTP) request, a Web Socket Protocol (WSP) connection, or other network protocol. After receiving the new package file, the client uses hot update technology to replace the old software modules before the modification. Hot update can be specifically understood as a method for updating some application modules in real time without refreshing the entire page.

[0060] The technical solution of the embodiment of the present invention determines the first content that has changed in the first module after monitoring the modification operation on 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 according to the module dependency graph, thereby identifying other modules that have a dependency relationship with the changed module; filters out at least one recompiled module whose imported content contains the first content from at least one second module according to the binding mapping table, thereby filtering out modules whose imported content contains the changed content; recompiles the at least one filtered recompiled module to ensure the consistency and correctness of the code, and only compiles the affected parts, saving time and computing resources for software module compilation and hot update, 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 A flowchart of another software module compilation method provided in Example 2 of the present invention. This embodiment is a refinement of the software module compilation method in the above embodiment, and specifically may include: before detecting a modification operation on the first module, it may also include: in the process of packaging the modules of the software project through a static module packaging tool, a parser for code parsing in the static module packaging tool builds a module dependency graph of the software project, and captures the export content and import content of each module through a hook function; and a plug-in module of the static module packaging tool builds a binding mapping table of the software project based on the captured export content and import content.

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

[0064] S210. In the process of packaging the modules of the software project using a static module packaging tool, a parser for code parsing in the static module packaging tool constructs a module dependency graph of the software project and captures the export content and import content of each module through a hook function.

[0065] In the embodiment of the present invention, the parser can be specifically understood as: a component in the static module packaging tool that converts the source code into an abstract syntax tree, parses the source code file, 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 modules in a software project, the specific execution methods of each module's exports and imports can be captured based on the abstract syntax tree corresponding to the source code.

[0067] Specifically, when a static module packaging tool is used to package the modules of a software project, 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 building the module dependency graph of the software project.

[0068] In the process of packaging the modules of the software project through the static module packaging tool, the static module packaging tool captures the export content (that is, the content exported by the module through the export statement) and import content (that is, the content used by the module through the import statement) of each module through the hook function.

[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 crawling function may 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 crawling function may include: the currently parsed export statement node, the export content path, the export content name, and the export content identifier;

[0072] Accordingly, the method of capturing the export content and import content of each module through the hook function 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 export content of the target module.

[0075] In an embodiment of the present invention, the import statement capture function can be specifically understood as: being triggered when the import statement of a module is identified, and capturing information about other modules that the module depends on. The currently parsed import statement node can be specifically understood as: the specific position 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), a variable (data) or a class element. The import content identifier can be specifically understood as: an identifier used to reference the imported member in the current module (such as BA in func BA), which is generally the same as the export content identifier.

[0076] The export statement capture function is specifically defined as being triggered when a module's export statement is identified, capturing the module's externally provided function interfaces or variable information. The currently parsed export statement node is specifically defined as the specific location and structure of the export statement in the abstract syntax tree. The export content path is specifically defined as the path of the exported content, which is the same as the current module. The export content name is specifically defined as the name of the member exported by the current module, such as a function, variable, or class. The export content identifier is the identifier of the exported member within the current module.

[0077] Specifically, when the parser parses the 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 the export statement of a module, it calls the export statement capture function to capture the interface or variable information provided by the module to the outside world; it is used to build a module dependency graph based on the dependency relationship between the captured import content and export content.

[0078] By using hook functions including import statement capture function and export statement capture function to capture the import and export content of the module, the code segmentation and lazy loading strategy in the packaging process are optimized, the modularity of the code is enhanced, and the code is easier to maintain and expand. By dynamically processing imports and exports, resource utilization is optimized, especially when dealing with large projects, unnecessary calculations and input and output operations are reduced, and development efficiency is improved.

[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] Correspondingly, the import content name 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 contents exported by other modules;

[0081] The import content name in the 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 export content name in the specific export function is the specified export name, and the export content identifier is the specified export identifier; wherein the specified export identifier is used to indicate the export of the specified content of this module.

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

[0084] The export statement capture function can also include the default export function. The default export function can be specifically understood as: used to capture the default export of the module, for example, using export default _{...}. Since the export content name and identifier are not specified, it indicates the default export, and all types of elements such as functions, variables and classes in the module are exported. The specific export function can be specifically understood as: used to capture the named export of the module, for example: export func has() {...}, where func is the specified export name, indicating that the exported type is a function (func can also be data, indicating that the exported type is a variable), and has is the specified export identifier, indicating that has is exported.

[0085] For the default export, the name and identifier are usually not explicitly specified because it is the default export of the module. For special exports, the name and identifier are explicitly specified. The name points to the specific member name of the exported function, variable, or class in the module (such as func for functions and data for variables), and the corresponding identifier is clearly specified (such as has).

[0086] For a default import, the name and identifier are usually the same, because they both refer to the default export of the corresponding module. For a special import, the name is the specific type of import (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 export.

[0087] It can be understood that when the instantiated parser is used in the static module packaging tool to parse the import statement, there are two ways to trigger the hook function: one is to trigger an access to the module import statement capture function (default import function) when encountering a specific imported identifier (such as import), and to trigger an access to the module export statement capture function (default export function) when encountering a specific exported identifier (such as export) when parsing the export statement; the other is to trigger an access to the module import statement capture function (specific import function, importing the function or variable corresponding to the specific identifier) ​​when encountering a specific imported name (func or data) after encountering a specific imported identifier (such as import), and to trigger an access to the module export statement capture function (specific export function, exporting the function or variable corresponding to the specific identifier) ​​when encountering a specific exported identifier (such as export) when parsing the export statement.

[0088] By distinguishing between default imports and specific imports, as well as default exports and specific exports in static module bundling tools, more accurate dependency tracking can be achieved, packaging efficiency can be optimized, and the modularity and maintainability of the code can be enhanced. This helps to build a more detailed module dependency graph, implement more effective code splitting and lazy loading strategies, reduce the size of the final packaged file, speed up the loading speed of the application, and improve operational efficiency.

[0089] S220: Build a binding mapping table for the software project based on the captured export content and import content through a plug-in module of a static module packaging tool.

[0090] Specifically, developers create custom plugins and subscribe to the hook functions provided by the parser. When the hook functions are triggered, the plugin collects detailed information about exports and imports, such as the module path, 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 a first content that has changed in the first module.

[0092] The first module is any module of a software project.

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

[0094] The module dependency graph is a dependency graph constructed when a static module packaging tool is used to package the modules of the software project; the binding mapping table records the export content and import content of each module in the software project.

[0095] S250: Determine at least one second module having a dependency relationship with the first module according to the module dependency graph.

[0096] S260: Filter out, from the at least one second module according to the binding mapping table, at least one recompilation module whose imported content includes the first content.

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

[0098] The technical solution of the embodiment of the present invention is that, in the process of packaging the modules of the software project by a static module packaging tool, a module dependency graph of the software project is constructed by a parser for code parsing in the static module packaging tool, and the export content and import content of each module are captured by a hook function; a binding mapping table of the software project is constructed based on the captured export content and import content by a plug-in module of the static module packaging tool, so as to realize accurate identification of the interface of each module and provide basic data for subsequent dependency analysis and management. The created binding mapping table records the export and import content of each module, thereby improving the ability to locate dependency relationships between modules. The system improves the efficiency of the system; after monitoring the modification operation on the first module, the first content that has changed in the first module is determined; the pre-generated module dependency graph and binding mapping table are obtained, other modules that have a dependency relationship with the changed module are identified, and the recompiled modules whose imported content contains the changed content are screened out, and the recompiled modules are recompiled, thereby optimizing the compilation and update process, improving development efficiency, ensuring the consistency and correctness of the code, optimizing resource utilization, and compiling only the affected parts, saving time and computing resources for software module compilation and hot update, and improving the maintainability, scalability and project management efficiency of the software project.

[0099] Example 3

[0100] Figure 3 A flowchart of another software module compilation method provided in Example 3 of the present invention. This embodiment is a refinement of the software module compilation method in the above embodiment, and specifically may be: the software module compilation method may also include: when the first content involves the addition of exported content or imported content, adding the corresponding exported content or imported content of the first module in the binding mapping table; when the first content involves the deletion of exported content, removing the corresponding exported content of the first module in the binding mapping table, and updating the imported content of the recompiled module that has imported the exported content; when the first content involves the modification of 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 has imported the exported content.

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

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

[0103] The first module is any module of a software project.

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

[0105] The module dependency graph is a dependency graph constructed when a static module packaging tool is used to package the modules of the software project; the binding mapping table records the export content and import content of each module in the software project.

[0106] S330: Determine at least one second module having a dependency relationship with the first module according to the module dependency graph.

[0107] S340: Filter out, from the at least one second module according to the binding mapping table, at least one recompilation module whose imported content includes the first content.

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

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

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

[0111] S370: When the first content involves deletion of exported content, remove the corresponding exported content of the first module in the binding mapping table, and update the imported 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, and it is determined which recompiled modules have 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 content involves a modification of the internal code logic of the exported content, and the modification involves the structure or type of the exported content, such as a change in the export name (an exported function becomes an exported variable or an exported variable becomes an exported function, etc.), a new parameter is added to the exported function, or the type of the exported variable changes (such as from a character to a 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, it is necessary to update the structure or type of the corresponding exported content of the first module to the new target structure or type, identify all recompiled modules that have imported the changed exported content, and update their imported content to match the new exported content structure or type.

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

[0116] Figure 4 This is a schematic diagram of a module dependency applicable to an embodiment of the present invention, such as Figure 4 As shown in the figure, 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 in each module. Variable BA is a data variable in module B. Arrows represent dependencies between modules, which are also 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 contents of the binding mapping table may be as follows:

[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 export and import contents of the module. Among them, Utiles represents the export module. Exports represent the content exported by the module, which can be functions (func), variables (data), and classes. Consumers represent other modules that import the exported content of a module and their imported content. For example, module B exports function BA and function BB, and module C imports function BA and function BB. Figure 4 Corresponding to the dependency relationship in , module C depends on functions BA and BB provided by module B.

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

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

[0125] When the export content of module B is deleted, such as canceling the export of function BA, remove func BA in exports and func BA of module C in consumers.

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

[0127] When the internal code logic of module B's exported content function BB is modified, involving the structure or type of the exported content (for example, function BB is changed to variable BB), the exports section (change func BB to DATABB) and consumers section (change funcBB to DATA BB) in the binding mapping table need to be updated.

[0128] During the software development process, the binding mapping table is updated to reflect changes in module exports and imports. Combined with the module dependency graph for analysis, this ensures the accuracy of the 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 the embodiment of the present invention determines the first content that has changed in the first module after monitoring the modification operation on the first module; obtains a pre-generated module dependency graph and binding mapping table, identifies other modules that have a dependency relationship with the changed module, and screens out recompiled modules whose imported content contains the changed content, recompiles the recompiled modules, optimizes the compilation and update process, improves development efficiency, ensures the consistency and correctness of the code, optimizes resource utilization, compiles only the affected parts, saves time and computing resources for software module compilation and hot update, and improves the scalability of software projects and the efficiency of project management. When the export or import content of a module changes, the corresponding export or import content is added to the binding mapping table to ensure real-time updating of the mapping table, thereby improving the accuracy of dependency analysis of subsequent modification operations and simplifying the module update process; when the export content is deleted, the content is removed from the mapping table and the import content of the relevant modules is updated to avoid errors caused by invalid dependencies and maintain the stability of the project; when the internal logic of the export content is modified to affect its structure or type, the mapping table is updated to reflect these changes, and the import content of the relevant modules is adjusted to ensure the compatibility and correctness of the mapping relationship between modules, improve the adaptability and flexibility of the project, further optimize the software module compilation and development process, and enhance the stability, reliability and maintainability of the software project.

[0130] Example 4

[0131] Figure 5 This is a schematic diagram of the structure of a software module compilation device provided by the fourth embodiment of the present invention. Figure 5 As shown, the apparatus includes: a change determination module 510, a graph acquisition module 520, a dependency determination module 530, a screening and recompilation module 540, and a recompilation module 550, wherein:

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

[0133] Obtaining a graph module 520, for obtaining a pre-generated module dependency graph and binding mapping table; wherein the module dependency graph is a dependency graph constructed by a static module packaging tool during the packaging of the modules of the software project; and the binding mapping table records the export content and import content of each module in the software project;

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

[0135] a screening and recompiling module 540, configured to screen out, from the at least one second module according to the binding mapping table, at least one recompiling module whose imported content includes the first content;

[0136] The recompiling module 550 is configured to recompile the at least one recompiling module that has been screened out.

[0137] The technical solution of the embodiment of the present invention determines the first content that has changed in the first module after monitoring the modification operation on 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 according to the module dependency graph, thereby identifying other modules that have a dependency relationship with the changed module; filters out at least one recompiled module whose imported content contains the first content from at least one second module according to the binding mapping table, thereby filtering out modules whose imported content contains the changed content; recompiles the at least one filtered recompiled module, thereby 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 update, and improving the maintainability, scalability and project management efficiency of the software project.

[0138] Based on the above embodiments, the change determination module 510 is specifically configured to:

[0139] Compile the changed first module, compare the obtained compilation result with the compilation result of the first module before the change, and determine the changed first content in the first module according to the comparison result.

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

[0141] A dependency graph building module is configured to, before a modification operation on the first module is detected, cause a parser for code parsing in the static module packaging tool to build a module dependency graph for the software project while packaging the modules of the software project using the static module packaging tool, and to capture the export content and import content of each module through a hook function;

[0142] A mapping table building module is used to build a binding mapping table of the software project based on the captured export content and import content through a plug-in module of a static module packaging tool.

[0143] On the basis of the above embodiments, the hook function may include: an import statement capture function and an export statement capture function;

[0144] The parameters in the import statement crawling function may 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 crawling function may 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 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 export content of the target module.

[0149] On the basis of the above embodiments, the import statement capture function may include: a default import function and a specific import function; the export statement capture function includes: a specific export function;

[0150] Correspondingly, the import content name 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 contents exported by other modules;

[0151] The import content name in the 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 export content name in the specific export function is the specified export name, and the export content identifier is the specified export identifier; wherein the specified export 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 device may further include: a first update table module, a second update table module and a third update table module, wherein:

[0154] A first update table module, configured to add the corresponding exported content or imported content of the first module to the binding mapping table when the first content involves the addition of exported content or imported content;

[0155] a second update table module, configured to, when the first content involves deletion of exported content, remove the corresponding exported content of the first module from the binding mapping table, 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 target 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 to update the import content of the recompiled module that imports the exported content.

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

[0158] In the technical solutions disclosed herein, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved 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 that can be used to implement an embodiment 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 assistants, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.

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

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

[0163] The processor 11 may be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the software module compilation method, namely:

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

[0165] Obtaining a pre-generated module dependency graph and binding mapping table; wherein the module dependency graph is a dependency graph constructed by a static module packaging tool during the packaging of the modules of the software project; and the binding mapping table records the export content and import content of each module in the software project;

[0166] Determine at least one second module having a dependency relationship with the first module according to the module dependency graph;

[0167] Filtering, from the at least one second module according to the binding mapping table, at least one recompilation module whose imported content includes the first content;

[0168] Recompile the at least one filtered recompilation module.

[0169] In some embodiments, the software module compilation method can be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can 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 can be performed. Alternatively, in other embodiments, processor 11 can be configured to execute the software module compilation method in any other appropriate manner (e.g., via firmware).

[0170] Various embodiments of the systems and techniques described 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), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system comprising at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0171] Computer programs for implementing 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 the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

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

[0173] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device that has: 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 can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the 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 acoustic input, voice input, or tactile input).

[0174] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0175] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.

[0176] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.

[0177] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.

Claims

1. A software module compilation method, characterized in that: include: After detecting a modification operation on a first module, determining a first content that has changed in the first module; wherein the first module is any module of a software project; Obtaining a pre-generated module dependency graph and binding mapping table; wherein the module dependency graph is a dependency graph constructed by a static module packaging tool during the packaging of the modules of the software project; and the binding mapping table records the export content and import content of each module in the software project; Determine at least one second module having a dependency relationship with the first module according to the module dependency graph; Filtering, from the at least one second module according to the binding mapping table, at least one recompilation module whose imported content includes the first content; Recompile the at least one filtered recompilation module.

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

3. The method according to claim 1, characterized in that Before detecting the modification operation on the first module, the method further includes: In the process of packaging the modules of the software project by the static module packaging tool, the parser for code parsing in the static module packaging tool builds a module dependency graph of the software project and captures the export content and import content of each module through a hook function; A binding mapping table of the software project is constructed based on the captured export content and import content through a plug-in module of a static module packaging tool.

4. The method according to claim 3, characterized in that The hook function includes: an import statement capture function and an export statement capture function; The parameters in the import statement crawling 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 capture function include: the currently parsed export statement node, the export content path, the export content name, and the import content identifier; Accordingly, the hook function is used to capture the export content and import content of each module, including: 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 export content of the target module.

5. The method according to claim 4, characterized in that Import statement capture functions include: default import function and specific import function; export statement capture functions include: specific export function; Correspondingly, the import content name 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 contents exported by other modules; The import content name in the 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 export content name in the specific export function is the specified export name, and the export content identifier is the specified export identifier; wherein the specified export identifier is used to indicate the export of the specified content of this module.

6. The method according to claim 1, characterized in that Also includes: When the first content involves the addition of exported content or imported content, adding the corresponding exported content or imported content of the first module in the binding mapping table; When the first content involves deletion of exported content, the corresponding exported content of the first module is removed from the binding mapping table, and the imported content of the recompiled module that imported the exported content is updated; When the first content involves a 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.

7. A software module compilation device, characterized in that: include: a change determination module, configured to determine a first content that has changed in a first module after detecting a modification operation on the first module; wherein the first module is any module of a software project; A graph acquisition module is used to obtain a pre-generated module dependency graph and a binding mapping table; wherein the module dependency graph is a dependency graph constructed by a static module packaging tool during the packaging of the modules of the software project; and the binding mapping table records the export content and import content of each module in the software project; Determining a dependent module, for determining at least one second module having a dependency relationship with the first module according to the module dependency graph; a screening recompilation module, configured to screen out, from the at least one second module according to the binding mapping table, at least one recompilation module whose imported content includes the first content; The recompiling module is configured to recompile the at least one recompiling module that has been screened out.

8. An electronic device, characterized in that: The electronic device comprises: 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 is executed by the at least one processor so that the at least one processor can execute the software module compiling method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the software module compilation method according to any one of claims 1 to 6 when executed.

10. A computer program product, characterized in that The computer program product comprises a computer program, which, when executed by a processor, implements the software module compiling method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Dependence graph generation method and device, equipment, storage medium and program product

    CN112925522A

  • Application program component compiling method and device, equipment and storage medium

    CN113127000A

  • Method and device for improving Android compiling efficiency, equipment, storage medium and product

    CN115756490A

  • Method and device for automatically converting functional modules between compiling construction systems

    CN116679936A

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

    CN117616387A