Application compilation method, device, equipment, medium and program product
By using the status injection tool in front-end application development, the status data of the public module is injected into the compiled data flow of the dedicated module, which solves the problem that the data flow cannot be communicated when the front-end page module is multiplexed in multiple applications, and achieves efficient data interaction and development efficiency improvement.
Patent Information
- Application Number
- CN202110786862.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-12
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2041-07-12
AI Technical Summary
In the prior art, when front-end page modules are multiplexed in multiple applications, data flows cannot be communicated, and other interface programs or complex data operations are required to achieve data interaction between modules or between modules and pages.
By obtaining the state injection tool, the target substate machine is injected into the compiled data flow of the application to be compiled, so that the compilation operations of the public module warehouse are integrated into the compilation process of the dedicated module warehouse, thereby realizing data interaction between each module and between modules and between the pages.
Eliminates the separation and interaction barriers between data streams, improves the efficiency of front-end application development, reduces access risks, and has very little modification to the original code, which has low modification costs.
Smart Images

Figure CN113760295B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of front-end application development, and in particular to an application compilation method, device, equipment, medium and program product. Background Art
[0002] With the continuous development of Web (Global Wide Area Network) technology and APP (Application) applications, front-end application functions are becoming more and more powerful, and technology changes are changing with each passing day. While embracing these changes, developers are also facing the impact of excessive warehouse code and increasingly complex file structures.
[0003] On the one hand, developers need to consider the code reuse capability to avoid migrating projects by copying and pasting, and then modifying them according to business requirements, which leads to high maintenance costs. On the other hand, although there are some technologies that can solve the problem of code reuse to a certain extent, the coordination of multi-module data flows, such as status data, has not been well solved. Various technologies have some defects, which leads to a poor user experience during use.
[0004] Therefore, this application is to solve the technical problem in the prior art that when the front-end page module is reused in multiple applications, the data streams cannot be interoperable, and other interface programs or complex data operations are needed to achieve data interaction between modules or between modules and pages. Summary of the invention
[0005] The present application provides an application compilation method, device, equipment, medium and program product to solve the technical problem in the prior art that when the front-end page module is reused in multiple applications, the data streams cannot be interoperable and other interface programs or complex data operations are required to achieve data interaction between modules or between modules and pages.
[0006] In a first aspect, the present application provides an application compilation method, comprising:
[0007] Get the state injection tool;
[0008] Using a state injection tool, the target sub-state machine is injected into the compilation data flow of the application to be compiled, so that the compilation operation of the public module repository is integrated into the compilation process of the dedicated module repository;
[0009] The target sub-state machine is used to encapsulate the state data of the target common module in the common module warehouse, and the state data includes: the attribute parameters of the target common module at each preset application moment, and the dedicated module warehouse includes all dedicated modules of the application to be compiled.
[0010] In a possible design, obtaining the state injection tool includes: declaring the state injection tool to initialize various internal parameters in the state injection tool.
[0011] In a possible design, a state injection tool is used to inject a target sub-state machine into a compiled data flow of an application to be compiled, including:
[0012] When the compiler of the application to be compiled generates a state machine, the target sub-state machine is registered into the state machine using the state injection tool;
[0013] The state machine is used to encapsulate the state data of each module in the application to be compiled.
[0014] In a possible design, when the compiler of the application to be compiled generates a state machine, a state injection tool is used to register the target sub-state machine into the state machine, including:
[0015] When the state machine is generated, the state injection tool intercepts the generated function of the state machine to suspend the execution of the generated function;
[0016] Add the target sub-state machine to the incoming parameters of the generated function;
[0017] Continue executing the generator function.
[0018] Optionally, declare a state injection tool, including:
[0019] Before executing the compilation entry file of the application to be compiled, perform parameter initialization settings for the state injection tool, such as declaring the state injection tool.
[0020] In a possible design, the state injection tool is initialized with parameters, including:
[0021] Call the configuration file, determine the target common module from the common module repository, and the target common module includes the target sub-state machine;
[0022] Read the target sub-state machine from the target common module;
[0023] Stores the target sub-state machine in the state injection tool.
[0024] In a possible design, after registering the target sub-state machine into the state machine, it also includes:
[0025] Use the compiler to distribute the state data in the state machine to the corresponding target page;
[0026] Use the compiler to call the module components and state machines in each module to compile the target page;
[0027] Among them, the modules include dedicated modules and public modules.
[0028] Optionally, use the compiler to call the module components and state machines in each module to compile the target page, including:
[0029] Using a compiler, importing a first module component and a second module component into a target page, wherein the first module component is a module component of a target common module, and the second module component is a module component of a dedicated module;
[0030] The state machine is used to configure the first state data for the first module component and the second state data for the second module component. The state machine includes the first state data and the second state data.
[0031] In a possible design, before obtaining the state injection tool, it also includes:
[0032] On the preset platform, a master-slave warehouse creation tool is used to establish a master-slave mapping relationship between a dedicated module warehouse and a public module warehouse, wherein the dedicated module warehouse is the master warehouse and the public module warehouse is the slave warehouse;
[0033] In response to the user's submission instruction, the submission tool is used to synchronously update the slave library to the to-be-compiled application corresponding to the main library, so that the to-be-compiled application can call the target common module during compilation.
[0034] Optionally, on the preset platform, a master-slave repository creation tool is used to establish a master-slave mapping relationship between a dedicated module repository and a public module repository, including:
[0035] Create at least one public module repository storage address on the preset platform;
[0036] Use the master-slave repository creation tool to set at least one public module repository as a slave repository and at least one dedicated module repository as a master repository.
[0037] In a second aspect, the present application provides an application compilation device, including:
[0038] Acquisition module, used to obtain the state injection tool;
[0039] A state injection module is used to inject the target sub-state machine into the compilation data stream of the application to be compiled by using a state injection tool, so that the compilation operation of the public module repository is integrated into the compilation process of the dedicated module repository;
[0040] The target sub-state machine is used to encapsulate the state data of the target common module in the common module warehouse, and the state data includes: the attribute parameters of the target common module at each preset application moment, and the dedicated module warehouse includes all dedicated modules of the application to be compiled.
[0041] In a possible design, the state injection module is used to register the target sub-state machine into the state machine using a state injection tool when the compiler of the application to be compiled generates the state machine;
[0042] The state machine is used to encapsulate the state data of each module in the application to be compiled.
[0043] In a possible design, the state injection module is specifically used to:
[0044] When the state machine is generated, the state injection tool intercepts the generated function of the state machine to suspend the execution of the generated function;
[0045] Add the target sub-state machine to the incoming parameters of the generated function;
[0046] Continue executing the generator function.
[0047] Optionally, the acquisition module is used to initialize parameters for the state injection tool before executing the compilation entry file of the application to be compiled.
[0048] In a possible design, the acquisition module is specifically used to:
[0049] Call the configuration file, determine the target common module from the common module repository, and the target common module includes the target sub-state machine;
[0050] Read the target sub-state machine from the target common module;
[0051] Stores the target sub-state machine in the state injection tool.
[0052] In a possible design, the state injection module is also used to:
[0053] Use the compiler to distribute the state data in the state machine to the corresponding target page;
[0054] Use the compiler to call the module components and state machines in each module to compile the target page;
[0055] Among them, the modules include dedicated modules and public modules.
[0056] Optional, state injection module, specifically used for:
[0057] Using a compiler, importing a first module component and a second module component into a target page, wherein the first module component is a module component of a target common module, and the second module component is a module component of a dedicated module;
[0058] The state machine is used to configure the first state data for the first module component and the second state data for the second module component. The state machine includes the first state data and the second state data.
[0059] In a possible design, the application compilation device further includes:
[0060] The master-slave warehouse management module is used to establish a master-slave mapping relationship between a dedicated module warehouse and a public module warehouse on a preset platform using a master-slave warehouse creation tool, wherein the dedicated module warehouse is the master warehouse and the public module warehouse is the slave warehouse;
[0061] The synchronization management module is used to respond to the user's submission instruction and use the submission tool to synchronize the slave library to the application to be compiled corresponding to the main library, so that the application to be compiled can call the target common module during compilation.
[0062] Optional, master-slave warehouse management module, specifically used for:
[0063] Create at least one public module repository storage address on the preset platform;
[0064] Use the master-slave repository creation tool to set at least one public module repository as a slave repository and at least one dedicated module repository as a master repository.
[0065] In a third aspect, the present application provides an electronic device, including:
[0066] A memory for storing program instructions;
[0067] The processor is used to call and execute the program instructions in the memory to execute any possible application compilation method provided by the first aspect.
[0068] In a fourth aspect, the present application provides a storage medium, wherein the readable storage medium stores a computer program, and the computer program is used to execute any possible application compilation method provided in the first aspect.
[0069] In a fifth aspect, the present application also provides a computer program product, including a computer program, which, when executed by a processor, implements any possible application compilation method provided in the first aspect.
[0070] The present application provides an application compilation method, device, equipment, medium and program product, which first declares a state injection tool to initialize the state injection tool, and then uses the state injection tool to inject the target sub-state machine into the compilation data stream of the application to be compiled, so that the compilation operation of the public module warehouse is integrated into the compilation process of the dedicated module warehouse. The data stream of the reused public module is integrated into the data stream of the dedicated module, eliminating the separation and interaction barriers between data streams, and solving the technical problem in the prior art that when the front-end page module is reused in multiple applications, the data stream cannot communicate with each other, and other interface programs or complex data operations are required to realize data interaction between modules or between modules and pages. The technical effect of extremely small intrusion into the original code, low transformation cost, reduced access risk, and improved front-end application development efficiency is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0072] Figure 1 A flowchart of an application compilation method provided in an embodiment of the present application
[0073] Figure 2 A schematic diagram of an application scenario of a state injection tool provided in this application;
[0074] Figure 3 A flowchart of another application compilation method provided in an embodiment of the present application;
[0075] Figure 4 A flowchart of another application compilation method provided in an embodiment of the present application
[0076] Figure 5 A schematic diagram of the structure of an application compilation device provided in an embodiment of the present application;
[0077] Figure 6 A schematic diagram of the structure of an electronic device provided in this application.
[0078] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0079] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work, including but not limited to the combination of multiple embodiments, belong to the scope of protection of this application.
[0080] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application 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 data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising 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.
[0081] To facilitate understanding, the professional terms involved in each embodiment are first introduced below.
[0082] State machine: A container for storing and managing data on a page at a certain moment. The presentation of the page at the next moment can be modified by changing the state.
[0083] Routing: A tool used to parse URLs (uniform resource locator) and call corresponding controllers to display corresponding pages.
[0084] NPM package: NPM is a package manager for Node.JS (JavaScript development platform), which is used to share compiled Node packages; NPM packages can be copied and applied to multiple applications in the form of plug-ins.
[0085] Tags: The most basic unit in HTML language, such as Both are ways of expressing labels.
[0086] Git: An open source distributed version control system. Git is an open source version control software developed by Linus Torvalds to help manage Linux kernel development. Git is different from commonly used version control tools such as CVS (Concurrent Versions System) and Subversion. It uses a distributed version library and does not require server-side software support.
[0087] git submodule: Git's built-in method for implementing master-slave repositories. The slave repository is stored in the master repository as a separate git project. The slave repository has its own independent Git flow operations such as commit, push, and pull. The master repository only records the git header of the slave repository in the Git flow. The slave repository can be considered to be stored in the Git flow of the master repository in the form of a hyperlink. During local development, the slave repository will pull code from the remote according to the header.
[0088] Export file: The modules written in the slave library are exported here, and the main library can use the modules written in the slave library by referencing this file.
[0089] Proxy technology: A JS (JavaScript development platform) proxy technology that can customize the basic operations of all legal objects in JS and can also overwrite the original methods of the object.
[0090] child_process: A module provided in Node.JS that simulates the terminal environment. It opens multiple threads for operation in a single process running an application.
[0091] The following is an analysis and introduction to the background of code reuse involved in this application:
[0092] Module code reuse is a technical issue that must be faced in the current front-end application development and maintenance process to improve development efficiency.
[0093] The relevant technologies involved in the reuse of existing module codes include: routing distribution, front-end microservices, NPM packages, iframe technology, Web component, etc.
[0094] The inventors of this application have discovered through long-term practice that there is a technical problem in the prior art that when the front-end page module is reused in multiple applications, the data flows cannot be interoperable, and other interface programs or complex data operations are required to achieve data interaction between modules or between modules and pages.
[0095] In order to solve the above technical problems, the invention concept of this application is:
[0096] Put the reused common modules into a special common module warehouse, and then establish a master-slave relationship between the common module warehouse (slave library) and the professional module library (master library) in multiple front-end applications. You only need to update the slave library and synchronize the updated content to multiple applications to complete the update and maintenance of the reused modules. In this process, in order to avoid the problem of separation and interaction barriers between the state data stream of the master library and the state data stream of the slave library, with the help of the state injection tool, when the application is compiled, the data stream in the slave library is merged into the state data stream of the master library, thus realizing the fusion interaction of the data streams of each module in the master and slave libraries. There is no need to rely on independently developed API interface programs or other complex operations like the existing technology, so as to achieve the purpose of improving the efficiency of front-end application development.
[0097] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0098] Figure 1 A flowchart of an application compilation method provided in an embodiment of the present application. Figure 1 As shown, the specific steps of the application compilation method include:
[0099] S101. Obtain a state injection tool.
[0100] In this step, the state injection tool is declared to initialize various internal parameters in the state injection tool.
[0101] In this embodiment, the module repository of the application to be compiled includes two parts, a main library and a slave library. The main library is a dedicated module repository for the application to be compiled, and the slave library is a public module repository corresponding to public modules that can be reused in multiple applications.
[0102] It should be noted that the page presentation of an application requires the compiler to compile the source files of the application. The compilation process can be understood as the compiler selecting the modules required for the target page from the module repository, and then embedding each module into the page architecture template. Since an application has multiple functions and multiple display effects, it is necessary to manage the parameters corresponding to each module under different functions or effects, that is, state management. The compilation process of the application also requires that after each module is combined into the target page according to the page architecture template, a state is assigned to each module, and then after rendering, the final page or interface presented to the user is obtained.
[0103] The application compilation method provided in this embodiment declares the state injection tool before the compilation process starts, or when the compiler just starts compiling.
[0104] For example, add a declaration function of the state injection tool at the beginning of the compiler code.
[0105] It should be noted that the purpose of declaring a function is to inform the compilation system where the compiler is located of the name of the state injection tool, the function type corresponding to the state injection tool, the parameter type, the number of function or formal parameters, the calling order, etc., so that the compiler can check whether the function corresponding to the state injection tool is called correctly according to the declared content when calling it.
[0106] In addition, in a possible design, during the process of declaring the state injection tool, the state injection tool is also initialized.
[0107] Specifically, the sub-state machine in the common module needed to assemble the page from the library, that is, the target sub-state machine of the target common module, is read and temporarily stored in the state injection tool, thus completing the initialization.
[0108] S102: using a state injection tool, injecting the target sub-state machine into the compilation data stream of the application to be compiled, so that the compilation operation of the public module repository is integrated into the compilation process of the dedicated module repository.
[0109] In this step, the target sub-state machine is used to encapsulate the state data of the target common module in the common module warehouse, the state data includes: the attribute parameters of the target common module at each preset application moment, and the dedicated module warehouse includes all dedicated modules of the application to be compiled.
[0110] Specifically, when the compiler of the application to be compiled generates a state machine, the target sub-state machine is registered in the state machine using a state injection tool.
[0111] Among them, the state machine is used to encapsulate the status data of each module in the application to be compiled
[0112] Specific implementation process reference Figure 2 :
[0113] Figure 2 This is a schematic diagram of an application scenario of a state injection tool provided in this application. Figure 2 As shown, the public module warehouse 101 includes multiple public modules, each of which includes a module component and a sub-state machine. The module component is a specific component unit of the module, and the sub-state machine is used to record various state data of the module component. The public module warehouse 101 can provide public modules for multiple applications, so that the modules can be reused and the development efficiency can be improved.
[0114] The application 103 includes: page components, state machine and page routing. The page routing is used to distribute the page components to different target pages, and the state machine is used to distribute the state data of each page component at different pages and at different times.
[0115] Different from the prior art, the common module repository of this embodiment does not require independent compilation operations or real-time calling operations through an API interface. Instead, when an application 103, i.e., the application to be compiled, compiles a page, the target sub-state machine of the target common module is input into the state machine of the application 103 at one time through the state injection tool 102, such as adding data corresponding to the sub-state machine in the input parameters of the state machine generation function.
[0116] In this way, when the application to be compiled is compiled, the sub-state machine can find the corresponding common module components in the slave library (that is, the copy of the common module repository in the application to be compiled) that has been synchronized in advance in the application to be compiled, and distribute the state data of the sub-state machine to each common module component.
[0117] Then, after the compilation of the page architecture template is completed, the public module components are combined with the dedicated module components for rendering, and finally the page is presented to the user through a preset channel, such as a browser.
[0118] With the application compilation method of this embodiment, the modification to the original compilation program for compiling the application is very small, and the developer does not need to customize a special compilation operation for the common module repository.
[0119] This embodiment provides an application compilation method, which first obtains a state injection tool, and then uses the state injection tool to inject the target sub-state machine into the compilation data stream of the application to be compiled, so that the compilation operation of the public module warehouse is integrated into the compilation process of the dedicated module warehouse. The data stream of the reused public module is integrated into the data stream of the dedicated module, eliminating the separation and interaction barriers between data streams, and solving the technical problem in the prior art that when the front-end page module is reused in multiple applications, the data streams cannot communicate with each other, and other interface programs or complex data operations are required to achieve data interaction between modules or between modules and pages. The technical effect of extremely small intrusion into the original code, low modification cost, reduced access risk, and improved front-end application development efficiency is achieved.
[0120] Figure 3 A flowchart of another application compilation method provided in an embodiment of the present application. Figure 3 As shown, the specific steps of the application compilation method include:
[0121] S301. Before executing the compilation entry file of the application to be compiled, initialize the parameters of the state injection tool.
[0122] In this embodiment, the module repository of the application to be compiled includes two parts, a main library and a slave library. The main library is a dedicated module repository of the application to be compiled, and the slave library is a public module repository that is synchronized to the database file in the application to be compiled through a remote management platform.
[0123] In this step, after the application to be compiled starts compiling and before executing the compilation entry file of the application to be compiled, the compiler first calls the configuration file to determine the target common module from the slave library corresponding to the common module repository;
[0124] Then, read the target sub-state machine from the target common module;
[0125] Next, the target sub-state machine is stored in the state injection tool, so that the target sub-state machine is temporarily stored in the state injection tool.
[0126] It should be noted that the target common module includes a target sub-state machine.
[0127] Specifically, after the application to be compiled starts compiling, before the compilation entry file of the application to be compiled is executed, the injection tool is declared. The declaration needs to import the sub-state machines of each public module in the slave library as needed according to the user's configuration to avoid importing modules that are useless to the main application. During the declaration process, the state injection tool will automatically read the sub-state machines of the public modules and temporarily store them.
[0128] S302: When the compiler of the application to be compiled generates a state machine, a state injection tool is used to register the target sub-state machine into the state machine.
[0129] In this step, the state machine is used to encapsulate the state data of each module in the application to be compiled.
[0130] Specifically, in a possible implementation, when the state machine is generated, the state injection tool intercepts the generation function of the state machine to suspend the execution of the generation function;
[0131] Then, add the target sub-state machine to the incoming parameters of the generated function;
[0132] Then, continue to execute the generated function.
[0133] Specifically, for example, after the declaration is completed, the application to be compiled starts to compile normally. When the state machine is generated, the state injection tool will intercept it. This interception is based on Proxy technology. During the interception process, the state injection tool first receives the input parameters when the state machine of the application to be compiled is generated, and appends the temporary target sub-state machine to the end, and then executes the state machine generation function.
[0134] S303: Use the compiler to distribute the state data in the state machine to the corresponding target page.
[0135] In this embodiment, after the state machine is generated, the compiler distributes the states in the state machine to pages that need to use the states.
[0136] S304: Using the compiler, calling the module components and state machines in each module, and compiling the target page.
[0137] In this step, the modules include: dedicated modules in the master library and common modules in the slave library.
[0138] In one possible design, it specifically includes:
[0139] Using a compiler, importing a first module component and a second module component into a target page, wherein the first module component is a module component of a target common module, and the second module component is a module component of a dedicated module;
[0140] The state machine is used to configure the first state data for the first module component and the second state data for the second module component. The state machine includes the first state data and the second state data.
[0141] For example, the compiler first obtains the first module component to be imported from the library. After the import is completed, the state obtained from the target page in the previous step is sent to each first module component according to the configuration path preset in the configuration file.
[0142] It should be noted that, in a possible implementation, for the first module component in the slave library, in addition to obtaining the state declared by itself, it can also obtain other states in the state machine of the application to be compiled as required.
[0143] Similarly, for a dedicated module, the compiler imports the second module components of the dedicated module from the main library, and after the import is completed, configures the states allocated from the state machine to each second module component.
[0144] S305: Complete the page architecture compilation and the combination of each module component, and render the page.
[0145] In this step, the compiler continues to compile the page architecture template of the target page, combines the various module components according to the architecture template, and then renders the page display effect and presents it to the user through a preset method such as a browser or APP interface.
[0146] It should be noted that, through steps S303 to S304, the compilation operation of the public module repository is integrated into the compilation process of the dedicated module repository, so that the application compilation method of this embodiment has a minimal impact on the compilation program of the original application, reducing the custom development workload of developers and improving development efficiency.
[0147] This embodiment provides an application compilation method, which first obtains a state injection tool, and then uses the state injection tool to inject the target sub-state machine into the compilation data stream of the application to be compiled, so that the compilation operation of the public module warehouse is integrated into the compilation process of the dedicated module warehouse. The data stream of the reused public module is integrated into the data stream of the dedicated module, eliminating the separation and interaction barriers between data streams, and solving the technical problem in the prior art that when the front-end page module is reused in multiple applications, the data streams cannot communicate with each other, and other interface programs or complex data operations are required to achieve data interaction between modules or between modules and pages. The technical effect of extremely small intrusion into the original code, low modification cost, reduced access risk, and improved front-end application development efficiency is achieved.
[0148] In order to illustrate the establishment and management mechanism of the master-slave repository in the application to be compiled in S301, and how the common module library is synchronized and updated to each application to be compiled after independent maintenance, the following is combined with Figure 4 To explain.
[0149] Figure 4 A flowchart of another application compilation method provided in an embodiment of the present application is shown below. Figure 4 As shown, the specific steps of the application compilation method include:
[0150] S401. On a preset platform, a master-slave repository creation tool is used to establish a master-slave mapping relationship between a dedicated module repository and a public module repository.
[0151] In this step, the dedicated module warehouse is the master warehouse and the public module warehouse is the slave warehouse.
[0152] Specifically, create at least one storage address of a public module repository on a preset platform;
[0153] Use the master-slave repository creation tool to set at least one public module repository as a slave repository and at least one dedicated module repository as a master repository.
[0154] For example, building a master-slave repository based on Git technology:
[0155] First, you need to create the storage address of the slave library on the code hosting platform, and then initialize the master-slave warehouse architecture through the relevant instructions of git submodule.
[0156] In this embodiment, a script is quickly generated through a common module, and a basic file of the common module is generated from a library according to data input by a user on an input interface.
[0157] That is, the common module includes: module component files, module state machine files, interface request files, and constant declaration files.
[0158] The code in the template component file is mainly written in HTML, which is used for page display;
[0159] The module's state machine file contains the module's state machine and its related operations of adding, deleting, modifying, and checking.
[0160] The interface request file contains the HTTP request required by the module, and also includes the quick generation of constant declaration files.
[0161] With the help of Node.JS's fs file operation function, the script can dynamically generate template files through user input and automatically modify the export files from the library, reducing the learning cost of developers.
[0162] S402 . In response to a user's submission instruction, the submission tool is used to synchronously update the slave library to the to-be-compiled application corresponding to the master library, so that the to-be-compiled application can call the target common module during compilation.
[0163] In this embodiment, in order to make up for the deficiencies of Git's master-slave repository submission tool function, a master-slave repository Git synchronization management script is provided for the structure of the master-slave repository to avoid the problem of misoperation that developers are prone to when operating multiple Git streams:
[0164] After the user creates, deletes, or changes the data of a public module on the operation interface, selects multiple applications that need to be synchronized, and clicks the Submit button, the Git synchronization management script will synchronize the updated data to the slave libraries in multiple applications to eliminate the data inconsistency and fragmentation problem caused by separate maintenance of the application to be compiled and the public module repository.
[0165] It should be noted that the information of the master and slave references will be displayed on the operation interface, including: the name of the warehouse, whether it is a slave warehouse, the current Git branch of each warehouse, and each line is the information of each warehouse submitted this time.
[0166] It should also be noted that after the user completes the input, the script tool can automatically perform a series of operations such as Git submission and push to remote, and output the submission information when the submission is completed, including: warehouse name, branch of this submission, submission id, etc.
[0167] S403: Obtain a status injection tool.
[0168] S404: Using a state injection tool, inject the target sub-state machine into the compilation data flow of the application to be compiled, so that the compilation operation of the public module repository is integrated into the compilation process of the dedicated module repository.
[0169] For detailed explanation of terms and working principle of steps S403-S404, please refer to Figure 1 and Figure 3 The embodiments shown will not be described in detail here.
[0170] This embodiment provides an application compilation method, which uses a master-slave repository creation tool on a preset platform to establish a master-slave mapping relationship between a dedicated module repository and a public module repository, and then responds to a user's submission instruction by using the submission tool to synchronize updates from the slave repository to the application to be compiled corresponding to the master repository, so that the application to be compiled can call the target public module during compilation.
[0171] Figure 5 A schematic diagram of the structure of an application compilation device provided in an embodiment of the present application.
[0172] The application compiling device 500 may be implemented by software, hardware or a combination of both.
[0173] like Figure 5 As shown, the application compilation device 500 includes:
[0174] The acquisition module 501 is used to declare the state injection tool to initialize the state injection tool;
[0175] The state injection module 502 is used to inject the target sub-state machine into the compilation data flow of the application to be compiled by using the state injection tool, so that the compilation operation of the public module repository is integrated into the compilation process of the dedicated module repository;
[0176] The target sub-state machine is used to encapsulate the state data of the target common module in the common module warehouse, and the state data includes: the attribute parameters of the target common module at each preset application moment, and the dedicated module warehouse includes all dedicated modules of the application to be compiled.
[0177] In a possible design, the state injection module 502 is used to register the target sub-state machine into the state machine using a state injection tool when the compiler of the application to be compiled generates the state machine;
[0178] The state machine is used to encapsulate the state data of each module in the application to be compiled.
[0179] In a possible design, the state injection module 502 is specifically used to:
[0180] When the state machine is generated, the state injection tool intercepts the generated function of the state machine to suspend the execution of the generated function;
[0181] Add the target sub-state machine to the incoming parameters of the generated function;
[0182] Continue executing the generator function.
[0183] Optionally, the acquisition module 501 is used to initialize parameters of the state injection tool before executing the compilation entry file of the application to be compiled.
[0184] In a possible design, the acquisition module 501 is specifically used to:
[0185] Call the configuration file, determine the target common module from the common module repository, and the target common module includes the target sub-state machine;
[0186] Read the target sub-state machine from the target common module;
[0187] Stores the target sub-state machine in the state injection tool.
[0188] In a possible design, the state injection module 502 is further used to:
[0189] Use the compiler to distribute the state data in the state machine to the corresponding target page;
[0190] Use the compiler to call the module components and state machines in each module to compile the target page;
[0191] Among them, the modules include dedicated modules and public modules.
[0192] Optionally, the state injection module 502 is specifically used for:
[0193] Using a compiler, importing a first module component and a second module component into a target page, wherein the first module component is a module component of a target common module, and the second module component is a module component of a dedicated module;
[0194] The state machine is used to configure the first state data for the first module component and the second state data for the second module component. The state machine includes the first state data and the second state data.
[0195] In a possible design, the application compilation device further includes:
[0196] The master-slave warehouse management module is used to establish a master-slave mapping relationship between a dedicated module warehouse and a public module warehouse on a preset platform using a master-slave warehouse creation tool, wherein the dedicated module warehouse is the master warehouse and the public module warehouse is the slave warehouse;
[0197] The synchronization management module is used to respond to the user's submission instruction and use the submission tool to synchronize the slave library to the application to be compiled corresponding to the main library, so that the application to be compiled can call the target common module during compilation.
[0198] Optional, master-slave warehouse management module, specifically used for:
[0199] Create at least one public module repository storage address on the preset platform;
[0200] Use the master-slave repository creation tool to set at least one public module repository as a slave repository and at least one dedicated module repository as a master repository.
[0201] It is worth mentioning that Figure 5 The device provided in the illustrated embodiment can execute the method provided in any of the above method embodiments. Its specific implementation principles, technical features, professional terminology explanations and technical effects are similar and will not be repeated here.
[0202] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 6 As shown, the electronic device 600 may include: at least one processor 601 and a memory 602 . Figure 6 An electronic device is shown using a processor as an example.
[0203] The memory 602 is used to store programs. Specifically, the programs may include program codes, and the program codes include computer operation instructions.
[0204] The memory 602 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0205] The processor 601 is used to execute the computer-executable instructions stored in the memory 602 to implement the methods described in the above method embodiments.
[0206] The processor 601 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.
[0207] Optionally, the memory 602 may be independent or integrated with the processor 601. When the memory 602 is a device independent of the processor 601, the electronic device 600 may further include:
[0208] The bus 603 is used to connect the processor 601 and the memory 602. The bus can be an industry standard architecture (ISA) bus, a peripheral component interconnect (PCI) bus, or an extended industry standard architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc., but it does not mean that there is only one bus or one type of bus.
[0209] Optionally, in a specific implementation, if the memory 602 and the processor 601 are integrated on a chip, the memory 602 and the processor 601 can communicate through an internal interface.
[0210] An embodiment of the present application also provides a computer-readable storage medium, which may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, and other media that can store program codes. Specifically, the computer-readable storage medium stores program instructions, and the program instructions are used for the methods in the above-mentioned method embodiments.
[0211] An embodiment of the present application further provides a computer program product, including a computer program, which implements the methods in the above-mentioned method embodiments when executed by a processor.
[0212] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the claims of the present application.
[0213] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
[0214] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. An application compilation method, characterized in that: include: Get the state injection tool; When the compiler of the application to be compiled generates a state machine, the state injection tool intercepts the generation function of the state machine to suspend the execution of the generation function; Adding the target sub-state machine to the input parameters of the generation function; Continue to execute the generation function so that the compilation operation of the public module repository is integrated into the compilation process of the dedicated module repository; wherein the state machine is used to encapsulate the state data of each module in the application to be compiled; The target sub-state machine is used to encapsulate the state data of the target common module in the common module warehouse, and the state data includes: the attribute parameters of the target common module at each preset application moment, and the dedicated module warehouse includes all dedicated modules of the application to be compiled.
2. The application compilation method according to claim 1, characterized in that: The method further comprises: Before executing the compilation entry file of the application to be compiled, the state injection tool is declared.
3. The application compiling method according to claim 2, characterized in that: The statement state injection tool comprises: Calling a configuration file, determining the target common module from the common module repository, wherein the target common module includes the target sub-state machine; Reading the target sub-state machine from the target common module; The target sub-state machine is stored in the state injection tool.
4. The application compilation method according to claim 1, characterized in that: Also includes: Using a compiler to distribute the state data in the state machine to corresponding target pages; Using the compiler, calling the module components in each module and the state machine to compile the target page; The modules include the dedicated modules and the common modules.
5. The application compiling method according to claim 4, characterized in that: The using the compiler to call the module components in each module and the state machine to compile the target page includes: Using the compiler, importing a first module component and a second module component into the target page, wherein the first module component is a module component of the target common module, and the second module component is a module component of the dedicated module; The state machine is used to configure first state data for the first module component and second state data for the second module component. The state machine includes the first state data and the second state data.
6. The application compiling method according to claim 1, characterized in that: Before obtaining the state injection tool, it also includes: On a preset platform, a master-slave warehouse creation tool is used to establish a master-slave mapping relationship between the dedicated module warehouse and the public module warehouse, wherein the dedicated module warehouse is the master warehouse and the public module warehouse is the slave warehouse; In response to a user's submission instruction, the submission tool is used to synchronously update the slave library to the to-be-compiled application corresponding to the master library, so that the to-be-compiled application can call the target common module during compilation.
7. The application compiling method according to claim 6, characterized in that: The master-slave mapping relationship between the dedicated module warehouse and the public module warehouse is established on the preset platform using a master-slave warehouse creation tool, including: Creating at least one storage address of the public module warehouse on a preset platform; By using the master-slave repository creation tool, at least one of the public module repositories is set as the slave repository, and at least one of the dedicated module repositories is set as the master repository.
8. An application compilation device, characterized in that: include: Acquisition module, used to obtain the state injection tool; A state injection module, used for intercepting the generation function of the state machine when the compiler of the application to be compiled generates the state machine, so as to suspend the execution of the generation function; Adding the target sub-state machine to the input parameters of the generation function; Continue to execute the generation function so that the compilation operation of the public module repository is integrated into the compilation process of the dedicated module repository; wherein the state machine is used to encapsulate the state data of each module in the application to be compiled; The target sub-state machine is used to encapsulate the state data of the target common module in the common module warehouse, and the state data includes: the attribute parameters of the target common module at each preset application moment, and the dedicated module warehouse includes all dedicated modules of the application to be compiled.
9. An electronic device, characterized in that: include: processor and memory; wherein, The memory is used to store a computer program of the processor; The processor is configured to perform the application compiling method according to any one of claims 1 to 7 by executing the computer program.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the application compiling method according to any one of claims 1 to 7 is implemented.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the application compiling method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Embedded software target code unit testing method based on injection mode
CN108132876A
Implementation method and device of state machine engine, computer equipment and storage medium
CN110580155A