Package generation method and device, storage medium and computer device
By instrumenting intermediate compilation files in the project directory to generate the target application package, the problem of low instrumentation efficiency during project version updates is solved, and efficient code instrumentation is achieved.
Patent Information
- Application Number
- CN202210476156.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-29
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2042-04-29
AI Technical Summary
In existing technologies, whenever a new version of a project is released, the instrumentation plugin needs to be modified based on the corresponding source code version, which affects the efficiency of code instrumentation.
By acquiring the instrumentation files and storing them in the project directory, and responding to the package generation instructions, the intermediate compilation files are instrumented in the project directory to generate the target application package, thus avoiding modification of the project source code.
It improves the efficiency of code instrumentation, avoids modifications to the project source code, and ensures that the plugin does not need to be changed when the project version is updated.
Smart Images

Figure CN114721709B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer programming technology, and more specifically, to a method, apparatus, storage medium, and computer device for generating software packages. Background Technology
[0002] Code instrumentation is a testing method that inserts target programs into test items to obtain program execution information; it is also known as dynamic program analysis. Code instrumentation is of great significance for memory monitoring, instruction tracing, and error detection during program execution, and therefore has wide applications in the field of computer programming.
[0003] Because project development often involves generating packages with new application features, the new code is frequently inserted by instrumenting the project source code. However, whenever a new version of the project is released, the instrumentation plugin needs to be modified based on the corresponding source code version, which affects the efficiency of code instrumentation. Summary of the Invention
[0004] This application provides a method, apparatus, storage medium, and computer device for generating software packages. The aim is to improve the efficiency of code instrumentation.
[0005] On one hand, embodiments of this application provide a package generation method, which includes: obtaining an instrumentation file; storing the instrumentation file in a project directory; and, in response to a package generation instruction, performing an instrumentation operation on a first intermediate compilation file based on the instrumentation file in the project directory, so as to insert target code into the first intermediate compilation file and generate a target application package.
[0006] On the other hand, embodiments of this application also provide a package generation apparatus, which includes: an acquisition module for acquiring an instrumentation file; a storage module for storing the instrumentation file in a project directory; and a generation module for, in response to a package generation instruction, performing an instrumentation operation on a first intermediate compilation file in the project directory based on the instrumentation file, so as to insert target code into the first intermediate compilation file and generate a target application package.
[0007] On the other hand, embodiments of this application also provide a computer-readable storage medium storing program code, wherein the above-described package generation method is executed when the program code is run by a processor.
[0008] On the other hand, this application also provides a computer device, which includes a processor and a memory. The memory stores computer program instructions, and when the computer program instructions are called by the processor, the above-described package generation method is executed.
[0009] On the other hand, embodiments of this application also provide a computer program product or computer program, which includes computer instructions stored in a storage medium. A processor of a computer device reads the computer instructions from the storage medium and executes the computer instructions, causing the computer to perform the steps in the above-described package generation method.
[0010] This application provides a method for generating a program package. It obtains an instrumentation file and stores it in the project directory. Further, in response to a program package generation command, it performs instrumentation operations on a first intermediate compilation file based on the instrumentation file in the project directory, inserting target code into the first intermediate compilation file to generate a target application package. Thus, instrumentation operations performed on intermediate compilation files during project compilation can avoid modifying the project source code, generating a target application package with corresponding instrumentation functions, thereby improving the efficiency of code instrumentation. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 The illustration shows a schematic diagram of an instrumentation method based on modified source code provided in an embodiment of this application.
[0013] Figure 2 A flowchart illustrating a package generation method provided in an embodiment of this application is shown.
[0014] Figure 3 A flowchart illustrating another package generation method provided in an embodiment of this application is shown.
[0015] Figure 4 A flowchart illustrating a compilation operation provided in an embodiment of this application is shown.
[0016] Figure 5 A flowchart illustrating another compilation operation provided in an embodiment of this application is shown.
[0017] Figure 6 A block diagram of a package generation apparatus provided in an embodiment of this application is shown.
[0018] Figure 7 This is a block diagram of a computer device provided in an embodiment of this application.
[0019] Figure 8This is a block diagram of a computer-readable storage medium provided in an embodiment of this application. Detailed Implementation
[0020] The embodiments of this application are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.
[0021] To enable those skilled in the art to better understand the solutions of this application, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0022] Aspect-Oriented Programming (AOP) is a key technology that uses pre-compilation and runtime dynamic proxies to achieve unified maintenance of program functionality. AOP allows code to be dynamically inserted into specified classes at runtime to implement practical functions such as logging and performance statistics. For example, the commonly used program modification framework AspectD implements compile-time code insertion. However, this approach requires modifying the Flutter SDK (Software Development Kit) source code. Whenever a new version of Flutter is released, AspectD needs to be modified based on the corresponding source code version, and developers can only use the modified SDK source code, which is inconvenient for both use and maintenance.
[0023] Please see Figure 1 , Figure 1 This diagram illustrates a source code modification-based instrumentation method according to this application. When FlutterProject is packaged to generate an Android Application Package (APK), the source code of FlutterProject is modified to implement instrumentation, thereby generating an intermediate compilation file app.dill. The intermediate compilation file app.dill is then used to generate the app.so file, ultimately producing the APK.
[0024] To address the aforementioned problems, the inventors, through research, proposed a package generation method as provided in this application. This method obtains an instrumentation file and stores it in the project directory. Furthermore, in response to a package generation instruction, it performs instrumentation operations on a first intermediate compilation file based on the instrumentation file in the project directory, thereby inserting target code into the first intermediate compilation file and generating the target application package. By instrumenting the intermediate compilation file during project compilation, modifications to the Flutter SDK source code are avoided. Furthermore, when upgrading the Flutter SDK source code, the plugins used for code instrumentation do not need to be modified, thus improving the efficiency of code instrumentation.
[0025] In this embodiment, from such Figure 6 The package generation apparatus shown is described from the perspective of a computer device 500 that has a storage unit and is equipped with a microprocessor and has computing capabilities. Figure 7 )middle.
[0026] Of course, it is understood that the computer equipment used in this embodiment can be a server or a terminal, etc. The server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, blockchain, and big data and artificial intelligence platforms. The terminal can be a tablet computer, a laptop computer, a desktop computer, etc., but is not limited to these. The various embodiments in this application will be described in detail below with reference to the accompanying drawings.
[0027] Please see Figure 2 , Figure 2 A flowchart illustrating a package generation method according to an embodiment of this application is shown. The package generation method may include the following steps:
[0028] Step S110: Obtain the instrumentation file.
[0029] A plugin is a program written according to a specific application programming interface (API). It can only run on the system platform specified by the program (and may support multiple platforms simultaneously), and cannot run independently of a designated platform. This is because plugins need to call function libraries or data provided by the original clean system. In actual development, developers create instrumentation plugins to facilitate code instrumentation. After compilation, these plugins generate corresponding executable files, also known as instrumentation files.
[0030] As one implementation method, the corresponding functional code block for the instrumentation can be obtained based on the actual functional requirements of the project. An instrumentation plugin can then be generated based on this functional code block, and subsequently, instrumentation files can be generated by compiling the instrumentation plugin. For example, for a click event tracking task, an Android method bytecode instrumentation Hook plugin can be used to call back all currently running parameters to a fixed interface when the method enters and exits, thus enabling method-slice development. Optionally, the Hook plugin can be developed by customizing Hook rules and hooking the code of any method in the project to generate instrumentation files.
[0031] Step S120: Save the instrumentation file to the project directory.
[0032] In actual development, in order to effectively manage the diverse and numerous source files, developers will store all source files in one directory (folder), and this directory will only contain resources related to the current program.
[0033] Therefore, the Integrated Development Environment (IDE) used for project development creates a dedicated directory for each program, centralizing all the files used in this directory, i.e., the project directory, and managing them conveniently, such as renaming, deleting, and editing files.
[0034] As one implementation, after obtaining the instrumentation file, it can be stored in the project's project directory so that it can be referenced during compilation for instrumentation operations. For example, instrumentation file A can be stored in the Flutter Project's project directory (HelloFlutter / target / plug / A).
[0035] Step S130: In response to the package generation instruction, in the project directory, instrument the first intermediate compilation file based on the instrumentation file to insert the target code into the first intermediate compilation file and generate the target application package.
[0036] Considering that inserting new code directly into the project source code is detrimental to project maintenance, this embodiment performs instrumentation operations on intermediate compilation files during the application package generation process. The package generation instruction refers to the instruction used to generate the APK, for example, the instruction to generate an APK using Flutter. The first compiled file refers to the intermediate file generated during compilation before the instrumentation operation, such as the app.dill file.
[0037] One implementation method involves first compiling the target project to be instrumented, obtaining a first intermediate compilation file. Then, instrumentation is performed on this first intermediate compilation file, and the resulting instrumented intermediate compilation file is used as a second intermediate compilation file. Finally, the second intermediate compilation file is compiled to generate the target application package. Since the second compilation operation is not based on the target project's source code, and the instrumentation operation does not modify the target project's source code, the efficiency of instrumenting the target project can be improved.
[0038] In this embodiment, an instrumentation file can be obtained and stored in the project directory. Further, in response to a package generation instruction, instrumentation operations are performed on a first intermediate compilation file based on the instrumentation file in the project directory, so that target code is inserted into the first intermediate compilation file, generating a target application package. Thus, instrumentation operations are performed on intermediate compilation files during project compilation, avoiding modification of the project source code and generating a target application package with code insertion functionality, thereby improving the efficiency of code instrumentation.
[0039] Based on the methods described in the above embodiments, the following examples will provide further detailed explanations.
[0040] In this embodiment, the example of the package generation device being specifically integrated into a computer device will be used for illustration.
[0041] like Figure 3 As shown, Figure 3 This illustration schematically shows another package generation method provided in an embodiment of the present application, which may include the following steps:
[0042] Step S210: The computer device obtains the instrumentation file.
[0043] During project development, it is sometimes necessary to trace the relevant execution steps of the SDK source code in order to locate problems that occur during code execution. However, the SDK source code is usually difficult to debug. Directly modifying the SDK source code, for example, by adding a large amount of code, is very time-consuming and not universal.
[0044] Therefore, instrumentation can be performed on the SDK source code portions of the compiled intermediate file app.dill to add program steps to the relevant code and trace the execution process of the corresponding source code, without modifying the SDK source code. The instrumentation operation is based on an instrumentation file, which is an executable file generated after compiling the developed instrumentation plugin.
[0045] As one implementation, the step of the computer device acquiring the instrumentation file may include:
[0046] (1) Computer equipment acquires target code.
[0047] (2) Computer equipment generates instrumentation plugins based on target code.
[0048] (3) The computer equipment performs a third compilation operation on the instrumentation plug-in to generate the instrumentation file.
[0049] The target code refers to the functional code written by the developer to correspond to the required functionality of the instrumentation. For example, code that implements log printing. The third compilation operation refers to the compilation of the instrumentation plugin, through which the instrumentation plugin can generate an executable instrumentation file.
[0050] For example, developers can edit target code in the integrated development environment Android Studio. This target code can be used to troubleshoot class files or methods, add log printing, and after the computer device obtains the target code, it can generate instrumentation plugins based on the target code. Furthermore, a third compilation operation is performed on the instrumentation plugins to generate instrumentation files. For example, the troubleshooting class files or methods can be written in the form of configuration files, and an executable file can be generated using Dart instructions.
[0051] Step S220: The computer device stores the instrumentation file to the project directory.
[0052] As one implementation method, when a computer device obtains an instrumentation file, it can store the instrumentation file in the project directory. For example, a smart switch terminal cannot store sensitive information, such as passwords, birthdays, or card numbers, in its logs. In this case, instrumentation can be used to instrument the project directory where the logs are stored in the code, thereby replacing the sensitive information in advance. Therefore, the instrumentation file can be stored in the project directory where the logs are stored, so that the logs in the project directory can be instrumented to replace the sensitive information.
[0053] Step S230: In response to the package generation instruction, the computer device performs a first compilation operation based on the target project in the project directory to obtain a first intermediate compilation file.
[0054] The first compilation operation refers to the action of converting a programming language into an executable target program, such as the Dart compilation operation used by the Flutter framework. The first intermediate compilation file refers to the intermediate compilation file generated during the execution of the first compilation operation.
[0055] As one implementation method, a computer device can respond to a package generation instruction by executing a packaging script in the project directory. Once the compilation instructions in the script are successfully executed, an APK package containing the inserted code can be generated. For example, such as... Figure 4 As shown, Figure 4 A flowchart illustrating a compilation operation is shown. In response to the Flutter APK generation command, the computer device performs a first compilation operation. Specifically, the Flutter Project compiles the source code to generate a first intermediate compilation file, app.dill. Further, the computer device can generate a first link library file, app.so, and a first application package, APK, based on the first intermediate compilation file, app.dill.
[0056] The first link library file, app.so, is a dynamic link library file. app.so is a shared library file under Linux, and its file format is called ELF. Because the Android operating system is based on Linux, the app.so file can run on the Android platform.
[0057] Step S240: The computer device performs instrumentation on the first intermediate compilation file according to the instrumentation file, so that the target code is inserted into the first intermediate compilation file to obtain the second intermediate compilation file.
[0058] Instrumentation refers to the replacement of the first intermediate compilation file. Executing the instrumented file inserts the target code into the first intermediate compilation file, resulting in the instrumented intermediate compilation file, which is also the second intermediate compilation file. This way, the final generated APK will contain the corresponding instrumented functionality.
[0059] In one implementation, the computer device instrumentes a first intermediate compilation file according to an instrumentation file to insert target code into the first intermediate compilation file, thereby obtaining a second intermediate compilation file. This step may include:
[0060] (1) The computer device executes the instrumentation file, inserts the target code into the first intermediate compilation file, and obtains the intermediate compilation file with the inserted target code.
[0061] (2) The computer device uses the intermediate compilation file into which the target code is inserted as the second intermediate compilation file.
[0062] (3) The computer device deletes the first link library file and the first application package corresponding to the first compilation intermediate file.
[0063] (4) The computer device obtains the first information digest value corresponding to the first compilation intermediate file and updates the first information digest value to obtain the second information digest value.
[0064] Linked library files refer to other intermediate files generated during the compilation process based on the intermediate compilation files. The message-digest value, also known as the MD5 (Message-Digest Algorithm) value, can be seen as a file's "fingerprint." If the original file is modified, the MD5 value will also change. Therefore, the change in the MD5 value can be used to determine if a file has been modified. During the first compilation operation, the computer generates a first message-digest value corresponding to the first intermediate compilation file and stores this value in a cache.
[0065] For example, during the execution of the instrumentation file by the computer device, the target code can be inserted into the first intermediate compilation file app.dill of Flutter to obtain the intermediate compilation file app_aop.dill with the inserted target code, and the intermediate compilation file app_aop.dill with the inserted target code can be used as the second intermediate compilation file of Flutter to replace the first intermediate compilation file to obtain the new app.dill.
[0066] Furthermore, the computer device can delete the first link library file app.so and the first application package APK generated during the first compilation operation. It can also update the first digest value corresponding to the first intermediate compilation file to obtain a second digest value. Since the SDK relies on the digest value of the intermediate compilation file when compiling it, replacing the intermediate compilation file and its digest value allows the SDK to directly add the replaced intermediate compilation file to the compilation process during the second compilation operation.
[0067] Step S250: The computer device performs a second compilation operation based on the second intermediate compilation file to obtain the target application package.
[0068] The second compilation operation refers to the compilation operation that is re-executed after the computer device has completed the instrumentation operation. This compilation operation repackages the second link library file generated from the second compilation intermediate file to generate an APK with instrumentation functionality.
[0069] In one implementation, the step of the computer device performing a second compilation operation based on a second intermediate compilation file to obtain a target application package may include:
[0070] (1) The computer device performs a second compilation operation based on the second intermediate file and the second information digest value to obtain the second link library file.
[0071] (2) The computer device generates the target application package based on the second link library file.
[0072] For example, such as Figure 5 As shown, Figure 5 This diagram illustrates another compilation operation. After instrumenting the first intermediate compilation file app.dill, the computer device obtains an intermediate compilation file app_aop.dill with inserted target code as the second intermediate compilation file, which is also the new intermediate compilation file app.dill.
[0073] Furthermore, the computer device can perform a second compilation operation based on the second intermediate file app.dill and the second message digest value to obtain the second link library file app.so, and then generate the target application package APK based on the second link library file app.so.
[0074] For example, this program generation method can be applied to the scenario of packaging a Flutter APK. As one implementation, a code instrumentation plugin is developed, compiled, and an executable file (i.e., an instrumentation file) is generated and placed in the project directory. When it is necessary to package the Flutter APK, the packaging script is executed at the specified location, i.e., in the project directory. After the compilation instructions in the script are successfully executed, an APK package with the inserted code is generated.
[0075] Specifically, execute the normal Flutter APK generation instructions. After generating the APK package, delete the app.so file generated during the Flutter project compilation. Further, execute the instrumentation file in the project directory. For example, input the Flutter compilation intermediate artifact app.dill file, output the instrumented app_aop.dill file, rename it to app.dill, and replace the original intermediate artifact and its cached MD5 value.
[0076] Furthermore, the Flutter APK generation command is executed again. This time, since the source code in the Flutter project has not changed, the packaging can be repackaged from the point where the app.so file is generated from the app.dill file, based on the caching mechanism during Flutter source code packaging. Since the app.dill file has already been instrumented, the generated new APK package has instrumentation functionality. At the same time, since the instrumentation operation is performed without changing the source code in the Flutter project, the packaging script can still be used after the Flutter SDK version is upgraded, and the instrumentation plugin does not need to be changed.
[0077] In this embodiment, an instrumentation file can be obtained and stored in the project directory. Further, in response to a package generation instruction, a first compilation operation is performed based on the target project in the project directory to obtain a first intermediate compilation file. The first intermediate compilation file is then instrumented according to the instrumentation file, inserting the target code into it to obtain a second intermediate compilation file. A second compilation operation is then performed based on the second intermediate compilation file to obtain the target application package. Thus, modifications to the project source code are avoided during project compilation; instead, instrumentation is performed on the intermediate compilation files, ensuring the newly generated application package has instrumentation functionality. Furthermore, even when the project version is updated, the plugins used for code instrumentation do not need to be modified, thereby improving the efficiency of code instrumentation.
[0078] Please see Figure 6 This diagram illustrates a structural block diagram of a package generation apparatus 400 provided in an embodiment of this application. The package generation apparatus 400 includes: an acquisition module 410, a storage module 420, and a generation module 430. The acquisition module 410 is used to acquire instrumentation files; the storage module 420 is used to store the instrumentation files in the project directory; and the generation module 430, in response to a package generation instruction, performs instrumentation operations on a first intermediate compilation file in the project directory based on the instrumentation files, thereby inserting target code into the first intermediate compilation file and generating a target application package.
[0079] In some embodiments, the generation module 430 includes: a first compilation unit, an instrumentation unit, and a second compilation unit. The first compilation unit is used to perform a first compilation operation based on the target project to obtain a first intermediate compilation file; the instrumentation unit is used to perform an instrumentation operation on the first intermediate compilation file according to the instrumentation file, so that the target code is inserted into the first intermediate compilation file to obtain a second intermediate compilation file; the second compilation unit is used to perform a second compilation operation based on the second intermediate compilation file to obtain a target application package.
[0080] In some embodiments, the instrumentation unit may be specifically used to: execute the instrumentation file, insert the target code into the first intermediate compilation file, and obtain the intermediate compilation file with the inserted target code; and use the intermediate compilation file with the inserted target code as the second intermediate compilation file.
[0081] In some embodiments, the instrumentation unit may also be specifically used to: delete the first link library file and the first application package corresponding to the first intermediate compilation file; obtain the first information digest value corresponding to the first intermediate compilation file, and update the first information digest value to obtain the second information digest value.
[0082] In some embodiments, the second compilation unit may be specifically used to: perform a second compilation operation based on a second intermediate file and a second message digest value to obtain a second link library file; and generate a target application package based on the second link library file.
[0083] In some embodiments, the acquisition module 410 may be specifically used to: acquire target code, which is functional code generated based on user input; generate an instrumentation plugin based on the target code; and perform a third compilation operation on the instrumentation plugin to generate an instrumentation file, which is an executable file.
[0084] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described device and module can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0085] In the several embodiments provided in this application, the coupling between modules can be electrical, mechanical, or other forms of coupling.
[0086] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.
[0087] The solution provided in this application can obtain instrumentation files and store them in the project directory. Furthermore, in response to package generation instructions, instrumentation operations are performed on the first intermediate compilation file based on the instrumentation files in the project directory, so that target code is inserted into the first intermediate compilation file, generating the target application package. In this way, instrumentation operations are performed on the intermediate compilation files during project compilation, avoiding modifications to the project source code. Even when the project version is updated, the plugins used for code instrumentation do not need to be modified, thereby improving the efficiency of code instrumentation.
[0088] like Figure 7 As shown in the figure, this application embodiment also provides a computer device 500, which includes a processor 510, a memory 520, a power supply 530, and an input unit 540. The memory 520 stores computer program instructions. When the computer program instructions are called by the processor 510, they can execute various method steps provided in the above embodiments. Those skilled in the art will understand that the structure of the computer device shown in the figures does not constitute a limitation on the computer device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:
[0089] The processor 510 may include one or more processing cores. The processor 510 connects to various parts of the entire battery management system using various interfaces and lines. It executes instructions, programs, code sets, or instruction sets stored in the memory 520, calls data stored in the memory 520, performs various functions and processes data within the battery management system, and performs various functions and processes data within the computer device, thereby providing overall control of the computer device. Optionally, the processor 510 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 510 may integrate one or more of the following: a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), and a modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the displayed content; and the modem handles wireless communication. It is understood that the modem may also be implemented separately as a communication chip, without being integrated into the processor 510.
[0090] The memory 520 may include random access memory (RAM) or read-only memory (ROM). The memory 520 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 520 may include a program storage area and a data storage area. The program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as touch functionality, sound playback functionality, image playback functionality, etc.), instructions for implementing the various method embodiments described below, etc. The data storage area may also store data created during the use of the computer device (such as phonebook and audio / video data). Accordingly, the memory 520 may also include a memory controller to provide the processor 510 with access to the memory 520.
[0091] The power supply 530 can be logically connected to the processor 510 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 530 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0092] The input unit 540 can be used to receive input digital or character information, and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0093] Although not shown, the computer device 500 may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 510 in the computer device loads the executable files corresponding to the processes of one or more applications into the memory 520 according to the following instructions, and the processor 510 runs the applications stored in the memory 520, thereby implementing the various method steps provided in the foregoing embodiments.
[0094] like Figure 8 As shown, this application embodiment also provides a computer-readable storage medium 600, which stores computer program instructions 610, which can be called by a processor to execute the methods described in the above embodiments.
[0095] Computer-readable storage media can be electronic storage devices such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM. Optionally, computer-readable storage media includes non-volatile computer-readable storage medium. Computer-readable storage medium 600 has storage space for program code that performs any of the method steps described above. This program code can be read from or written to one or more computer program products. The program code can be compressed, for example, in a suitable form.
[0096] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in the various optional implementations of the above embodiments.
[0097] The above are merely preferred embodiments of this application and are not intended to limit this application in any way. Although this application has disclosed preferred embodiments as above, it is not intended to limit this application. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the technical solution of this application. Any simple modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of this application without departing from the scope of the technical solution of this application shall still fall within the scope of the technical solution of this application.
Claims
1. A method for generating a program package, characterized in that, The method includes: Obtain the instrumentation file; Store the instrumentation file in the project directory; In response to the package generation instruction, a first compilation operation is performed based on the target project in the project directory to obtain a first intermediate compilation file. The instrumentation file is then executed to insert the target code into the first intermediate compilation file, resulting in a second intermediate compilation file with the inserted target code. The name of the second intermediate compilation file is updated to match the name of the first intermediate compilation file. A first digest value corresponding to the first intermediate compilation file is obtained, and the first digest value is updated to obtain a second digest value. The second digest value indicates that the first intermediate compilation file has been modified. Through the caching mechanism during packaging, a second compilation operation is performed based on the second intermediate compilation file and the second digest value to obtain a second link library file. This allows for repackaging from the second intermediate compilation file to the point where the second link library file is obtained, while the plugins required for instrumentation do not need to be changed. The target application package is then generated based on the second link library file.
2. The method according to claim 1, characterized in that, The first compilation operation based on the target project yields the first intermediate compilation file, including: The first compilation operation is performed based on the target project to obtain the first intermediate compilation file, the first link library file corresponding to the first intermediate compilation file, and the first application package. The method further includes: During the execution of the instrumentation file, the first link library file and the first application package corresponding to the first intermediate compilation file are deleted.
3. The method according to claim 1, characterized in that, The process of obtaining the instrumentation file includes: Obtain the target code, which is a functional code generated based on user input; Generate instrumentation plugins based on the target code; A third compilation operation is performed on the instrumentation plugin to generate an instrumentation file, which is an executable file.
4. A package generation apparatus, characterized in that, The device includes: The acquisition module is used to acquire instrumentation files; The storage module is used to store the instrumentation files to the project directory; The generation module, in response to a package generation instruction, performs a first compilation operation based on the target project in the project directory to obtain a first intermediate compilation file. It then executes the instrumentation file to insert target code into the first intermediate compilation file, resulting in a second intermediate compilation file containing the target code. The name of the second intermediate compilation file is updated to match the name of the first intermediate compilation file. A first digest value corresponding to the first intermediate compilation file is obtained, and the first digest value is updated to obtain a second digest value. The second digest value indicates that the first intermediate compilation file has been modified. Through a caching mechanism during packaging, a second compilation operation is performed based on the second intermediate compilation file and the second digest value to obtain a second link library file. This allows for repackaging from the second intermediate compilation file to the point where the second link library file is obtained, without requiring changes to the plugins needed for instrumentation. Finally, the target application package is generated based on the second link library file.
5. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores program code that can be invoked by a processor to execute the method as described in any one of claims 1 to 3.
6. A computer device, characterized in that, include: Memory; One or more processors are coupled to the memory; One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more applications being configured to perform the method as described in any one of claims 1 to 3.
7. A computer program product or computer program, characterized in that, The computer program product or computer program includes computer instructions stored in a storage medium, a processor of a computer device reads the computer instructions from the storage medium, and the processor executes the computer instructions to cause the computer to perform the method as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Code generation method and device, electronic equipment and storage medium
CN113656042A
Byte code instrumentation method and system and byte code instrumentation plug-in framework
CN113885879A