CN116775099A - Program data processing method, program data processing device, electronic equipment, medium and program product - Google Patents

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

Info

Publication number
CN116775099A
CN116775099A CN202210234951.XA CN202210234951A CN116775099A CN 116775099 A CN116775099 A CN 116775099A CN 202210234951 A CN202210234951 A CN 202210234951A CN 116775099 A CN116775099 A CN 116775099A
Authority
CN
China
Prior art keywords
program
compiling
program resource
packaging
resource library
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210234951.XA
Other languages
Chinese (zh)
Inventor
张勇
李可先
费斌洋
王肖雄
覃志强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202210234951.XA priority Critical patent/CN116775099A/en
Publication of CN116775099A publication Critical patent/CN116775099A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/48Incremental compilation

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application discloses a program data processing method, a device, electronic equipment, a medium and a program product, which are applied to the technical field of cloud. The method comprises the following steps: acquiring a program compiling file of an application program; the program compiling file comprises at least one compiling statement, the comprised compiling statement is subjected to grammar analysis, a new compiling statement in the at least one compiling statement is determined based on a grammar analysis result, a target program resource library called by the new compiling statement is obtained, a program resource package set called by the at least one compiling statement in the target program resource library is obtained, and a packaging strategy for the target program resource library is determined based on the program resource package set. By adopting the embodiment of the application, the optimization effect of the volume of the installation package can be improved. The embodiment of the application can be applied to various scenes such as cloud technology, artificial intelligence, intelligent traffic, auxiliary driving and the like.

Description

