Program data processing method and device, electronic equipment, medium and program product

CN116775099BActive Publication Date: 2026-09-22TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210234951.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-09
Publication Date
2026-09-22
Estimated Expiration
2042-03-09

AI Technical Summary

Benefits of technology

[0018]相应地,根据本申请的一个方面,提供了一种计算机程序产品或者计算机程序,该计算机程序产品或计算机程序包括程序指令,该程序指令存储在计算机可读存储介质中。计算机设备的处理器从计算机可读存储介质读取该程序指令,处理器执行该程序指令,使得该计算机设备执行上述提供的程序数据处理方法。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116775099B_ABST
    Figure CN116775099B_ABST
Patent Text Reader

Abstract

Embodiments of the application disclose a program data processing method and device, electronic equipment, medium and program product, which are applied to the technical field of cloud. The method comprises the following steps: obtaining a program compilation file of an application program; the program compilation file comprises at least one compilation statement; performing syntax analysis on the compilation statements; determining a new compilation statement in the at least one compilation statement based on the syntax analysis result; obtaining a target program resource library called by the new compilation statement; obtaining a program resource package set called by the at least one compilation statement in the target program resource library; and determining a packaging strategy for the target program resource library based on the program resource package set. The embodiments of the application can improve the optimization effect of the installation package size. The embodiments of the application can be applied to various scenes such as cloud technology, artificial intelligence, intelligent transportation and auxiliary driving.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of cloud technology, and in particular to a program data processing method, apparatus, electronic device, medium, and program product. Background Technology

[0002] Currently, program resource libraries can be packaged according to preset packaging methods to obtain corresponding installation packages. Programs can then call the required program resource packages based on the program resource libraries packaged in the installation package. For example, a program can call a program resource package with image recognition capabilities to enable the program to perform image recognition.

[0003] One approach to packaging an application involves packaging each resource library separately, then having technical staff, based on experience, determine whether to streamline the packaging to reduce the installation package size. However, manual judgment is inaccurate, leading to low packaging efficiency and limited effectiveness in optimizing the installation package size. Therefore, improving packaging efficiency and optimizing the installation package size has become a pressing issue. Summary of the Invention

[0004] This application provides a program data processing method, apparatus, electronic device, medium, and program product, which can improve the efficiency and accuracy of determining the packaging method for program resource packages, and can improve the size optimization effect of program installation packages.

[0005] On one hand, embodiments of this application provide a program data processing method, the method comprising:

[0006] Obtain the application's compiled file; the compiled file contains at least one compilation statement; the compiled file has at least one associated program resource library, and any program resource library contains at least one program resource package called by at least one compilation statement;

[0007] Perform syntax analysis on the compilation statements contained in the program compilation file, and determine the newly added compilation statement in at least one compilation statement based on the syntax analysis results;

[0008] Obtain the target program resource library called by the newly added compilation statement from at least one program resource library;

[0009] Obtain a set of program resource packages called by at least one compilation statement in the target program resource library, and determine a packaging strategy for the target program resource library based on the set of program resource packages; the target program resource library packaged based on the packaging strategy is used to generate the application's program installation package.

[0010] On one hand, embodiments of this application provide a program data processing apparatus, the apparatus comprising:

[0011] The acquisition module is used to acquire the program compilation file of the application; the program compilation file contains at least one compilation statement; the program compilation file has at least one associated program resource library, and any program resource library contains at least one program resource package called by at least one compilation statement;

[0012] The processing module is used to perform syntax analysis on the compilation statements contained in the program compilation file, and determine the newly added compilation statement in at least one compilation statement based on the syntax analysis results.

[0013] The acquisition module is also used to acquire the target program resource library called by the newly added compilation statement from at least one program resource library;

[0014] The acquisition module is also used to acquire a set of program resource packages called by at least one compilation statement in the target program resource library;

[0015] The determination module is also used to determine a packaging strategy for the target program resource library based on the program resource package set; the target program resource library packaged based on the packaging strategy is used to generate the application's program installation package.

[0016] On one hand, embodiments of this application provide an electronic device including a processor and a memory, wherein the memory is used to store a computer program, the computer program including program instructions, and the processor is configured to invoke the program instructions to execute some or all of the steps in the above method.

[0017] On one hand, embodiments of this application provide a computer-readable storage medium storing a computer program, the computer program including program instructions, which, when executed by a processor, are used to perform some or all of the steps in the above-described method.

[0018] Accordingly, according to one aspect of this application, a computer program product or computer program is provided, comprising program instructions stored in a computer-readable storage medium. A processor of a computer device reads the program instructions from the computer-readable storage medium and executes the program instructions, causing the computer device to perform the program data processing method provided above.

[0019] In this embodiment, the application's compiled program file can be obtained, its compiled statements can be parsed, and new compiled statements in the compiled program file can be identified based on the parsing results. The target program resource package called by the new compiled statements can be obtained, and the program resource library to which the target program resource package belongs can be identified as the target program resource library. At least one set of program resource packages called by a compiled statement in the target program resource library can be obtained, and a packaging strategy for the target program resource library can be determined based on the set of program resource packages. Through this method, the optimal packaging strategy can be determined based on the set of called program resource packages, improving the efficiency and accuracy of packaging strategy determination. Furthermore, this packaging strategy can make the program installation package smaller than the program installation package obtained under other packaging strategies for the target program resource library, thereby improving the size optimization effect of the program installation package. Attached Figure Description

[0020] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1 A schematic diagram of an application architecture provided for an embodiment of this application;

[0022] Figure 2 A flowchart illustrating a program data processing method provided in an embodiment of this application;

[0023] Figure 3 A schematic diagram illustrating a scenario for determining newly added compilation statements, provided as an embodiment of this application;

[0024] Figure 4 A flowchart illustrating a program data processing method provided in an embodiment of this application;

[0025] Figure 5 A schematic diagram of a syntax analysis tree provided for an embodiment of this application;

[0026] Figure 6 A flowchart illustrating a multi-process data processing method is provided as an embodiment of this application.

[0027] Figure 7 An interactive schematic diagram of a program data processing flow provided for an embodiment of this application;

[0028] Figure 8 A schematic diagram illustrating the amount of packaged data provided in an embodiment of this application;

[0029] Figure 9This is a schematic diagram of the structure of a program data processing device provided in an embodiment of this application;

[0030] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0031] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0032] The program data processing method proposed in this application is implemented in an electronic device, which can be a server or a terminal. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The terminal can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, smart voice interaction device, smart home appliance, vehicle terminal, aircraft, etc., but is not limited to these. This application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, and assisted driving.

[0033] Next, the technical terms involved in the technical field to which the solutions of the embodiments of this application may be applied will be introduced:

[0034] I. Artificial Intelligence:

[0035] This application relates to the field of artificial intelligence (AI) technology. AI is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new type of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess perception, reasoning, and decision-making functions. For example, AI technology can be used to perform syntax analysis on the compiled program files in the technical solution of this application.

[0036] II. Cloud Technology:

[0037] Cloud technology is a collective term for network technologies, information technologies, integration technologies, management platform technologies, and application technologies applied based on the cloud computing business model. It can form resource pools, providing flexible and convenient on-demand access. Cloud computing technology will become a crucial support. Backend services of technical network systems require substantial computing and storage resources, such as video websites, image websites, and many portal websites. With the rapid development and application of the internet industry, every item may have its own identification mark in the future, requiring transmission to backend systems for logical processing. Data at different levels will be processed separately, and various industry data will all require robust system support, which can only be achieved through cloud computing.

[0038] In one possible implementation, the program data processing method provided in this application embodiment can be combined with cloud technology. For example, the packaging strategy of program compilation files and associated program resource libraries can be used to store this data through cloud storage technology, facilitating further application of this data. Cloud storage is a new concept that extends and develops from the concept of cloud computing. A distributed cloud storage system (hereinafter referred to as a storage system) refers to a storage system that uses cluster applications, grid technology, and distributed storage file systems to aggregate a large number of various types of storage devices (also called storage nodes) in a network through application software or application interfaces to work together and jointly provide data storage and business access functions.

[0039] In some embodiments, see Figure 1 , Figure 1 This is a schematic diagram of an application architecture provided for an embodiment of this application, through which the program data processing method proposed in this application can be executed. For example... Figure 1 As shown, it can include electronic devices, target objects, and terminal devices. The target object can be a developer. The electronic device can obtain the program compilation files generated by the developer during the application development process, perform syntax analysis on the program compilation files to determine newly added compilation statements, the target program resource libraries called by the newly added compilation statements, and the set of program resource packages called by the program compilation files in the target program resource libraries. Based on this set of program resource packages, a packaging strategy for the target program resource libraries is determined. The electronic device can perform packaging operations according to the packaging strategies of all program resource libraries associated with the program compilation files to obtain the application's installation package. The electronic device can then send the installation package to the terminal device, allowing the terminal device to install the application. The terminal device can call the corresponding packaged program resource packages in different business scenarios within the application.

[0040] Understandable, Figure 1 This is merely an illustrative representation of a possible application architecture for the technical solution of this application, and does not limit the specific architecture of the technical solution of this application. That is, the technical solution of this application may also provide other forms of application architecture.

[0041] Optionally, in some embodiments, the electronic device can execute the program data processing method according to actual business needs to improve the size optimization effect of the program installation package. The technical solution of this application can be applied to any application installation package size optimization scenario. That is, the electronic device can obtain the application's program compilation file, perform syntax analysis on the program compilation file to determine the newly added compilation statements in the program compilation file, determine the target program resource library to be called based on the newly added compilation statements, determine the set of program resource packages that the program compilation file can call from the target program resource library, and determine the optimal packaging strategy for the target program resource library based on the set of program resource packages. Subsequently, the target program resource library can be packaged based on the optimal packaging strategy to obtain the program installation package. The determined packaging strategy can minimize the size of the program installation package and improve the efficiency and accuracy of determining the packaging strategy for the program resource library.

[0042] Optionally, the data involved in this application, such as program compilation files and packaging strategies for the target program resource library corresponding to the application, can be stored in a database or in a blockchain. This application does not limit the storage of such data through a blockchain distributed system.

