Compiling method and electronic equipment

By compiling and decompiling modules in application projects, redundant data is removed, data redundancy and compatibility issues caused by binary closed-source modules are solved, and smaller installation package size and higher loading performance are achieved.

CN118689482APending Publication Date: 2024-09-24HUAWEI TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202310315262.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-21
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

In large-scale application development scenarios, when the application project relies on commercial closed-source modules, the binary closed-source modules are incorporated into the application installation package, resulting in data redundancy, large size, affecting loading performance, and compatibility issues.

Method used

By compiling and decompiling the first module and the second module, the intermediate compilation data structure is removed and merged, an application installation package is generated that does not contain redundant data, and the compatibility of the binary closed source module and the adaptability of the JS virtual machine are achieved. match.

Benefits of technology

The size of the application installation package has been reduced, loading performance has been improved, and the compatibility issue between binary closed source modules and JS virtual machines has been solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118689482A
    Figure CN118689482A
Patent Text Reader

Abstract

The embodiment of the invention provides a compiling method and electronic equipment. According to the technical scheme, the method comprises the steps that first compiling operation is conducted on a first module and a second module, a first intermediate compiling data structure and a second intermediate compiling data structure are obtained, and the second module comprises a binary module corresponding to the first module; performing deduplication merging operation on the first intermediate compiled data structure and the second intermediate compiled data structure to obtain a first merged intermediate compiled data structure; a first application installation package is obtained according to the first combined intermediate compilation data structure, and when the application engineering and the binary closed source module depend on the same module, the application installation package does not have data redundancy and is smaller in size.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] The present invention relates to the field of computer technology, and in particular to a compiling method and electronic equipment. [Background technology]

[0002] In large-scale application development scenarios, application engineering usually relies on commercial closed-source modules. For reasons such as commercial code protection and commercial security, closed-source module developers usually only release binary closed-source modules compiled from source code. Since binary closed-source modules are compiled binary file packages, the modules they depend on are compiled into their own binary files. Therefore, this method will cause duplicate modules to appear in the application installation package when the application engineering and the binary closed-source module rely on the same module, resulting in data redundancy in the application installation package and a larger size. [Summary of the invention]

[0003] In view of this, an embodiment of the present invention provides a compilation method and an electronic device, when an application project and a binary closed-source module depend on the same module, the application installation package will not have data redundancy and will be smaller in size.

[0004] In a first aspect, an embodiment of the present invention provides a compilation method, the method comprising:

[0005] Performing a first compile operation on the first module and the second module to obtain a first intermediate compiled data structure and a second intermediate compiled data structure, wherein the second module includes a binary module corresponding to the first module;

[0006] performing a de-duplication and merging operation on the first intermediate compiled data structure and the second intermediate compiled data structure to obtain a first merged intermediate compiled data structure;

[0007] According to the first merged intermediate compiled data structure, a first application installation package is obtained. Since the second module includes a binary module corresponding to the first module, if the first module is compiled into a binary file and then directly packaged with the second module to generate an application installation package, there are two binary modules corresponding to the first module in the application installation package, and there is data redundancy. Therefore, the embodiment of the present invention removes redundant data through a deduplication and merging operation, reduces the size of the application installation package, and improves the loading performance of the application.

[0008] In combination with the first aspect, in some implementations of the first aspect, performing a first compile operation on the first module and the second module to obtain a first intermediate compiled data structure and a second intermediate compiled data structure includes:

[0009] Compiling the first module to obtain the first intermediate compiled data structure;

[0010] The second module is decompiled to obtain the second intermediate compiled data structure. In an embodiment of the present invention, since the second module includes a binary module corresponding to the first module, the first module and the second module are modules of different formats, and the first module and the second module cannot be directly de-duplicated and merged, and the first module and the second module need to be converted into files of the same format first. Therefore, the electronic device compiles the first module to obtain the first intermediate compiled data structure; and decompiles the second module to obtain the second intermediate compiled data structure, so as to perform subsequent de-duplication and merge operations. Therefore, by disassembling the compiled data of the second module and making the second module participate in the project compilation again, the duplicate data can be de-duplicated and merged.

[0011] In combination with the first aspect, in some implementations of the first aspect, obtaining a first application installation package according to the first merged intermediate compiled data structure includes:

[0012] Converting the first merged intermediate compiled data structure into a first merged binary file;

[0013] The first merged binary file is packaged to obtain the first application installation package. Since the object of the operation in the JS virtual machine is a binary file, it is necessary to first convert the optimized intermediate compiled data structure into a binary file, and then perform the operation on the binary file. Then, the first merged binary file is packaged to obtain the first application installation package.

[0014] In combination with the first aspect, in some implementations of the first aspect, performing a first compile operation on the first module and the second module includes:

[0015] The first compile operation is performed on the first module and the second module by a compiler. The electronic device performs the first compile operation on the first module and the second module by a compiler to obtain a first intermediate compile data structure and a second intermediate compile data structure. Since the first module and the second module are modules of different formats, the compiler can implement mixed compilation.

[0016] In combination with the first aspect, in some implementations of the first aspect, the performing a de-duplication and merging operation on the first intermediate compiled data structure and the second intermediate compiled data structure includes:

[0017] The compiler performs the de-duplication and merging operation on the first intermediate compiled data structure and the second intermediate compiled data structure. After the electronic device performs the first compilation operation on the first module and the second module through the compiler, two intermediate compiled data structures are obtained, and then the compiler performs the de-duplication and merging operation on the two intermediate compiled data structures to obtain a merged intermediate compiled data structure. Therefore, the compiler removes redundant data through the de-duplication and merging operation to reduce the size of the application installation package.