Program data processing method, program data processing device, electronic equipment, medium and program product
Technical Field
The present application relates to the field of cloud technologies, and in particular, to a program data processing method, a device, an electronic apparatus, a medium, and a program product.
Background
At present, the program resource library can be packaged according to a preset packaging mode to obtain a corresponding installation package, and the program can call a required program resource package based on the program resource library packaged in the installation package. For example, a program may call a program resource package having an image recognition function so that the program can perform image recognition.
When the program resource libraries are packaged, all program resource libraries required to be called by the application program are packaged respectively, and then a technician judges whether the packaging mode of the program resource libraries is simplified according to experience so as to reduce the volume of the installation package. However, the manual judgment is not accurate enough, resulting in low packing efficiency and insufficient effect in optimizing the volume of the installation package. Therefore, how to improve packing efficiency and the optimizing effect on the volume of the installation package is a problem to be solved.
Disclosure of Invention
The embodiment of the application provides a program data processing method, a device, electronic equipment, a medium and a program product, which can improve the determination efficiency and accuracy of a packing mode of a program resource package and can improve the volume optimization effect of a program installation package.
In one aspect, an embodiment of the present application provides a program data processing method, including:
acquiring a program compiling file of an application program; the program compilation file contains at least one compilation statement; the program compiling file is provided with at least one associated program resource library, and any program resource library comprises at least one program resource package called by at least one compiling statement;
carrying out grammar analysis on compiling sentences contained in the program compiling file, and determining a newly added compiling sentence in at least one compiling sentence based on a grammar analysis result;
acquiring a target program resource library called by a new compiling statement from at least one program resource library;
acquiring a program resource package set called by at least one compiling statement in a target program resource library, and determining 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 policy is used for generating a program installation package of the application program.
In one aspect, an embodiment of the present application provides a program data processing apparatus, including:
the acquisition module is used for acquiring a program compiling file of the application program; the program compilation file contains at least one compilation statement; the program compiling file is provided with at least one associated program resource library, and any program resource library comprises at least one program resource package called by at least one compiling statement;
The processing module is used for carrying out grammar analysis on the compiling sentences contained in the program compiling file and determining a new compiling sentence in at least one compiling sentence based on a grammar analysis result;
the acquisition module is also used for acquiring a target program resource library called by the newly added compiling statement from at least one program resource library;
the acquisition module is also used for acquiring a program resource package set called by at least one compiling statement in the target program resource library;
the determining module is further used for determining 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 policy is used for generating a program installation package of the application program.
In one aspect, an embodiment of the present application provides an electronic device, including a processor and a memory, where the memory is configured to store a computer program, the computer program including program instructions, and the processor is configured to invoke the program instructions to perform some or all of the steps in the above method.
In one aspect, embodiments of the present application provide a computer readable storage medium storing a computer program comprising program instructions for performing part or all of the steps of the above method when executed by a processor.
Accordingly, according to one aspect of the present application, there is provided a computer program product or computer program comprising program instructions stored in a computer readable storage medium. The processor of the computer device reads the program instructions from the computer-readable storage medium, and the processor executes the program instructions, so that the computer device executes the program data processing method provided above.
In the embodiment of the application, a program compiling file of an application program can be obtained, grammar analysis is carried out on compiling sentences contained in the compiling file, a new compiling sentence in the program compiling file is determined based on a grammar analysis result, a target program resource package called by the new compiling sentence is obtained, a program resource library to which the target program resource package belongs is determined as a target program resource library, a program resource package set called by at least one compiling sentence in the target program resource library is obtained, and a packaging strategy for the target program resource library is determined based on the program resource package set. By the method, the optimal packing strategy can be determined according to the invoked program resource package set, the determining efficiency and accuracy of the packing strategy are improved, and the packing strategy can enable the size of the program installation package to be smaller than that of the program installation package obtained under other packing strategies of the target program resource library, so that the size optimizing effect of the program installation package is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of an application architecture according to an embodiment of the present application;
FIG. 2 is a flowchart of a program data processing method according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a scenario for determining a newly added compiled sentence according to an embodiment of the present application;
FIG. 4 is a flowchart of a program data processing method according to an embodiment of the present application;
FIG. 5 is a schematic diagram of a parse tree according to an embodiment of the present application;
FIG. 6 is a schematic flow chart of a multi-process-based data processing according to an embodiment of the present application;
FIG. 7 is an interactive schematic diagram of a program data processing flow provided in an embodiment of the present application;
FIG. 8 is a diagram of a packed data amount according to an embodiment of the present application;
FIG. 9 is a schematic diagram of a program data processing apparatus according to an embodiment of the present application;
Fig. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The program data processing method provided by the embodiment of the application is implemented in electronic equipment, and the electronic equipment can be a server or a terminal. The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs (Content Delivery Network, content delivery networks), basic cloud computing services such as big data and artificial intelligent platforms, and the like. The terminal may be, but is not limited to, a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch smart voice interaction device, a smart home appliance, a vehicle-mounted terminal, an aircraft, and the like. The embodiment of the application can be applied to various scenes, including but not limited to cloud technology, artificial intelligence, intelligent transportation, auxiliary driving and the like.
Next, technical terms related to the technical field of possible application of the scheme of the embodiment of the present application are described in the following:
1. artificial intelligence:
the embodiment of the application relates to the technical field of artificial intelligence, in particular to a theory, a method, a technology and an application system which simulate, extend and expand human intelligence by using a digital computer or a machine controlled by the digital computer, sense environment, acquire knowledge and acquire an optimal result by using the knowledge. In other words, artificial intelligence is an integrated technology of computer science that attempts to understand the essence of intelligence and to produce a new intelligent machine that can react in a similar way to human intelligence. Artificial intelligence, i.e. research on design principles and implementation methods of various intelligent machines, enables the machines to have functions of sensing, reasoning and decision. For example, artificial intelligence technology can be utilized to parse the program compiling file in the technical scheme of the application.
2. Cloud technology:
cloud technology (Cloud technology) is a generic term of network technology, information technology, integration technology, management platform technology, application technology and the like based on Cloud computing business model application, and can form a resource pool, so that the Cloud computing business model application system is flexible and convenient as required. Cloud computing technology will become an important support. Background services of technical networking systems require a large amount of computing, storage resources, such as video websites, picture-like websites, and more portals. Along with the high development and application of the internet industry, each article possibly has an own identification mark in the future, the identification mark needs to be transmitted to a background system for logic processing, data with different levels can be processed separately, and various industry data needs strong system rear shield support and can be realized only through cloud computing.
In a possible implementation manner, the program data processing method provided by the embodiment of the application can be combined with cloud technology, such as program compiling files, packaging strategies of associated program resource libraries and the like, and the data can be stored by cloud storage technology in the cloud technology field, so that the data can be conveniently further applied. The cloud storage (cloud storage) is a new concept that extends and develops in the concept of cloud computing, and the distributed cloud storage system (hereinafter referred to as a storage system for short) refers to a storage system that provides data storage and service access functions for the outside through aggregation of a large number of storage devices (storage devices are also referred to as storage nodes) of different types in a network through application software or application interfaces by means of functions such as cluster application, grid technology, and distributed storage file systems.
In some embodiments, please refer to fig. 1, fig. 1 is a schematic diagram of an application architecture according to an embodiment of the present application, through which the program data processing method according to the present application can be executed. As shown in fig. 1, may include an electronic device, a target object, and a terminal device; the electronic device may obtain a program compiling file generated by the developer in a development process of the application program, parse the program compiling file to determine a new compiling sentence in the program compiling file, determine a target program resource library called by the new compiling sentence, determine a program resource package set called by the program compiling file in the target program resource library, determine a packaging policy for the target program resource library based on the program resource package set, and perform packaging operation according to packaging policies of all program resource libraries associated with the program compiling file to obtain a program installation package of the application program, and then the electronic device may send the program installation package to the terminal device for the terminal device to install the application program through the program installation package, where the terminal device may call the corresponding packaged program resource package in different service scenarios in the application program.
It should be understood that fig. 1 is merely exemplary to represent possible application architectures of the technical solution of the present application, and is not limited to specific architectures of the technical solution of the present application, that is, the technical solution of the present application may also provide other application architectures.
Optionally, in some embodiments, the electronic device may execute the program data processing method according to actual service requirements to improve the volume optimization effect of the program installation package. The technical scheme of the application can be applied to an installation package volume optimization scene of any application program, namely, the electronic equipment can acquire a program compiling file of the application program, parse the program compiling file to determine a new compiling statement in the program compiling file, determine a called target program resource library according to the new compiling statement, determine a program resource package set which can be called from the target program resource library by the program compiling file, determine an optimal packaging strategy for the target program resource library according to the program resource package set, package the target program resource library based on the optimal packaging strategy to obtain a program installation package, and ensure that the volume of the program installation package is as small as possible through the determined packaging strategy, thereby improving the determination efficiency and accuracy of the packaging strategy for the program resource library.
Optionally, the data related to the present application, such as a program compiled file, a packaging policy for a target program resource library corresponding to an application program, etc., may be stored in a database, or may be stored in a blockchain, for example, stored through a blockchain distributed system, which is not limited by the present application.
It can be understood that the above scenario is merely an example, and does not constitute a limitation on the application scenario of the technical solution provided by the embodiment of the present application, and the technical solution of the present application may also be applied to other scenarios. For example, as one of ordinary skill in the art can know, with the evolution of the system architecture and the appearance of new service scenarios, the technical solution provided by the embodiment of the present application is also applicable to similar technical problems.
Based on the above description, an embodiment of the present application proposes a program data processing method, which can be executed by the above-mentioned electronic device. Referring to fig. 2, fig. 2 is a flowchart of a program data processing method according to an embodiment of the application. As shown in fig. 2, the flow of the program data processing method according to the embodiment of the present application may include the following:
s201, acquiring a program compiling file of an application program.
Wherein the program compiling file comprises at least one compiling statement; the program compiling file is provided with at least one associated program resource library, and any program resource library contains at least one program resource package called by at least one compiling statement.
In some embodiments, the application may be a program in any scenario, for example, an application software program installed in any terminal device, a program in the form of an applet or a web page, or the like. The program compiling file may be a source code file corresponding to the application program, and the at least one compiling statement may be obtained by developing source code written by the application program based on a developer. And the compilation statements in the program compilation file may be source code in any computer language, such as may be in Java (a computer programming language), C (a computer programming language), etc.
In some embodiments, the electronic device may acquire a corresponding program compilation file during the development process, specifically may acquire a currently generated program compilation file every specific period (for example, every 5 minutes), may detect a development operation of a developer, may acquire a program compilation file generated at this time when detecting the development operation that satisfies a trigger condition (for example, may detect that a compilation statement input in real time or having an edit is a source code for calling a program resource package or a program resource library, etc.), may acquire a complete program compilation file after the development is completed, may acquire an existing program compilation file at this time when detecting an installation package optimization request sent by the developer after the development is completed, etc.
In some embodiments, the program resource library is a preset resource library containing at least one program resource package, the program resource package contains a plurality of program codes, the program resource package has corresponding service functions, for example, a program resource package capable of realizing image recognition or a program resource package capable of realizing image enhancement, and the program codes in the program resource package can be in any language form, for example, javaScript (JS, a lightweight, interpreted or just-in-time compiled programming language with function priority), VBScript (a lightweight interpreted language) language form, or the like. The application program can use the service functions of the program resource package by calling the program resource package under the corresponding preset service scene based on the specific use mode of the program resource package description in the program compiling file. For example, there may be some compilation statements in the program compilation file that describe: in an image recognition scene, an application program invokes a program resource package with an image recognition function to perform image recognition processing on a face image of a user after the face image of the user is acquired; in the specific embodiment of the present application, if related data of user information such as a user face image and the like are involved, when the above embodiment of the present application is applied to a specific product or technology, user permission or consent needs to be obtained, and the collection, use and processing of the related data need to comply with related laws and regulations and standards of related countries and regions.
In some embodiments, an application may call a package of program resources that the corresponding program compilation file contains that the compilation statement indicates to call. And the called program resource package has the program resource library to which the called program resource package belongs, so that the program resource library to which all the called program resource packages belong in the program compiling file can be used as at least one program resource library associated with the program compiling file. Wherein program resource packages contained in different program resource libraries are different, and at least one program resource library associated with program compilation files of different application programs may be different.
In some embodiments, at least one of the compilation statements may include a first compilation statement of a first type for calling a first compilation statement of a program resource package, a second compilation statement of a second type for calling a second compilation statement of a program resource library, and a third compilation statement of a third type that is not used for calling any program resource package or a third compilation statement of any program resource library (e.g., business logic code, etc.). One first compiling statement may call one or more program resource packages, the called one or more program resource packages may be from the same or different program resource libraries, the obtained program installation package may have a packaging result obtained by packaging all program resource packages called by at least one compiling statement, and all the called program resource packages may be regarded as program resource packages actually used by an application program.
In some embodiments, when a second compilation statement of a second type is present in the program compilation file, then there may be one or more first compilation statements in the program compilation file associated with the second compilation statement, the associated first compilation statement indicating a package of program resources that is actually used in a program repository called from the second compilation statement. For example, when there is a second compilation statement and indicates that the program repository a is called, there is a first compilation statement associated with the second compilation statement and that is used to indicate the package of program resources that was actually called (actually used) from the program repository a. That is, the resulting program installation package will have all program packages contained in the program resource library called by the packaged second compilation statement, but the application will actually use some of the program packages in all of the contained program resource packages (i.e., the program resource packages indicated in the program resource library by the associated first compilation statement).
It will be appreciated that the package of program resources called by the electronic device is the package of program resources referenced in the package of program installation, the library of program resources called is the library of program resources referenced in the package of program installation, and when there is a second compilation statement calling the library of program resources a, the package of program installation references the library of program resources a as a whole, the application has the right to call any of the packages of program resources a (but the application determines which of the packages of program resources a is actually called in the specified business scenario based on the associated first compilation statement), and when there is no second compilation statement calling the library of program resources B and there is a first compilation statement calling the package of program resources C in the library of program resources B, the package of program installation references the package of program resources C alone, the application has only the right to call the package of program resources C in the library of program resources B. Furthermore, a packaging policy for a program repository may be understood as a reference policy for the program repository.
S202, analyzing grammar of compiling sentences contained in the program compiling file, and determining a new compiling sentence in at least one compiling sentence based on the grammar analysis result.
In one possible embodiment, the program compilation file may be a compilation file of the application at a first time; the electronic device parses the compiled sentences contained in the program compilation file, and determines, based on the parsing result, that the newly added compiled sentences in the program compilation file may specifically be a first sentence analysis result for the program compilation file is generated, and a second sentence analysis result of the historical program compilation file of the application program at the second time is obtained.
The second time is earlier than the first time, the history program compiling file contains at least one history compiling sentence, the second sentence analysis result is a history sentence analysis result, the program compiling file is subjected to grammar analysis through the first sentence analysis result and the second sentence analysis result, and a new compiling sentence in the at least one compiling sentence is determined based on the obtained grammar analysis result, wherein the new compiling sentence is newly added in the program compiling file at the first time and the second time. The obtained program compiling file at the first moment is obtained based on the historical program compiling file at the second moment and the newly added compiling sentence.
The first time may be a time when the currently generated program compilation file is acquired, that is, the program compilation file at the first time is the latest compilation file, and the second time may be any designated time earlier than the first time, and may be designated by a developer, or may be a time determined by the electronic device according to a manner of acquiring the program compilation file, which is not limited herein.
For example, if the method of acquiring the program compiled file is to acquire the program compiled file once every specified period, the first time is the time corresponding to the current period, and the second time may be the time corresponding to the previous period; if the program compiling file is obtained and the research and development operation meeting 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 last detection point; if the method of acquiring the program compiling file is to acquire the complete compiling file after the research and development is completed, the first time is the time corresponding to the compiling of the complete program compiling file, and the second time may be the initial time, that is, the time when the compiling of the compiling file is not performed, where the acquired historical program compiling file is the initial program compiling file, and the source code compiled by the developer is not included.
It can be understood that the technical solution of the present application is to determine an newly added compiling sentence in a program compiling file at a first time, determine a packaging policy for a target program resource library to which the target program resource package belongs based on a target program resource package called by the newly added compiling sentence, obtain a corresponding policy compiling sentence according to the packaging policy for the target program resource library, and determine whether a program compiling file needs to be updated according to the policy compiling sentence corresponding to the packaging policy, so that an updated (or not updated) program compiling file can be obtained as a target program compiling file corresponding to the first time, and the obtained historical program compiling file at a second time is a target program compiling file obtained based on the program compiling file of the application program at the second time. Therefore, the method can be understood as a process of iteratively determining the optimal packaging strategies for the target program resource library at different moments and updating the latest compiling files at different moments according to the optimal packaging strategies so as to obtain the final program compiling files.
For example, as shown in fig. 3, fig. 3 is a schematic view of a scenario for determining a newly added compiling sentence according to an embodiment of the present application; the method comprises the steps of setting a program compiling statement obtaining mode to obtain every appointed period, setting a third time as an x-th period arrival time, setting a second time as an x+1th period arrival time, and setting a first time as an x+2th period arrival time;
(1) The method comprises the steps that an electronic device obtains a program compiling file (setting a file A) at a first moment, obtains a history program compiling file (setting a file B) at a second moment, analyzes grammar of the file A and the file B to determine a new compiling sentence (1) of the file A compared with the file B, determines a packaging strategy (1) aiming at a program resource library (1) based on the new compiling sentence (1), determines the file A as a target program compiling file at the first moment if the packaging mode aiming at the program resource library (1) in the file A is the packaging strategy (1) at the moment, and updates the packaging mode aiming at the program resource library (1) in the file A as the packaging strategy (1) if the packaging mode aiming at the program resource library (1) in the file A is not the packaging strategy (1), determines the updated file A as a target program file at the first moment, and obtains the target program compiling file when the history program compiling file serving as the first moment is obtained;
(2) Therefore, the historical program compiling file at the second moment is the target program compiling file at the second moment; the electronic device obtains a program compiling file (set file C) at the second moment and a history program compiling file (set file D) of the application program at the third moment, parses the file C and the file D to determine a newly added compiling sentence (2) of the file C compared with the file D, determines a packaging policy (2) for a program resource library (2) (a resource library which may be the same as the program resource library (1)) based on the newly added compiling sentence (2), determines the file C as a target program compiling file at the second moment if the packaging manner for the program resource library (2) in the file C is the packaging policy (2), and updates the packaging manner for the program resource library (2) in the file C as the packaging policy (2) if the packaging manner for the program resource library (2) in the file C is not the packaging policy (2), and determines the updated file C as a target program compiling file at the second moment (i.e., the file B is obtained).
In some embodiments, the generating, by the electronic device, a first statement analysis result for the program compiling file may specifically be that each compiling statement in the program compiling file is subjected to statement analysis to obtain structural information for each compiling statement, and the structural information is determined as the first statement analysis result, where the structural information is used to indicate elements and meanings included in the corresponding compiling statement.
For example, if the compiled sentence is "x1=x2", the structured information obtained based on the sentence analysis may be: element "X1" and its meaning, element "=" and its meaning, element "X2" and its meaning, each element corresponds to one sub-compilation statement. When a compiling statement can call a program resource package, the corresponding structural information of the compiling statement contains a character string of a corresponding element for representing the program resource package and a corresponding meaning for indicating that the corresponding element is the program resource package in a program resource library; when a compiling sentence can call the program resource library, the corresponding structural information of the compiling sentence contains a character string of a corresponding element for representing the program resource library, and contains a corresponding meaning for indicating that the corresponding element is a program resource library. The second sentence analysis result of the history program compilation file may be obtained in the same manner as the first sentence analysis result.
Alternatively, the second statement analysis result may be obtained by obtaining the historical program compilation file at the second time and performing statement analysis on the historical program compilation file, or the second statement analysis result may be obtained by performing statement analysis when the historical program compilation file at the second time is determined, and the second statement analysis result is cached and obtained from the cache by the electronic device. Therefore, when the electronic device determines the target program compiling file at the first moment, the target program compiling file may be cached, or the target statement analysis result of the target program compiling file may be determined, and the target statement analysis result may be cached for obtaining at the next moment.
In some embodiments, the electronic device parses the program compiled file according to the first sentence analysis result and the second sentence analysis result, determines, based on the obtained parsing result, that a new compiled sentence in the at least one compiled sentence may specifically be, compares structural information of each compiled sentence included in the first sentence analysis result with structural information of each historical compiled sentence included in the second sentence analysis result, and obtains difference structural information of the first sentence analysis result compared with that of the second sentence analysis result, where the difference structural information is structural information existing in the first sentence analysis result and not existing in the second sentence analysis result, and determines a compiled sentence corresponding to the difference structural information in the program compiled file as the new compiled sentence.
For example, the first sentence analysis result includes the structured information 1 of the compiled sentence a, the structured information 2 of the compiled sentence B, and the structured information 3 of the compiled sentence C, and the second sentence analysis result includes the structured information 4 of the compiled sentence B (the structured information 4 and the structured information 2 are the same), the structured information 5 of the compiled sentence C (the structured information 5 and the structured information 3 are different), and the structured information 6 of the compiled sentence D is compared to obtain the structured information 3 and the structured information 1 as differential structured information, which can be regarded as the structured information that does not exist in the second sentence analysis result. Because the historical program compiling file is the compiling file which is updated at the second time (namely, the described installation package volume optimizing step is executed), the newly added compiling sentence between the first time and the second time can be obtained, and the latest program compiling file is optimized based on the newly added compiling sentence.
S203, acquiring a target program resource library called by the newly added compiling statement from at least one program resource library.
In some embodiments, the newly added compilation statement may be one or more. If the new compiling statement includes a first compiling statement for calling the program resource package, determining the program resource package called by the new compiling statement as a target program resource package, and taking a program resource library to which the target program resource package belongs as a target program resource library.
The target program resource package may be one or more, and the corresponding target program resource library may be one or more. If the newly added compiling statement comprises a second compiling statement for calling the program resource library, determining the called program resource library as a target program resource library; if the new compiling sentence belongs to the third compiling sentence, namely, if the new compiling sentence does not have any called program resource package or program resource library, the new compiling sentence does not have a called target program resource library, the following steps are not executed, and the program compiling file at the moment is used as the target program compiling file at the first moment. The determining whether the newly added compiling statement has a call or whether the program resource package or the program resource library is called may be determined by the electronic device from structural information corresponding to the newly added compiling statement.
In some embodiments, the program resource package (or program resource library) called by the newly added compiling statement may be understood as a newly called program resource package (or program resource library) between the first time and the second time, and the newly called program resource package (or program resource library) may be a program resource package (or program resource library) which is not called before, that is, a program resource package (or program resource library) which is not called before in the historical compiling file, and may be a program resource package (or program resource library) which is called before, that is, a program resource package (or program resource library) which is called before in the historical compiling file. The target program resource library can be understood as a program resource library with a new call record, and the new compiled statement contains a compiled statement that makes the program resource library have the new call record.
S204, acquiring a program resource package set called by at least one compiling 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 packaging strategy is used for determining whether to package the whole target program resource library or package program resources contained in the program resource package set, and the target program resource library packaged based on the packaging strategy is used for generating a program installation package of the application program, namely the program installation package contains resource files indicated by the packaging strategy. If the packing strategy indicates to pack the target program resource library, the program installation package contains the target program resource library, namely contains all program resource packages in the target program resource library; if the packaging policy indicates that the program resource package set is packaged, the program installation package only contains all program resource packages in the program resource package set.
In some embodiments, the electronic device may specifically acquire a set of program resource packages called by at least one compiling sentence in the target program resource library, determine that there is a compiling sentence calling the program resource package according to structural information corresponding to each compiling sentence in the at least one compiling sentence, acquire the program resource package called by the compiling sentence, and acquire one or more program resource packages belonging to the target program resource library from the previously called program resource packages as the set of program resource packages. When the target program resource library is determined by the program resource library called by the newly added compiling statement belonging to the second compiling statement, acquiring the program resource package set can determine the program resource package belonging to the target program resource library from all the program resource packages called by the first compiling statement in at least one compiling statement as the program resource package set; when the target program resource library is determined by the program resource package called by the new compiling sentence belonging to the first compiling sentence, the acquiring the program resource package set may determine the program resource package belonging to the target program resource library from all the program resource packages called by the first compiling sentence except the new compiling sentence in the at least one compiling sentence, and determine the program resource package called by the program resource package and the new compiling sentence as the program resource package set.
In some embodiments, the determining, by the electronic device, a packaging policy for the target program resource library based on the program resource package set may specifically be obtaining a first amount of packaging data for packaging the program resource package set, and obtaining a second amount of packaging data for packaging the target program resource library, and determining, by the electronic device, the packaging policy for the target program resource library according to the first amount of packaging data and the second amount of packaging data. The first packed data amount is the sum of packed data amounts obtained by respectively packing each program resource package in the program resource package set, and the second packed data amount is the packed data amount obtained by packing the whole target program resource library. The first packed data amount refers to the occupied volume of a packed result obtained by packing the program resource package set in the program installation package, and the second packed data amount refers to the occupied volume of a packed result obtained by packing the target program resource library in the program installation package, so that the whole volume of the program installation package can be optimized by optimizing the occupied volume of the part.
The first packed data amount may be determined according to a data size of each program resource package in the set of program resource packages and a data size of resource package association information of each program resource package, and the second packed data amount may be determined according to a data size of each program resource package in the target program resource library and a data size of resource library association information of the target program resource library. The detailed description herein may be found in relation to the following embodiments.
The set of program packages is typically part of the program packages in the target program repository. It should be noted that, if all program resource packages in the target program resource library included in the program resource package set, that is, all program resource packages indicating that the application program may actually use the target program resource library, the packaging policy for the target program resource library may be directly determined as packaging the whole target program resource library without executing the subsequent steps.
In some embodiments, the determining, by the electronic device, the packaging policy for the target program resource repository according to the first packet data amount and the second packet data amount may specifically be determining that the packaging policy is a policy for packaging the program resource package set if the first packet data amount is less than the second packet data amount; and if the first packed data amount is greater than or equal to the second packed data amount, determining that the packing strategy is a strategy for packing the target program resource library. Packaging the whole program resource library or packaging a specific program resource package in the program resource library can be called a packaging strategy for the program resource library.
The packaging strategy of the program resource library is provided with corresponding strategy compiling sentences, the strategy compiling sentences are different under different packaging strategies, and when the packaging strategy is to package the whole program resource library, the strategy compiling sentences belong to a second compiling sentence of a second type, namely the second compiling sentence can represent that the whole program resource library is called into a program installation package, namely the packaging strategy of the program resource library is represented; when the packaging policy is to package a specific program resource package, the policy compiling statement belongs to a first compiling statement of a first type, that is, the first compiling statement may include a compiling statement (set as a compiling statement i) that represents a packaging policy for calling the specific program resource package to a program installation package and representing a program resource library to which the specific program resource package belongs.
In addition, the first compiling sentence may further include two compiling sentences: (1) A compiling statement (which is expressed as a compiling statement II) for indicating how the application program calls the program resource package in the compiling statement I to use, namely the compiling statement II is used for indicating a specific calling mode of the application program for the program resource package quoted by the compiling statement I; (2) And the compiling statement (which is indicated as compiling statement III) is used for indicating a specific calling mode for the appointed program resource packages in the referenced program resource library, wherein the appointed program resource packages are the program resource packages actually used in the referenced program resource library, and the compiling statement III is related to the second compiling statement corresponding to the affiliated program resource library.
For example, (1) the second compilation statement "AAA (1)" represents a reference to the entire program repository (1) and a packaging policy for the program repository (1); (2) The first compiling sentence (compiling sentence I) "AAA (2). M" represents a program resource package m in the reference program resource library (2) and a packaging strategy for the program resource library (2); (3) A first compiling sentence (compiling sentence iii), (1), "n (X1, X2)" means a program resource package n in the reference program resource library (1) and specifically called in such a manner that X1 and X2 are input into the program resource package n for operation, and the first compiling sentence is associated with the second compiling sentence; (4) The first compiling sentence (compiling sentence II), (2), "m (X1, X2)" refers to a program resource package m in the reference program resource library (2) and specifically invokes the program resource package m by inputting X1 and X2 into the program resource package m for operation; the above-described compilation statements are merely examples, and compilation statements under different compilation languages and tools may differ.
In some embodiments, the packaging policy is embodied by a corresponding policy compiling statement, that is, a policy compiling statement corresponding to a packaging policy of an associated program resource library exists in the program compiling file obtained at this time, after determining an optimal packaging policy of a target program resource library called by the newly added compiling statement, a policy compiling statement corresponding to a packaging policy (packaging policy to be updated) existing in the program compiling file in the target program resource library may be obtained, and the program compiling file is updated by using the optimal packaging policy, so that the policy compiling statement of the packaging policy of the target program resource library existing in the updated program compiling file is a policy compiling statement indicating the optimal packaging policy.
For example, if the packaging policy to be updated for the target program resource library is to package the target program resource library as a whole, then the policy compiling statement corresponding to the packaging policy to be updated at this time belongs to the second compiling statement, so that:
(1) If the determined optimal packaging strategy is to package a program resource package which is specifically used in a target program resource library, generating a target strategy compiling sentence corresponding to the optimal packaging strategy, wherein the target strategy compiling sentence belongs to a first compiling sentence, updating the strategy compiling sentence corresponding to the packaging strategy to be updated into a target strategy compiling sentence in a program compiling file, and determining an updated program compiling file as a target program compiling file;
(2) If the strategy compiling statement corresponding to the packaging strategy to be updated of the target program resource library comprises the strategy for packaging the program resource package A and the program resource package B in the target program resource library, and if the optimal packaging strategy is the whole packaging of the target program resource library, updating the corresponding strategy compiling statement into a target strategy compiling statement corresponding to the optimal packaging strategy in the program compiling file;
(3) If the strategy compiling statement corresponding to the packaging strategy to be updated of the target program resource library simultaneously comprises strategy compiling statements corresponding to strategies for packaging a program resource package A and a program resource package B in the target program resource library and strategy compiling statements corresponding to the whole packaging of the target program resource library, and if the optimal packaging strategy is the whole packaging of the target program resource library (or packaging of the program resource package A and the program resource package B), updating the strategy compiling statements corresponding to the two strategies into target strategy compiling statements corresponding to the optimal packaging strategy only in a program compiling file;
(4) If the strategy compiling statement corresponding to the packaging strategy to be updated of the target program resource library simultaneously comprises the strategy for packaging the program resource package A and the program resource package B in the target program resource library and the overall packaging of the target program resource library, and if the optimal packaging strategy is for packaging the program resource package A, the program resource package B and the program resource package C in the target program resource library, the strategy compiling statement corresponding to the packaging strategy to be updated is updated into the target strategy compiling statement corresponding to the optimal packaging strategy only in the program compiling file.
Thus, in the updated program compilation file, there is only one policy compilation statement for the packaging policy of the associated program repository. And it can be understood that the technical solution of the present application is to optimize the installation package volume by optimizing the packaging policy, so that the optimized application program is a program that references any program resource library or any program resource package.
In the embodiment of the application, a program compiling file of an application program can be obtained, compiling sentences contained in the program compiling file are subjected to grammar analysis, a new compiling sentence in at least one compiling sentence is determined based on a grammar analysis result, a target program resource library called by the new compiling sentence is obtained from at least one program resource library, a program resource package set called by the at least one compiling sentence in the target program resource library is obtained, and a packaging strategy for the target program resource library is determined based on the program resource package set. By the method, the optimal packing strategy can be determined according to the invoked program resource package set, the determining efficiency and accuracy of the packing strategy are improved, and the packing strategy can enable the size of the program installation package to be smaller than that of the program installation package obtained under other packing strategies of the target program resource library, so that the size optimizing effect of the program installation package is improved.
Referring to fig. 4, fig. 4 is a flowchart of a program data processing method according to an embodiment of the application, and the method may be performed by the above-mentioned electronic device. As shown in fig. 4, the process of the program processing method in the embodiment of the present application may include the following steps:
s401, acquiring a program compiling file of an application program. The specific implementation manner of step S401 may be referred to the related description of the above embodiments, which is not repeated herein.
S402, acquiring a syntax analysis tree of a program compiling file and acquiring a history syntax analysis tree of a history program compiling file of an application program.
In some embodiments, the program compilation file is a compilation file of an application at a first time, the parse tree includes at least one tree node, and any compilation statement of the program compilation file corresponds to the at least one tree node of the parse tree. And the history program compiling file is a compiling file at the second moment, the history program compiling file comprises at least one history compiling sentence, the history syntax analysis tree comprises at least one history tree node, and any history compiling sentence corresponds to the at least one history tree node of the history syntax analysis tree. The relevant description of the first moment and the second moment can be found in the above-described embodiments.
The grammar analysis tree is obtained based on a first statement analysis result generated by carrying out statement analysis on the program compiling file, the first statement analysis result comprises structural information of each compiling statement in the program compiling file, the structural information comprises each element and meaning in the corresponding compiling statement, and the elements are sub-compiling statements disassembled from the compiling statement.
In some embodiments, the electronic device may obtain the parse tree based on the first statement analysis result by corresponding each compiling statement to a tree node, where the corresponding tree node may represent corresponding structural information, and the tree node associates a position of the corresponding compiling statement in the program compiling file (e.g. what line in the program compiling file); the corresponding tree node may represent the meaning of the corresponding element and element, that is, the sub-compiled sentence in each compiled sentence corresponds to a tree node, where the tree node has an association relationship (corresponding relationship) with the corresponding sub-compiled sentence and the original compiled sentence where the sub-compiled sentence is located, and the tree node associates the positions of the corresponding sub-compiled sentence and the located compiled sentence in the program compiled file (such as what row and what column in the program compiled file). Thus, at least one of the tree nodes included in the parse tree has a tree node calling a corresponding program resource package or program resource library, and also has a tree node not called. The historical grammar analysis tree is obtained based on the historical sentence analysis result generated by carrying out sentence analysis on the historical program compiling file, and the concrete mode can be the same as the determination mode of the grammar analysis tree.
For example, as shown in fig. 5, fig. 5 is a schematic diagram of a parse tree according to an embodiment of the present application; the program compiling file is provided to contain compiling sentences 1"y =x' and compiling sentences 2 AAA (1)", and is obtained based on sentence analysis: the structured information of the compiling sentence 1 comprises a sub compiling sentence 1 ("y") and a meaning 1, a sub compiling sentence 2 ("=") and a meaning 2, a sub compiling sentence 3 ("x") and a meaning 3, and the structured information of the compiling sentence 2 comprises a sub compiling sentence 4 ("AAA") and a meaning 4, a sub compiling sentence 5 ("(1)") and a meaning 5; thus:
(a) If one compiling sentence corresponds to one tree node, the generated syntax analysis tree may have two tree nodes, as shown in (1) in fig. 5, each tree node represents the structural information of the corresponding compiling sentence, and the tree node is associated with the position of the corresponding compiling sentence in the program compiling file (the figure also includes a main node (not being a tree node corresponding to any compiling sentence));
(b) If one sub-compiled sentence in the compiled sentences corresponds to one tree node, the generated parse tree may have 5 tree nodes, as shown in (2) in fig. 5, each tree node represents the meaning of the corresponding sub-compiled sentence and sub-compiled sentence, each tree node corresponds to the compiled sentence where the sub-compiled sentence is located, and the tree nodes are associated with the positions of the corresponding sub-compiled sentence and compiled sentence in the program compiled file (the map also includes the main node (not being the tree node corresponding to any compiled sentence)), which is merely an example herein, and the parse tree may also have other forms.
In some embodiments, if the program compilation file is obtained according to the specified period, the syntax analysis tree is obtained based on the program compilation file at the arrival time of the current period, and the history syntax analysis tree is obtained based on the program compilation file at the arrival time of the previous period; if the acquired program compiling file is detected to satisfy the development operation of the trigger condition, the syntax analysis tree is obtained based on the program compiling file at the moment indicated by the current detection point, and the history syntax analysis tree is obtained based on the program compiling file at the moment indicated by the last detection point; if the obtained program compiling file is obtained after the research and development is completed, the syntax analysis tree is obtained based on the complete program compiling file, the history syntax analysis tree is obtained based on the initial program compiling file, and any compiling statement written in the initial program compiling file can be absent, so that the history syntax analysis tree can be a tree with only one main node or a tree with only initial nodes, and at the moment, the difference tree nodes can be all tree nodes (except the main nodes) in the syntax analysis tree.
Therefore, the technical scheme of the application can be used for not only the new project under development, namely, the optimization is automatically realized in the code compiling stage, but also the project which is already developed and completed, the technical scheme of the application can be packaged into a plug-in, the plug-in is installed in the project which is already developed and completed, and when the installation package optimization request of a user is detected to trigger the updating operation of each compiling script included in the project, the electronic equipment can acquire the compiling script corresponding to the project through the plug-in, so as to realize the optimization updating of the quote program resource library mode in the compiling script.
S403, determining a new compiling sentence in at least one compiling sentence based on the syntax analysis tree and the historical syntax analysis tree.
The electronic device may parse the program compiling file based on the history parse tree and the parse tree, and determine an newly added compiling sentence based on a result of the parsing.
In some embodiments, the electronic device parses the program compiled file based on the history parse tree and the parse tree, and determines the newly added compiled sentence based on the parse result may specifically be comparing a history tree node included in the history parse tree with a tree node included in the parse tree, to obtain a parse tree, and determine the difference tree node as the parse result compared with a difference tree node of the history parse tree, and determine a compiled sentence corresponding to the difference tree node in the program compiled file as the newly added compiled sentence.
The newly added compiling sentence may be a compiling sentence corresponding to the node of the difference tree, or may be a corresponding sub-compiling sentence, or may also be an original compiling sentence where the corresponding sub-compiling sentence is located. When the newly added compiling sentence is a sub compiling sentence, and a target program resource library called by the newly added compiling sentence is determined subsequently, an original compiling sentence corresponding to the newly added compiling sentence can be obtained and determined by utilizing the original compiling sentence; or the related compiling tree nodes of the difference tree nodes corresponding to the new compiling sentence can be obtained, the compiling tree nodes can be all the tree nodes (including the difference tree nodes corresponding to the new compiling sentence) generated based on the original compiling sentence corresponding to the new compiling sentence, and the called target program resource library is determined according to the information represented by the related compiling tree nodes.
And the difference tree node can be obtained based on a compiling statement newly written in the program compiling file or can be obtained based on a compiling statement modified in the program compiling file. That is, the tree node corresponding to the newly written compiling sentence does not exist in the history parse tree, and the tree node corresponding to the modified compiling sentence does not have the same information represented in the history parse tree and the parse tree, so that the tree node having the different information represented based on the comparison indication is also used as the difference tree node.
For example, the parse tree includes a tree node 1 corresponding to a compile statement 1 (set "a=b") and a tree node 2 corresponding to a compile statement 2, the history parse tree includes a tree node 3 corresponding to a history compile statement 1 (set "a=c") and a tree node 4 corresponding to a history compile statement 2, the compile statement 1 is set to be obtained by modifying the history compile statement 1, at this time, the tree node 1 and the tree node 3 represent information which is not identical, the compile statement 2 is newly written, and the obtained differential tree node is the tree node 1 and the tree node 2, and the determined newly added compile statement is the corresponding compile statement 1 and the compile statement 2.
S404, acquiring a target program resource library called by the newly added compiling statement from at least one program resource library. The specific implementation of step S404 may be referred to the related description of the above embodiments, which is not repeated here.
S405, acquiring a program resource package set called by at least one compiling statement in a target program resource library.
In some embodiments, if any one of the compiled sentences corresponds to a plurality of tree nodes of the parse tree, the plurality of tree nodes are generated based on a plurality of sub-compiled sentences resulting from parsing any one of the compiled sentences, any one of the plurality of tree nodes corresponding to any one of the plurality of sub-compiled sentences. Either one compiled sentence corresponds to one tree node or one sub-compiled sentence corresponds to one tree node. Thus, the obtaining the target program resource library called by the newly added compiling sentence from at least one program resource library may specifically be obtaining the calling information of the compiling sentence or the sub-compiling sentence corresponding to each tree node in the parse tree, where the calling information may include a calling program resource package, a calling program resource library or a non-calling program resource package and a program resource library, determining the program resource package corresponding to the calling from the calling information, determining the tree node of the target program resource library to which the called program resource package belongs in the parse tree as the reference tree node, and generating the program resource package set according to the program resource package called by the compiling sentence or the sub-compiling sentence corresponding to the reference tree node. The set of program packages may be program packages belonging to one or more program repositories.
S406, determining a packaging strategy for the target program resource library based on the program resource package set.
In one possible implementation, the electronic device may determine the corresponding packaging policy according to the program resource packages included in the program resource package set and the program resource packages included in the target program resource library. The determining a packaging policy for the target program resource library based on the program resource package set may specifically be that a first packaging data amount for packaging the program resource package set is obtained, a second packaging data amount for packaging the target program resource library is obtained, and the packaging policy for the target program resource library is determined according to the first packaging data amount and the second packaging data amount.
The first packed data amount is the data amount to be occupied in the program installation package when the program resource package set is packed, and the second packed data amount is the data amount to be occupied in the program installation package when the target program resource library is packed. The first packed data amount and the second packed data amount may be determined after the electronic device performs the packing operation, or may be determined by a process of respectively analyzing and packing the program resource package set and the target program resource library through a packing analysis tool to determine the packed data amount to be occupied.
In some embodiments, the process of packaging the program resource package set may specifically be: acquiring resource package association information corresponding to each program resource package in a program resource package set, packaging each program resource package in each program resource package set in the program resource package set and the resource package association information corresponding to each program resource package respectively to obtain a first transitional packaging result, and determining the data volume of the first transitional packaging result as a first package data volume. The resource package association information may be configuration information of a program resource package, etc., such as a version number of the program resource package, definition language information in the program resource package, declaration information for the program resource package, etc. In addition, other relevant information may be included in the actual scenario, which is merely an example, and the resource package association information may be obtained when the developer codes the program resource package.
In some embodiments, the process of packaging the target program resource library may specifically be: and acquiring the resource library associated information corresponding to the target program resource library, packaging each program resource package and the resource library associated 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 a second packaging data volume. The repository-related information may be configuration information of the program repository, etc., such as a version number of the included program package, definition language information of the included program package, declaration information for the program repository, etc. In addition, other relevant information may be included in the actual scenario, which is merely exemplary herein, and the repository association information may be obtained when the developer codes the program resource package.
It should be noted that, the resource package association information belongs to the resource library association information, when program packaging is performed, all program resource packages in the target program resource library can share the resource library association information, and when one program resource package is packaged independently, the resource package association information corresponding to each program resource package is independent and complete, how many program resource packages are introduced independently, and how many corresponding resource package association information are, so that the data volume of the resource library association information of the target program resource library may be smaller than the sum of the data volumes of all the resource package association information corresponding to the program resource package set. For example, all program resource packages in the target program resource library can share declaration information for the program resource library, that is, only one piece of declaration information can exist in the resource library association information, and when the program resource packages are individually packaged, individual declaration information of the program resource packages can be generated, that is, individual declaration information corresponding to each program resource package in the program resource package set exists in all the resource package association information, so that the data volume of the resource library association information is smaller than the data volume of all the resource package association information.
Optionally, in some embodiments, the packaging processing is performed on each program resource package in the program resource package set and the resource package association information corresponding to each program resource package respectively, so that a first transitional packaging result may specifically be obtained, where the each program resource package and the resource package association information corresponding to each program resource package are referred to the program installation package according to a specified format, and the program resource package set and the corresponding resource package association information in the specified format are determined as the first transitional packaging result; for example, the program resource package is a file in the format A, and the package is led into the program installation package, and the package can be called by the program only in the format B, and then the package is processed into a target file for converting the program resource package into the format B; or the packaging process needs to encapsulate the resource package association information into a file of a specified format and add it to the program installation package or the like.
Optionally, in some embodiments, the packaging processing is performed on each program resource package and the resource library association information in the target program resource library, so as to obtain a second transitional packaging result, which specifically may be that each program resource package and the resource library association information in the target program resource library are referenced to the program installation package according to the specified format, and the target program resource library including the program resource package in the specified format and the corresponding resource library association information are determined as the second transitional packaging result.
Further optionally, the first transitional packaging result may further include a reference address of the program resource package to the program installation package; the reference addresses for the individual program resource packages may be different and the first transitional packaging result contains a reference address for each individual program resource package. And the second transitional packaging result can also comprise a reference address from the target program resource library to the program installation package; the reference addresses corresponding to the program resource packages in the target program resource library are the same, and the second transitional packaging result only comprises the reference addresses of the target program resource library. When an application invokes a program resource package in the target program resource library, a reference address of the target program resource library may be obtained, and a specified program resource package may be searched and invoked from the reference address in a specified manner, such as by a program resource package name search.
Based on the above description, in general, the number of program resource packages in the program resource package set is smaller than the number of program resource packages contained in the target program resource library, but there may still be a case where the first packet data amount is larger than the second packet data amount.
Therefore, in some embodiments, the determining, by the electronic device, the packaging policy for the target program resource repository according to the first packet data amount and the second packet data amount may specifically be determining that the packaging policy is a policy for packaging the set of program resource packages if the first packet data amount is less than the second packet data amount; and if the first packed data amount is greater than or equal to the second packed data amount, determining that the packing strategy is a strategy for packing the target program resource library. The electronic device may determine a corresponding target program compilation file according to a packaging policy for the target program repository.
In some embodiments, after the code writing of the application program is completed and the optimal packaging policy for each program resource library is determined, the electronic device may obtain a final optimized program compilation file, and package the final program compilation file to obtain a program installation package. When the final program compiling file is packaged, program resource libraries except the target program resource library in at least one program resource library are determined to be undetermined program resource libraries, undetermined packaging strategies aiming at the undetermined program resource libraries are obtained from the program compiling file, packaging processing is conducted on the undetermined program resource libraries according to the undetermined packaging strategies to obtain a first packaging result, packaging processing is conducted on the target program resource library according to the packaging strategies to obtain a second packaging result, and a program installation package of the application program is generated based on the first packaging result and the second packaging result.
The electronic device, through the packaging policy ultimately determined by each associated program repository, may determine whether each program repository references a full amount of program packages in the program installation package or references a portion of the program packages in the program repository. Therefore, compared with the manual judgment of the reference mode of part of program resource libraries, the technical scheme of the application can automatically simplify the packaging strategy for referencing all program resource libraries, and improves the comprehensiveness of optimization.
It may be appreciated that when there are multiple target program resource libraries, the program resource package set at this time includes program resource packages of the multiple target program resource libraries, program resource package sub-sets belonging to each target program resource library are determined from the program resource package set, and a packaging policy of each target program resource library is correspondingly determined according to the above-described manner based on each program resource package sub-set.
For example, there are a program resource package (1) and a program resource package (2) in the program resource library a in the program resource package set (and all program resource packages in the program resource package library a are set to (1) (2) (1)), a program resource package (3) and a program resource package (4) in the program resource library B are set to (3) (4) (3)), a program resource package (5) and a program resource package (6) in the program resource library C are set to (and all program resource packages in the program resource package library C are set to (5) (6)), so the electronic device determines a packaging policy for the program resource library a based on the program resource package (1) and the program resource package (2), and determines a packaging policy for the program resource library B based on the program resource package (3) and the program resource package (4), and directly determines the packaging policy for the program resource library C as a policy for packaging the program resource library C as a whole.
In some embodiments, if the program compiling file is obtained by detecting that the compiling statement which is written or changed newly is a compiling statement which makes the program resource library have a new call record, the obtaining times may be frequent, and the first packed data amount and the second packed data amount are calculated frequently, so that the situation that the electronic device is blocked is caused, therefore, the above problem can be improved by realizing throttling in a mode of obtaining according to a specified period and caching the calculated packed data amount each time; however, when the data is acquired according to a specified period, a plurality of compiling sentences which enable different program resource libraries to call and change may exist in the newly added compiling sentences, so that the data amount of the packaged data under the program resource libraries is calculated for a plurality of times at one time, and the workload is large and long, and therefore the data amount of the packaged data can be calculated for the program resource libraries in parallel in a multi-process mode, so that the efficiency is improved.
For example, as shown in fig. 6, fig. 6 is a schematic flow chart of a multi-process-based data processing according to an embodiment of the present application; wherein:
(1) When a plurality of target program resource libraries are provided, the electronic equipment respectively creates a calculation task for each target program resource library;
(2) Each computing task is put into a task queue, a computing process is allocated for the computing task in the task queue, the computing task is issued for the allocated computing process to perform multiprocessing task processing, and the computing task comprises a corresponding target program resource library and a program resource package set belonging to the corresponding target program resource library;
(3) Executing corresponding computing tasks in each computing process, wherein the process comprises the following steps: inquiring whether the second packed data quantity corresponding to the target program resource library is calculated before and whether the first packed data quantity corresponding to the process sequence resource package sub-set is calculated before from the cache, acquiring the cache if the first packed data quantity exists, calculating the packed data quantity for the calculation task if the first packed data quantity does not exist, and caching the calculation result;
(4) Taking the first packed data quantity/the second packed data quantity in the cache or obtained by calculation as a task result of the calculation task, and the electronic equipment acquires the task result of each calculation task and executes the subsequent steps of the technical scheme of the application.
In some embodiments, the electronic device may configure a plurality of installation package optimization modules to perform the above-described steps. For example, the installation package optimization module may include a program detection module, a syntax analysis module, a packed data amount calculation module, and a packing policy recommendation module; the plurality of installation package optimization modules can be configured in other devices, or can be partially or completely positioned in the same other device or different other devices, and the electronic device schedules the installation package optimization modules on the other devices.
For example, the execution interaction between the installation package optimization modules may be as shown in fig. 7, where fig. 7 is an interaction schematic diagram of a program data processing flow provided by an embodiment of the present application; wherein:
s1, a developer can input program source codes in electronic equipment;
s2, the electronic equipment can detect program input behaviors of developers through a program detection module, and the program detection module is used for detecting changes of compiling sentences contained in a program compiling file;
s3, if the program detection module detects that a new call record generated by a newly written or changed compiling statement exists, generating first prompt information and sending the first prompt information to the grammar analysis module;
wherein detecting a newly written or altered compilation statement to generate a new call record may be: detecting whether the newly written compiling statement invokes the program resource library or the program resource package, for example, a keyword in a policy compiling statement representing a packaging policy appears (if the compiling statement is JS language, the keyword may be an import or a request (for example, "import a" represents a reference to the program resource library a, and when the import keyword appears, a new call record is generated), and different compiling statements may be different), or a specific usage mode (for example, compiling statement "(1) ·n (X1, X2)") of the program resource package is indicated, a name of the program resource package appears and usage of the program resource package n in the calling program resource library a is indicated; the new call record generated by the compiled statement that detects the change may be: detecting whether the modified compiling statement modifies a program resource library or a program resource package, for example, the program resource package A is modified into a program resource package B;
S4, the electronic equipment can obtain a new compiling sentence through a syntax analysis module, the syntax analysis module is used for obtaining a program compiling file and performing syntax analysis when receiving first prompt information to determine the new compiling sentence, the syntax analysis module can obtain a syntax analysis tree of the program compiling file at the first moment, and inquire a historical program compiling file at the second moment or a historical syntax analysis tree of the historical program compiling file from a cache (if the cache does not exist, the initial program compiling file is used as the historical program compiling file, the initial syntax analysis tree is used as the historical syntax analysis tree), and a tree difference analysis (tree diff) flow is performed to achieve syntax analysis on the syntax analysis tree and the historical syntax analysis tree, and the new compiling sentence is determined according to a syntax analysis result;
the tree difference analysis flow comprises the following steps: performing syntax analysis on each tree node included in the syntax analysis tree and each history tree node included in the history syntax analysis tree to obtain a difference tree node of the syntax analysis tree compared with the history syntax analysis tree, wherein the difference tree node is a tree node of which the syntax analysis tree is changed compared with the history syntax analysis tree between the first moment and the second moment, and a compiling sentence corresponding to the difference tree node is a newly added compiling sentence;
S5, the grammar analysis module generates second prompt information according to the newly added compiling statement and sends the second prompt information to the packed data quantity calculation module, wherein the second prompt information can be specifically: determining a target program resource library generating a new call record according to the newly added compiling statement, determining which tree nodes (or called compiling statements) call program resource packages in the target program resource library through a syntax analysis tree after determining the target program resource library, and obtaining a program resource package set based on the determined tree nodes (or compiling statements), wherein the second prompt information comprises the target program resource library and the program resource package set;
s6, the electronic device can obtain a first packed data amount and a second packed data amount through a packed data amount calculation module, the packed data amount calculation module is used for obtaining a target program resource library when receiving second prompt information, and calling a packing analysis tool (the packing analysis tool can be a packing analysis tool in a JavaScript-based packer) to search all program resource packages according to a catalog of the target program resource library, packing the all program resource packages to obtain a second packed data amount of the target program resource library, searching corresponding partial program resource packages from the catalog of the target program resource library according to an instruction of a program resource package set, and packing and analyzing the partial program resource packages to obtain a first packed data amount for packing the program resource set;
The process of performing package analysis on the program resource package set may include: acquiring resource package association information of each program resource package in a program resource package set, and packaging the resource package association information of each program resource package and each program resource package to obtain a first transitional packaging result, wherein the first transitional packaging result comprises a plurality of data files (such as the program resource package set and the resource package association information in a specified format and also can comprise a reference address of each program resource package respectively), and the data size of the plurality of data files contained in the first transitional packaging result is used as a first packaging data size;
and, the process of performing the package analysis on the whole program resource package may include: acquiring the resource library associated information of the target program resource library, and packaging the resource library associated information and all program resource packages to obtain a second transitional packaging result, wherein the second transitional packaging result comprises a plurality of data files (such as all program resource packages and resource library associated information in a specified format and reference addresses of the target program resource library), and the data size of the plurality of data files contained in the second transitional packaging result is used as a second packaging data size;
Illustratively, the calculation result obtained by the packed data amount calculation module may be as shown in fig. 8, in which a first packed data amount obtained by packing a target program resource library (set denoted as "M") is 134kb (Kilobyte, a metering unit), and a second packed data amount obtained by packing a program resource package set (set denoted as "M.n", indicating a program resource package n in the program resource library M) is 2kb;
s7, the packed data amount calculation module generates third prompt information after obtaining a calculation result aiming at packing and sends the third prompt information to the packing strategy recommendation module, wherein the third prompt information comprises a first packed data amount and a second packed data amount;
alternatively, when calculation is required for a plurality of target program resource libraries, the packed data amount calculation module may create one calculation task for each target program resource library, and process each calculation task in parallel through multiple processes;
s8, the electronic equipment can determine a packaging strategy aiming at the target program resource library through a packaging strategy recommendation module, wherein the packaging strategy recommendation module is used for determining an optimal packaging strategy according to the size relation between the first packaging data amount and the second packaging data amount when receiving the third prompt information and interacting with a code editor operated by the electronic equipment;
S9, the packed data amount calculation module generates fourth prompt information and outputs the fourth prompt information to a code editor of the electronic equipment, wherein the fourth prompt information comprises a determined packing strategy, and the fourth prompt information is used for displaying on the electronic equipment so as to remind a developer whether to update the packing strategy; after the developer confirms, the electronic equipment combines a code generation interface provided by a code editor and determines a corresponding recommended strategy compiling statement based on the packaging strategy and updates a program compiling file;
optionally, the electronic device may receive the third prompt information without using the packaging policy recommendation module, determine a packaging policy for the target program resource library based on the third prompt information, directly combine with the code editor and update the program compiling file based on the packaging policy, so that a policy compiling statement corresponding to the determined packaging policy can be automatically replaced by a policy compiling statement corresponding to the original packaging policy in the program compiling file, and user programming experience can be improved without affecting original compiling logic in the program compiling file.
The application can automatically determine the packing strategy of the program resource library at the front end, improve the quality and efficiency of optimizing the volume of the program installation package obtained after packing, perform the operation described above on any optimizable packing strategy in the program compiling file, and determine the optimal packing strategy for the current program compiling file when the program compiling file is obtained each time, thereby realizing that the program resource library in the research and development process is optimally introduced in a locally optimal mode and the volume of the constructed program installation package is optimally.
In addition, the application can be applied to electronic equipment of any operating system, can be used on any code editor (for example, VSCode (Visual Studio Code, a cross-platform source code editor), intelliJ IDEA (a source code editor based on Java development language)) to update program compiling files in the code editor, and can be packaged into a plug-in and uploaded to npm warehouse through npm (node package manager ) tools for use by any developer, thereby improving the flexibility of use.
In the embodiment of the application, a program compiling file of an application program, a syntax analysis tree of the program compiling file and a history syntax analysis tree of a history program compiling file of the application program can be obtained, a new compiling sentence in at least one compiling sentence is determined based on the syntax analysis tree and the history syntax analysis tree, a target program resource library called by the new compiling sentence is obtained from at least one program resource library, a program resource package set called by the at least one compiling sentence in the target program resource library is obtained, and a packaging strategy for the target program resource library is determined based on the program resource package set. By the method, the optimal packing strategy can be determined according to the invoked program resource package set, the determining efficiency and accuracy of the packing strategy can be improved, and the packing strategy can enable the size of the program installation package to be smaller than that of the program installation package obtained under other packing strategies of the target program resource library, so that the volume optimizing effect of the program installation package is improved.
The foregoing details of the method of embodiments of the present application are provided for the purpose of better implementing the foregoing aspects of embodiments of the present application, and accordingly, the following provides an apparatus of embodiments of the present application.
Referring to fig. 9, fig. 9 is a schematic structural diagram of a program data processing apparatus according to the present application; the program data processing means may be a computer program (comprising program code) running in the electronic device, for example the program data processing means may be an application program (e.g. a program enabling program data processing) in the electronic device. It should be noted that the program data processing apparatus shown in fig. 9 is used to execute some or all of the steps in the methods of the embodiments shown in fig. 2 and fig. 4 of the present application. The program data processing apparatus 900 may include: an acquisition module 901, a processing module 902, a determination module 903. Wherein:
an acquiring module 901, configured to acquire a program compilation file of an application program; the program compilation file contains at least one compilation statement; the program compiling file is provided with at least one associated program resource library, and any program resource library comprises at least one program resource package called by at least one compiling statement;
The processing module 902 is configured to parse a compiled sentence included in the program compilation file, and determine a newly added compiled sentence in at least one compiled sentence based on a result of the parsing;
the obtaining module 901 is further configured to obtain a target program resource library called by the newly added compiling statement from at least one program resource library;
the acquiring module 901 is further configured to acquire a program resource package set invoked by at least one compiling statement in a target program resource library;
a determining module 902, configured to determine a packaging policy for the target program resource library based on the set of program resource packages; the target program resource library packaged based on the packaging policy is used for generating a program installation package of the application program.
In one possible embodiment, the program compiled file is a compiled file of the application program at the first time;
the processing module 902 is specifically configured to, when performing syntax analysis on a compiled sentence included in a program compiled file, determine an newly added compiled sentence in the program compiled file based on a result of the syntax analysis:
generating a syntax analysis tree of the program compiling file; the parse tree comprises at least one tree node, and any compiling statement of the program compiling file corresponds to the at least one tree node of the parse tree;
Acquiring a historical grammar analysis tree of a historical program compiling file of the application program at a second moment; the second moment is earlier than the first moment; the history syntax analysis tree comprises at least one history tree node, the history program compilation file comprises at least one history compilation statement, any history compilation statement of the history program compilation file corresponding to the at least one history tree node of the history syntax analysis tree;
performing grammar analysis on the program compiling file based on the history grammar analysis tree and the grammar analysis tree, and determining a newly added compiling statement based on a grammar analysis result; the newly added compiled statement is newly added at a first time and a second time.
In one possible implementation, the processing module 902 is specifically configured to, when configured to parse a program compilation file based on a historical parse tree and a parse tree, and determine an additional compilation statement based on a result of the parsing:
comparing the historical tree nodes contained in the historical parse tree with the tree nodes contained in the parse tree to obtain a difference tree node of the parse tree compared with the historical parse tree;
and determining the difference tree node as a grammar analysis result, and determining a compiling sentence corresponding to the difference tree node in the program compiling file as a newly added compiling sentence.
In one possible embodiment, if any one of the compiled sentences corresponds to a plurality of tree nodes of the parse tree, the plurality of tree nodes are generated based on a plurality of sub-compiled sentences obtained by decomposing any one of the compiled sentences, and any one of the plurality of tree nodes corresponds to any one of the plurality of sub-compiled sentences;
the obtaining module 901, when used for obtaining a program resource package set called by at least one compiling sentence in a target program resource library, is specifically configured to:
acquiring a program resource package called by a compiling statement or a sub-compiling statement corresponding to each tree node in the syntax analysis tree;
determining a tree node of a program resource package called in the syntax analysis tree belonging to a target program resource library as a reference tree node;
and generating a program resource package set according to the program resource package called by the compiling statement or the sub-compiling statement corresponding to the reference tree node.
In one possible implementation, the determining module 902, when configured to determine a packaging policy for a target program resource library based on a set of program resource packages, is specifically configured to:
acquiring a first package data amount for packaging a program resource package set;
acquiring a second packed data amount for packing the target program resource library;
And determining a packaging strategy for the target program resource base according to the first packaging data quantity and the second packaging data quantity.
In one possible implementation, the process of packaging the program resource package set includes:
acquiring resource packet association information corresponding to each program resource packet in a program resource packet set;
packaging each program resource package in the program resource package set and the resource package association information corresponding to each program resource package respectively to obtain a first transition packaging result;
determining the data quantity of the first transitional packaging result as a first packaged data quantity;
the process of packaging the target program resource library comprises the following steps:
acquiring resource library association information corresponding to a target program resource library;
packaging each program resource package and the associated information of the resource library in the target program resource library to obtain a second transitional packaging result;
and determining the data quantity of the second transitional packing result as a second packed data quantity.
In one possible implementation, the determining module 902, when configured to determine a packaging policy for the target program resource library according to the first amount of packaging data and the second amount of packaging data, is specifically configured to:
if the first packed data quantity is smaller than the second packed data quantity, determining that the packing strategy is a strategy for packing the program resource package set;
And if the first packed data amount is greater than or equal to the second packed data amount, determining that the packing strategy is a strategy for packing the target program resource library.
In one possible implementation, the processing module 902 is further configured to:
determining a program resource library except a target program resource library in at least one program resource library as a pending program resource library;
acquiring a pending packaging strategy aiming at a pending program resource library;
packaging the undetermined program resource library according to a undetermined packaging strategy to obtain a first packaging result;
packaging the target program resource library according to a packaging strategy to obtain a second packaging result;
and generating a program installation package of the application program based on the first packing result and the second packing result.
According to an embodiment of the present application, each unit in the program data processing apparatus shown in fig. 9 may be separately or completely combined into one or several other units, or some unit(s) thereof may be further split into a plurality of units having smaller functions, which may achieve the same operation without affecting the achievement of the technical effects of the embodiment of the present application. The above units are divided based on logic functions, and in practical applications, the functions of one unit may be implemented by a plurality of units, or the functions of a plurality of units may be implemented by one unit.
In other embodiments of the application, the program data processing means may also comprise other units, and in practical applications, these functions may also be realized with the aid of other units, and may be realized by cooperation of a plurality of units. According to another embodiment of the present application, a program data processing apparatus as shown in fig. 9 may be constructed by running a computer program (including program code) capable of executing the steps involved in the respective methods as shown in fig. 2 and 4 on a general-purpose computing device such as a computer including a processing element such as a Central Processing Unit (CPU), a random access storage medium (RAM), a read only storage medium (ROM), and the like, and a storage element, and the program data processing method of the embodiment of the present application is implemented. The computer program may be recorded on, for example, a computer-readable recording medium, and loaded into and run in the above-described electronic device through the computer-readable recording medium.
In the embodiment of the application, an acquisition module acquires a program compiling file of an application program; the processing module carries out grammar analysis on compiling sentences contained in the program compiling file and determines newly added compiling sentences in the program compiling file based on grammar analysis results; the acquisition module acquires a target program resource package called by the newly added compiling statement; the determining module determines a program resource library to which a target program resource package in at least one program resource library belongs as a target program resource library; the method comprises the steps that an acquisition module acquires a program resource package set called by at least one compiling statement in a target program resource library; the determination module determines a packaging policy for the target program resource library based on the set of program resource packages. By the device, the optimal packing strategy can be determined according to the invoked program resource package set, the determining efficiency and accuracy of the packing strategy are improved, and the packing strategy can enable the size of the program installation package to be smaller than that of the program installation package obtained under other packing strategies of the target program resource library, so that the size optimizing effect of the program installation package is improved.
The functional modules in the embodiments of the present application may be integrated into one processing module, or each module may exist alone physically, or two or more modules may be integrated into one module. The integrated modules may be implemented in hardware or in software functional modules, which is not limited by the present application.
Referring to fig. 10, fig. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 10, the electronic device 1000 includes: a processor 1001, a communication interface 1002, and a computer-readable storage medium 1003. Wherein the processor 1001, the communication interface 1002, and the computer-readable storage medium 1003 may be connected by a bus or other means. Wherein the communication interface 1002 is for receiving and transmitting data. The computer readable storage medium 1003 may be stored in a memory of the electronic device, the computer readable storage medium 1003 is used to store a computer program comprising program instructions, and 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 a computing core as well as a control core of the electronic device, which is adapted to implement one or more instructions, in particular to load and execute one or more instructions to implement a corresponding method flow or a corresponding function.
The embodiment of the application also provides a computer readable storage medium (Memory), which is a Memory device in the electronic device and is used for storing programs and data. It is understood that the computer readable storage medium herein may include both built-in storage media in an electronic device and extended storage media supported by the electronic device. The computer readable storage medium provides a memory space that stores a processing system of the electronic device. Also stored in this memory space are one or more instructions, which may be one or more computer programs (including program code), adapted to be loaded and executed by the processor 1001. Note that the computer readable storage medium can be either a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as at least one magnetic disk memory; alternatively, it may be at least one computer-readable storage medium located remotely from the aforementioned processor.
In one embodiment, the computer-readable storage medium has one or more instructions stored therein; one or more instructions stored in a computer-readable storage medium are loaded and executed by the processor 1001 to implement the corresponding steps in the document processing method embodiments described above; in particular implementations, one or more instructions in a computer-readable storage medium are loaded by the processor 1001 and perform the steps of:
Acquiring a program compiling file of an application program; the program compilation file contains at least one compilation statement; the program compiling file is provided with at least one associated program resource library, and any program resource library comprises at least one program resource package called by at least one compiling statement;
carrying out grammar analysis on compiling sentences contained in the program compiling file, and determining a newly added compiling sentence in at least one compiling sentence based on a grammar analysis result;
acquiring a target program resource library called by a new compiling statement from at least one program resource library;
acquiring a program resource package set called by at least one compiling statement in a target program resource library, and determining 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 policy is used to generate a program installation package for the application program.
In one possible embodiment, the program compiled file is a compiled file of the application program at the first time;
the processor 1001 is specifically configured to, when performing parsing on a compilation sentence included in a program compilation file, determine an newly added compilation sentence in the program compilation file based on a result of the parsing:
Generating a syntax analysis tree of the program compiling file; the parse tree comprises at least one tree node, and any compiling statement of the program compiling file corresponds to the at least one tree node of the parse tree;
acquiring a historical grammar analysis tree of a historical program compiling file of the application program at a second moment; the second moment is earlier than the first moment; the history syntax analysis tree comprises at least one history tree node, the history program compilation file comprises at least one history compilation statement, any history compilation statement of the history program compilation file corresponding to the at least one history tree node of the history syntax analysis tree;
performing grammar analysis on the program compiling file based on the history grammar analysis tree and the grammar analysis tree, and determining a newly added compiling statement based on a grammar analysis result; the newly added compiled statement is newly added at a first time and a second time.
In one possible implementation, the processor 1001 is specifically configured to, when configured to parse a program compilation file based on a history parse tree and a parse tree, and determine an newly added compilation statement based on a result of the parsing:
comparing the historical tree nodes contained in the historical parse tree with the tree nodes contained in the parse tree to obtain a difference tree node of the parse tree compared with the historical parse tree;
And determining the difference tree node as a grammar analysis result, and determining a compiling sentence corresponding to the difference tree node in the program compiling file as a newly added compiling sentence.
In one possible embodiment, if any one of the compiled sentences corresponds to a plurality of tree nodes of the parse tree, the plurality of tree nodes are generated based on a plurality of sub-compiled sentences obtained by decomposing any one of the compiled sentences, and any one of the plurality of tree nodes corresponds to any one of the plurality of sub-compiled sentences;
the processor 1001, when configured to obtain a set of program resource packages invoked by at least one compiled statement in the target program resource library, is specifically configured to:
acquiring a program resource package called by a compiling statement or a sub-compiling statement corresponding to each tree node in the syntax analysis tree;
determining a tree node of a program resource package called in the syntax analysis tree belonging to a target program resource library as a reference tree node;
and generating a program resource package set according to the program resource package called by the compiling statement or the sub-compiling statement corresponding to the reference tree node.
In one possible implementation, the processor 1001, when configured to determine a packaging policy for a target program resource library based on a set of program resource packages, is specifically configured to:
Acquiring a first package data amount for packaging a program resource package set;
acquiring a second packed data amount for packing the target program resource library;
and determining a packaging strategy for the target program resource base according to the first packaging data quantity and the second packaging data quantity.
In one possible implementation, the process of packaging the program resource package set includes:
acquiring resource packet association information corresponding to each program resource packet in a program resource packet set;
packaging each program resource package in the program resource package set and the resource package association information corresponding to each program resource package respectively to obtain a first transition packaging result;
determining the data quantity of the first transitional packaging result as a first packaged data quantity;
the process of packaging the target program resource library comprises the following steps:
acquiring resource library association information corresponding to a target program resource library;
packaging each program resource package and the associated information of the resource library in the target program resource library to obtain a second transitional packaging result;
and determining the data quantity of the second transitional packing result as a second packed data quantity.
In one possible implementation, the processor 1001 is specifically configured to, when configured to determine a packaging policy for the target program resource library according to the first amount of packaging data and the second amount of packaging data:
If the first packed data quantity is smaller than the second packed data quantity, determining that the packing strategy is a strategy for packing the program resource package set;
and if the first packed data amount is greater than or equal to the second packed data amount, determining that the packing strategy is a strategy for packing the target program resource library.
In one possible implementation, the processor 1001 is further configured to:
determining a program resource library except a target program resource library in at least one program resource library as a pending program resource library;
acquiring a pending packaging strategy aiming at a pending program resource library;
packaging the undetermined program resource library according to a undetermined packaging strategy to obtain a first packaging result;
packaging the target program resource library according to a packaging strategy to obtain a second packaging result;
and generating a program installation package of the application program based on the first packing result and the second packing result.
In the embodiment of the application, the processor can acquire the program compiling file of the application program, parse the compiling sentences contained in the program compiling file, determine the newly added compiling sentences in the program compiling file based on the result of the syntax parsing, acquire the target program resource packages called by the newly added compiling sentences, determine the program resource library to which the target program resource packages belong in at least one program resource library as the target program resource library, acquire the program resource package set called by the at least one compiling sentences in the target program resource library, and determine the packaging strategy for the target program resource library based on the program resource package set. Through the scheme, the optimal packing strategy can be determined according to the invoked program resource package set, the determining efficiency and accuracy of the packing strategy are improved, and the packing strategy can enable the size of the program installation package to be smaller than that of the program installation package obtained under other packing strategies of the target program resource library, so that the size optimizing effect of the program installation package is improved.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in accordance with embodiments of the present application are produced in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable devices. The computer instructions may be stored in or transmitted across a computer-readable storage medium. The computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by a wired (e.g., coaxial cable, fiber optic, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). Computer readable storage media can be any available media that can be accessed by a computer or data storage devices, such as servers, data centers, etc., that contain an integration of one or more available media. The usable medium may be a magnetic medium (e.g., a floppy Disk, a hard Disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a Solid State Disk (SSD)), or the like.
The foregoing is merely illustrative of the present application, and the present application is not limited thereto, and any person skilled in the art will readily recognize that variations or substitutions are within the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (12)