[0043] It is understood that the above scenarios are merely examples and do not constitute a limitation on the application scenarios of the technical solutions provided in the embodiments of this application. The technical solutions of this application can also be applied to other scenarios. For example, as those skilled in the art will know, with the evolution of system architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.

[0044] Based on the foregoing description, this application proposes a program data processing method, which can be executed by the aforementioned electronic device. Please refer to... Figure 2 , Figure 2 This is a flowchart illustrating a program data processing method provided in an embodiment of this application. Figure 2 As shown, the flow of the program data processing method in this application embodiment may include the following:

[0045] S201. Obtain the application's compiled files.

[0046] The program compilation file contains at least one compilation statement; the program compilation file has at least one associated program resource library, and any program resource library contains at least one program resource package called by at least one compilation statement.

[0047] In some embodiments, the application can be a program in any scenario, such as an application software program, applet, or webpage program installed on any terminal device. The compiled file can be the source code file corresponding to the application, and at least one compilation statement can be derived from the source code written by the developer to develop the application. Furthermore, the compilation statements in the compiled file can be source code in any computer language, such as source code in Java (a computer programming language), C (a computer programming language), etc.

[0048] In some embodiments, the electronic device may acquire the corresponding program compilation file during the research and development process. Specifically, it may acquire the currently generated program compilation file once every specified period (e.g., every 5 minutes), or it may detect the research and development operations of the developers and acquire the program compilation file that has been generated at this time when a research and development operation that meets the trigger conditions is detected (e.g., it may detect that the compilation statement that is entered in real time or edited is the source code that calls the program resource package or the program resource library, etc.), or it may acquire the complete program compilation file after the research and development is completed, such as when the installation package optimization request sent by the developers after the research and development is completed is detected.

[0049] In some embodiments, the program resource library is a pre-defined library containing at least one program resource package. Each program resource package contains multiple program codes, which enable the program resource package to perform corresponding business functions. For example, it may be a program resource package capable of image recognition or image enhancement. The program codes in the program resource package can be in any language, such as JavaScript (JS, a lightweight, interpreted, or just-in-time compiled programming language) or VBScript (a lightweight interpreted language). The application can use the business functions provided by the program resource package by calling it in the corresponding pre-defined business scenario, based on the specific usage described in the program compilation file. For example, the program compilation file may contain some compilation statements to describe: in an image recognition scenario, if the application collects a user's face image, it calls a program resource package with image recognition function to perform image recognition processing on the face image; wherein, in the specific implementation of this application, if user information such as user face images and other related data are involved, when the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0050] In some embodiments, an application may invoke a program resource package as indicated by the compilation statements contained in the corresponding program compilation file. Since the invoked program resource package belongs to a program resource library, the program resource libraries to which all invoked program resource packages in the program compilation file belong can be considered as at least one program resource library associated with the program compilation file. Different program resource libraries may contain different program resource packages, and the at least one program resource library associated with the program compilation files of different applications may be different.

[0051] In some embodiments, at least one compilation statement may include a first compilation statement of a first type, a second compilation statement of a second type, and a third compilation statement of a third type. The first compilation statement is used to call a first compilation statement of a program resource package, the second compilation statement is used to call a second compilation statement of a program resource library, and the third compilation statement is not used to call any program resource package or any program resource library (e.g., business logic code). A first compilation statement may call one or more program resource packages, which may come from the same or different program resource libraries. The resulting program installation package will contain all program resource packages called by at least one compilation statement in the packaged result, and all the called program resource packages can be considered as program resource packages that the application will actually use.

[0052] In some embodiments, when a second compilation statement of the second type exists in the program compilation file, one or more first compilation statements associated with that second compilation statement will also exist in the program compilation file. These associated first compilation statements indicate the program resource packages actually used in the program resource library called by the second compilation statement. For example, when a second compilation statement exists and indicates a call to program resource library A, there will be a first compilation statement associated with the second compilation statement, used to indicate the program resource packages actually called (actually used) from program resource library A. That is, the resulting program installation package will contain all the program resource packages included in the program resource library called by the packaged second compilation statement, but the application will actually use a portion of the included program resource packages (i.e., the program resource packages indicated by the associated first compilation statement in that program resource library).

[0053] It is understandable that the program resource packages called by the electronic device are those referenced in the program installation package, and the program resource libraries called are those referenced in the program installation package. When a second compilation statement calls program resource library A, it means that the program installation package references the entire program resource library A, and the application has the permission to call any program resource package in program resource library A (but which program resource package in program resource library A the application actually calls in a specific business scenario is determined based on the associated first compilation statement). Conversely, when there is no second compilation statement calling program resource library B, but a first compilation statement calls program resource package C in program resource library B, it means that the program installation package references program resource package C separately, and the application only has the permission to call program resource package C in program resource library B. Furthermore, the packaging strategy for program resource libraries can be understood as a referencing strategy for program resource libraries.

[0054] S202. Perform syntax analysis on the compilation statements contained in the program compilation file, and determine the newly added compilation statement in at least one compilation statement based on the syntax analysis results.

[0055] In one possible implementation, the program compilation file can be the compilation file of the application at a first moment; the electronic device performs syntax analysis on the compilation statements contained in the program compilation file, and determines the newly added compilation statements in the program compilation file based on the syntax analysis results. Specifically, it can generate the first statement analysis result for the program compilation file, and obtain the second statement analysis result of the historical program compilation file of the application at a second moment.

[0056] The second time step mentioned above is earlier than the first time step. This historical program compilation file contains at least one historical compilation statement. The analysis result of this second statement is the result of the historical statement analysis. Syntax analysis is performed on the program compilation file using the analysis results of the first and second statements. Based on the obtained syntax analysis results, newly added compilation statements are identified in at least one compilation statement. These newly added compilation statements were added to the program compilation file between the first and second time steps. In other words, the program compilation file obtained at the first time step is based on the historical program compilation file at the second time step and the newly added compilation statements.

[0057] The first moment can be the moment when the currently generated program compilation file is obtained, that is, the program compilation file at the first moment is the latest compilation file. The second moment can be any specified moment earlier than the first moment. The second moment can be specified by the developer or determined by the electronic device according to the method of obtaining the program compilation file. There is no limitation here.

[0058] For example, if the program compilation file is obtained once every specified period, the first moment is the moment corresponding to the current period, and the second moment can be the moment corresponding to the previous period; if the program compilation file is obtained when a development operation that meets the trigger condition is detected, the first moment is the moment corresponding to the current detection point, and the second moment can be the moment corresponding to the previous detection point; if the program compilation file is obtained after the development is completed, the first moment is the moment corresponding to the moment when the complete program compilation file is written, and the second moment can be the initial moment, that is, the moment when the compilation file has not been written. At this time, the historical program compilation file obtained is the initial program compilation file, which does not contain the source code written by the developers.

[0059] It is understood that the technical solution of this application lies in its ability to determine the newly added compilation statements in the program compilation file at the first moment, and to determine the packaging strategy for the target program resource library to which the target program resource package belongs based on the target program resource package called by the newly added compilation statements. According to the packaging strategy for the target program resource library, the corresponding strategy compilation statement can be obtained, and it can be determined whether the program compilation file needs to be updated based on the strategy compilation statement corresponding to the packaging strategy. Thus, an updated (or unupdated) program compilation file can be obtained as the target program compilation file corresponding to the first moment, and the obtained historical program compilation file at the second moment is the target program compilation file obtained based on the application's program compilation file at the second moment. Therefore, this application can be understood as an iterative process of determining the optimal packaging strategy for the target program resource library at different moments, and updating the latest compilation file at different moments according to the optimal packaging strategy, thereby obtaining the final program compilation file.

[0060] For example, such as Figure 3 As shown, Figure 3 This is a schematic diagram of a scenario for determining newly added compilation statements provided in an embodiment of this application; wherein, the method of obtaining program compilation statements is to obtain them every specified period, and the third time is the arrival time of the xth period, the second time is the arrival time of the (x+1)th period, and the first time is the arrival time of the (x+2)th period;

[0061] (1) The electronic device obtains the program compilation file at the first moment (let's call it file A) and the historical program compilation file at the second moment (let's call it file B). It performs syntax analysis on file A and file B to determine the new compilation statement ① in file A compared to file B, and determines the packaging strategy ① for program resource library ① based on the new compilation statement ①. If the packaging method for program resource library ① in file A is packaging strategy ① at this time, then file A is determined as the target program compilation file at the first moment. If the packaging method for program resource library ① in file A is not packaging strategy ① at this time, then the packaging method for program resource library ① in file A is updated to packaging strategy ①, and the updated file A is determined as the target program compilation file at the first moment. When obtaining the historical program compilation file at the first moment later, the target program compilation file is obtained.

[0062] (2) Therefore, the historical program compilation file at the second moment is the target program compilation file at the second moment; the electronic device obtains the program compilation file at the second moment (let's say file C) and the historical program compilation file of the application at the third moment (let's say file D), performs syntax analysis on file C and file D to determine the newly added compilation statement ② in file C compared to file D, and determines the packaging strategy ② for program resource library ② (which can be the same resource library ①) based on the newly added compilation statement ②. If the packaging method for program resource library ② in file C is packaging strategy ② at this time, then file C is determined as the target program compilation file at the second moment. If the packaging method for program resource library ② in file C is not packaging strategy ② at this time, then the packaging method for program resource library ② in file C is updated to the packaging strategy ②, and the updated file C is determined as the target program compilation file at the second moment (i.e., file B is obtained).

[0063] In some embodiments, the electronic device generates a first statement analysis result for a program compilation file by performing statement analysis on each compilation statement in the program compilation file to obtain structured information for each compilation statement, and determining the structured information as the first statement analysis result. The structured information is used to indicate the elements and meanings contained in the corresponding compilation statement.