[0018] In combination with the first aspect, in some implementations of the first aspect, obtaining a first application installation package according to the first merged intermediate compiled data structure includes:

[0019] Converting the first merged intermediate compiled data structure into a first merged binary file by a compiler;

[0020] The first combined binary file is packaged by the compiler to obtain the first application installation package. The electronic device can compile the first module and the second module by the compiler, and directly output the application installation package without redundant data.

[0021] In combination with the first aspect, in some implementations of the first aspect, before performing the first compile operation on the first module and the second module, the method further includes:

[0022] In response to a user's downloading operation on the first module and the second module, the first module and the second module are downloaded.

[0023] In combination with the first aspect, in some implementations of the first aspect, the first module is a source code module; and the second module is a binary closed source module.

[0024] The application project references a binary third-party package, that is, a binary closed-source module. The binary file is a file compiled from the source code and usually cannot be re-compiled in the application project. Therefore, compared with the source code third-party package, the application size is expanded and the application loading time is degraded. The compilation method provided in the embodiment of the present invention can compile the source code and binary mixedly. In the scenario where the application project references a binary third-party package, by disassembling the compiled data from the binary closed-source module, the binary closed-source module can be re-compiled in the application project compilation, and duplicate data can be de-duplicated and merged; the application installation package produced after the application project is compiled is smaller in size, which improves the application loading performance.

[0025] When an application project references a binary third-party package and directly compiles the binary closed-source module into the application, compatibility issues may occur, such as incompatibility of the JS virtual machine, resulting in the inability to execute the application. The compilation method provided in the embodiment of the present invention can achieve the recompilation of the third-party package to be compatible with the existing JS virtual machine version in the scenario where the application project references a third-party package in binary form that is incompatible with the virtual machine. Specifically, the binary closed-source module is recompiled after disassembly, so that the developer of the binary closed-source module does not need to re-release an updated version, and the JS virtual machine can execute the originally incompatible binary closed-source module, thereby solving the compatibility problem of the binary closed-source module. Therefore, the embodiment of the present invention takes into account the execution efficiency of the application end and the size of the application installation package, and solves the compatibility problem of the binary closed-source module backward adaptation to the updated version of the JS virtual machine.

[0026] In combination with the first aspect, in some implementations of the first aspect, the method further includes:

[0027] Performing a second compiling operation on the third module and the fourth module to obtain a third intermediate compiled data structure and a fourth intermediate compiled data structure, wherein the fourth module includes the third module;

[0028] performing a de-duplication and merging operation on the third intermediate compiled data structure and the fourth intermediate compiled data structure to obtain a second merged intermediate compiled data structure;

[0029] According to the second merged intermediate compiled data structure, a second application installation package is obtained. Since the fourth module includes the third module, if the third module and the fourth module are directly packaged to generate an application installation package, there are two third modules in the application installation package, and there is data redundancy. Therefore, the embodiment of the present invention removes redundant data through a de-duplication merging operation, reduces the size of the application installation package, and improves the loading performance of the application.

[0030] In combination with the first aspect, in some implementations of the first aspect, performing a second compile operation on the third module and the fourth module to obtain a third intermediate compiled data structure and a fourth intermediate compiled data structure includes:

[0031] Decompile the third module and the fourth module to obtain the third intermediate compiled data structure and the fourth intermediate compiled data structure. The third module and the fourth module are usually unable to re-participate in the application engineering compilation. The embodiment of the present invention disassembles the compiled data of the third module and the fourth module, so that the third module and the fourth module can re-participate in the application engineering compilation, and duplicate data can be de-duplicated and merged; directly incorporating the fourth module into the application may cause compatibility issues such as the incompatibility of the JS virtual machine and the inability to execute the application. Disassembling the fourth module and re-compiling it can solve the compatibility problem, so that the developer of the fourth module does not need to re-release an updated version, and the JS virtual machine can execute the originally incompatible fourth module.

[0032] In combination with the first aspect, in some implementations of the first aspect, obtaining a second application installation package according to the second merged intermediate compiled data structure includes:

[0033] converting the second merged intermediate compiled data structure into a second merged binary file;

[0034] The second merged binary file is packaged to obtain the second application installation package. Since the object of the operation in the JS virtual machine is a binary file, it is necessary to first convert the optimized intermediate compiled data structure into a binary file, and then perform the operation on the binary file. Then, the first merged binary file is packaged to obtain the first application installation package.

[0035] In combination with the first aspect, in some implementations of the first aspect, the performing a second compile operation on the third module and the fourth module includes:

[0036] The second compiling operation is performed on the third module and the fourth module by a compiler.

[0037] In combination with the first aspect, in some implementations of the first aspect, the performing a de-duplication and merging operation on the third intermediate compiled data structure and the fourth intermediate compiled data structure includes:

[0038] The de-duplication and merging operation is performed on the third intermediate compiled data structure and the fourth intermediate compiled data structure by the compiler. After the electronic device decompiles the third module and the fourth module by the compiler, two intermediate compiled data structures are obtained, and then the compiler performs a de-duplication and merging operation on the two intermediate compiled data structures to obtain a merged intermediate compiled data structure. Therefore, the compiler removes redundant data through the de-duplication and merging operation to reduce the size of the application installation package.

[0039] In combination with the first aspect, in some implementations of the first aspect, obtaining a second application installation package according to the second merged intermediate compiled data structure includes:

[0040] Converting the second merged intermediate compiled data structure into a second merged binary file by a compiler;

[0041] The second combined binary file is packaged by the compiler to obtain the second application installation package. The electronic device can decompile the third module and the fourth module by the compiler, and directly output the application installation package without redundant data.

[0042] In combination with the first aspect, in some implementations of the first aspect, before performing the second compile operation on the third module and the fourth module, the method further includes:

[0043] In response to a user's downloading operation on the third module and the fourth module, the third module and the fourth module are downloaded.

[0044] In combination with the first aspect, in some implementations of the first aspect, the third module is a binary module, and the fourth module is a binary closed-source module.

[0045] The application project references a binary third-party package, that is, a binary closed-source module. The binary file is a file compiled from the source code and usually cannot be re-compiled into the application project. Therefore, compared with the source code third-party package, the application size expands and the application loading time is degraded. The compilation method provided in the embodiment of the present invention can decompile the binary. In the scenario where the application project references a binary third-party package, by disassembling the compiled data from the binary closed-source module, the binary closed-source module can be re-compiled into the application project compilation, and duplicate data can be de-duplicated and merged; the application installation package produced after the application project is compiled is smaller in size, which improves the application loading performance.

[0046] When an application project references a binary third-party package and directly compiles the binary closed-source module into the application, compatibility issues may occur, such as incompatibility of the JS virtual machine, resulting in the inability to execute the application. The compilation method provided in the embodiment of the present invention can achieve the recompilation of the third-party package to be compatible with the existing JS virtual machine version in the scenario where the application project references a third-party package in binary form that is incompatible with the virtual machine. Specifically, the binary closed-source module is recompiled after disassembly, so that the developer of the binary closed-source module does not need to re-release an updated version, and the JS virtual machine can execute the originally incompatible binary closed-source module, thereby solving the compatibility problem of the binary closed-source module. Therefore, the embodiment of the present invention takes into account the execution efficiency of the application end and the size of the application installation package, and solves the compatibility problem of the binary closed-source module backward adaptation to the updated version of the JS virtual machine.

[0047] In a second aspect, an embodiment of the present invention provides an electronic device, comprising a processor and a memory, wherein the memory is used to store a computer program, and the computer program comprises program instructions, and when the processor runs the program instructions, the electronic device executes the steps of the method described above.

[0048] In a third aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program request is executed by a computer, the computer is caused to execute the method as described above.

[0049] In a fourth aspect, an embodiment of the present invention provides a computer program product, which includes instructions, and when the computer program product is run on a computer or any at least one processor, the computer executes the functions / steps in the above method.

Brief Description of the Drawings

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

[0051] Figure 1 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention;

[0052] Figure 2 is a software structure block diagram of the electronic device 100 according to an embodiment of the present invention;

[0053] Figure 3 This is a schematic diagram of the JS virtual machine's processing of source code files and binary files;

[0054] Figure 4 This is a schematic diagram of the JS application software package form;

[0055] Figure 5 A schematic diagram of a compilation scheme;

[0056] Figure 6 A schematic diagram of an application installation package generated using a source code dependency package for application development;

[0057] Figure 7 A schematic diagram of another compilation scheme;

[0058] Figure 8 A schematic diagram of an application installation package generated using a binary dependency package for application development;

[0059] Fig. 9 A flowchart of a compilation method provided by an embodiment of the present invention;

[0060] Fig.10 for Fig. 9 A specific flow chart of performing a first compiling operation on the first module and the second module to obtain a first intermediate compiled data structure and a second intermediate compiled data structure;

[0061] Fig.11 A schematic diagram of a compilation scenario according to an embodiment of the present invention;

[0062] Fig.12It is a schematic diagram of obtaining an application installation package according to a source code module and a binary closed source module in an embodiment of the present invention;

[0063] Fig.13 A schematic diagram of an example of a deduplication and merging operation in an embodiment of the present invention;

[0064] Fig.14 for Fig. 9 According to the first merged intermediate compiled data structure, a specific flow chart of the first application installation package is obtained;

[0065] Fig.15 A schematic diagram of a compilation solution according to an embodiment of the present invention;

[0066] Fig.16 for Fig. 9 According to the second merged intermediate compiled data structure, a specific flow chart of the second application installation package is obtained;

[0067] Fig.17 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. [Specific implementation method]

[0068] In order to better understand the technical solution of the present invention, the embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0069] It should be clear that the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0070] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.

[0071] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0072] Figure 1 A schematic structural diagram of an electronic device 100 is shown.

[0073] The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0074] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0075] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0076] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.

[0077] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0078] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0079] The USB interface 130 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transfer data between the electronic device 100 and a peripheral device. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices, etc.

[0080] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0081] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device through the power management module 141.

[0082] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.

[0083] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0084] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

[0085] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0086] The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.

[0087] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0088] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).

[0089] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.

[0090] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.

[0091] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.

[0092] ISP is used to process the data fed back by camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 193.

[0093] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.

[0094] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.

[0095] Video codecs are used to compress or decompress digital videos. The electronic device 100 may support one or more video codecs. Thus, the electronic device 100 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0096] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.

[0097] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.

[0098] The internal memory 121 can be used to store computer executable program codes, which include instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the internal memory 121, and / or instructions stored in a memory provided in the processor.

[0099] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

[0100] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.

[0101] The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 170A.

[0102] The receiver 170B, also called a "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the voice can be received by placing the receiver 170B close to the human ear.

[0103] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to microphone 170C to input the sound signal into microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify the sound source, realize directional recording function, etc.

[0104] The earphone interface 170D is used to connect a wired earphone and can be a USB interface 130 or a 3.5 mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.

[0105] The key 190 includes a power key, a volume key, etc. The key 190 may be a mechanical key or a touch key. The electronic device 100 may receive key input and generate key signal input related to user settings and function control of the electronic device 100.

[0106] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.

[0107] Indicator 192 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.

[0108] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to and separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.

[0109] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. In the embodiment of the present invention, the Android system of the layered architecture is taken as an example to exemplify the software structure of the electronic device 100.

[0110] Figure 2 1 is a software structure block diagram of the electronic device 100 according to an embodiment of the present invention.

[0111] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system library, and the kernel layer.

[0112] The application layer can include a series of application packages.

[0113] like Figure 2 As shown, the application package may include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications.

[0114] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0115] like Figure 2 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.

[0116] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.

[0117] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

[0118] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.

[0119] The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including connecting, hanging up, etc.).

[0120] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.

[0121] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.

[0122] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.

[0123] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.

[0124] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.

[0125] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.

[0126] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.

[0127] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0128] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

[0129] A 2D graphics engine is a drawing engine for 2D drawings.

[0130] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.

[0131] The following is an illustrative description of the workflow of the software and hardware of the electronic device 100 in conjunction with capturing a photo scene.

[0132] When the touch sensor 180K receives a touch operation, the corresponding hardware interrupt is sent to the kernel layer. The kernel layer processes the touch operation into a raw input event (including touch coordinates, timestamp of the touch operation, and other information). The raw input event is stored in the kernel layer. The application framework layer obtains the raw input event from the kernel layer and identifies the control corresponding to the input event. For example, if the touch operation is a touch single-click operation and the control corresponding to the single-click operation is the control of the camera application icon, the camera application calls the interface of the application framework layer to start the camera application, and then starts the camera driver by calling the kernel layer to capture static images or videos through the camera 193.

[0133] The file types loaded and executed by different JavaScript (abbreviation: JS) virtual machines in the industry mainly include source code files and compiled binary files. For example, some companies' engines directly load and execute source code files, some companies' virtual machines load binary files compiled from source code, and some companies' engines can execute both source code files and binary files.

[0134] Figure 3 This is a schematic diagram of the JS virtual machine's processing of source code files and binary files. Figure 3 As shown in the figure, the JS virtual machine that directly loads the source code file mainly performs syntax analysis (Parsing), compilation (Compiling) and optimization (Optimizing) on ​​the source code to generate a binary file, and then executes (Executing) the binary file. Since Parsing and Compiling are two relatively time-consuming stages, many JS virtual machines that are used on end-side devices and are sensitive to performance choose to separate Parsing and Compiling, and let the compiler compile the source code file to generate a binary file. Figure 3 As shown, when the JS virtual machine loads a binary file, it only needs to execute instructions, which can improve performance compared to loading source code.

[0135] Figure 4 This is a schematic diagram of the JS application software package form, such as Figure 4 As shown in the figure, the application software packages of JavaScript language in the industry mainly have two forms: JS source code packages or compiled binary packages. For example, the Nodejs ecosystem uses source code packages; the ReactNative ecosystem uses binary packages.

[0136] Figure 5 A schematic diagram of a compilation scheme is shown in FIG. Figure 5 As shown in the figure, taking the Nodejs ecosystem as an example, application development uses source code dependency packages (also called dependency modules). By adding the name and version number of the dependency package to the corresponding fields in the package.json of the application project, and using the package management tool to download the dependent source code module from the Npm warehouse, that is, the source code package to the node_modules directory for development dependency or operation dependency, the development dependency source code module A will be compiled into the project source code by the packaging tool (such as webpack) to generate an installation package, which includes the source code module A; and the operation dependency source code module B is called during the operation of the application.

[0137] Figure 6 A schematic diagram of an application installation package generated using source code dependency packages for application development, such as Figure 6As shown, the application installation package includes source code module A and source code module B in source code form. However, before the source code file is loaded and executed by the JS virtual machine, it needs to go through preliminary processes such as parsing, compiling, and optimizing. Compared with direct execution of binary files, it is inefficient; and the security of the source code file is low, and code protection is difficult.

[0138] In large-scale application development scenarios, application engineering usually relies on commercial closed-source modules. For reasons such as commercial code protection and commercial security, closed-source module developers usually only release binary file packages compiled from source code (also called binary closed-source modules). Therefore, during the compilation process of the terminal application installation package, it is necessary to compile and package the source code module and the binary closed-source module at the same time. The current common practice in the industry is that application developers choose to download the binary closed-source module that is compatible with the JS virtual machine, and then only compile the source code module into a binary module, and package the binary module and the binary closed-source module together to obtain the application installation package.

[0139] Figure 7 A schematic diagram of another compilation scheme is shown below. Figure 7 As shown in the figure, taking the ReactNative framework ecosystem as an example, the source code modules that the application engineering and development depend on are compiled and packaged into binary modules by the compiler and installed on the end-side device. The binary closed-source modules that have been installed on the end-side are relied on and called by the application during the runtime, where the binary closed-source modules include binary modules. Since the modules that the application engineering development depends on and the modules that the operation depends on are all binary packages, the JS virtual machine can execute them directly without the need for preliminary processing during the runtime. Since the binary closed-source module itself is a compiled installation package, the binary modules it depends on will be compiled into its own binary file. Therefore, this method will cause duplicate modules to appear in the application installation package when the application engineering and the binary closed-source module depend on the same binary module, resulting in data redundancy in the application installation package and an increase in the total volume compared to source code compilation. The increase in the application size will also affect the performance when loading modules at runtime. In addition, the binary file is compiled and generated based on a specific version of the compiler, so the closed-source modules released in binary form have the problem of backward compatibility with the updated version of the virtual machine.

[0140] Figure 8 A schematic diagram of an application installation package generated using binary dependency packages for application development, such as Figure 8As shown in the figure, when both the binary module that the application project depends on and the binary closed-source module that the operation depends on have binary modules, the terminal device will install two binary modules, and the application will require more loading time during operation, resulting in an increase in the application startup time. Therefore, the binary closed-source module causes the application volume to expand and degrades the application loading time; in addition, the binary closed-source module is strongly associated with the JS virtual machine version, and there is a problem of incompatibility with the target virtual machine, which causes the application to fail to run normally.

[0141] In summary, for the two forms of JS application software packages, the above compilation scheme cannot take into account execution efficiency, virtual machine compatibility and the size of the compiled application.

[0142] Based on the above technical problems, an embodiment of the present invention provides a compilation method and an electronic device, wherein the electronic device includes a JS compiler that supports mixed compilation of source code and binary, so that application engineering development can take into account the execution efficiency on the application side and the size of the application installation package when relying on binary closed-source modules, and solve the compatibility problem of the binary closed-source modules backward adapting to the updated version of the virtual machine.

[0143] Fig. 9 A flowchart of a compilation method provided by an embodiment of the present invention. Fig. 9 As shown, the method includes:

[0144] Step 202: Perform a first compile operation on the first module and the second module to obtain a first intermediate compiled data structure and a second intermediate compiled data structure, wherein the second module includes a binary module corresponding to the first module.

[0145] In the embodiment of the present invention, each step is performed by an electronic device. The hardware structure and software structure of the electronic device provided by the embodiment of the present invention can be found in Figure 1 and Figure 2 Related description about electronic device 100.

[0146] In some possible embodiments, Fig.10 As shown, step 202 specifically includes:

[0147] Step 2022: Compile the first module to obtain a first intermediate compiled data structure.

[0148] Step 2024: Decompile the second module to obtain a second intermediate compiled data structure.

[0149] Among them, the first module is a source code module; the second module is a binary closed source module. Fig.11 Schematic diagram of a compilation scenario according to an embodiment of the present invention. Fig.11As shown, for example, the first electronic device is an electronic device used by a closed-source module developer, and the second electronic device is an electronic device used by an application developer; the closed-source module developer uses the first electronic device to convert a JS source code file into a binary closed-source module, and publishes the binary closed-source module to the cloud for sharing; the electronic device used by the application developer uses the second electronic device to download the binary closed-source module from the cloud, and compiles and packages the binary closed-source module and the source code module at the same time to generate an application installation package.

[0150] like Figure 3 As shown in the figure, after the source code file undergoes syntax analysis and compilation operations, an intermediate compiled data structure is obtained; after the intermediate compiled data structure undergoes optimization operations, an optimized intermediate compiled data structure is obtained. Since the object of the execution operation in the JS virtual machine is a binary file, it is necessary to first convert the optimized intermediate compiled data structure into a binary file, and then perform the execution operation on the binary file.

[0151] Since the second module includes a binary module corresponding to the first module, if the first module is compiled into a binary file and then directly packaged with the second module to generate an application installation package, there will be two binary modules corresponding to the first module in the application installation package, and there will be data redundancy. Therefore, the embodiment of the present invention needs to perform de-duplication and merging operations on the first module and the second module. However, the first module is a source code module, and the second module is a binary closed source module. It is impossible to directly perform de-duplication and merging operations on the first module and the second module, and the first module and the second module need to be converted into files of the same format first.

[0152] Since the intermediate compiled data structure is an intermediate product of converting a source code file into a binary file, in order to convert the first module and the second module into files of the same format, the embodiment of the present invention converts both the first module and the second module into the intermediate compiled data structure. Thus, the electronic device compiles the first module to obtain the first intermediate compiled data structure; and decompiles the second module to obtain the second intermediate compiled data structure, so as to perform subsequent de-duplication and merging operations.

[0153] There is no specific limitation on the execution order between step 2022 and step 2024, and they may be executed simultaneously or not simultaneously.

[0154] In some possible embodiments, step 202 specifically includes: performing a first compile operation on the first module and the second module through a compiler to obtain a first intermediate compiled data structure and a second intermediate compiled data structure, wherein the second module includes a binary module corresponding to the first module.

[0155] Exemplarily, the electronic device includes a compiler. The electronic device performs a first compiling operation on the first module and the second module through the compiler to obtain a first intermediate compiled data structure and a second intermediate compiled data structure. Therefore, the compiler can implement mixed compilation of source code files and binary files.

[0156] Step 204: perform a de-duplication and merging operation on the first intermediate compiled data structure and the second intermediate compiled data structure to obtain a first merged intermediate compiled data structure.

[0157] Fig.12 FIG. 1 is a schematic diagram of obtaining an application installation package according to a source code module and a binary closed source module in an embodiment of the present invention. Fig.12 As shown, the electronic device performs a first compilation operation on the source code module and the binary closed source module to obtain two intermediate compiled data structures, and then performs a de-duplication and merging operation on the two intermediate compiled data structures to obtain a merged intermediate compiled data structure, thereby removing redundant data and reducing the application size.

[0158] In some possible embodiments, step 204 specifically includes: performing a de-duplication and merging operation on the first intermediate compiled data structure and the second intermediate compiled data structure by a compiler to obtain a first merged intermediate compiled data structure.

[0159] Exemplarily, the electronic device performs a de-duplication and merging operation on the first intermediate compiled data structure and the second intermediate compiled data structure through a compiler to obtain a first merged intermediate compiled data structure. Therefore, after the compiler performs a mixed compilation operation on the source code file and the binary file, it also removes redundant data through a de-duplication and merging operation to reduce the size of the application installation package.

[0160] Fig.13 FIG. 1 is a schematic diagram of an example of a deduplication and merging operation in an embodiment of the present invention. Fig.13 As shown, for example, the first intermediate compiled data structure includes three data a, b, and c, and the second intermediate compiled data structure includes three data b, c, and d; wherein the storage addresses corresponding to the three data a, b, and c are 0x01, 0x02, and 0x03, respectively, and the storage addresses corresponding to the three data b, c, and d are 0x0a, 0x0b, and 0x0c, respectively. The two data b and c exist in both the first intermediate compiled data structure and the second intermediate compiled data structure. The first intermediate compiled data and the second intermediate compiled data structure are deduplicated and merged to obtain a first merged intermediate compiled data structure, which includes four data a, b, c, and d, wherein the storage addresses corresponding to the four data a, b, c, and d are 0x01, 0x02, 0x03, and 0x04, respectively.

[0161] Step 206: Obtain a first application installation package according to the first merged intermediate compilation data structure.

[0162] In some possible embodiments, Fig.14 As shown, step 206 specifically includes:

[0163] Step 2062: Convert the first merged intermediate compilation data structure into a first merged binary file.

[0164] In some possible embodiments, step 2062 specifically includes: converting the first merged intermediate compiled data structure into a first merged binary file through a compiler.

[0165] Step 2064: Package the first merged binary file to obtain a first application installation package.

[0166] In some possible embodiments, step 2064 specifically includes: packaging the first merged binary file through a compiler to obtain a first application installation package.

[0167] Fig.15 Schematic diagram of a compilation solution of an embodiment of the present invention, such as Fig.15 As shown, when the application source code used in the application project relies on both the source code module and the binary closed source module, the electronic device can compile the source code module and the binary closed source module in a mixed manner through the compiler, and directly output an application installation package that does not contain redundant data.

[0168] Optionally, before step 202, the method further includes:

[0169] Step 201 : In response to a user's downloading operation on a first module and a second module, the first module and the second module are downloaded, and step 202 is continued.

[0170] Exemplarily, the electronic device downloads the first module and the second module from the cloud.

[0171] Optionally, after step 206, the method further includes:

[0172] Step 208: In response to the user's download operation on the third module and the fourth module, download the third module and the fourth module.

[0173] The third module is a binary module, and the fourth module is a binary closed-source module.

[0174] Exemplarily, the electronic device downloads the third module and the fourth module from the cloud.

[0175] Step 210: Perform a second compile operation on the third module and the fourth module to obtain a third intermediate compiled data structure and a fourth intermediate compiled data structure.

[0176] In some possible embodiments, step 210 specifically includes: performing a decompile operation on the third module and the fourth module to obtain a third intermediate compiled data structure and a fourth intermediate compiled data structure.

[0177] In some possible embodiments, step 210 specifically includes: performing a second compiling operation on the third module and the fourth module by a compiler to obtain a third intermediate compiled data structure and a fourth intermediate compiled data structure.

[0178] Exemplarily, the electronic device performs a decompile operation on the third module and the fourth module through a compiler to obtain a third intermediate compiled data structure and a fourth intermediate compiled data structure.

[0179] Step 212: Perform a deduplication and merging operation on the third intermediate compiled data structure and the fourth intermediate compiled data structure to obtain a second merged intermediate compiled data structure.

[0180] In some possible embodiments, step 212 specifically includes: performing a de-duplication and merging operation on the third intermediate compiled data structure and the fourth intermediate compiled data structure by a compiler to obtain a second merged intermediate compiled data structure.

[0181] Exemplarily, the electronic device performs a de-duplication and merging operation on the third intermediate compiled data structure and the fourth intermediate compiled data structure through a compiler to obtain a second merged intermediate compiled data structure.

[0182] Step 214: Obtain a second application installation package according to the second merged intermediate compiled data structure.

[0183] In some possible embodiments, Fig.16 As shown, step 214 specifically includes:

[0184] Step 2142: Convert the second merged intermediate compiled data structure into a second merged binary file.

[0185] In some possible embodiments, step 2142 specifically includes: converting the second merged intermediate compiled data structure into a second merged binary file through a compiler.

[0186] Step 2144: package the second merged binary file to obtain a second application installation package.

[0187] In some possible embodiments, step 2144 specifically includes: packaging the second merged binary file through a compiler to obtain a second application installation package.

[0188] Exemplarily, the electronic device converts the second merged intermediate compiled data structure into a second merged binary file through a compiler, and the second merged binary file is a second application installation package.

[0189] In summary, no matter it is a pure source code file, a pure binary file, or a mixed file of a source code file and a binary file, the electronic device can obtain the application installation package through the compilation method provided by the embodiment of the present invention, and there will be no data redundancy problem.

[0190] Since the above compiler supports mixed compilation of source code files and binary files, whether it is a pure source code file, a pure binary file, or a mixed file of source code files and binary files, the application installation package can be obtained through the compiler provided by the embodiment of the present invention, and there will be no data redundancy problem.

[0191] The embodiment of the present invention does not specifically limit the execution order of steps 201-206 and steps 208-214, and steps 208-214 may also be executed before steps 201-206. Furthermore, steps 201-206 and steps 208-214 may also exist independently.

[0192] The application project references a binary third-party package, that is, a binary closed-source module. The binary file is a file compiled from the source code and usually cannot be re-compiled in the application project. Therefore, compared with the source code third-party package, the application size is expanded and the application loading time is degraded. The compilation method provided in the embodiment of the present invention can compile the source code and binary mixedly. In the scenario where the application project references a binary third-party package, by disassembling the compiled data from the binary closed-source module, the binary closed-source module can be re-compiled in the application project compilation, and duplicate data can be de-duplicated and merged; the application installation package produced after the application project is compiled is smaller in size, which improves the application loading performance.

[0193] When an application project references a binary third-party package and directly compiles the binary closed-source module into the application, compatibility issues may occur, such as incompatibility of the JS virtual machine, resulting in the inability to execute the application. The compilation method provided in the embodiment of the present invention can achieve the recompilation of the third-party package to be compatible with the existing JS virtual machine version in the scenario where the application project references a third-party package in binary form that is incompatible with the virtual machine. Specifically, the binary closed-source module is recompiled after disassembly, so that the developer of the binary closed-source module does not need to re-release an updated version, and the JS virtual machine can execute the originally incompatible binary closed-source module, thereby solving the compatibility problem of the binary closed-source module. Therefore, the embodiment of the present invention takes into account the execution efficiency of the application end and the size of the application installation package, and solves the compatibility problem of the binary closed-source module backward adaptation to the updated version of the JS virtual machine.

[0194] In the technical solution of the compilation method provided by the embodiment of the present invention, the electronic device performs a first compilation operation on a first module and a second module to obtain a first intermediate compilation data structure and a second intermediate compilation data structure, wherein the second module includes a binary module corresponding to the first module; a de-duplication and merging operation is performed on the first intermediate compilation data structure and the second intermediate compilation data structure to obtain a first merged intermediate compilation data structure; and a first application installation package is obtained according to the first merged intermediate compilation data structure. When the application project and the binary closed-source module depend on the same module, the application installation package will not have data redundancy and will be smaller in size.

[0195] Fig.17 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. It should be understood that the electronic device 300 can perform each step in the above screen projection method. To avoid repetition, it will not be described in detail here. The electronic device 300 includes: a processing unit 301.

[0196] The processing unit 301 is used to perform a first compilation operation on the first module and the second module to obtain a first intermediate compilation data structure and a second intermediate compilation data structure, wherein the second module includes a binary module corresponding to the first module; perform a deduplication and merging operation on the first intermediate compilation data structure and the second intermediate compilation data structure to obtain a first merged intermediate compilation data structure; and obtain a first application installation package according to the first merged intermediate compilation data structure.

[0197] Optionally, the processing unit 301 is specifically configured to perform a compile operation on the first module to obtain the first intermediate compiled data structure; and perform a decompile operation on the second module to obtain the second intermediate compiled data structure.

[0198] Optionally, the processing unit 301 is specifically configured to convert the first merged intermediate compiled data structure into a first merged binary file; and package the first merged binary file to obtain the first application installation package.

[0199] Optionally, the processing unit 301 is specifically configured to perform the first compiling operation on the first module and the second module through a compiler.

[0200] Optionally, the processing unit 301 is specifically configured to perform the de-overlapping and merging operation on the first intermediate compiled data structure and the second intermediate compiled data structure through a compiler.

[0201] Optionally, the processing unit 301 is specifically configured to:

[0202] Optionally, the processing unit 301 is further configured to convert the first merged intermediate compiled data structure into a first merged binary file through a compiler; and package the first merged binary file through the compiler to obtain the first application installation package.

[0203] Optionally, the processing unit 301 is further configured to download the first module and the second module in response to a user's download operation on the first module and the second module.

[0204] Optionally, the first module is a source code module; and the second module is a binary closed source module.

[0205] Optionally, the processing unit 301 is further used to perform a second compilation operation on the third module and the fourth module to obtain a third intermediate compilation data structure and a fourth intermediate compilation data structure, wherein the fourth module includes the third module; perform a deduplication and merging operation on the third intermediate compilation data structure and the fourth intermediate compilation data structure to obtain a second merged intermediate compilation data structure; and obtain a second application installation package based on the second merged intermediate compilation data structure.

[0206] Optionally, the processing unit 301 is specifically configured to perform a decompile operation on the third module and the fourth module to obtain the third intermediate compiled data structure and the fourth intermediate compiled data structure.

[0207] Optionally, the processing unit 301 is specifically configured to convert the second merged intermediate compiled data structure into a second merged binary file; and package the second merged binary file to obtain the second application installation package.

[0208] Optionally, the processing unit 301 is specifically configured to perform the second compiling operation on the third module and the fourth module through a compiler.

[0209] Optionally, the processing unit 301 is specifically configured to perform the de-duplication and merging operation on the third intermediate compiled data structure and the fourth intermediate compiled data structure through a compiler.

[0210] Optionally, the processing unit 301 is specifically configured to convert the second merged intermediate compiled data structure into a second merged binary file through a compiler; and package the second merged binary file through the compiler to obtain the second application installation package.

[0211] Optionally, the processing unit 301 is further configured to download the third module and the fourth module in response to a user's download operation on the third module and the fourth module.

[0212] Optionally, the third module is a binary module, and the fourth module is a binary closed-source module.

[0213] It should be understood that the electronic device 300 here is embodied in the form of a functional unit. The term "unit" here can be implemented in the form of software and / or hardware, and is not specifically limited to this. For example, a "unit" can be a software program, a hardware circuit, or a combination of the two that implements the above functions. The hardware circuit may include an application-specific integrated circuit (ASIC), an electronic circuit, a processor (such as a shared processor, a proprietary processor, or a group processor, etc.) and a memory for executing one or more software or firmware programs, a merged logic circuit, and / or other suitable components that support the described functions.

[0214] Therefore, the units of each example described in the embodiments of the present invention can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0215] The embodiment of the present application provides an electronic device, which may be a terminal device or a circuit device built into the terminal device. The electronic device may be used to execute the functions / steps in the above method embodiment.

[0216] An embodiment of the present application provides a computer-readable storage medium, in which instructions are stored. When the instructions are executed on a terminal device, the terminal device executes the functions / steps in the above method embodiment.

[0217] The embodiment of the present application also provides a computer program product comprising instructions, and when the computer program product is run on a computer or any at least one processor, the computer executes the functions / steps in the above method embodiment.

[0218] In the embodiments of the present application, "at least one" refers to one or more, and "plurality" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. Among them, A and B can be singular or plural. The character " / " generally indicates that the previous and subsequent associated objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can be represented by: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.

[0219] Those of ordinary skill in the art will appreciate that the various units and algorithm steps described in the embodiments disclosed herein can be implemented in a combination of electronic hardware, computer software, and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0220] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0221] In several embodiments provided in the present application, any function can be stored in a computer-readable storage medium if it is implemented in the form of a software functional unit and sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for enabling an electronic device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0222] The above is only a specific implementation of the present application. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. The protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A compiling method, characterized in that: The method comprises: Performing a first compile operation on the first module and the second module to obtain a first intermediate compiled data structure and a second intermediate compiled data structure, wherein the second module includes a binary module corresponding to the first module; performing a de-duplication and merging operation on the first intermediate compiled data structure and the second intermediate compiled data structure to obtain a first merged intermediate compiled data structure; A first application installation package is obtained according to the first merged intermediate compiled data structure.

2. The method according to claim 1, characterized in that The performing a first compile operation on the first module and the second module to obtain a first intermediate compiled data structure and a second intermediate compiled data structure includes: Compiling the first module to obtain the first intermediate compiled data structure; Decompile the second module to obtain the second intermediate compiled data structure.

3. The method according to claim 1 or 2, characterized in that: The step of obtaining a first application installation package according to the first merged intermediate compiled data structure includes: Converting the first merged intermediate compiled data structure into a first merged binary file; The first merged binary file is packaged to obtain the first application installation package.

4. The method according to any one of claims 1 to 3, characterized in that The performing a first compiling operation on the first module and the second module includes: The first compiling operation is performed on the first module and the second module by a compiler.

5. The method according to any one of claims 1 to 4, characterized in that The performing a de-duplication and merging operation on the first intermediate compiled data structure and the second intermediate compiled data structure includes: The compiler performs the de-overlapping and merging operation on the first intermediate compiled data structure and the second intermediate compiled data structure.

6. The method according to any one of claims 1 to 5, characterized in that The step of obtaining a first application installation package according to the first merged intermediate compiled data structure includes: Converting the first merged intermediate compiled data structure into a first merged binary file by a compiler; The first merged binary file is packaged by the compiler to obtain the first application installation package.

7. The method according to any one of claims 1 to 6, characterized in that Before performing the first compile operation on the first module and the second module, the method further includes: In response to a user's downloading operation on the first module and the second module, the first module and the second module are downloaded.

8. The method according to any one of claims 1 to 7, characterized in that The first module is a source code module; the second module is a binary closed source module.

9. The method according to any one of claims 1 to 8, characterized in that The method further comprises: Performing a second compiling operation on the third module and the fourth module to obtain a third intermediate compiled data structure and a fourth intermediate compiled data structure, wherein the fourth module includes the third module; performing a de-duplication and merging operation on the third intermediate compiled data structure and the fourth intermediate compiled data structure to obtain a second merged intermediate compiled data structure; A second application installation package is obtained according to the second merged intermediate compiled data structure.

10. The method according to claim 9, characterized in that The performing the second compiling operation on the third module and the fourth module to obtain the third intermediate compiled data structure and the fourth intermediate compiled data structure includes: Decompile the third module and the fourth module to obtain the third intermediate compiled data structure and the fourth intermediate compiled data structure.

11. The method according to claim 9 or 10, characterized in that: The step of obtaining a second application installation package according to the second merged intermediate compiled data structure includes: converting the second merged intermediate compiled data structure into a second merged binary file; The second merged binary file is packaged to obtain the second application installation package.

12. The method according to any one of claims 9 to 11, characterized in that: The performing a second compiling operation on the third module and the fourth module includes: The second compiling operation is performed on the third module and the fourth module by a compiler.

13. The method according to any one of claims 9 to 12, characterized in that: The performing a de-duplication and merging operation on the third intermediate compiled data structure and the fourth intermediate compiled data structure comprises: The de-duplication and merging operation is performed on the third intermediate compiled data structure and the fourth intermediate compiled data structure by a compiler.

14. The method according to any one of claims 9 to 12, characterized in that: The step of obtaining a second application installation package according to the second merged intermediate compiled data structure includes: Converting the second merged intermediate compiled data structure into a second merged binary file by a compiler; The second merged binary file is packaged by the compiler to obtain the second application installation package.

15. The method according to any one of claims 9 to 14, characterized in that: Before performing the second compiling operation on the third module and the fourth module, the method further includes: In response to a user's downloading operation on the third module and the fourth module, the third module and the fourth module are downloaded.

16. The method according to any one of claims 9 to 15, characterized in that: The third module is a binary module, and the fourth module is a binary closed-source module.

17. An electronic device, characterized in that: The electronic device comprises a processor and a memory, wherein the memory is used to store a computer program, and the computer program comprises program instructions. When the processor runs the program instructions, the electronic device executes the steps of the method as claimed in any one of claims 1 to 16.

18. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program request is executed by a computer, the computer is caused to execute the method according to any one of claims 1 to 16.

Citation Information

Cited By

  • Self-construction context decompiling method and device and storage medium

    CN119356690A

  • A self-constructed context decompilation method, device and storage medium

    CN119356690B