1. A program data processing method, the method comprising:
acquiring a program compiling file of an application program; the program compiling file comprises at least one compiling statement; the program compiling file is provided with at least one associated program resource library, and any program resource library comprises at least one program resource package called by the at least one compiling statement;
carrying out grammar analysis on compiling sentences contained in the program compiling file, and determining newly added compiling sentences in the at least one compiling sentence based on grammar analysis results;
acquiring a target program resource library called by the newly added compiling statement from the at least one program resource library;
acquiring a program resource package set called by the at least one compiling 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 target program resource library packaged based on the packaging policy is used for generating a program installation package of the application program.
2. The method of claim 1, wherein the program compilation file is a compilation file of the application at a first time;
the parsing of the compiling sentence contained in the program compiling file, and determining the newly added compiling sentence in the program compiling file based on the result of the parsing, includes:
generating a syntax analysis tree of the program compiling file; the parse tree includes at least one tree node, and any compiling statement of the program compiling file corresponds to the at least one tree node of the parse tree;
acquiring a history grammar analysis tree of a history program compiling file of the application program at a second moment; the second time is earlier than the first time; the history syntax analysis tree comprises at least one history tree node, the history program compilation file comprises at least one history compilation statement, any history compilation statement of the history program compilation file corresponds to at least one history tree node of the history syntax analysis tree;
carrying out grammar analysis on the program compiling file based on the history grammar analysis tree and the grammar analysis tree, and determining the newly added compiling sentence based on the grammar analysis result; the newly added compiling sentence is newly added between the first time and the second time.
3. The method of claim 2, wherein parsing the program compilation file based on the historical parse tree and the parse tree and determining the newly added compilation statement based on the parse result comprises:
comparing the historical tree nodes contained in the historical analysis tree with the tree nodes contained in the analysis tree to obtain a difference tree node of the analysis tree compared with the historical analysis tree;
and determining the difference tree node as the grammar analysis result, and determining the compiling statement corresponding to the difference tree node in the program compiling file as the newly added compiling statement.
4. The method of claim 2, wherein if the any one of the compiled sentences corresponds to a plurality of tree nodes of the parse tree, the plurality of tree nodes are generated based on a plurality of sub-compiled sentences resulting from parsing the any one of the compiled sentences, any one of the plurality of tree nodes corresponding to any one of the plurality of sub-compiled sentences;
the acquiring the program resource package set called by the at least one compiling statement in the target program resource library comprises the following steps:
Acquiring a program resource package called by a compiling statement or a sub-compiling statement corresponding to each tree node in the syntax analysis tree;
determining a tree node of the called program resource package belonging to the target program resource library in the syntax analysis tree as a reference tree node;
and generating the program resource package set according to the program resource package called by the compiling statement or the sub-compiling statement corresponding to the reference tree node.
5. The method of claim 1, wherein the determining a packaging policy for the target program resource library based on the set of program resource packages comprises:
acquiring a first packed data amount for packing the program resource package set;
acquiring a second packed data amount for packing the target program resource library;
determining the packaging policy for the target program resource library according to the first packaging data amount and the second packaging data amount.
6. The method of claim 5, wherein the process of packaging the set of program resource packages comprises:
acquiring resource package association information corresponding to each program resource package in the program resource package set;
Packaging each program resource package in the program resource package set and the resource package association information corresponding to each program resource package respectively to obtain a first transitional packaging result;
determining the data quantity of the first transitional packaging result as the first packaged data quantity;
the process of packaging the target program resource library comprises the following steps:
acquiring resource library association information corresponding to the target program resource library;
packaging each program resource package in the target program resource library and the associated information of the resource library to obtain a second transitional packaging result;
and determining the data quantity of the second transition package result as the second package data quantity.
7. The method of claim 5, wherein the determining the packaging policy for the target program resource library based on the first amount of packaging data and the second amount of packaging data comprises:
if the first packed data amount is smaller than the second packed data amount, determining that the packing strategy is a strategy for packing the program resource package set;
and if the first packed data amount is greater than or equal to the second packed data amount, determining that the packing strategy is a strategy for packing the target program resource library.
8. The method according to claim 1, wherein the method further comprises:
determining a program resource library except the target program resource library in the at least one program resource library as a pending program resource library;
acquiring a pending packaging strategy aiming at the pending program resource library;
packaging the undetermined program resource library according to the undetermined packaging strategy to obtain a first packaging result;
packaging the target program resource library according to the packaging strategy to obtain a second packaging result;
and generating the program installation package of the application program based on the first packing result and the second packing result.
9. A program data processing apparatus, the apparatus comprising:
the acquisition module is used for acquiring a program compiling file of the application program; the program compiling file comprises at least one compiling statement; the program compiling file is provided with at least one associated program resource library, and any program resource library comprises at least one program resource package called by the at least one compiling statement;
the processing module is used for carrying out grammar analysis on the compiling sentences contained in the program compiling file and determining a new compiling sentence in the at least one compiling sentence based on a grammar analysis result;
The acquisition module is further used for acquiring a target program resource library called by the newly added compiling statement from the at least one program resource library;
the acquisition module is further used for acquiring a program resource package set called by the at least one compiling statement in the target program resource library;
the determining module is further used for determining 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 policy is used for generating a program installation package of the application program.
10. An electronic device comprising a processor and a memory, wherein the memory is configured to store a computer program comprising program instructions, the processor being configured to invoke the program instructions to perform the method of any of claims 1-8.
11. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program comprising program instructions which, when executed by a processor, cause the processor to perform the method of any of claims 1-8.
12. A computer program product comprising computer instructions which, when executed by a processor, implement the method of any of claims 1-8.
CN202210234951.XA 2022-03-09 2022-03-09 Program data processing method, program data processing device, electronic equipment, medium and program product Pending CN116775099A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210234951.XA CN116775099A (en) 2022-03-09 2022-03-09 Program data processing method, program data processing device, electronic equipment, medium and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210234951.XA CN116775099A (en) 2022-03-09 2022-03-09 Program data processing method, program data processing device, electronic equipment, medium and program product

