Increment construction method and device, electronic equipment, storage medium and program product
By setting up multiple dynamic libraries for the application, only the dynamic libraries corresponding to the modified component files are rebuilt, while the symbols of other dynamic libraries are retained. This solves the problem of long incremental build time in the prior art and achieves faster incremental build speed.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING ZITIAO NETWORK TECH CO LTD
- Filing Date
- 2024-10-15
- Publication Date
- 2026-04-17
AI Technical Summary
Incremental builds in existing technologies take a long time, and are particularly affected by the amount of unmodified code.
By setting multiple dynamic libraries for the application, only the dynamic libraries corresponding to the modified component files are rebuilt, while the symbols of other dynamic libraries are retained, avoiding the need to relink the unmodified component files. The dynamic library linking method of the component files is dynamically determined using preset conditions.
It improves incremental build speed, reduces the time required for incremental builds, and optimizes the application build process.
Smart Images

Figure CN121879767A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and more particularly to an incremental construction method, apparatus, electronic device, storage medium, and program product. Background Technology
[0002] Incremental building refers to rebuilding a binary program by making minor modifications after a previous build has been completed. However, in related technologies, incremental building can be time-consuming. Summary of the Invention
[0003] This disclosure provides an incremental build method, apparatus, electronic device, storage medium, and program product to improve incremental build speed and reduce the time required for incremental builds.
[0004] In a first aspect, embodiments of this disclosure provide an incremental construction method, including:
[0005] In response to an incremental build instruction for an application, a target component file corresponding to the incremental build instruction is obtained, wherein the target component file is a modified component file, and the executable file of the application calls at least two dynamic libraries, and different dynamic libraries are used to link different component files of the application;
[0006] Determine the target dynamic library to which the target component file should be linked from the at least two dynamic libraries;
[0007] The target dynamic library is reconstructed based on the target component file and the symbols to be retained in the target dynamic library, wherein the symbols to be retained are defined by the target dynamic library and referenced by at least one other dynamic library, which is a dynamic library other than the target dynamic library among the at least two dynamic libraries.
[0008] Secondly, embodiments of this disclosure also provide an incremental build apparatus, comprising:
[0009] The file acquisition module is used to acquire the target component file corresponding to the incremental build instruction in response to the incremental build instruction for the application. The target component file is a modified component file. The executable file of the application calls at least two dynamic libraries, and different dynamic libraries are used to link different component files of the application.
[0010] A dynamic library determination module is used to determine the target dynamic library to which the target component file is to be linked from the at least two dynamic libraries;
[0011] A dynamic library construction module is used to reconstruct the target dynamic library based on the target component file and the symbols to be retained of the target dynamic library, wherein the symbols to be retained are defined by the target dynamic library and referenced by at least one other dynamic library, and the other dynamic library is a dynamic library other than the target dynamic library among the at least two dynamic libraries.
[0012] Thirdly, embodiments of this disclosure also provide an electronic device, including:
[0013] One or more processors;
[0014] Memory, used to store one or more programs.
[0015] When the one or more programs are executed by the one or more processors, the one or more processors implement the incremental build method as described in the embodiments of this disclosure.
[0016] Fourthly, embodiments of this disclosure also provide a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the incremental construction method as described in embodiments of this disclosure.
[0017] Fifthly, embodiments of this disclosure also provide a computer program product that, when executed by a computer, enables the computer to implement the incremental construction method as described in embodiments of this disclosure.
[0018] The incremental build method, apparatus, electronic device, storage medium, and program product provided in this disclosure provide multiple dynamic libraries for an application. Incremental build of the application is achieved by rebuilding the dynamic libraries corresponding to the modified component files, without having to relink the component files linked to other dynamic libraries. This enriches the incremental build methods of the application, improves the incremental build speed of the application, and reduces the time spent on incremental build of the application. Attached Figure Description
[0019] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.
[0020] Figure 1 A flowchart illustrating an incremental construction method provided in an embodiment of this disclosure;
[0021] Figure 2 This is a schematic diagram illustrating the process of incrementally building applications in related technologies;
[0022] Figure 3A flowchart illustrating another incremental construction method provided in this disclosure embodiment;
[0023] Figure 4 This is a diagram illustrating the link between the APP source code and components in related technologies;
[0024] Figure 5 A schematic diagram illustrating the linking of APP source code and components provided in an embodiment of this disclosure;
[0025] Figure 6 A schematic diagram illustrating the construction process of a dynamic library provided in this embodiment of the disclosure;
[0026] Figure 7 A structural block diagram of an incremental construction apparatus provided in an embodiment of this disclosure;
[0027] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0028] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0029] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.
[0030] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.
[0031] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0032] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0033] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0034] It is understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and related provisions.
[0035] Figure 1 This is a flowchart illustrating an incremental build method provided in an embodiment of this disclosure. The method can be executed by an incremental build device, which can be implemented in software and / or hardware and can be configured in an electronic device, typically a computer. The incremental build method provided in this disclosure is applicable to scenarios involving incremental builds based on dynamic libraries and the symbols to be retained within those dynamic libraries.
[0036] The process of transforming source files into a final executable binary program using specific tools and procedures is generally called building. Building a binary program typically includes compilation and linking. Compilation is the process of converting source code into binary files, which are then used for linking. Linking is the process of combining all the compiled binary files to form the final executable binary file.
[0037] Incremental builds refer to creating a modified binary program by making minor modifications after an initial build has been completed. Because a large amount of intermediate code is cached and does not need to be regenerated, the overall build speed is much faster than the initial build. Theoretically, incremental builds are only related to the amount of code modified, and not to the amount of unmodified code.
[0038] Figure 2 This is a schematic diagram illustrating the process of incrementally building binary programs in related technologies. For example... Figure 2 As shown, during incremental builds, the compiler can process each source file individually, meaning it can recompile only the modified source files. The linker, however, needs to aggregate all compiled binaries—including those from modified source files and those from unchanged source files—for its work. Therefore, regardless of the amount of modification, the linking time is directly proportional to the complexity of all code in the project.
[0039] Furthermore, besides the linking time, the size of the resulting executable file is also positively correlated with code complexity. The time spent transferring binary files between electronic devices (such as from a computer to a mobile phone) and debugging and starting them on electronic devices (such as mobile phones) is positively correlated with the size of the executable file, and therefore is essentially positively correlated with the complexity of the project code.
[0040] It is evident that, under the existing tool system, even with the same code changes, the time spent on linking, installation, debugging, and startup can vary drastically depending on the complexity of the project. Furthermore, the speed of incremental builds is greatly affected by the amount of unmodified code, and incremental builds can take a considerable amount of time.
[0041] In view of this, the present disclosure provides an incremental build method that builds at least two dynamic libraries that can be called by the executable file, and performs incremental build based on these dynamic libraries. This can reduce the impact of unmodified code on the incremental build speed and reduce the time required for incremental build.
[0042] like Figure 1 As shown, the incremental construction method provided in this embodiment may include:
[0043] S101. In response to an incremental build instruction for an application, obtain a target component file corresponding to the incremental build instruction, wherein the target component file is a modified component file, and the executable file of the application calls at least two dynamic libraries, and different dynamic libraries are used to link different component files of the application.
[0044] Incremental build instructions are commands used to instruct the application to be built incrementally. During an incremental build, only the changed source files are compiled and linked, while the unchanged source files are not, thus reducing the time required to rebuild the application.
[0045] Target component files can be understood as the component files corresponding to incremental build instructions. It's understood that an application can have different components to implement different functionalities. Target component files can be component files that have undergone modifications, such as component files that have been modified between the current incremental build instruction received from the current user and the previous incremental build instruction received from the current user. A component file for an application can be either its source file or a binary file. The following explanation uses a binary file as an example. A component's source file is the file that records the component's uncompiled source code. A component's binary file is the file obtained by compiling the component's source file.
[0046] An application's executable file is a file that can run directly on the operating system. The instructions and data contained in this executable file are those that the electronic device can understand and execute. A dynamic library is a dynamic link library. In this embodiment of the disclosure, the application's executable file calls at least two dynamic libraries. Different dynamic libraries can be used to link different component files of the application. Therefore, at runtime, the application's executable file can implement the functionality of the corresponding component by calling the component files linked in the dynamic libraries.
[0047] The method for determining the dynamic libraries linked to by different component files is not limited. For example, the dynamic libraries linked to by the component files of each component in the application can be preset; or the dynamic libraries linked to by the component files of each component can be dynamically determined and adjusted according to the changes of each component to further improve the incremental build speed of the application. In this case, optionally, the at least two dynamic libraries include a first dynamic library and a second dynamic library. The first dynamic library is used to link component files whose changes meet preset conditions, and the second dynamic library is used to link component files whose changes do not meet preset conditions.
[0048] The preset conditions can be understood as the conditions that must be met for the modifications to component files linked to the first dynamic library. Preset conditions can be set in advance as needed. For example, preset conditions can be associated with the number of modifications and / or the modification time of each component file. For instance, component files corresponding to source files that developers have frequently modified recently and / or recently modified can be linked to the first dynamic library, while component files corresponding to source files that developers have not frequently modified and have not recently modified can be linked to the second dynamic library. Thus, in most cases, during incremental builds, only the component files linked to the first dynamic library need to be relinked, without needing to relink the component files linked to the second dynamic library, significantly reducing the time required for incremental builds. The first dynamic library can be a dynamic library used to link component files of the application that meet the preset conditions, and its number can be one or more. The second dynamic library can be a dynamic library used to link component files of the application that do not meet the preset conditions, and its number can be one or more. For example, the first and / or second dynamic libraries can be presented in the form of files. By setting preset conditions, the number of component files linked in the first dynamic library can be much smaller than the number of component files linked in the second dynamic library, thereby further improving the incremental build speed of the application.
[0049] The modification status of component files can be understood as the modifications made to the component by developers. This could refer to modifications made by some developers of the application or modifications made by all developers of the application. Considering that the modifications made to the components of the application by different developers are generally different, for example, a first dynamic library and a second dynamic library corresponding to each developer and the application can be built according to the modifications made to the components of the application by different developers, in order to further improve the incremental build speed of the application. In this case, optionally, the modification status refers to the modifications made to the component files of the application by the current developer, and the at least two dynamic libraries correspond to the current developer. For example, different developers may have different dynamic libraries corresponding to the application, such as different first dynamic libraries and / or different second dynamic libraries. The number of modifications to component files can be understood as the number of times the developer modifies the component, such as the number of times the application is incrementally built after modifying the source file of the component. The current developer can be the developer who triggered the generation of this incremental build instruction.
[0050] Specifically, upon receiving an incremental build instruction for a certain application, the system can respond to this instruction by obtaining the component file corresponding to the incremental build instruction that has been modified in the application, and use it as the target component file, so as to perform an incremental build of the application based on this target component file.
[0051] For example, a developer can modify the source code of an application component and, when an incremental build is needed (such as to check the effect of the modified component), trigger an incremental build instruction for the application. Correspondingly, the electronic device can respond to this incremental build instruction by obtaining the source file of the component corresponding to the component identifier carried in the instruction, or by obtaining the source file that has been modified between the currently received incremental build instruction and the previously received incremental build instruction for the application. The obtained source file is then compiled, and the resulting binary file is used as the target component file corresponding to the currently generated incremental build instruction. The component identifier can be understood as the component's identifier, such as the component name and / or component code (Identity Document, ID).
[0052] S102. Determine the target dynamic library to which the target component file is to be linked from the at least two dynamic libraries.
[0053] In this context, the target dynamic library can be understood as the dynamic library to be rebuilt. For example, when there is only one target component file, or when there are multiple target component files and these multiple target component files are component files to be linked from the same dynamic library, this dynamic library can be used as the target dynamic library. When there are multiple target component files and these multiple target component files are not component files to be linked from the same dynamic library, the dynamic libraries to be linked from these multiple target component files can be determined, and for each dynamic library, it can be used as the target dynamic library, and this target dynamic library can be rebuilt, and so on. The following explanation uses the example of target component files being linked to the same dynamic library. The target dynamic library to be linked to by a target component can be the first dynamic library or the second dynamic library, depending on the dynamic library linked to by the original component file before this modification.
[0054] For example, after determining the target component file, the target dynamic library to which this component file should be linked can be determined based on the component identifier corresponding to this target component file. For instance, each time a dynamic library is built, the component identifier corresponding to the component file linked in this dynamic library can be recorded. Thus, after determining the target component file, the dynamic library to which the original component file corresponding to this component file was linked before this incremental build can be determined based on the component identifier corresponding to this target component file, and this dynamic library will be used as the target dynamic library to which this target component file should be linked.
[0055] S103. Reconstruct the target dynamic library based on the target component file and the symbols to be retained in the target dynamic library, wherein the symbols to be retained are defined by the target dynamic library and referenced by at least one other dynamic library, and the other dynamic library is a dynamic library other than the target dynamic library among the at least two dynamic libraries.
[0056] Here, "symbols to be retained" can be understood as symbols that need to be additionally retained in the target dynamic library during its construction. Symbols to be retained can be symbols defined by the target dynamic library and referenced by other dynamic libraries besides the target dynamic library. For example, a symbol to be retained can be a symbol referenced only by symbols in other dynamic libraries and not by symbols in the target dynamic library. "Other dynamic libraries" can be understood as any of the at least two dynamic libraries called by the executable file of the aforementioned application, excluding the target dynamic library currently being rebuilt; the number of such libraries can be one or more.
[0057] In this embodiment, since there are at least two dynamic libraries, when building a dynamic library (including initial building and rebuilding), the linker deletes symbols in the dynamic library that are not referenced by other symbols in that dynamic library in order to introduce as few symbols as possible to reduce the storage space occupied by the dynamic library. However, if such symbols disappear, the symbols that were originally introduced because they were dependent on such symbols will also no longer be introduced because they are no longer referenced. As a result, other dynamic libraries may lack references, causing the application to fail to start normally. Therefore, it is possible to set the symbols that each dynamic library needs to retain that are not referenced by other symbols in that dynamic library, and when building each dynamic library, retain the symbols that each dynamic library needs to retain in the corresponding dynamic library for reference by other dynamic libraries.
[0058] Specifically, after obtaining the target component file, this target component file can be used as at least part of the component file to be linked in the target component dynamic library. For example, this target component file can be used to replace the original component file of the component corresponding to this target component file, the target dynamic library can be rebuilt, and the symbols to be retained in the target dynamic library can be retained in the target dynamic library for reference by other dynamic libraries other than this target dynamic library.
[0059] In some implementations, the application rebuilding process may further include rebuilding the application itself, i.e., rebuilding the executable program of the application. For example, after rebuilding the target dynamic library, the application can be further built based on the rebuilt target dynamic library, such as rebuilding the executable program corresponding to the application based on the rebuilt target dynamic library. Here, the executable program can be understood as an application that can be run directly.
[0060] In some optional examples, the application described above can run on a current electronic device that performs the incremental build method provided in this embodiment. For instance, after rebuilding the target dynamic library, an executable program for the application described above can be built based on this rebuilt target dynamic library.
[0061] In some alternative instances, the application described above can run on an electronic device other than the current electronic device; that is, the current electronic device executing the incremental build method provided in this embodiment and the electronic device running the executable program of the application described above can be different devices. In this case, for example, after rebuilding the target dynamic library, this target dynamic library can be transferred to other electronic devices running the application described above, so that the other electronic devices can rebuild the executable program of the application based on this target dynamic library.
[0062] Optionally, the method is executed by a first electronic device, and after reconstructing the target dynamic library based on the target component file and the symbols to be retained in the target dynamic library, it further includes: regenerating the target program file package of the application based on the reconstructed target dynamic library; comparing the target program file package with the original program file package in the second electronic device to obtain the content to be transmitted in the target program file package that has been changed, the content to be transmitted including the target dynamic library; and transmitting the content to be transmitted to the second electronic device, wherein the second electronic device is used to update the original program file package to the target program file package based on the content to be transmitted, and to reconstruct the application based on the target program file package.
[0063] In this embodiment, the first electronic device can be understood as the electronic device executing the incremental build method provided in this embodiment, i.e., the current electronic device. The second electronic device can be understood as the electronic device running the aforementioned application, i.e., the electronic device running the executable program of the aforementioned application. In some examples, the first electronic device and the second electronic device can be different electronic devices; for example, the first electronic device can be a computer, and the second electronic device can be a mobile phone or tablet computer. The program file package can be understood as the installation package of the application, which may contain application-related files, such as executable files and the dynamic libraries called by the executable files. The target program file package can be the updated program file package generated after this rebuild. The original program file package can be the original program file package of the aforementioned application before this rebuild. The content to be transferred can be understood as the content that needs to be transferred to the second electronic device during this incremental build, which can be the content of the target program file package that has changed relative to the original program file package. For example, the content to be transferred in the target program file package can be determined on a file-by-file basis. In this case, the content to be transferred can be the files in the target program file package that have changed compared to the original file package. This content to be transferred may include the target dynamic libraries obtained during this rebuild.
[0064] In the above implementation, since at least two dynamic libraries that support executable file calls are set up, during incremental build, only the changed content (such as the target dynamic library) can be transferred. There is no need for the executable file to directly link all component files of the application, nor is there a need to transfer the executable file that links all component files. This reduces the amount of data that needs to be transferred, thereby reducing the time spent on data transfer during incremental build and improving the speed of incremental build of the application.
[0065] For example, after the first electronic device reconstructs the target dynamic library, it can regenerate the target program file package of the aforementioned application based on the reconstructed target dynamic library. It then compares the files contained in this target program file package with the files contained in the original program file package stored in the second electronic device, and obtains the files in the target program file package that are different from those in the original program file package, as the content to be transmitted. This content to be transmitted is then transmitted to the second electronic device. Correspondingly, after receiving the content to be transmitted from the first electronic device, the second electronic device can update its locally stored original program file package to the same target program file package as the one in the first electronic device, and reconstruct the executable program of the aforementioned application based on this target program file package, i.e., reconstruct the application.
[0066] The incremental build method provided in this embodiment, in response to an incremental build instruction for an application, obtains the target component file corresponding to this incremental build instruction. The target component file is a modified component file of the application. The executable file of this application calls at least two dynamic libraries, which are used to link different component files of the application. The method then determines the target dynamic library to which the target component file should be linked from these at least two dynamic libraries. Based on the target component file and the symbols to be retained in the target dynamic library, the target dynamic library is reconstructed. The symbols to be retained in the target dynamic library are those defined by the target dynamic library and referenced by other dynamic libraries besides the target dynamic library among the at least two dynamic libraries. This embodiment utilizes the above technical solution to set up multiple dynamic libraries for the application. Incremental build of the application is achieved by reconstructing the dynamic libraries corresponding to the modified component files, eliminating the need to relink component files linked by other dynamic libraries. This enriches the incremental build methods for the application, improves the incremental build speed, and reduces the time spent on incremental builds.
[0067] In some embodiments, before reconstructing the target dynamic library based on the target component file and the symbols to be retained in the target dynamic library, the symbols to be retained in the target dynamic library can be obtained, such as obtaining pre-stored symbols to be retained in the target dynamic library; or, the defined symbols of the target dynamic library and the undefined symbols of other dynamic libraries besides the target dynamic library can be obtained, and the symbols to be retained in the target dynamic library can be determined based on the defined symbols of the target dynamic library and the undefined symbols of other dynamic libraries besides the target dynamic library, etc. The defined symbols of the target dynamic library and / or the undefined symbols of other dynamic libraries can be stored in the form of a list or set, etc., and this embodiment does not limit this.
[0068] Optionally, before reconstructing the target dynamic library based on the target component file and the symbols to be retained in the target dynamic library, the method further includes: determining the intersection between the set of defined symbols in the target dynamic library and the set of undefined symbols in the other dynamic libraries, and using at least a portion of the symbols in the intersection as the symbols to be retained in the target dynamic library, wherein the set of defined symbols in the target dynamic library contains at least one symbol defined in the target dynamic library, and the set of undefined symbols in the other dynamic libraries contains at least one symbol referenced by the other dynamic libraries and not defined in the other dynamic libraries.
[0069] The set of defined symbols for a dynamic library (such as a target dynamic library or other dynamic libraries besides the target dynamic library) can be understood as a set of defined symbols in this dynamic library, containing at least one defined symbol of this dynamic library. The set of undefined symbols for a dynamic library (such as a target dynamic library or other dynamic libraries besides the target dynamic library) can be understood as a set of undefined symbols in this dynamic library, containing at least one undefined symbol of this dynamic library. A defined symbol can be understood as a symbol that has been defined. For example, a defined symbol for a dynamic library can be a symbol that has been defined in at least one component file linked to or to be linked by this dynamic library. In other words, the definition information of the defined symbols of a dynamic library is contained in at least one component file linked to or to be linked by this dynamic library. An undefined symbol can be understood as a symbol that is referenced but not defined. For example, an undefined symbol in a dynamic library can be a symbol that is referenced in at least some component files linked to or to be linked by this dynamic library, but is not defined in any of the component files linked to or to be linked by this dynamic library. In other words, an undefined symbol in a dynamic library is referenced by at least some component files linked to or to be linked by this dynamic library, but the definition information of this symbol is not contained in any of the component files linked to or to be linked by this dynamic library.
[0070] In the above implementation, at least some symbols that are referenced in other dynamic libraries but are not defined, and that are defined in the current dynamic library, can be obtained as symbols to be retained in the target dynamic library.
[0071] Specifically, the process can begin by obtaining the defined symbol set of the target dynamic library and the undefined symbol sets of other dynamic libraries besides the target dynamic library. For example, a pre-stored defined symbol set of the target dynamic library can be obtained, and / or a pre-stored undefined symbol set of the target dynamic library can be obtained. Alternatively, symbol analysis can be performed on at least some component files of the target dynamic library to be linked, and the defined symbol set of the target dynamic library can be determined based on the symbol analysis results. And / or, symbol analysis can be performed on at least some component files of other dynamic libraries linked to or to be linked, and the undefined symbol sets of the other dynamic libraries can be determined based on the symbol analysis results. After determining the defined symbol set of the target dynamic library and the undefined symbol sets of other dynamic libraries, the intersection of the defined symbol set of the target dynamic library and the undefined symbol sets of each other dynamic library can be determined, and at least some of the symbols in this intersection can be obtained as symbols to be retained in the target dynamic library.
[0072] When retrieving the symbols to be retained from a target dynamic library, for example, all symbols in the intersection can be obtained as the symbols to be retained from the target dynamic library, simplifying the operations required to determine the symbols to be retained from the target dynamic library. For example, when there is only one intersection, such as when there is only one other dynamic library, all symbols in this intersection are used as the symbols to be retained from the target dynamic library; when there are multiple intersections, such as when there are multiple other dynamic libraries, the union of these multiple intersections is taken, and all symbols in this union are used as the symbols to be retained from the target dynamic library, and so on.
[0073] Considering that if a defined symbol in the target dynamic library is referenced by other symbols in the target dynamic library besides itself, it is only necessary to consider whether these other symbols need to be set as reserved symbols in the target dynamic library, without having to consider whether the defined symbol needs to be set as reserved symbols in the target dynamic library again. Therefore, symbols in this intersection that are not referenced by any symbol in the target dynamic library besides itself can also be obtained as reserved symbols in the target dynamic library, thereby improving the practicality of the determined reserved symbols. For example, for each symbol in the intersection, it can be determined whether this symbol is referenced by one or more other symbols besides itself in each component file to be linked in the target dynamic library. If this symbol is not applied by any other symbols besides itself in any component file to be linked in the target dynamic library, then this symbol can be determined as a reserved symbol in the target dynamic library; and / or, if this symbol is referenced by one or more other symbols besides itself in at least some component files to be linked in the target dynamic library, then this symbol does not need to be determined as a reserved symbol in the target dynamic library.
[0074] It is understood that this embodiment can also determine the symbols to be retained in the target dynamic library based on the defined symbol set of the target dynamic library and the undefined symbol sets of other dynamic libraries besides the target dynamic library in other ways. For example, for each symbol in the defined symbol set of the target dynamic library, the symbol can be searched in the undefined symbol sets of other dynamic libraries. If the symbol is found in the undefined symbol sets of at least one other dynamic library and is not referenced by any other symbol in the target dynamic library, then the symbol is determined as a symbol to be retained in the target dynamic library. Alternatively, for each symbol in the undefined symbol sets of other dynamic libraries, the symbol can be searched in the defined symbol set of the target dynamic library. If the symbol is found in the defined symbol set of the target dynamic library and is not referenced by any other symbol in the target dynamic library, then the symbol is determined as a symbol to be retained in the target dynamic library, and so on.
[0075] In this embodiment, after determining the target dynamic library to which the target component file is to be linked, the defined symbol set and / or undefined symbol set of the target dynamic library can be updated based on the target component file to retain newly defined symbols in the target component file, avoiding the situation where newly defined symbols are accidentally deleted, and / or, when rebuilding other dynamic libraries, retain newly referenced symbols in the target component file that are defined by other dynamic libraries.
[0076] Optionally, before determining the intersection between the defined symbol set of the target dynamic library and the undefined symbol set of the other dynamic libraries, the method further includes: performing symbol analysis on the target component file to determine the defined and undefined symbols in the target component file; updating the defined symbol set of the target dynamic library based on the defined symbols in the target component file, and updating the undefined symbol set of the target dynamic library based on the undefined symbols in the target component file.
[0077] In this context, defined symbols in a component file (such as a target component file) can be understood as symbols that are defined within that component file, meaning that the component file contains their definition information. Undefined symbols in a component file (such as a target component file) can be understood as symbols contained within that component file but not defined within it. Thus, undefined symbols in a component file can be included in the component file itself, but their definition information is not included in the component file.
[0078] For example, symbol analysis can be performed on the target component file to determine the defined and undefined symbols of the target component file. For instance, symbol analysis instructions (such as the nm instruction) can be used to perform symbol analysis on the target component file to obtain a list of defined and undefined symbols of the target component file.
[0079] After determining the definition symbols of the target component file, it can be determined whether the definition symbols in the target component file are the same as those in the original component file before the incremental build. If they are the same, the definition symbol set of the target dynamic library can be kept unchanged; otherwise, the definition symbol set of the target dynamic library can be updated based on the definition symbols in the target component file. For example, adding definition symbols in the target component file that are not included in the definition symbol set of the target dynamic library to the definition symbol set of the target dynamic library, and / or deleting symbols in the definition symbol set of the target dynamic library that are defined in the original component file but not in the target component file.
[0080] After identifying the undefined symbols in the target component file, it can be determined whether these undefined symbols are the same as those in the original component file before the incremental build. If they are the same, the set of undefined symbols in the target dynamic library remains unchanged; otherwise, the set of undefined symbols in the target dynamic library can be updated based on the undefined symbols in the target component file. The method for updating the set of undefined symbols in the target dynamic library is similar to the method for updating its defined symbol set, and will not be elaborated further here.
[0081] In some implementations, after determining the symbols to be retained in the target dynamic library, the lifecycle of these symbols can be set to a preset lifecycle, such as setting the lifecycle attribute value of the symbols to "alive," to ensure that even if the symbols to be retained are not referenced by any other symbol in the target dynamic library, they will not be deleted from the target dynamic library during dead code stripping. Optionally, after determining at least a portion of the symbols in the intersection as the symbols to be retained in the target dynamic library, the method further includes: adjusting the lifecycle of the symbols to be retained to a preset lifecycle, wherein the symbols to be retained with the preset lifecycle support retention during dead code stripping of the target dynamic library.
[0082] In some implementations, after determining the symbols to be retained in the target dynamic library, the visibility of these symbols can be set to be visible to all dynamic libraries called by the executable file. For example, after determining the symbols to be retained in the target dynamic library, the visibility of these symbols can be changed from being visible only to the target dynamic library to being visible to all dynamic libraries called by the application. For instance, by default, the visibility of the definition symbols of the target dynamic library can be visible only to the target dynamic library. After determining the symbols to be retained in the target dynamic library, the attribute value of its visibility attribute can be adjusted from private to public to ensure that other dynamic libraries can reference the definition symbols in the target dynamic library. Optionally, after determining at least some of the symbols in the intersection as the symbols to be retained in the target dynamic library, the method further includes: adjusting the visibility of the symbols to be retained to be visible to the at least two dynamic libraries.
[0083] In some embodiments, component files whose modifications meet preset conditions can be linked to a first dynamic library, while component files whose modifications do not meet preset conditions can be linked to a second dynamic library. When the dynamic library update conditions are met, updating the first and / or second dynamic libraries can also be supported to avoid affecting the rebuilding speed of the first dynamic library due to an excessive number of component files linked to it, thereby further improving the incremental build speed of the application. Optionally, the incremental build method may further include: updating at least some of the dynamic libraries called by the executable file based on the modifications of each component file of the application. Taking the existence of a first dynamic library and a second dynamic library as an example, when the dynamic library update conditions are met, such as when the component files that meet the preset conditions change, the component files of the application that meet the preset conditions can be re-acquired and linked to form the first dynamic library; and / or, the component files of the application that do not meet the preset conditions can be re-acquired and linked to form the second dynamic library.
[0084] In some implementations, updating the first dynamic library and the second dynamic library according to a set update cycle can be supported. Optionally, updating at least some of the dynamic libraries called by the executable file based on changes to the component files of the application includes: in response to reaching the update cycle of the dynamic library, obtaining at least one modified component file of the application, wherein the number of modifications to the modified component file within the most recent preset time period meets a preset number condition; reconstructing the first dynamic library based on the at least one modified component file, and reconstructing the second dynamic library based on the other component files of the application besides the at least one modified component file.
[0085] The update cycle of the dynamic library can be understood as the cycle in which the dynamic library is updated. The length of this update cycle is unlimited; for example, it can be set to 1 day or 2 days. Preset conditions can be associated with the number of modifications to component files, and can be set as needed. For example, the preset condition can be set to the number of modifications within the most recent preset time period being greater than or equal to a preset number, and / or, to be among the top N in the sorted order based on the number of modifications within the most recent preset time period. N is a positive integer, and its specific value is unlimited; for example, N can be set to 5 or 10. The preset time period can be set as needed; for example, it can be set to 2 weeks or 1 month. Modifying component files can be understood as component files whose number of modifications within the most recent preset time period meets the preset conditions.
[0086] Specifically, when the dynamic library update cycle is reached, modified component files of the above application that have been modified within the most recent preset time period and meet the preset conditions can be obtained, and the first dynamic library can be reconstructed based on the obtained modified component files; and non-modified component files of the above application that have not been modified within the most recent preset time period can be obtained, and the second dynamic library can be reconstructed based on the obtained non-modified component files.
[0087] Taking a preset condition, including a first preset condition (which could be ranked among the top N in a recent preset time period based on the number of modifications), the process of updating the first and second dynamic libraries based on the preset conditions can be described as follows: When the dynamic library update cycle is reached, the number of modifications to each component file of the application within the recent preset time period can be determined. The top N component files with the most modifications within the recent preset time period are obtained in descending order of the number of modifications and are used as the modified component files for this update cycle. It is determined whether the component corresponding to each modified component file is the same as the component corresponding to each component file currently linked to by the first dynamic library. For example, it is determined whether the first dynamic library currently links to and only links to each modified component file. If so, the first and second dynamic libraries do not need to be updated; otherwise, the first dynamic library can be rebuilt based on the obtained modified component files, and the second dynamic library can be rebuilt based on all non-modified component files other than the obtained modified component files, so that component files frequently modified by developers can be linked to the first dynamic library.
[0088] In some implementations, it is possible to support linking the modified target component files obtained during the incremental build to a first dynamic library after the incremental build of the application is completed, so that developers can modify the target component files again and perform another incremental build. Optionally, updating at least some of the dynamic libraries called by the executable file based on the changes to the application's component files includes: in response to the application completing the incremental build, if the target dynamic library is the second dynamic library, switching the dynamic library currently linked to the target component file from the second dynamic library to the first dynamic library.
[0089] The preset conditions may include a second preset condition, which may be associated with the time of incremental build of the modified component file, such as the component file corresponding to the latest completed incremental build instruction.
[0090] Specifically, after completing the incremental build in response to the incremental build instruction for the application, such as after transmitting the content to be transmitted to the second electronic device and / or after rebuilding the executable program of the aforementioned application based on the rebuilt target dynamic library, it is determined whether the rebuilt target dynamic library is the first dynamic library. If the rebuilt target dynamic library is the first dynamic library, it means that the target component file is currently linked to the first dynamic library, and in this case, it is not necessary to switch the dynamic library currently linked to the target component file; if the rebuilt target dynamic library is not the first dynamic library, such as the rebuilt target dynamic library is the second dynamic library... If the target component file is not currently linked to the first dynamic library, it means that the target component file is not yet linked to the first dynamic library. In this case, the dynamic library currently linked to the target component file can be switched from the second dynamic library to the first dynamic library. For example, the component files currently linked to the first dynamic library and the component files currently linked to the second dynamic library can be obtained. The first dynamic library can be rebuilt based on the component files currently linked to the first dynamic library and the target component file. The second dynamic library can also be rebuilt based on the component files currently linked to the second dynamic library, excluding the target component file. This will allow the latest modified component files by the developers to be linked to the first dynamic library.
[0091] Figure 3This is a flowchart illustrating another incremental build method provided by an embodiment of this disclosure. The scheme in this embodiment can be combined with one or more optional schemes in the above embodiments. Optionally, the step of reconstructing the target dynamic library based on the target component file and the symbols to be retained in the target dynamic library includes: determining at least one component file of the original link of the target dynamic library; replacing the original component file in the at least one component with the target component file, wherein the original component file and the target component file correspond to the same components of the application; reconstructing the target dynamic library based on the replaced at least one component file, and retaining the symbols to be retained in the target dynamic library.
[0092] Correspondingly, such as Figure 3 As shown, the incremental construction method provided in this embodiment may include:
[0093] S201. In response to an incremental build instruction for an application, obtain a target component file corresponding to the incremental build instruction, wherein the target component file is a modified component file, and the executable file of the application calls at least two dynamic libraries, and different dynamic libraries are used to link different component files of the application.
[0094] S202. Determine the target dynamic library to which the target component file is to be linked from the at least two dynamic libraries.
[0095] S203. Determine at least one component file of the original link of the target dynamic library.
[0096] For example, after determining the target dynamic library to which the target component file is to be linked, the component files linked in the constructed target dynamic library can be determined, such as by determining the component files linked in the target dynamic library based on the component identifiers of the component files in the target dynamic library, as at least one component file originally linked to the target dynamic library.
[0097] S204. Replace the original component file in the at least one component with the target component file, wherein the original component file and the target component file correspond to the same component of the application.
[0098] The original component file can be a component file that is already linked to the target dynamic library and corresponds to the same component file as the target component file. For example, assuming the target component file is the component file of component A, the original component file corresponding to the target component file can be the component file of component A linked in the already built target dynamic library, which can be the component file of component A before it was modified. For example, a developer can edit the source file of a component to obtain the edited source file. The original component file can be the binary file obtained by compiling the original source file, and the target component file can be the binary file obtained by compiling the edited source file.
[0099] In this embodiment, after determining at least one component file of the original link of the target dynamic library, the original component file of the at least one component file that corresponds to the target component file can be determined based on the component identifier corresponding to the target component file, and the original component file in the at least one component file can be replaced by the target component file.
[0100] S205. Reconstruct the target dynamic library based on the replaced at least one component file, and retain the symbols to be retained in the target dynamic library, wherein the symbols to be retained are defined by the target dynamic library and referenced by at least one other dynamic library, and the other dynamic libraries are dynamic libraries other than the target dynamic library among the at least two dynamic libraries.
[0101] Specifically, after replacing the original component file in at least one of the original component files of the target dynamic library with the target component file, the target dynamic library can be rebuilt based on the replaced at least one component file (including the target component file). For example, the target dynamic library can be relinked based on the replaced at least one component file, and the symbols to be retained in the target dynamic library can be retained in the rebuilt target dynamic library.
[0102] In this embodiment, the method for retaining the symbols to be retained in the target dynamic library during reconstruction is not limited. For example, the construction process of the target dynamic library may include a definition information lookup sub-process, and during this sub-process, the symbols to be retained in the target dynamic library may be added as searchable symbols to the searchable symbol array of the target dynamic library, thereby retaining the symbols to be retained in the target dynamic library.
[0103] Optionally, retaining the symbol to be retained in the target dynamic library includes: adding the symbol to be retained as a searchable symbol in the target dynamic library during the construction of the target dynamic library; searching for the definition information of the searchable symbol in the replaced at least one component file for each searchable symbol in the searchable symbol array; and retaining the searchable symbol and its definition information in the target dynamic library in response to finding the definition information of the searchable symbol.
[0104] The target dynamic library's search symbols can be symbols whose definition information needs to be found when constructing the target dynamic library. The search symbol array can be an array consisting of one or more search symbols. The search symbol array can contain one or more search symbols, and may include, but is not limited to, searchable symbols, such as symbols that are at least partially included in the search symbol array and are not the same as the added searchable symbols.
[0105] Specifically, during the construction of the target dynamic library, when definition information needs to be searched, an array of symbols to be searched can be constructed. After the construction is completed, the symbols to be retained in the target dynamic library are added to this array of symbols to be searched. For each symbol to be searched in the array of symbols to be searched, the definition information of the symbol to be searched is searched in at least one component file after replacement. If the definition information of the symbol to be searched is found, the symbol to be searched and its definition information are written into the target dynamic library.
[0106] In some examples, where the array of symbols to be searched is the array of undefined symbols to be searched, and the symbols to be searched are the undefined symbols whose definition information is to be found, the definition information search process during the construction of the target dynamic library can be described as follows:
[0107] Perform initialization symbol lookup. For example, obtain each initialization symbol in at least one component file after replacement based on the initialization symbol identifier. For each initialization symbol, find the definition information of the initialization symbol in at least one component file after replacement and write it into the target dynamic library. Also, add the symbols referenced by this initialization symbol as undefined symbols whose definition information needs to be found in the next round to the array of undefined symbols to be searched in the next round.
[0108] After all the initialization symbols have been traversed, the undefined symbols to be searched in the next round will contain the undefined symbols referenced by each initialization symbol. At this point, the symbols to be retained from the target dynamic library can be added to this undefined symbol array as undefined symbols, and the undefined symbol array after adding the symbols to be retained will be used as the current undefined symbol array.
[0109] For each undefined symbol in the current undefined symbol array, search for its definition information in at least one of the replaced component files. If its definition information is found, write the undefined symbol and its definition information into the target dynamic library, and add the symbols referenced by this undefined symbol to the next round of the undefined symbol array as symbols whose definition information needs to be searched. Alternatively, if its definition information is not found, the undefined symbol can be written into the target dynamic library, and the symbols referenced by this undefined symbol can be added to the next round of the undefined symbol array as symbols whose definition information needs to be searched.
[0110] After traversing all undefined symbols in the current undefined symbol array, the next undefined symbol array to be searched will contain the symbols referenced by each undefined symbol in the current undefined symbol array. At this point, this next undefined symbol array to be searched can be used as the current undefined symbol array, and the operation of searching for the definition information of each undefined symbol in the current undefined symbol array in at least one of the replaced component files will be executed again until the current undefined symbol array is empty. When the current undefined symbol array is empty, it can be determined that the definition information search subprocess in the target dynamic library construction process has been completed.
[0111] In the above implementation, when the definition information lookup subprocess in the target dynamic library construction process is completed, only the symbols whose definition information has been looked up are written into the target dynamic library, thereby enabling the symbols to be retained in the target dynamic library to be written into the target dynamic library.
[0112] Furthermore, after the definition information lookup sub-process in the target dynamic library construction process is completed, dead code stripping can be performed on the target dynamic library. During this dead code stripping sub-process, for each symbol already written to the target dynamic library (excluding initialization symbols), it is determined whether this symbol is referenced by one or more other symbols already written to the target dynamic library. If so, this symbol is retained in the target dynamic library. If not, it can be further determined whether the symbol's lifecycle is a preset lifecycle. If the symbol's lifecycle is a preset lifecycle, it is retained in the target dynamic library, thus allowing symbols with preset lifecycles to be retained in the target dynamic library. Conversely, if the symbol's lifecycle is not a preset lifecycle, it can be deleted from the target dynamic library.
[0113] The incremental build method provided in this embodiment replaces the original component file linked in the target dynamic library with the target component file during incremental build, and rebuilds the target dynamic library. This enables incremental build of the application by rebuilding the dynamic library, improving the speed of incremental build of the application and ensuring the integrity of the symbols retained in the rebuilt target dynamic library.
[0114] In an alternative embodiment, taking a common organizational form of a project as an example, the project may consist of application (App) source code (Sources) and components (Pods).
[0115] Figure 4 This is a diagram illustrating the link between the APP source code and components in related technologies. Figure 5 This is a schematic diagram illustrating the linking of APP source code and components according to an embodiment of this disclosure. Figure 4 As shown, in related technologies, these components are linked into the final executable file. In this embodiment, it is supported to convert certain components into dynamic libraries. In this case, these components are independently linked into a first dynamic library, and the remaining components are linked into a second dynamic library, such as... Figure 5 As shown in the diagram (using the example of linking component 1-2 to the first dynamic library and component 3-M to the second dynamic library), if the components linked in the first dynamic library are subsequently modified, only the first dynamic library needs to be relinked. Compared to the linking methods in related technologies, this can greatly reduce the linking time and the size of the modified output.
[0116] During the process of linking components as a dynamic library, since the components in the first dynamic library no longer participate in the linking of the second dynamic library, the second dynamic library may lack one or more symbols defined in the first dynamic library; correspondingly, since the components in the second dynamic library no longer participate in the linking of the first dynamic library, the first dynamic library may also lack one or more symbols defined in the second dynamic library.
[0117] Furthermore, taking the second dynamic library as an example, in order to reduce the package size, the linker will try to introduce as few symbols as possible. Therefore, when the second dynamic library is missing one or more symbols defined in the first dynamic library, that is, when one or more symbols defined in the first dynamic library disappear, some symbols that were originally introduced in the second dynamic library because of the dependency of this symbol will no longer be introduced. Therefore, in actual scenarios, there may be more missing symbols than the one or more symbols defined in the first dynamic library. This is determined by the working characteristics of the linker.
[0118] Therefore, to address the problem of missing symbols, this embodiment also provides a procedure for retaining missing symbols, such as... Figure 6 As shown in the diagram (using the example of linking components 1-2 to the first dynamic library and component 3-M to the second dynamic library), this process can be described as follows:
[0119] For each component, its source files are compiled to obtain its binary file (i.e., the component file). The `nm` command is then used to perform symbol analysis on the component's source files, yielding a list of defined and undefined symbols. After obtaining these lists, symbol calculations are performed to determine the symbols to be retained in the first dynamic library and the second dynamic library. The first dynamic library is constructed based on the binary files of the components to be linked in the first dynamic library (e.g., components 1-2) and the symbols to be retained. Similarly, the second dynamic library is constructed based on the binary files of the components to be linked in the second dynamic library (e.g., components 3-M) and the symbols to be retained.
[0120] Taking the example of retaining one or more symbols defined in the first dynamic library in the second dynamic library, for instance, when compiling component 1 and component 2, the system can record which symbols component 1 and component 2 possess (i.e., determine their undefined symbol list) and which symbols are missing (i.e., determine their defined symbol list), and based on this, determine the missing symbols of the first dynamic library as the symbols to be retained in the second dynamic library. When linking the second dynamic library, the symbols to be retained in the second dynamic library can be input into the linker to instruct the linker to retain these symbols and expose them to the first dynamic library. Thus, by modifying the linker's linking process, the linker can support the retention of arbitrary symbols.
[0121] Furthermore, considering that linking too many components to the first dynamic library would reduce its rebuilding efficiency, this embodiment also provides a component selection strategy that supports different developers having different dynamic libraries. In this case, the first dynamic library can link components selected from both the cloud and local libraries. Specifically, for cloud-based selection, when the dynamic library's update cycle is reached, analysis can be performed based on the current developer's recent (i.e., the most recent preset time period) build records to identify the top N (e.g., the top 5) most frequently modified components, and their binary files are automatically linked to the first dynamic library. Additionally, the binary files of all other components besides the top N are automatically linked to the second dynamic library. For local selection, after incrementally building the application in response to the current user's incremental build command, analysis can be performed based on the user's local code changes to identify modified components (e.g., the component corresponding to the target component file), and the binary files of these modified components (e.g., the target component file) are automatically linked to the first dynamic library. Therefore, the components ultimately linked to the first dynamic library are a combination of local and cloud-based analysis results.
[0122] In this embodiment, incremental building is implemented based on dynamic libraries. Dynamic libraries can be linked independently and loaded into the executable program at startup. Since they do not participate in the executable program's linking process, the independent linking speed of dynamic libraries is extremely fast. This reduces the time consumed in the linking and transmission phases during incremental building from linearly increasing with project complexity to constant-level time consumption. Therefore, converting components into dynamic libraries for independent linking improves linking speed and application installation speed; furthermore, it supports retaining arbitrary symbols in dynamic libraries, thus enabling the conversion of any component into a dynamic library.
[0123] Figure 7 This is a structural block diagram of an incremental build apparatus provided in an embodiment of this disclosure. The apparatus can be implemented in software and / or hardware, and can be configured in an electronic device, typically a computer, to perform incremental builds based on a dynamic library and the symbols to be retained in the dynamic library by executing an incremental build method. Figure 7 As shown, the incremental build apparatus provided in this embodiment may include: a file acquisition module 701, a dynamic library determination module 702, and a dynamic library build module 703, wherein,
[0124] The file acquisition module 701 is used to acquire the target component file corresponding to the incremental build instruction in response to the incremental build instruction for the application, wherein the target component file is a modified component file, and the executable file of the application calls at least two dynamic libraries, and different dynamic libraries are used to link different component files of the application.
[0125] The dynamic library determination module 702 is used to determine the target dynamic library to which the target component file is to be linked from the at least two dynamic libraries;
[0126] The dynamic library construction module 703 is used to reconstruct the target dynamic library based on the target component file and the symbols to be retained of the target dynamic library, wherein the symbols to be retained are defined by the target dynamic library and referenced by at least one other dynamic library, and the other dynamic library is a dynamic library other than the target dynamic library among the at least two dynamic libraries.
[0127] The incremental build apparatus provided in this embodiment, in response to an incremental build instruction for an application, obtains the target component file corresponding to this instruction via a file acquisition module. The target component file is a modified component file of the application. The executable file of this application calls at least two dynamic libraries, which are used to link different component files of the application. A dynamic library determination module determines the target dynamic library to which the target component file should be linked from these at least two dynamic libraries. A dynamic library construction module reconstructs the target dynamic library based on the target component file and the symbols to be retained in the target dynamic library. The symbols to be retained in the target dynamic library are symbols defined by the target dynamic library and referenced by other dynamic libraries besides the target dynamic library among the at least two dynamic libraries. This embodiment utilizes the above technical solution to set up multiple dynamic libraries for the application. Incremental build of the application is achieved by reconstructing the dynamic libraries corresponding to the modified component files, without needing to relink component files linked by other dynamic libraries. This enriches the incremental build methods of the application, improves the incremental build speed, and reduces the time spent on incremental builds.
[0128] Optionally, the dynamic library construction module 703 includes: a file determination unit, configured to determine at least one component file of the original link of the target dynamic library; a file replacement unit, configured to replace the original component file in the at least one component with the target component file, wherein the original component file and the target component file correspond to the same component of the application; and a dynamic library construction unit, configured to reconstruct the target dynamic library based on the replaced at least one component file, and retain the symbol to be retained in the target dynamic library.
[0129] Optionally, the dynamic library construction unit may be specifically used to: during the construction of the target dynamic library, add the symbol to be retained as the symbol to be searched in the target dynamic library to the symbol to be searched array of the target dynamic library; for each symbol to be searched in the symbol to be searched array, search for the definition information of the symbol to be searched in the replaced at least one component file; in response to the finding of the definition information of the symbol to be searched, retain the symbol to be searched and the definition information of the symbol to be searched in the target dynamic library.
[0130] Furthermore, the incremental construction apparatus may further include: a symbol determination module, configured to determine the intersection between the defined symbol set of the target dynamic library and the undefined symbol set of the other dynamic libraries before reconstructing the target dynamic library based on the target component file and the symbols to be retained in the target dynamic library, and to use at least a portion of the symbols in the intersection as the symbols to be retained in the target dynamic library, wherein the defined symbol set of the target dynamic library contains at least one symbol defined in the target dynamic library, and the undefined symbol set of the other dynamic libraries contains at least one symbol referenced by the other dynamic libraries and not defined in the other dynamic libraries.
[0131] Furthermore, the incremental construction device may further include: a symbol analysis module, configured to perform symbol analysis on the target component file to determine the defined symbols and undefined symbols in the target component file before determining the intersection between the defined symbol set of the target dynamic library and the undefined symbol set of the other dynamic libraries; and a set update module, configured to update the defined symbol set of the target dynamic library according to the defined symbols in the target component file, and update the undefined symbol set of the target dynamic library according to the undefined symbols in the target component file.
[0132] Furthermore, the incremental build apparatus may further include at least one of the following: a visibility adjustment module, configured to adjust the visibility of the symbols to be retained to be visible to the at least two dynamic libraries after at least a portion of the symbols in the intersection are designated as symbols to be retained in the target dynamic library; and a lifecycle adjustment module, configured to adjust the lifecycle of the symbols to be retained to a preset lifecycle after at least a portion of the symbols in the intersection are designated as symbols to be retained in the target dynamic library, wherein the symbols to be retained with the preset lifecycle support retention during dead code stripping of the target dynamic library.
[0133] Optionally, the method is executed by a first electronic device, and the incremental construction apparatus may further include: a file package generation module, configured to regenerate the target program file package of the application based on the reconstructed target dynamic library after the target dynamic library is reconstructed based on the target component file and the symbols to be retained of the target dynamic library; a file package comparison module, configured to compare the target program file package with the original program file package in the second electronic device, and obtain the content to be transmitted that has changed in the target program file package, the content to be transmitted including the target dynamic library; and a transmission module, configured to transmit the content to be transmitted to the second electronic device, wherein the second electronic device is configured to update the original program file package to the target program file package based on the content to be transmitted, and reconstruct the application based on the target program file package.
[0134] Optionally, the at least two dynamic libraries include a first dynamic library and a second dynamic library, wherein the first dynamic library is used to link component files whose modifications meet preset conditions, and the second dynamic library is used to link component files whose modifications do not meet preset conditions.
[0135] Furthermore, the incremental build apparatus may further include: a dynamic library update module, used to update at least some of the dynamic libraries called by the executable file based on the changes to the component files of the application.
[0136] Optionally, the dynamic library update module may be specifically used to: in response to reaching the update cycle of the dynamic library, obtain at least one modified component file of the application, wherein the number of modifications of the modified component file within the most recent preset time period meets a preset condition; reconstruct the first dynamic library based on the at least one modified component file, and reconstruct the second dynamic library based on other component files of the application other than the at least one modified component file.
[0137] Optionally, the dynamic library update module may be specifically used to: in response to the application completing an incremental build, if the target dynamic library is the second dynamic library, switch the dynamic library currently linked to the target component file from the second dynamic library to the first dynamic library.
[0138] Optionally, the modification refers to changes made by the current developer to the component files of the application, and the at least two dynamic libraries correspond to the current developer.
[0139] The incremental construction apparatus provided in this disclosure can execute the incremental construction method provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects for executing the incremental construction method. Technical details not described in detail in this embodiment can be found in the incremental construction method provided in any embodiment of this disclosure.
[0140] The following is for reference. Figure 8 This illustration shows a structural diagram of an electronic device (e.g., a computer) 800 suitable for implementing embodiments of the present disclosure. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 8 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0141] like Figure 8As shown, the electronic device 800 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 808 into a random access memory (RAM) 803. The RAM 803 also stores various programs and data required for the operation of the electronic device 800. The processing device 801, ROM 802, and RAM 803 are interconnected via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0142] Typically, the following devices can be connected to I / O interface 805: input devices 806 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 807 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 808 including, for example, magnetic tapes, hard disks, etc.; and communication devices 809. Communication device 809 allows electronic device 800 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 8 An electronic device 800 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0143] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 809, or installed from a storage device 808, or installed from a ROM 802. When the computer program is executed by a processing device 801, it performs the functions defined in the methods of embodiments of this disclosure.
[0144] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0145] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0146] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0147] The aforementioned computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device causes the following: in response to an incremental build instruction for an application, to obtain a target component file corresponding to the incremental build instruction, wherein the target component file is a modified component file, and the executable file of the application calls at least two dynamic libraries, different dynamic libraries being used to link different component files of the application; to determine, from the at least two dynamic libraries, a target dynamic library to which the target component file is to be linked; and to reconstruct the target dynamic library based on the target component file and the symbols to be retained in the target dynamic library, wherein the symbols to be retained are defined by the target dynamic library and referenced by at least one other dynamic library, the other dynamic library being a dynamic library other than the target dynamic library among the at least two dynamic libraries.
[0148] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including but not limited to object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0149] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0150] The units described in the embodiments of this disclosure can be implemented in software or hardware. The names of modules do not necessarily limit the specific unit itself.
[0151] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0152] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0153] According to one or more embodiments of this disclosure, Example 1 provides an incremental build method, including:
[0154] In response to an incremental build instruction for an application, a target component file corresponding to the incremental build instruction is obtained, wherein the target component file is a modified component file, and the executable file of the application calls at least two dynamic libraries, and different dynamic libraries are used to link different component files of the application;
[0155] Determine the target dynamic library to which the target component file should be linked from the at least two dynamic libraries;
[0156] The target dynamic library is reconstructed based on the target component file and the symbols to be retained in the target dynamic library, wherein the symbols to be retained are defined by the target dynamic library and referenced by at least one other dynamic library, which is a dynamic library other than the target dynamic library among the at least two dynamic libraries.
[0157] According to one or more embodiments of this disclosure, Example 2, based on the method described in Example 1, the step of reconstructing the target dynamic library based on the target component file and the symbols to be retained in the target dynamic library includes:
[0158] Identify at least one component file in the original link of the target dynamic library;
[0159] The original component file in at least one component is replaced with the target component file, wherein the original component file and the target component file correspond to the same component in the application;
[0160] The target dynamic library is reconstructed based on the replaced at least one component file, and the symbols to be retained are preserved in the target dynamic library.
[0161] According to one or more embodiments of this disclosure, Example 3 describes the method described in Example 2, wherein reserving the symbol to be retained in the target dynamic library includes:
[0162] During the construction of the target dynamic library, the symbols to be retained are added to the target dynamic library's array of symbols to be searched.
[0163] For each symbol to be searched in the array of symbols to be searched, the definition information of the symbol to be searched is searched in the replaced at least one component file;
[0164] In response to the finding of the definition information of the symbol to be searched, the symbol to be searched and its definition information are stored in the target dynamic library.
[0165] According to one or more embodiments of this disclosure, Example 4, based on the method of Example 1, further includes, before reconstructing the target dynamic library based on the target component file and the symbols to be retained of the target dynamic library:
[0166] Determine the intersection between the defined symbol set of the target dynamic library and the undefined symbol set of the other dynamic libraries, and select at least a portion of the symbols in the intersection as the symbols to be retained in the target dynamic library. The defined symbol set of the target dynamic library contains at least one symbol defined in the target dynamic library, and the undefined symbol set of the other dynamic libraries contains at least one symbol referenced by the other dynamic libraries but not defined in the other dynamic libraries.
[0167] According to one or more embodiments of this disclosure, Example 5, based on the method of Example 4, further includes, before determining the intersection between the defined symbol set of the target dynamic library and the undefined symbol set of the other dynamic libraries:
[0168] Perform symbol analysis on the target component file to determine the defined and undefined symbols in the target component file;
[0169] The set of defined symbols in the target dynamic library is updated according to the defined symbols in the target component file, and the set of undefined symbols in the target dynamic library is updated according to the undefined symbols in the target component file.
[0170] According to one or more embodiments of this disclosure, Example 6, based on the method of Example 4, further includes at least one of the following after setting at least a portion of the symbols in the intersection as symbols to be retained in the target dynamic library:
[0171] Adjust the visibility of the symbols to be retained to be visible to the at least two dynamic libraries;
[0172] The lifecycle of the symbol to be retained is adjusted to a preset lifecycle, wherein the symbol to be retained with the preset lifecycle supports retention when the target dynamic library is stripped of dead code.
[0173] According to one or more embodiments of this disclosure, Example 7 describes the method according to any one of Examples 1-6, wherein the at least two dynamic libraries include a first dynamic library and a second dynamic library, the first dynamic library being used to link component files whose modifications meet preset conditions, and the second dynamic library being used to link component files whose modifications do not meet preset conditions.
[0174] According to one or more embodiments of this disclosure, Example 8, based on the method described in Example 7, further includes:
[0175] Based on the changes to the component files of the application, update at least some of the dynamic libraries called by the executable file.
[0176] According to one or more embodiments of this disclosure, Example 9 describes the method described in Example 8, wherein updating at least a portion of the dynamic libraries called by the executable file based on changes to the component files of the application includes at least one of the following:
[0177] In response to reaching the update cycle of the dynamic library, at least one modified component file of the application is obtained; the first dynamic library is reconstructed based on the at least one modified component file, and the second dynamic library is reconstructed based on other component files of the application besides the at least one modified component file, wherein the number of modifications to the modified component file within the most recent preset time period meets a preset condition;
[0178] In response to the application completing an incremental build, if the target dynamic library is the second dynamic library, the dynamic library currently linked to the target component file is switched from the second dynamic library to the first dynamic library.
[0179] According to one or more embodiments of this disclosure, Example 10 provides an incremental build apparatus, comprising:
[0180] The file acquisition module is used to acquire the target component file corresponding to the incremental build instruction in response to the incremental build instruction for the application. The target component file is a modified component file. The executable file of the application calls at least two dynamic libraries, and different dynamic libraries are used to link different component files of the application.
[0181] A dynamic library determination module is used to determine the target dynamic library to which the target component file is to be linked from the at least two dynamic libraries;
[0182] A dynamic library construction module is used to reconstruct the target dynamic library based on the target component file and the symbols to be retained of the target dynamic library, wherein the symbols to be retained are defined by the target dynamic library and referenced by at least one other dynamic library, and the other dynamic library is a dynamic library other than the target dynamic library among the at least two dynamic libraries.
[0183] According to one or more embodiments of this disclosure, Example 12 provides an electronic device, including:
[0184] One or more processors;
[0185] Memory, used to store one or more programs.
[0186] When the one or more programs are executed by the one or more processors, the one or more processors implement the incremental build method as described in any of Examples 1-9.
[0187] According to one or more embodiments of the present disclosure, Example 13 provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the incremental construction method as described in any of Examples 1-9.
[0188] According to one or more embodiments of this disclosure, Example 14 provides a computer program product that, when executed by a computer, causes the computer to implement the incremental build method as described in any of Examples 1-9.
[0189] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0190] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0191] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
Claims
1. An incremental construction method, characterized in that, include: In response to an incremental build instruction for an application, a target component file corresponding to the incremental build instruction is obtained, wherein the target component file is a modified component file, and the executable file of the application calls at least two dynamic libraries, and different dynamic libraries are used to link different component files of the application; Determine the target dynamic library to which the target component file should be linked from the at least two dynamic libraries; The target dynamic library is reconstructed based on the target component file and the symbols to be retained in the target dynamic library, wherein the symbols to be retained are defined by the target dynamic library and referenced by at least one other dynamic library, which is a dynamic library other than the target dynamic library among the at least two dynamic libraries.
2. The method according to claim 1, characterized in that, The process of reconstructing the target dynamic library based on the target component file and the symbols to be retained in the target dynamic library includes: Identify at least one component file in the original link of the target dynamic library; The original component file in at least one component is replaced with the target component file, wherein the original component file and the target component file correspond to the same component in the application; The target dynamic library is reconstructed based on the replaced at least one component file, and the symbols to be retained are preserved in the target dynamic library.
3. The method according to claim 2, characterized in that, The step of reserving the symbol to be retained in the target dynamic library includes: During the construction of the target dynamic library, the symbols to be retained are added to the target dynamic library's array of symbols to be searched. For each symbol to be searched in the array of symbols to be searched, the definition information of the symbol to be searched is searched in the replaced at least one component file; In response to the finding of the definition information of the symbol to be searched, the symbol to be searched and its definition information are stored in the target dynamic library.
4. The method according to claim 1, characterized in that, Before reconstructing the target dynamic library based on the target component file and the symbols to be retained in the target dynamic library, the method further includes: Determine the intersection between the defined symbol set of the target dynamic library and the undefined symbol set of the other dynamic libraries, and select at least a portion of the symbols in the intersection as the symbols to be retained in the target dynamic library. The defined symbol set of the target dynamic library contains at least one symbol defined in the target dynamic library, and the undefined symbol set of the other dynamic libraries contains at least one symbol referenced by the other dynamic libraries but not defined in the other dynamic libraries.
5. The method according to claim 4, characterized in that, Before determining the intersection between the defined symbol set of the target dynamic library and the undefined symbol set of the other dynamic libraries, the method further includes: Perform symbol analysis on the target component file to determine the defined and undefined symbols in the target component file; The set of defined symbols in the target dynamic library is updated according to the defined symbols in the target component file, and the set of undefined symbols in the target dynamic library is updated according to the undefined symbols in the target component file.
6. The method according to claim 4, characterized in that, After selecting at least a portion of the symbols in the intersection as the symbols to be retained in the target dynamic library, the method further includes at least one of the following: Adjust the visibility of the symbols to be retained to be visible to the at least two dynamic libraries; The lifecycle of the symbol to be retained is adjusted to a preset lifecycle, wherein the symbol to be retained with the preset lifecycle supports retention when the target dynamic library is stripped of dead code.
7. The method according to any one of claims 1-6, characterized in that, The at least two dynamic libraries include a first dynamic library and a second dynamic library. The first dynamic library is used to link component files whose modifications meet preset conditions, and the second dynamic library is used to link component files whose modifications do not meet preset conditions.
8. The method according to claim 7, characterized in that, Also includes: Based on the changes to the component files of the application, update at least some of the dynamic libraries called by the executable file.
9. The method according to claim 8, characterized in that, The update of at least some of the dynamic libraries called by the executable file based on the changes to the component files of the application includes at least one of the following: In response to reaching the update cycle of the dynamic library, at least one modified component file of the application is obtained; the first dynamic library is reconstructed based on the at least one modified component file, and the second dynamic library is reconstructed based on other component files of the application besides the at least one modified component file, wherein the number of modifications to the modified component file within the most recent preset time period meets a preset condition; In response to the application completing an incremental build, if the target dynamic library is the second dynamic library, the dynamic library currently linked to the target component file is switched from the second dynamic library to the first dynamic library.
10. An incremental construction apparatus, characterized in that, include: The file acquisition module is used to acquire the target component file corresponding to the incremental build instruction in response to the incremental build instruction for the application. The target component file is a modified component file. The executable file of the application calls at least two dynamic libraries, and different dynamic libraries are used to link different component files of the application. A dynamic library determination module is used to determine the target dynamic library to which the target component file is to be linked from the at least two dynamic libraries; A dynamic library construction module is used to reconstruct the target dynamic library based on the target component file and the symbols to be retained of the target dynamic library, wherein the symbols to be retained are defined by the target dynamic library and referenced by at least one other dynamic library, and the other dynamic library is a dynamic library other than the target dynamic library among the at least two dynamic libraries.
11. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the incremental construction method according to any one of claims 1-9.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the incremental construction method of any one of claims 1-9.
13. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the incremental construction method of any one of claims 1-9.