[0064] For example, if the compilation statement is "X1 = X2", the structured information obtained from statement analysis can be: element "X1" and its meaning, element "=" and its meaning, element "X2" and its meaning, with each element corresponding to a sub-compilation statement. That is, when a compilation statement can call a program resource package, the structured information corresponding to that statement contains a string representing the program resource package, and a meaning indicating that the corresponding element is a program resource package in a program library; when a compilation statement can call a program library, the structured information corresponding to that statement contains a string representing the program library, and a meaning indicating that the corresponding element is a program library. The method for obtaining the analysis results of the second statement in a historical program compilation file can be the same as that for the analysis results of the first statement.

[0065] Optionally, the system may obtain the historical program compilation file at the second time step and perform statement analysis on the historical program compilation file to obtain the second statement analysis result. Alternatively, it may perform statement analysis to obtain the second statement analysis result when the historical program compilation file at the second time step is determined, and cache the second statement analysis result for retrieval by the electronic device. Therefore, when the electronic device determines the target program compilation file at the first time step, it may either cache the target program compilation file or determine the target statement analysis result of the target program compilation file and cache the target statement analysis result for retrieval in the next time step.

[0066] In some embodiments, the electronic device performs syntax analysis on the program compilation file using the first statement analysis result and the second statement analysis result. Based on the obtained syntax analysis result, it determines at least one new compilation statement in the compilation statement. Specifically, it compares the structured information of each compilation statement included in the first statement analysis result with the structured information of each historical compilation statement included in the second statement analysis result to obtain the difference structured information between the first statement analysis result and the second statement analysis result. This difference structured information is structured information that exists in the first statement analysis result but does not exist in the second statement analysis result. The compilation statement corresponding to this difference structured information in the program compilation file is determined as the new compilation statement.

[0067] For example, the analysis result of the first statement contains structured information 1 for compiling statement A, structured information 2 for compiling statement B, and structured information 3 for compiling statement C. The analysis result of the second statement contains structured information 4 for compiling statement B (assuming structured information 4 is the same as structured information 2), structured information 5 for compiling statement C (assuming structured information 5 is different from structured information 3), and structured information 6 for compiling statement D. After comparison, structured information 3 and structured information 1 are found to be different structured information, which can be considered as structured information not present in the analysis result of the second statement. Since the historical program compilation file is the compilation file that has been updated at the second time step (i.e., executed with the described installation package size optimization steps), the newly added compilation statements between the first and second time steps can be obtained, and the latest program compilation file can be optimized based on these newly added compilation statements.

[0068] S203. Obtain the target program resource library called by the newly added compilation statement from at least one program resource library.

[0069] In some embodiments, the newly added compilation statement can be one or more. If the newly added compilation statement contains a first compilation statement that calls a program resource package, then the program resource package called by the newly added compilation statement is identified as the target program resource package, and the program resource library to which the target program resource package belongs is identified as the target program resource library.

[0070] The target program resource package can be one or more, and the corresponding target program resource library can also be one or more. If the newly added compilation statement contains a second compilation statement that calls a program resource library, then the called program resource library is identified as the target program resource library. If all the newly added compilation statements are third compilation statements, that is, if the newly added compilation statements do not call any program resource package or program resource library, then it means that the newly added compilation statements do not call any target program resource library, and the following steps are not executed. The program compilation file at this time is used as the target program compilation file at the first moment. The determination of whether the newly added compilation statement calls a program resource package or a program resource library can be determined by the electronic device from the structured information corresponding to the newly added compilation statement.

[0071] In some embodiments, the program resource package (or program library) called by the newly added compilation statement can be understood as a newly called program resource package (or program library) between the first and second time points. This newly called program resource package (or program library) can be a program resource package (or program library) that has not been called before, i.e., a program resource package (or program library) that has not been called in historical compilation files, or it can be a program resource package (or program library) that has been called before, i.e., a program resource package (or program library) that has been called in historical compilation files. Therefore, the target program resource library can be understood as a program resource library with a new call record, and the newly added compilation statement contains a compilation statement that causes the program resource library to have a new call record.

[0072] S204. Obtain a set of program resource packages called by at least one compilation statement in the target program resource library, and determine a packaging strategy for the target program resource library based on the set of program resource packages.

[0073] The packaging strategy determines whether to package the entire target program resource library or only the program resources contained in the program resource package set, and how the target program resource library packaged according to the packaging strategy is used to generate the application's installation package. In other words, the installation package contains the resource files indicated by the packaging strategy. If the packaging strategy instructs to package the target program resource library, the installation package contains the target program resource library, that is, all program resource packages in the target program resource library; if the packaging strategy instructs to package the program resource package set, the installation package only contains all program resource packages in the program resource package set.

[0074] In some embodiments, the electronic device may obtain a set of program resource packages called by at least one compiler statement in a target program resource library by: determining, based on the structured information corresponding to each compiler statement in the at least one compiler statement, that a compiler statement calling a program resource package exists; obtaining the program resource package called by the aforementioned compiler statement; and obtaining one or more program resource packages belonging to the target program resource library from the aforementioned called program resource packages, as a set of program resource packages. Specifically, when the target program resource library is determined by a program resource library called by a newly added compiler statement belonging to a second compiler statement, obtaining the set of program resource packages may involve determining program resource packages belonging to the target program resource library from all program resource packages called by the first compiler statement in the at least one compiler statement; when the target program resource library is determined by program resource packages called by a newly added compiler statement belonging to a first compiler statement, obtaining the set of program resource packages may involve determining program resource packages belonging to the target program resource library from all program resource packages called by the first compiler statement (excluding the newly added compiler statement) in the at least one compiler statement, and determining the aforementioned program resource packages and the program resource packages called by the newly added compiler statement as a set of program resource packages.

[0075] In some embodiments, the electronic device determines a packaging strategy for a target program resource library based on a set of program resource packages. Specifically, this involves obtaining a first packaging data volume for packaging the set of program resource packages and a second packaging data volume for packaging the target program resource library. The packaging strategy for the target program resource library is then determined based on the first and second packaging data volumes. The first packaging data volume is the sum of the packaging data volumes obtained by packaging each program resource package in the set separately, and the second packaging data volume is the packaging data volume obtained by packaging the entire target program resource library. The first packaging data volume refers to the volume occupied by the packaging result after packaging the set of program resource packages in the program installation package, and the second packaging data volume refers to the volume occupied by the packaging result after packaging the target program resource library in the program installation package. Therefore, the overall size of the program installation package can be optimized by optimizing this occupied volume.

[0076] The first packaged data volume can be determined based on the data size of each program resource package in the program resource package set and the data size of the resource package association information of each program resource package, and the second packaged data volume can be determined based on the data size of each program resource package in the target program resource library and the data size of the resource library association information of the target program resource library. For a detailed description, please refer to the relevant descriptions in the following embodiments.

[0077] The aforementioned set of program resource packages typically comprises a subset of program resource packages from the target program resource library. It should be noted that if the set includes all program resource packages from the target program resource library, meaning the application will actually use all program resource packages from the target program resource library, then subsequent steps can be omitted, and the packaging strategy for the target program resource library can be directly set to package the entire target program resource library.

[0078] In some embodiments, the electronic device determines the packaging strategy for the target program resource library based on the first packaged data volume and the second packaged data volume. Specifically, if the first packaged data volume is less than the second packaged data volume, the packaging strategy is determined to be a strategy for packaging the program resource package set; if the first packaged data volume is greater than or equal to the second packaged data volume, the packaging strategy is determined to be a strategy for packaging the target program resource library. Packaging the entire program resource library or packaging specific program resource packages within the program resource library can both be considered as a packaging strategy for the program resource library.

[0079] The packaging strategy of the program resource library has a corresponding strategy compilation statement. This strategy compilation statement is different under different packaging strategies. When the packaging strategy is to package the program resource library as a whole, the strategy compilation statement belongs to the second type of second compilation statement. That is, the second compilation statement can indicate that the entire program resource library is called into the program installation package, which indicates the packaging strategy of the program resource library. When the packaging strategy is to package specific program resource packages, the strategy compilation statement belongs to the first type of first compilation statement. That is, the first compilation statement can include compilation statements that indicate that the specific program resource package is called into the program installation package and that the packaging strategy of the program resource library to which the specific program resource package belongs (let's call it compilation statement I).

[0080] In addition, the first compilation statement mentioned above may also include the following two types of compilation statements: (1) a compilation statement indicating how the application calls the program resource package in compilation statement I to use (let's call it compilation statement II), that is, compilation statement II is used to indicate the specific calling method of the program resource package referenced by compilation statement I; (2) a compilation statement indicating how the application calls the program resource package to be used in the program resource library corresponding to the second compilation statement to use (let's call it compilation statement III), that is, compilation statement III is used to indicate the specific calling method of the specified program resource package in the referenced program resource library, these specified program resource packages are the program resource packages actually used in the referenced program resource library, and this type of compilation statement III is associated with the second compilation statement corresponding to the program resource library.

[0081] For example, (1) the second compiler statement “AAA①” indicates that the entire program resource library ① is referenced and the packaging strategy of the program resource library ① is applied; (2) the first compiler statement (compiler statement I) “AAA②.m” indicates that the program resource package m in the program resource library ② is referenced and the packaging strategy of the program resource library ② is applied; (3) the first compiler statement (compiler statement III) “①.n(X1,X2)” indicates that the program resource package n in the program resource library ① is referenced and the specific calling method is to input X1 and X2 into the program resource package n for calculation. This first compiler statement is associated with the aforementioned second compiler statement; (4) the first compiler statement (compiler statement II) “②.m(X1,X2)” indicates that the program resource package m in the program resource library ② is referenced and the specific calling method is to input X1 and X2 into the program resource package m for calculation. The above compiler statements are just examples. The compiler statements under different compiler languages ​​and tools may be different.

[0082] In some embodiments, the packaging strategy is reflected through the corresponding strategy compilation statement. That is, the program compilation file obtained at this time contains the strategy compilation statement corresponding to the packaging strategy of the associated program resource library. After determining the best packaging strategy of the target program resource library called by the newly added compilation statement, the strategy compilation statement corresponding to the packaging strategy (packaging strategy to be updated) of the target program resource library in the program compilation file can be obtained, and the program compilation file can be updated using the best packaging strategy so that the strategy compilation statement of the packaging strategy of the target program resource library in the updated program compilation file is the strategy compilation statement indicating the best packaging strategy.

[0083] For example, if the update packaging strategy for the target program resource library is to package the entire target program resource library, then the strategy compilation statement corresponding to this update packaging strategy is a second compilation statement. Therefore:

[0084] (1) If the determined best packaging strategy is to package the program resource package specifically used in the target program resource library, then the target strategy compilation statement corresponding to the best packaging strategy is generated. The target strategy compilation statement belongs to the first compilation statement. In the program compilation file, the strategy compilation statement corresponding to the packaging strategy to be updated is updated to the target strategy compilation statement, and the updated program compilation file is determined as the target program compilation file.

[0085] (2) If the strategy compilation statement corresponding to the packaging strategy to be updated for the target program resource library includes a strategy for packaging program resource package A and program resource package B in the target program resource library, and if the best packaging strategy is to package the target program resource library as a whole, then the corresponding strategy compilation statement in the program compilation file will be updated to the target strategy compilation statement corresponding to the best packaging strategy.

[0086] (3) If the strategy compilation statement corresponding to the packaging strategy to be updated for the target program resource library contains both the strategy compilation statement corresponding to the strategy of packaging program resource package A and program resource package B in the target program resource library and the strategy compilation statement corresponding to the overall packaging of the target program resource library, if the best packaging strategy is to package the target program resource library as a whole (or to package program resource package A and program resource package B), then the aforementioned two corresponding strategy compilation statements in the program compilation file will be updated to only the target strategy compilation statement corresponding to the best packaging strategy.

[0087] (4) If the strategy compilation statement corresponding to the packaging strategy to be updated for the target program resource library contains both the strategy of packaging program resource package A and program resource package B in the target program resource library and the strategy of packaging the target program resource library as a whole, and if the best packaging strategy is to package program resource package A, program resource package B and program resource package C in the target program resource library, then the strategy compilation statement corresponding to the aforementioned two strategies corresponding to the packaging strategy to be updated in the program compilation file will be updated to only contain the target strategy compilation statement corresponding to the best packaging strategy.

[0088] Therefore, the updated program compilation file contains only compilation statements for a packaging strategy that includes associated program libraries. It is also understood that the technical solution of this application aims to optimize the installation package size by optimizing the packaging strategy; therefore, the optimized application is one that references any program library or program package.

[0089] In this embodiment, the application's compiled program file can be obtained, the compiled statements contained in the compiled program file can be parsed, and based on the parsing results, at least one newly added compiled statement can be identified. The target program resource library called by the newly added compiled statement can be obtained from at least one program resource library. A set of program resource packages called by the at least one compiled statement in the target program resource library can be obtained, and a packaging strategy for the target program resource library can be determined based on the set of program resource packages. Through this method, the optimal packaging strategy can be determined based on the set of called program resource packages, improving the efficiency and accuracy of packaging strategy determination. Furthermore, this packaging strategy can make the program installation package smaller than the program installation package obtained under other packaging strategies for the target program resource library, thereby improving the size optimization effect of the program installation package.

[0090] Please see Figure 4 , Figure 4 This is a flowchart illustrating a program data processing method provided in an embodiment of this application. This method can be executed by the aforementioned electronic device. Figure 4 As shown, the process flow of the program data processing method in this embodiment may include the following:

[0091] S401. Obtain the compiled program file of the application. The specific implementation of step S401 can be found in the relevant descriptions of the above embodiments, and will not be repeated here.

[0092] S402, Obtain the syntax analysis tree of the program's compiled files, and obtain the historical syntax analysis tree of the application's historical compiled files.

[0093] In some embodiments, the program compilation file is the compilation file of the application at a first time step, the syntax analysis tree includes at least one tree node, and any compilation statement in the program compilation file corresponds to at least one tree node in the syntax analysis tree. The historical program compilation file is the compilation file at a second time step, the historical program compilation file contains at least one historical compilation statement, the historical syntax analysis tree contains at least one historical tree node, and any historical compilation statement corresponds to at least one historical tree node in the historical syntax analysis tree. The relevant descriptions of the first and second time steps can be found in the embodiments described above.

[0094] The syntax analysis tree is obtained based on the first statement analysis result generated by analyzing the program compilation file. The first statement analysis result includes the structured information of each compilation statement in the program compilation file. The structured information includes the elements and meanings of the corresponding compilation statement. The elements are the sub-compilation statements decomposed from the compilation statements.

[0095] In some embodiments, the electronic device obtains a syntax tree based on the analysis result of the first statement by assigning a tree node to each compiled statement. This tree node can represent the corresponding structured information and its associated position in the compiled program file (e.g., line number). Alternatively, each element contained in a compiled statement can correspond to a tree node, representing the element and its meaning. In other words, each sub-compiled statement within a compiled statement corresponds to a tree node. This tree node has a correspondence with the corresponding sub-compiled statement and the original compiled statement containing it, and it also associates the sub-compiled statement with its position in the compiled program file (e.g., line number and column number). Therefore, the syntax tree includes at least one tree node that calls a corresponding program resource package or library, as well as nodes that do not. The historical syntax tree is obtained based on the analysis results of historical statements generated from the analysis of historical compiled program files, and the specific method can be the same as the method used to determine the syntax tree.

[0096] For example, such as Figure 5 As shown, Figure 5This is a schematic diagram of a syntax analysis tree provided in an embodiment of this application; wherein, suppose the program compilation file contains compilation statement 1 "y = x" and compilation statement 2 "AAA①", based on statement analysis, the structured information of compilation statement 1 includes sub-compilation statement 1 ("y") and meaning 1, sub-compilation statement 2 ("=") and meaning 2, sub-compilation statement 3 ("x") and meaning 3; the structured information of compilation statement 2 includes sub-compilation statement 4 ("AAA") and meaning 4, sub-compilation statement 5 ("①") and meaning 5; therefore:

[0097] (a) If a compiler statement corresponds to one tree node, the generated parsing tree can have two tree nodes, such as Figure 5 As shown in (1) in the figure, each tree node represents the structured information of the corresponding compilation statement, as well as the position association between the tree node and the corresponding compilation statement in the program compilation file (the figure also includes the master node (which is not a tree node corresponding to any compilation statement)).

[0098] (b) If one sub-compilation statement in a compilation statement corresponds to one tree node, the generated parsing tree can have 5 tree nodes, such as... Figure 5 As shown in (2) in the figure, each tree node represents the meaning of the corresponding sub-compilation statement and the sub-compilation statement. Each tree node corresponds to the compilation statement where the sub-compilation statement is located, and the tree node is associated with the position of the corresponding sub-compilation statement and the compilation statement in the program compilation file (the figure also includes the master node (which is not a tree node corresponding to any compilation statement)). This is just an example, and the syntax analysis tree can also have other forms.

[0099] In some embodiments, if the program compilation file is obtained according to a specified cycle, the syntax analysis tree is obtained based on the program compilation file at the current cycle's arrival time, and the historical syntax analysis tree is obtained based on the program compilation file at the previous cycle's arrival time; if the program compilation file is obtained when a research and development operation that meets the trigger condition is detected, the syntax analysis tree is obtained based on the program compilation file at the time indicated by the current detection point, and the historical syntax analysis tree is obtained based on the program compilation file at the time indicated by the previous detection point; if the program compilation file is obtained after research and development is completed, the syntax analysis tree is obtained based on the complete program compilation file, and the historical syntax analysis tree is obtained based on the initial program compilation file. This initial program compilation file may not contain any written compilation statements, so the historical syntax analysis tree may be a tree with only one master node or a tree with only the initial node. In this case, the difference tree node can be all tree nodes in the syntax analysis tree (except for the master node).

[0100] Therefore, the technical solution of this application can not only be used in new projects under development, that is, to automatically achieve optimization during the code writing stage, but also in projects that have been developed and completed. The technical solution of this application can be packaged into a plugin and installed in projects that have been developed and completed. When the electronic device detects the user's installation package optimization request to trigger the update operation of each compilation script included in the project, it can obtain the compilation script corresponding to the project through the plugin, so as to optimize and update the reference program resource library in the compilation script.

[0101] S403. Based on the parsing tree and the history parsing tree, determine the newly added compilation statement in at least one compilation statement.

[0102] Among them, electronic devices can perform syntax analysis on program compilation files based on historical syntax analysis trees and syntax analysis trees, and determine new compilation statements based on the syntax analysis results.

[0103] In some embodiments, the electronic device performs syntax analysis on the program compilation file based on the historical syntax analysis tree and the syntax analysis tree, and determines the new compilation statement based on the syntax analysis result. Specifically, it compares the historical tree nodes contained in the historical syntax analysis tree with the tree nodes contained in the syntax analysis tree to obtain the difference tree nodes between the syntax analysis tree and the historical syntax analysis tree, determines the difference tree nodes as the syntax analysis result, and determines the compilation statement corresponding to the difference tree node in the program compilation file as the new compilation statement.

[0104] The newly added compilation statement can be the compilation statement corresponding to the difference tree node, the corresponding sub-compilation statement, or the original compilation statement containing the corresponding sub-compilation statement. When the newly added compilation statement is a sub-compilation statement, the target program resource library called by the newly added compilation statement can be determined by obtaining the original compilation statement corresponding to the newly added compilation statement and using it; alternatively, it can be the associated compilation tree node of the difference tree node corresponding to the newly added compilation statement. This compilation tree node can be any tree node generated based on the original compilation statement corresponding to the newly added compilation statement (including the difference tree node corresponding to the newly added compilation statement), and the target program resource library to be called can be determined based on the information represented by this associated compilation tree node.

[0105] Furthermore, the difference tree node can be obtained based on newly written compilation statements in the program compilation file, or based on modified compilation statements in the program compilation file. That is, the tree node corresponding to a newly written compilation statement does not exist in the historical parsing tree, and the tree node corresponding to a modified compilation statement does not represent completely the same information in the historical parsing tree and the parsing tree. Therefore, tree nodes whose information is different based on the comparison indicator are also considered as difference tree nodes.

[0106] For example, the syntax analysis tree includes tree node 1 corresponding to compiled statement 1 (let “A = b”) and tree node 2 corresponding to compiled statement 2. The history syntax analysis tree includes tree node 3 corresponding to historical compiled statement 1 (let “A = c”) and tree node 4 corresponding to historical compiled statement 2. Suppose that compiled statement 1 is obtained by modifying historical compiled statement 1. At this time, tree node 1 and tree node 3 indicate that the information is not completely the same. Compiled statement 2 is newly written. Therefore, the difference tree nodes are tree node 1 and tree node 2. The newly added compiled statement is the corresponding compiled statement 1 and compiled statement 2.

[0107] S404. Obtain the target program resource library called by the newly added compilation statement from at least one program resource library. The specific implementation of step S404 can be found in the relevant descriptions of the above embodiments, and will not be repeated here.

[0108] S405. Obtain a set of program resource packages called by at least one compilation statement in the target program resource library.

[0109] In some embodiments, if any compiler statement corresponds to multiple tree nodes in a syntax analysis tree, these multiple tree nodes are generated based on multiple sub-compilation statements obtained by decomposing any compiler statement, and any one of these multiple tree nodes corresponds to any one of the sub-compilation statements. That is, one compiler statement can correspond to one tree node, or one sub-compilation statement can correspond to one tree node. Therefore, obtaining the target program resource library called by the newly added compiler statement from at least one program resource library can specifically involve obtaining the calling information of the compiler statement or sub-compilation statement corresponding to each tree node in the syntax analysis tree. This calling information may include calling a program resource package, calling a program resource library, or not calling a program resource package and a program resource library. The calling information determines the corresponding program resource package to be called, and the tree nodes in the syntax analysis tree whose program resource packages belong to the target program resource library are determined as reference tree nodes. A set of program resource packages is generated based on the program resource packages called by the compiler statement or sub-compilation statement corresponding to the reference tree node. This set of program resource packages can be program resource packages belonging to one or more program resource libraries.

[0110] S406. Determine the packaging strategy for the target program resource library based on the program resource package set.

[0111] In one possible implementation, the electronic device can determine a corresponding packaging strategy based on the program resource packages contained in the program resource package set and the program resource packages contained in the target program resource library. Specifically, determining the packaging strategy for the target program resource library based on the program resource package set can involve obtaining a first packaging data volume for packaging the program resource package set and obtaining a second packaging data volume for packaging the target program resource library, and determining the packaging strategy for the target program resource library based on the first packaging data volume and the second packaging data volume.

[0112] The first packaged data volume is the amount of data determined to be used in the program installation package when packaging the program resource package set, and the second packaged data volume is the amount of data determined to be used in the program installation package when packaging the target program resource library. These first and second packaged data volumes can be determined by the electronic device after the packaging operation, or by using a packaging analysis tool to analyze the program resource package set and the target program resource library separately during the packaging process to determine the required packaged data volume.

[0113] In some embodiments, the process of packaging a collection of program resource packages may specifically include: obtaining the resource package association information corresponding to each program resource package in the collection; packaging each program resource package and its corresponding resource package association information in the collection to obtain a first transitional packaging result; and determining the data volume of the first transitional packaging result as the first packaged data volume. The resource package association information may be configuration information of the program resource package, such as the version number of the program resource package, the definition language information in the program resource package, and the declaration information for the program resource package. Furthermore, other relevant information may exist in real-world scenarios; this is merely an example, and the resource package association information may be based on what developers obtain when writing code for the program resource package.

[0114] In some embodiments, the process of packaging the target program resource library may specifically include: obtaining the resource library association information corresponding to the target program resource library; packaging each program resource package and its association information in the target program resource library to obtain a second transitional packaging result; and determining the data volume of the second transitional packaging result as the second packaged data volume. The resource library association information may be configuration information of the program resource library, such as the version number of the included program resource package, the definition language information of the included program resource package, and declaration information for the program resource library. Furthermore, there may be other related information in actual scenarios; this is only an example, and the resource library association information may be based on what the developers obtain when writing the code for the program resource package.

[0115] It's important to note that resource package association information belongs to resource library association information. When packaging a program, all program resource packages in the target program resource library can share resource library association information. However, when packaging a program resource package separately, the resource package association information for each program resource package is independent and complete. The number of resource package associations corresponds to the number of separately imported program resource packages. Therefore, the amount of data in the target program resource library's resource library association information may be less than the total amount of data in the resource package association information for the entire set of program resource packages. For example, all program resource packages in the target program resource library can share the declaration information for the program resource library, meaning there may only be one declaration information in the resource library association information. However, when packaging a program resource package separately, individual declaration information is generated for that program resource package. This means that the resource package association information contains individual declaration information for each program resource package in the set of program resource packages, resulting in the resource library association information being less than the total amount of data in the resource package association information.

[0116] Optionally, in some embodiments, packaging each program resource package and its corresponding resource package association information in the program resource package set to obtain a first transitional packaging result may specifically involve referencing each program resource package and its corresponding resource package association information to the program installation package according to a specified format, and determining the program resource package set and its corresponding resource package association information in the specified format as the first transitional packaging result; for example, if the program resource package is a file of format A, but needs to be in format B to be called by the program when packaged and referenced in the program installation package, then the packaging process is to convert the program resource package into a target file of format B; or the packaging process may require encapsulating the resource package association information into a file of a specified format and adding it to the program installation package, etc.

[0117] Optionally, in some embodiments, packaging each program resource package and resource library association information in the target program resource library to obtain a second transitional packaging result may specifically involve referencing each program resource package and resource library association information in the target program resource library to the program installation package according to a specified format, and determining the target program resource library containing the program resource package in the specified format and the corresponding resource library association information as the second transitional packaging result.

[0118] Optionally, the first transitional packaging result may further include reference addresses from the program resource package to the program installation package; the reference addresses corresponding to individual program resource packages may be different, and the first transitional packaging result includes the reference addresses corresponding to each individual program resource package. The second transitional packaging result may further include reference addresses from the target program resource library to the program installation package; the reference addresses corresponding to program resource packages in the target program resource library are the same, and the second transitional packaging result only includes the reference addresses of the target program resource library. When the application calls a program resource package in the target program resource library, it can obtain the reference address of the target program resource library and search for and call the specified program resource package from that reference address in a specified manner, such as searching by program resource package name.

[0119] Based on the above description, under normal circumstances, the number of program resource packages in the program resource package set is less than the number of program resource packages contained in the target program resource library, but there may still be a situation where the first package data volume is greater than the second package data volume.

[0120] Therefore, in some embodiments, the electronic device determines the packaging strategy for the target program resource library based on the first packaged data volume and the second packaged data volume. Specifically, if the first packaged data volume is less than the second packaged data volume, the packaging strategy is determined to be a strategy for packaging the program resource package set; if the first packaged data volume is greater than or equal to the second packaged data volume, the packaging strategy is determined to be a strategy for packaging the target program resource library. The electronic device can determine the corresponding target program compilation file based on the packaging strategy for the target program resource library.

[0121] In some embodiments, after the electronic device has completed the code for the application and determined the optimal packaging strategy for each program resource library, the final optimized program compilation file can be packaged to obtain an application installation package. When packaging the final program compilation file, at least one program resource library other than the target program resource library can be identified as a pending program resource library. A pending packaging strategy for the pending program resource library is obtained from the program compilation file. The pending program resource library is packaged according to the pending packaging strategy to obtain a first packaging result. The target program resource library is then packaged according to the packaging strategy to obtain a second packaging result. The application installation package is generated based on the first and second packaging results.

[0122] The electronic device can determine, through the packaging strategy ultimately determined for each associated program resource library, whether each program resource library in the program installation package references the full program resource package or only a portion of the program resource package. Therefore, compared to manually determining the referencing method of partial program resource libraries, the technical solution of this application can automatically simplify the packaging strategy that references all program resource libraries, improving the comprehensiveness of optimization.

[0123] It is understandable that when there are multiple target program resource libraries, the program resource package set contains program resource packages of multiple target program resource libraries. The program resource package subset belonging to each target program resource library is determined from the program resource package set, and the packaging strategy of each target program resource library is determined according to the method described above based on each program resource package subset.

[0124] For example, the program resource package set contains program resource packages ① and ② in program resource library A (and let all program resource packages in program resource library A be ①②①), program resource packages ③ and ④ in program resource library B (and let all program resource packages in program resource library B be ③④③), and program resource packages ⑤ and ⑥ in program resource library C (and let all program resource packages in program resource library C be ⑤⑥). Therefore, the electronic device determines the packaging strategy for program resource library A based on program resource packages ① and ②, and determines the packaging strategy for program resource library B based on program resource packages ③ and ④, and directly determines the packaging strategy for program resource library C as the strategy of packaging program resource library C as a whole.

[0125] In some embodiments, if the program compilation file is obtained by detecting newly written or modified compilation statements that result in new call records to the program resource library, it may lead to frequent retrieval and frequent calculation of the first and second packaged data volumes, causing electronic devices to lag. Therefore, the above problems can be improved by retrieving the file according to a specified period and caching the packaged data volume calculated each time. However, when retrieving the file according to a specified period, there may be multiple compilation statements in the newly added compilation statements that change the calls to different program resource libraries. This requires calculating the packaged data volume for multiple program resource libraries multiple times at once, resulting in a large workload and long time consumption. Therefore, the packaged data volume calculation for multiple program resource libraries can be performed in parallel using a multi-process approach to improve efficiency.

[0126] For example, such as Figure 6 As shown, Figure 6 A flowchart illustrating a multi-process data processing method is provided for embodiments of this application; wherein:

[0127] (1) When there are multiple target program resource libraries, the electronic device creates a computing task for each target program resource library separately;

[0128] (2) Each computing task is placed in a task queue, and a computing process is assigned to the computing tasks in the task queue. The computing tasks are then sent to the assigned computing processes for multi-process task processing. The computing tasks include the corresponding target program resource library and the program resource package sub-sets belonging to the corresponding target program resource library in the program resource package set.

[0129] (3) Execute the corresponding computing task in each computing process. The process includes: querying the cache to see if the second packaged data volume corresponding to the target program resource library and the first packaged data volume corresponding to the program resource package subset have been calculated before. If they exist, retrieve them from the cache. If they do not exist, calculate the packaged data volume for the computing task and cache the calculation result.

[0130] (4) The first packaged data volume / second packaged data volume in the cache or calculated is used as the task result of the calculation task. The electronic device obtains the task result of each calculation task and executes the subsequent steps of the technical solution of this application.

[0131] In some embodiments, the electronic device may be configured with multiple installation package optimization modules to perform the above steps. For example, the installation package optimization module may include a program detection module, a syntax analysis module, a package data volume calculation module, and a packaging strategy recommendation module; these multiple installation package optimization modules may all be configured in other devices, or they may be partially or entirely located in the same other device or different other devices, and the electronic device may schedule the installation package optimization modules on the other devices.

[0132] For example, the execution interaction between multiple installation package optimization modules can be as follows: Figure 7 As shown, Figure 7 An interactive schematic diagram of a program data processing flow provided in an embodiment of this application; wherein:

[0133] S1. Developers can input program source code into electronic devices;

[0134] S2. Electronic devices can detect the program input behavior of developers through a program detection module, which is used to detect changes in the compilation statements contained in the program compilation file.

[0135] S3. If the program detection module detects a new call record generated by a newly written or modified compilation statement, it generates the first prompt message and sends it to the syntax analysis module.

[0136] Specifically, detecting new call records generated by newly written or modified compiler statements can be done by: detecting whether the newly written compiler statement calls a program resource library or program resource package. For example, it could be the presence of keywords in a strategy compiler statement that indicates a packaging strategy (e.g., if the compiler statement is in JS, the keywords could be import or require (e.g., "importA" indicates referencing program resource library A, so the presence of the import keyword indicates a new call record), and different compiler statements can have different keywords); or it could be an indication of the specific usage of the program resource package (e.g., the compiler statement "①.n(X1, X2)" shows the name of the program resource package and indicates the use of program resource package n in program resource library A). Detecting new call records generated by modified compiler statements can be done by: detecting whether the modified compiler statement modifies the location of the program resource library or program resource package, for example, changing program resource package A to program resource package B.

[0137] S4. The electronic device can obtain the newly added compilation statement through the syntax analysis module. This syntax analysis module is used to obtain the program compilation file and perform syntax analysis to determine the newly added compilation statement when the first prompt information is received. The syntax analysis module can obtain the syntax analysis tree of the program compilation file at the first moment, and query the historical program compilation file or the historical syntax analysis tree of the historical program compilation file at the second moment from the cache (if there is no cache, the initial program compilation file is used as the historical program compilation file, and the initial syntax analysis tree is used as the historical syntax analysis tree). The tree diff analysis process is performed to realize the syntax analysis of the syntax analysis tree and the historical syntax analysis tree, and to determine the newly added compilation statement based on the syntax analysis result.

[0138] The tree difference analysis process includes: performing syntactic analysis on each tree node in the parse tree and each historical tree node in the historical parse tree to obtain the difference tree nodes between the parse tree and the historical parse tree. These difference tree nodes are the tree nodes in the parse tree that have changed between the first time step and the second time step compared to the historical parse tree. The compilation statement corresponding to the difference tree node is the newly added compilation statement.

[0139] S5. The syntax analysis module generates a second prompt message based on the newly added compilation statement and sends it to the packaged data volume calculation module. Specifically, it can be: determining the target program resource library that generated the new call record based on the newly added compilation statement, and after determining the target program resource library, determining which tree nodes (or compilation statements) called the program resource package in the target program resource library through the syntax analysis tree, and obtaining the program resource package set based on the determined tree nodes (or compilation statements). The second prompt message includes the target program resource library and the program resource package set.

[0140] S6. The electronic device can obtain the first packaged data volume and the second packaged data volume through the packaged data volume calculation module. The packaged data volume calculation module is used to obtain the target program resource library when receiving the second prompt information, and call the packaging analysis tool (which can be webpack-bundle-analyzer (a packaging analysis tool in a JavaScript-based packager), which can be called through the calculation module (caleSize module) in the packager) to find all program resource packages according to the directory where the target program resource library is located, perform packaging analysis on all program resource packages, and obtain the second packaged data volume of the target program resource library, and find the corresponding partial program resource packages from the directory where the target program library is located according to the instruction of the program resource package set, perform packaging analysis on the partial program resource packages, and obtain the first packaged data volume of the program resource set.

[0141] The process of packaging and analyzing the program resource package set may include: obtaining the resource package association information of each program resource package in the program resource package set, and packaging each program resource package and its resource package association information to obtain a first transitional packaging result. The first transitional packaging result includes multiple data files (such as a program resource package set and resource package association information in a specified format, and may also include the reference address of each program resource package). The size of the data files included in the first transitional packaging result is used as the first packaged data size.

[0142] Furthermore, the process of packaging and analyzing all program resource packages may include: obtaining the resource library association information of the target program resource library, and packaging the resource library association information and all program resource packages to obtain a second transitional packaging result. The second transitional packaging result includes multiple data files (such as all program resource packages and resource library association information in a specified format, or the reference address of the target program resource library), and the data size of the multiple data files included in the second transitional packaging result is used as the second packaged data size.

[0143] For example, the calculation result obtained by the packaged data volume calculation module can be as follows: Figure 8 As shown, the first packaged data volume obtained by packaging the target program resource library (let's call it "M") is 134kb (Kilobyte, a unit of measurement), and the second packaged data volume obtained by packaging the program resource package set (let's call it "Mn", representing program resource package n in program resource library M) is 2kb.

[0144] S7. After obtaining the calculation result for packaging, the packaged data volume calculation module generates a third prompt message and sends it to the packaging strategy recommendation module. The third prompt message includes the first packaged data volume and the second packaged data volume.

[0145] Optionally, when calculations are required for multiple target program libraries, the packaged data volume calculation module can create a calculation task for each target program library and process each calculation task in parallel through multiple processes.

[0146] S8. The electronic device can determine the packaging strategy for the target program resource library through the packaging strategy recommendation module. The packaging strategy recommendation module is used to determine the best packaging strategy based on the size relationship between the first packaged data volume and the second packaged data volume when the third prompt information is received, and interacts with the code editor running on the electronic device.

[0147] S9. The packaged data volume calculation module generates a fourth prompt message and outputs it to the code editor of the electronic device. The fourth prompt message includes the determined packaging strategy. The fourth prompt message is used to display on the electronic device to remind the developer whether to update to the packaging strategy. After the developer confirms, the electronic device combines the code generation interface provided by the code editor and determines the corresponding recommended strategy compilation statement based on the packaging strategy and updates the program compilation file.

[0148] Alternatively, instead of using a packaging strategy recommendation module, the electronic device can receive third-party prompts and determine a packaging strategy for the target program library based on these prompts. It can then directly combine the code editor with the packaging strategy to update the program compilation file. This allows the program compilation file to automatically replace the original packaging strategy's strategy compilation statement with the strategy compilation statement corresponding to the determined packaging strategy. This improves the user's programming experience without affecting the original writing logic in the program compilation file.

[0149] This application can automatically determine the packaging strategy for the program resource library at the front end and improve the quality and efficiency of optimizing the size of the packaged program installation package. It can perform the operations described above on any optimizable packaging strategy in the program compilation file, and can determine the optimal packaging strategy for the current program compilation file each time the program compilation file is obtained, thereby achieving optimal program resource library introduction during the development process and optimal size of the built program installation package in a locally optimal manner.

[0150] Furthermore, this application can be applied to electronic devices on any operating system, and can be used in any code editor (such as VSCode (Visual Studio Code, a cross-platform source code editor) or IntelliJ IDEA (a source code editor based on the Java programming language)) to update the program compilation files in the code editor. The technical solution of this application can also be packaged into a plugin and uploaded to the npm repository through the npm (node ​​package manager) tool for use by any developer, improving the flexibility of use.

[0151] In this embodiment, the application's compiled program file, its syntax tree, and the historical syntax tree of the application's historical compiled program files can be obtained. Based on the syntax tree and the historical syntax tree, a newly added compilation statement in at least one compilation statement is determined. The target program resource library called by the newly added compilation statement is obtained from at least one program resource library. The set of program resource packages called by the at least one compilation statement in the target program resource library is obtained. Based on the set of program resource packages, a packaging strategy for the target program resource library is determined. Through this method, the optimal packaging strategy can be determined based on the set of called program resource packages, improving the efficiency and accuracy of packaging strategy determination. Furthermore, this packaging strategy can result in a smaller program installation package size compared to other packaging strategies for the target program resource library, thereby improving the size optimization effect of the program installation package.

[0152] The methods of the embodiments of this application have been described in detail above. In order to facilitate better implementation of the above solutions of the embodiments of this application, the apparatus of the embodiments of this application is provided below.

[0153] Please see Figure 9 , Figure 9 This application provides a schematic diagram of a program data processing device; this program data processing device can be used as a computer program (including program code) running in an electronic device, for example, the program data processing device can be an application program (such as a program capable of processing program data) in an electronic device. It should be noted that... Figure 9 The program data processing apparatus shown is used to execute this application. Figure 2 and Figure 4 Some or all of the steps in the method of the illustrated embodiment. The program data processing apparatus 900 may include: an acquisition module 901, a processing module 902, and a determination module 903. Wherein:

[0154] The acquisition module 901 is used to acquire the program compilation file of the application; the program compilation file contains at least one compilation statement; the program compilation file has at least one associated program resource library, and any program resource library contains at least one program resource package called by at least one compilation statement;

[0155] Processing module 902 is used to perform syntax analysis on the compilation statements contained in the program compilation file, and determine the newly added compilation statement in at least one compilation statement based on the syntax analysis results.

[0156] The acquisition module 901 is also used to acquire the target program resource library called by the newly added compilation statement from at least one program resource library;

[0157] The acquisition module 901 is also used to acquire a set of program resource packages called by at least one compilation statement in the target program resource library;

[0158] The determination module 902 is further configured to determine a packaging strategy for the target program resource library based on the program resource package set; the target program resource library packaged based on the packaging strategy is used to generate the application's program installation package.

[0159] In one possible implementation, the above-mentioned program compilation file is the compilation file of the application at the first moment;

[0160] When processing module 902 performs syntax analysis on the compilation statements contained in the program compilation file and determines the newly added compilation statements in the program compilation file based on the syntax analysis results, it specifically performs the following functions:

[0161] Generate a syntax analysis tree for the compiled program file; the syntax analysis tree contains at least one tree node, and any compilation statement in the compiled program file corresponds to at least one tree node in the syntax analysis tree;

[0162] Obtain the historical parsing tree of the application's historical program compilation file at a second time point; the second time point is earlier than the first time point; the historical parsing tree contains at least one historical tree node, the historical program compilation file contains at least one historical compilation statement, and any historical compilation statement in the historical program compilation file corresponds to at least one historical tree node of the historical parsing tree;

[0163] The program compilation file is analyzed based on the historical parsing tree and the parsing tree, and new compilation statements are determined based on the parsing results; these new compilation statements are added between the first and second time points.

[0164] In one possible implementation, when processing module 902 performs syntax analysis on the compiled program file based on the historical parsing tree and the parsing tree, and determines the newly added compilation statements based on the parsing results, it specifically performs the following:

[0165] By comparing the historical tree nodes contained in the historical parsing tree with the tree nodes contained in the parsing tree, the difference tree nodes between the parsing tree and the historical parsing tree are obtained.

[0166] The difference tree nodes are identified as parsing results, and the compilation statements corresponding to the difference tree nodes in the program compilation file are identified as newly added compilation statements.

[0167] In one possible implementation, if any compiler statement corresponds to multiple tree nodes of a syntax analysis tree, then the multiple tree nodes are generated based on multiple sub-compilation statements obtained by decomposing any compiler statement, and any one of the multiple tree nodes corresponds to any one of the multiple sub-compilation statements.

[0168] When obtaining a set of program resource packages called by at least one compilation statement in the target program resource library, module 901 is specifically used for:

[0169] Obtain the program resource package called by the compilation statement or sub-compilation statement corresponding to each tree node in the parsing tree;

[0170] The tree nodes in the parsing tree that belong to the target program's resource library and are called by the program resource package are identified as reference tree nodes;

[0171] A set of program resource packages is generated based on the program resource packages called by the compiler statements or sub-compile statements corresponding to the reference tree nodes.

[0172] In one possible implementation, when determining the packaging strategy for the target program resource library based on the program resource package set, the determining module 902 is specifically used for:

[0173] Get the first package size of the program resource package collection;

[0174] Obtain the second packaged data volume for packaging the target program resource library;

[0175] The packaging strategy for the target program resource library is determined based on the first package data volume and the second package data volume.

[0176] In one possible implementation, the process of packaging a collection of program resource packages includes:

[0177] Retrieve the resource package association information corresponding to each program resource package in the program resource package collection;

[0178] Each program resource package in the program resource package set and its corresponding resource package association information are packaged to obtain the first transitional packaging result;

[0179] The data volume of the first transitional packaging result is defined as the first packaged data volume;

[0180] The process of packaging the target program resource library includes:

[0181] Obtain the resource library association information corresponding to the target program's resource library;

[0182] Each program resource package and its associated resource library in the target program resource library are packaged to obtain a second transitional packaging result.

[0183] The data volume of the second transitional packaging result is determined as the second packaged data volume.

[0184] In one possible implementation, when determining the packaging strategy for the target program resource library based on the first packaged data volume and the second packaged data volume, the determining module 902 is specifically used for:

[0185] If the first packaged data size is smaller than the second packaged data size, then the packaging strategy is determined to be a strategy for packaging the program resource package collection.

[0186] If the first packaged data volume is greater than or equal to the second packaged data volume, then the packaging strategy is determined to be the strategy for packaging the target program resource library.

[0187] In one possible implementation, the processing module 902 is further configured to:

[0188] At least one program resource library other than the target program resource library is identified as a pending program resource library;

[0189] Obtain the pending packaging strategy for the pending program resource library;

[0190] The pending program resource library is packaged according to the pending packaging strategy to obtain the first packaging result;

[0191] The target program resource library is packaged according to the packaging strategy to obtain the second packaging result;

[0192] The application installation package is generated based on the first and second packaging results.

[0193] According to one embodiment of this application, Figure 9The units in the program data processing device shown can be individually or entirely merged into one or more other units, or some of the units can be further divided into multiple functionally smaller units. This can achieve the same operation without affecting the technical effects of the embodiments of this application. The above units are based on logical function division. In practical applications, the function of one unit can also be implemented by multiple units, or the function of multiple units can be implemented by one unit.

[0194] In other embodiments of this application, the program data processing apparatus may also include other units. In practical applications, these functions may also be implemented with the assistance of other units, and may be implemented collaboratively by multiple units. According to another embodiment of this application, the program data processing apparatus can be executed on a general-purpose computing device, such as a computer, which includes processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), and read-only memory (ROM). Figure 2 and Figure 4 The computer program (including program code) for each step involved in the corresponding method shown, to construct such... Figure 9 The program data processing apparatus shown herein, and the program data processing method for implementing the embodiments of this application, are described. A computer program may be recorded on, for example, a computer-readable recording medium, loaded onto the aforementioned electronic device via the computer-readable recording medium, and executed therein.

[0195] In this embodiment, the acquisition module acquires the program compilation file of the application; the processing module performs syntax analysis on the compilation statements contained in the program compilation file and determines the newly added compilation statements in the program compilation file based on the syntax analysis results; the acquisition module acquires the target program resource package called by the newly added compilation statement; the determination module determines the program resource library to which the target program resource package belongs in at least one program resource library as the target program resource library; the acquisition module acquires the set of program resource packages called by at least one compilation statement in the target program resource library; and the determination module determines a packaging strategy for the target program resource library based on the set of program resource packages. Through the above apparatus, the optimal packaging strategy can be determined based on the set of called program resource packages, improving the efficiency and accuracy of packaging strategy determination. Furthermore, this packaging strategy can make the program installation package smaller than the program installation package obtained under other packaging strategies for the target program resource library, thereby improving the size optimization effect of the program installation package.

[0196] In the various embodiments of this application, the functional modules can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules, and this application does not impose any limitations on this.

[0197] Please see Figure 10 , Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 10 As shown, the electronic device 1000 includes a processor 1001, a communication interface 1002, and a computer-readable storage medium 1003. The processor 1001, communication interface 1002, and computer-readable storage medium 1003 can be connected via a bus or other means. The communication interface 1002 is used to receive and send data. The computer-readable storage medium 1003 can be stored in the memory of the electronic device and is used to store computer programs, including program instructions. The processor 1001 is used to execute the program instructions stored in the computer-readable storage medium 1003. The processor 1001 (or CPU (Central Processing Unit)) is the computing and control core of the electronic device, suitable for implementing one or more instructions, specifically suitable for loading and executing one or more instructions to achieve corresponding method flows or corresponding functions.

[0198] This application embodiment also provides a computer-readable storage medium (Memory), which is a memory device in an electronic device used to store programs and data. It is understood that the computer-readable storage medium here can include both built-in storage media in the electronic device and extended storage media supported by the electronic device. The computer-readable storage medium provides storage space that stores the processing system of the electronic device. Furthermore, the storage space also stores one or more instructions suitable for loading and execution by the processor 1001, which may be one or more computer programs (including program code). It should be noted that the computer-readable storage medium here can be high-speed RAM memory or non-volatile memory, such as at least one disk storage device; optionally, it may also be at least one computer-readable storage medium located remotely from the aforementioned processor.

[0199] In one embodiment, the computer-readable storage medium stores one or more instructions; the processor 1001 loads and executes one or more instructions stored in the computer-readable storage medium to implement the corresponding steps in the above-described document processing method embodiment; specifically, the one or more instructions in the computer-readable storage medium are loaded by the processor 1001 and executed as follows:

[0200] Obtain the application's compiled file; the compiled file contains at least one compilation statement; the compiled file has at least one associated program resource library, and any program resource library contains at least one program resource package called by at least one compilation statement;

[0201] Perform syntax analysis on the compilation statements contained in the program compilation file, and determine the newly added compilation statement in at least one compilation statement based on the syntax analysis results;

[0202] Obtain the target program resource library called by the newly added compilation statement from at least one program resource library;

[0203] Obtain a set of program resource packages called by at least one compilation statement in the target program resource library, and determine a packaging strategy for the target program resource library based on the set of program resource packages; the target program resource library packaged based on the packaging strategy is used to generate the application's program installation package.

[0204] In one possible implementation, the above-mentioned program compilation file is the compilation file of the application at the first moment;

[0205] When processor 1001 performs syntax analysis on the compilation statements contained in the program compilation file and determines new compilation statements in the program compilation file based on the syntax analysis results, it is specifically used for:

[0206] Generate a syntax analysis tree for the compiled program file; the syntax analysis tree contains at least one tree node, and any compilation statement in the compiled program file corresponds to at least one tree node in the syntax analysis tree;

[0207] Obtain the historical parsing tree of the application's historical program compilation file at a second time point; the second time point is earlier than the first time point; the historical parsing tree contains at least one historical tree node, the historical program compilation file contains at least one historical compilation statement, and any historical compilation statement in the historical program compilation file corresponds to at least one historical tree node of the historical parsing tree;

[0208] The program compilation file is analyzed based on the historical parsing tree and the parsing tree, and new compilation statements are determined based on the parsing results; these new compilation statements are added between the first and second time points.

[0209] In one possible implementation, when the processor 1001 performs syntax analysis on the program compilation file based on the historical parsing tree and the parsing tree, and determines the newly added compilation statements based on the parsing results, it specifically performs the following:

[0210] By comparing the historical tree nodes contained in the historical parsing tree with the tree nodes contained in the parsing tree, the difference tree nodes between the parsing tree and the historical parsing tree are obtained.

[0211] The difference tree nodes are identified as parsing results, and the compilation statements corresponding to the difference tree nodes in the program compilation file are identified as newly added compilation statements.

[0212] In one possible implementation, if any compiler statement corresponds to multiple tree nodes of a syntax analysis tree, then the multiple tree nodes are generated based on multiple sub-compilation statements obtained by decomposing any compiler statement, and any one of the multiple tree nodes corresponds to any one of the multiple sub-compilation statements.

[0213] When processor 1001 is used to obtain a set of program resource packages called by at least one compilation statement in the target program resource library, it is specifically used for:

[0214] Obtain the program resource package called by the compilation statement or sub-compilation statement corresponding to each tree node in the parsing tree;

[0215] The tree nodes in the parsing tree that belong to the target program's resource library and are called by the program resource package are identified as reference tree nodes;

[0216] A set of program resource packages is generated based on the program resource packages called by the compiler statements or sub-compile statements corresponding to the reference tree nodes.

[0217] In one possible implementation, when determining a packaging strategy for a target program resource library based on a set of program resource packages, the processor 1001 specifically performs the following:

[0218] Get the first package size of the program resource package collection;

[0219] Obtain the second packaged data volume for packaging the target program resource library;

[0220] The packaging strategy for the target program resource library is determined based on the first package data volume and the second package data volume.

[0221] In one possible implementation, the process of packaging a collection of program resource packages includes:

[0222] Retrieve the resource package association information corresponding to each program resource package in the program resource package collection;

[0223] Each program resource package in the program resource package set and its corresponding resource package association information are packaged to obtain the first transitional packaging result;

[0224] The data volume of the first transitional packaging result is defined as the first packaged data volume;

[0225] The process of packaging the target program resource library includes:

[0226] Obtain the resource library association information corresponding to the target program's resource library;

[0227] Each program resource package and its associated resource library in the target program resource library are packaged to obtain a second transitional packaging result.

[0228] The data volume of the second transitional packaging result is determined as the second packaged data volume.

[0229] In one possible implementation, when determining the packaging strategy for the target program resource library based on the first packaged data volume and the second packaged data volume, the processor 1001 specifically performs the following:

[0230] If the first packaged data size is smaller than the second packaged data size, then the packaging strategy is determined to be a strategy for packaging the program resource package collection.

[0231] If the first packaged data volume is greater than or equal to the second packaged data volume, then the packaging strategy is determined to be the strategy for packaging the target program resource library.

[0232] In one possible implementation, the processor 1001 is further configured to:

[0233] At least one program resource library other than the target program resource library is identified as a pending program resource library;

[0234] Obtain the pending packaging strategy for the pending program resource library;

[0235] The pending program resource library is packaged according to the pending packaging strategy to obtain the first packaging result;

[0236] The target program resource library is packaged according to the packaging strategy to obtain the second packaging result;

[0237] The application installation package is generated based on the first and second packaging results.

[0238] In this embodiment, the processor can obtain the program compilation file of the application, perform syntax analysis on the compilation statements contained in the program compilation file, determine the newly added compilation statements in the program compilation file based on the syntax analysis results, and obtain the target program resource package called by the newly added compilation statement. It then identifies the program resource library to which the target program resource package belongs in at least one program resource library as the target program resource library, obtains the set of program resource packages called by at least one compilation statement in the target program resource library, and determines a packaging strategy for the target program resource library based on the set of program resource packages. Through this scheme, the optimal packaging strategy can be determined based on the set of called program resource packages, improving the efficiency and accuracy of packaging strategy determination. Furthermore, this packaging strategy can make the program installation package smaller than the program installation package obtained under other packaging strategies for the target program resource library, thereby improving the size optimization effect of the program installation package.

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

[0240] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in or transmitted through a computer-readable storage medium. The computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).

[0241] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this invention should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for processing program data, characterized in that, The method includes: Obtain the program compilation file of the application; the program compilation file contains at least one compilation statement; the program compilation file has at least one associated program resource library, and any program resource library contains at least one program resource package called by the at least one compilation statement; Perform syntax analysis on the compilation statements contained in the program compilation file, and determine the newly added compilation statements in the at least one compilation statement based on the syntax analysis results; Obtain the target program resource library called by the newly added compilation statement from the at least one program resource library; Obtain a set of program resource packages called by the at least one compilation statement in the target program resource library, and determine a packaging strategy for the target program resource library based on the set of program resource packages; the target program resource library packaged based on the packaging strategy is used to generate the application's program installation package; the packaging strategy is determined based on a first packaging data volume and a second packaging data volume, where the first packaging data volume is the data volume for packaging the set of program resource packages, and the second packaging data volume is the data volume for packaging the target program resource library; wherein, the process of determining the packaging strategy based on the first packaging data volume and the second packaging data volume includes: If the first packaged data volume is less than the second packaged data volume, then it is determined that the packaging strategy is a strategy for packaging the program resource package set. If the first packaged data volume is greater than or equal to the second packaged data volume, then the packaging strategy is determined to be a strategy for packaging the target program resource library.

2. The method according to claim 1, characterized in that, The program compilation file is the compilation file of the application at the first moment; The step of performing syntax analysis on the compilation statements contained in the program compilation file, and determining the newly added compilation statements in the program compilation file based on the syntax analysis results, includes: Generate a syntax analysis tree for the compiled program file; the syntax analysis tree contains at least one tree node, and any compilation statement in the compiled program file corresponds to at least one tree node in the syntax analysis tree; Obtain the historical syntax analysis tree of the application's historical program compilation file at a second time point; the second time point is earlier than the first time point; the historical syntax analysis tree contains at least one historical tree node, the historical program compilation file contains at least one historical compilation statement, and any historical compilation statement of the historical program compilation file corresponds to at least one historical tree node of the historical syntax analysis tree; The program compilation file is parsed based on the historical parsing tree and the parsing tree, and the newly added compilation statement is determined based on the parsing results; the newly added compilation statement is added between the first time point and the second time point.

3. The method according to claim 2, characterized in that, The step of performing syntax analysis on the compiled program file based on the historical parsing tree and the parsing tree, and determining the newly added compilation statements based on the parsing results, includes: The historical tree nodes contained in the historical parsing tree and the tree nodes contained in the parsing tree are compared to obtain the difference tree nodes between the parsing tree and the historical parsing tree. The difference tree node is identified as the syntax analysis result, and the compilation statement corresponding to the difference tree node in the program compilation file is identified as the newly added compilation statement.

4. The method according to claim 2, characterized in that, If any one of the compilation statements corresponds to multiple tree nodes of the syntax analysis tree, then the multiple tree nodes are generated based on multiple sub-compilation statements obtained by decomposing the any one of the compilation statements, and any one of the multiple tree nodes corresponds to any one of the multiple sub-compilation statements. The step of obtaining the set of program resource packages called by the at least one compilation statement in the target program resource library includes: Obtain the program resource package called by the compilation statement or sub-compilation statement corresponding to each tree node in the syntax analysis tree; The tree nodes of the program resource packages called in the parsing tree that belong to the target program resource library are determined as reference tree nodes; The program resource package set is generated based on the program resource packages called by the compilation statements or sub-compilation statements corresponding to the reference tree nodes.

5. The method according to claim 1, characterized in that, The process of obtaining the first packaged data volume includes: Obtain the resource package association information corresponding to each program resource package in the program resource package set; Each program resource package in the program resource package set and the resource package association information corresponding to each program resource package are packaged to obtain a first transitional packaging result; The data volume of the first transitional packaging result is determined as the first packaged data volume; The process of obtaining the second packaged data volume includes: Obtain the resource library association information corresponding to the target program resource library; Each program resource package in the target program resource library and its associated information are packaged to obtain a second transitional packaging result. The data volume of the second transition packaging result is determined as the second packaged data volume.

6. The method according to claim 1, characterized in that, The method further includes: The program resource libraries other than the target program resource library in the at least one program resource library are identified as pending program resource libraries; Obtain the pending packaging strategy for the pending program resource library; The pending program resource library is packaged according to the pending packaging strategy to obtain the first packaging result; The target program resource library is packaged according to the packaging strategy to obtain a second packaging result; The application installation package is generated based on the first packaging result and the second packaging result.

7. A program data processing apparatus, characterized in that, The device includes: An acquisition module is used to acquire the program compilation file of the application; the program compilation file contains at least one compilation statement; the program compilation file has at least one associated program resource library, and any program resource library contains at least one program resource package called by the at least one compilation statement; The processing module is used to perform syntax analysis on the compilation statements contained in the program compilation file, and determine the newly added compilation statements in the at least one compilation statement based on the syntax analysis results. The acquisition module is further configured to acquire the target program resource library called by the newly added compilation statement from the at least one program resource library; The acquisition module is further configured to acquire the set of program resource packages called by the at least one compilation statement in the target program resource library; The determining module is further configured to determine a packaging strategy for the target program resource library based on the program resource package set; the target program resource library packaged based on the packaging strategy is used to generate the application's program installation package; the packaging strategy is determined based on a first packaging data volume and a second packaging data volume, wherein the first packaging data volume is the data volume for packaging the program resource package set, and the second packaging data volume is the data volume for packaging the target program resource library; wherein the process by which the determining module determines the packaging strategy based on the first packaging data volume and the second packaging data volume includes: If the first packaged data volume is less than the second packaged data volume, then it is determined that the packaging strategy is a strategy for packaging the program resource package set. If the first packaged data volume is greater than or equal to the second packaged data volume, then the packaging strategy is determined to be a strategy for packaging the target program resource library.

8. An electronic device, characterized in that, The device includes a processor and a memory, wherein the memory is used to store a computer program, the computer program including program instructions, and the processor is configured to invoke the program instructions to perform the method as described in any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, the computer program including program instructions that, when executed by a processor, cause the processor to perform the method as described in any one of claims 1-6.

10. A computer program product, characterized in that, The computer program product includes computer instructions that, when executed by a processor, implement the method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Method for analyzing software function change and influence thereof by using function diagram

    CN102831057A

  • Installation package compiling method and device, electronic device and readable storage medium

    CN110442347A