Publications (1)

Publication Number Publication Date
CN116775099A true CN116775099A (en) 2023-09-19

Family

ID=87990118

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210234951.XA Pending CN116775099A (en) 2022-03-09 2022-03-09 Program data processing method, program data processing device, electronic equipment, medium and program product

Country Status (1)

Country Link
CN (1) CN116775099A (en)

Similar Documents

Publication Publication Date Title
US11868231B2 (en) System and method for evaluating code by a hybrid of local and cloud-based computers
CN108920133B (en) Cross-language programming method and device, electronic equipment and storage medium
CN103164249B (en) Extension mechanism for script compiler
CN105022630B (en) A kind of assembly management system and assembly management method
CN108369591B (en) System and method for caching and parameterizing IR
US20090328016A1 (en) Generalized expression trees
CN106873952B (en) Data processing system and method for mobile terminal webpage development and application device
CN111324619B (en) Object updating method, device, equipment and storage medium in micro-service system
US11537367B1 (en) Source code conversion from application program interface to policy document
CN108804100B (en) Method and device for creating interface element, storage medium and mobile terminal
CN112328219A (en) Service access processing method, device and system and computer equipment
CN115599386A (en) Code generation method, device, equipment and storage medium
CN109634569B (en) Method, device and equipment for realizing flow based on annotation and readable storage medium
CN116560683A (en) Software updating method, device, equipment and storage medium
CN111240772A (en) Data processing method and device based on block chain and storage medium
CN113312046A (en) Sub-application page processing method and device and computer equipment
CN110851211A (en) Method, apparatus, electronic device, and medium for displaying application information
CN116089004A (en) Migration method and device for intelligent contract codes among heterogeneous blockchains
CN115373684A (en) Applet fusion method and device, electronic equipment and storage medium
CN116775099A (en) Program data processing method, program data processing device, electronic equipment, medium and program product
US11573777B2 (en) Method and apparatus for enabling autonomous acceleration of dataflow AI applications
CN110297639B (en) Method and apparatus for detecting code
US11429358B2 (en) Representing asynchronous state machine in intermediate code
CN114047923A (en) Error code positioning method, device, storage medium and electronic equipment
CN113138767A (en) Code language conversion method, device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination