Application compiling method, readable storage medium and program product

By utilizing the link auxiliary information of historical compilation results and processing the intermediate compilation results of newly added resources separately, the problem of time-consuming application compilation in the existing technology is solved, and more efficient resource linking and application compilation efficiency is achieved.

CN120803456APending Publication Date: 2025-10-17TENCENT MUSIC ENTERTAINMENT TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510834238.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-20
Publication Date
2025-10-17

AI Technical Summary

Technical Problem

In the prior art, the application compilation process takes a long time, especially when the resource files change, and the full link leads to low compilation efficiency.

Method used

By obtaining link auxiliary information of historical compilation results, resource linking is performed separately on the intermediate compilation results of new resources. Combined with the merging of historical and new resource link results, an application package is generated to reduce the number of intermediate compilation results processed during the resource linking process and avoid repeated linking.

Benefits of technology

This shortens the resource linking time during application compilation, improves compilation efficiency, and ensures the accuracy of new resource links and the integrity of the application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120803456A_ABST
    Figure CN120803456A_ABST
Patent Text Reader

Abstract

The invention relates to an application compiling method, a computer readable storage medium and a computer program product, relates to the technical field of computers, and can improve the application compiling efficiency. The method comprises the steps of obtaining a historical resource compiling result obtained after historical compiling processing of an application, and obtaining link auxiliary information related to resource link according to the historical resource compiling result; when a newly-added intermediate compiling result corresponding to newly-added resources of the application is obtained, performing resource linking on the newly-added intermediate compiling result according to the linking auxiliary information to obtain a newly-added resource linking result corresponding to the newly-added resources; and obtaining a first application package corresponding to the application according to a merging result of the increased resource link result and a historical resource link result corresponding to the historical resource compiling result, and determining an application compiling result of the application according to the first application package.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to an application compiling method, a computer device, a computer readable storage medium and a computer program product. BACKGROUND

[0002] With the development of computer technology, more and more computer applications are developed. After the developed application is compiled, the source code written in a high-level programming language can be converted into binary code which can be directly executed by a computer device.

[0003] In the related art, the compiling process includes two parts of compiling and linking. When part of the resource files of the application changes, the compiling stage can only compile the changed resource files into intermediate products, the linking stage is to input all the intermediate products of the changed resource files and all other unchanged intermediate products in full amount, link them together, and output all the linking results in full amount, thereby obtaining the final compiling result of the application.

[0004] However, it is found in practice that the above-mentioned compiling method is time-consuming, and there is a problem that the application compiling efficiency needs to be improved. SUMMARY

[0005] Therefore, it is necessary to provide an application compiling method, a computer device, a computer readable storage medium and a computer program product to solve the above technical problems.

[0006] In a first aspect, the present application provides an application compiling method, comprising:

[0007] obtaining a historical resource compiling result of an application obtained after historical compiling processing, and obtaining linking auxiliary information related to resource linking according to the historical resource compiling result;

[0008] when obtaining an intermediate compiling result corresponding to a new resource of the application, performing the resource linking on the intermediate compiling result according to the linking auxiliary information, to obtain a new resource linking result corresponding to the new resource;

[0009] obtaining a first application package corresponding to the application according to a merging result of the new resource linking result and a historical resource linking result corresponding to the historical resource compiling result, and determining an application compiling result of the application according to the first application package.

[0010] In one of the embodiments, the obtaining of the linking auxiliary information related to the resource linking according to the historical resource compiling result comprises:

[0011] obtaining target application information of the application related to the resource linking according to the historical resource compiling result;

[0012] Obtaining a software development kit corresponding to the application, and determining system resource information corresponding to system resources that the application depends on based on the software development kit;

[0013] According to the target application information and the system resource information, link auxiliary information related to resource linking is acquired.

[0014] In one embodiment, performing the resource linking on the newly added intermediate compilation result according to the link auxiliary information to obtain the newly added resource linking result corresponding to the newly added resource includes:

[0015] Determining a resource identifier corresponding to each of the newly added intermediate compilation results according to the target application information and the system resource information;

[0016] According to the resource identifier corresponding to each of the newly added intermediate compilation results, the resource linking is performed on the newly added intermediate compilation results to obtain a newly added resource linking result corresponding to the newly added resource.

[0017] In one embodiment, obtaining target application information related to the application and resource linking based on the historical resource compilation result includes:

[0018] If the historical resource compilation result includes a second application package obtained after the application is historically compiled, obtaining a resource identification mapping table and a resource file from the second application package;

[0019] The resource attributes are determined according to the resource file, and the target application information related to the application and resource linking is determined according to the resource identification mapping table and the resource attributes.

[0020] In one embodiment, obtaining target application information related to the application and resource linking based on the historical resource compilation result includes:

[0021] If the historical resource compilation result includes all existing intermediate compilation results obtained after the application is historically compiled, then obtaining a resource identification mapping table and resource attributes based on analysis results of all existing intermediate compilation results;

[0022] According to the resource identification mapping table and the resource attributes, the target application information related to the application and resource linking is determined; the resource identification mapping table records the path mapping relationship between the resource identification and the resource file.

[0023] In one embodiment, after obtaining link auxiliary information related to resource linking according to the historical resource compilation result, the method further includes:

[0024] caching and maintaining the link auxiliary information;

[0025] Before the resource linking is performed on the new intermediate compilation result according to the link auxiliary information, the method further includes:

[0026] When the new intermediate compilation result corresponding to the new resource of the application is obtained, the cached link auxiliary information is read.

[0027] In one embodiment, the determining of the application compilation result of the application according to the first application package includes:

[0028] If it is determined that the new resource identifier is not included in the new resource linking result, the application compilation result of the application is obtained according to the first application package and the historical resource index file corresponding to the historical resource compilation result;

[0029] If it is determined that the new resource identifier is included in the new resource linking result, the new resource index file corresponding to the new resource is generated, and the application compilation result of the application is obtained according to the new resource index file, the historical resource index file and the first application package.

[0030] In one embodiment, the obtaining of the first application package corresponding to the application according to the merging result of the new resource directory and the historical resource linking result corresponding to the historical resource compilation result includes:

[0031] The second application package obtained after the historical compilation processing of the application is obtained; the second application package includes the historical resource linking result corresponding to the historical resource compilation result;

[0032] The new resource linking result is added to the second application package to obtain the updated first application package of the application.

[0033] In a second aspect, the application further provides a computer device including a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:

[0034] The historical resource compilation result obtained after the historical compilation processing of the application is obtained, and the link auxiliary information related to the resource linking is obtained according to the historical resource compilation result;

[0035] When the new intermediate compilation result corresponding to the new resource of the application is obtained, the resource linking is performed on the new intermediate compilation result according to the link auxiliary information to obtain the new resource linking result corresponding to the new resource.

[0036] According to the merging result of the incremental resource linking result and the historical resource linking result corresponding to the historical resource compilation result, a first application program package corresponding to the application is acquired, and an application compilation result of the application is determined according to the first application program package.

[0037] In a third aspect, the present application further provides a computer readable storage medium, which has a computer program stored thereon, and the computer program is executed by a processor to implement the following steps:

[0038] A historical resource compilation result obtained after an application is historically compiled is acquired, and linking auxiliary information related to resource linking is acquired according to the historical resource compilation result.

[0039] When an incremental intermediate compilation result corresponding to an incremental resource of the application is acquired, the resource linking is performed on the incremental intermediate compilation result according to the linking auxiliary information, so that an incremental resource linking result corresponding to the incremental resource is obtained.

[0040] According to the merging result of the incremental resource linking result and the historical resource linking result corresponding to the historical resource compilation result, a first application program package corresponding to the application is acquired, and an application compilation result of the application is determined according to the first application program package.

[0041] In a fourth aspect, the present application further provides a computer program product, which comprises a computer program, and the computer program is executed by a processor to implement the following steps:

[0042] A historical resource compilation result obtained after an application is historically compiled is acquired, and linking auxiliary information related to resource linking is acquired according to the historical resource compilation result.

[0043] When an incremental intermediate compilation result corresponding to an incremental resource of the application is acquired, the resource linking is performed on the incremental intermediate compilation result according to the linking auxiliary information, so that an incremental resource linking result corresponding to the incremental resource is obtained.

[0044] According to the merging result of the incremental resource linking result and the historical resource linking result corresponding to the historical resource compilation result, a first application program package corresponding to the application is acquired, and an application compilation result of the application is determined according to the first application program package.

[0045] The above-mentioned application compilation method, computer device, computer-readable storage medium and computer program product can obtain the historical resource compilation result obtained after the application is historically compiled, and obtain link auxiliary information related to resource linking based on the historical resource compilation result. When the new intermediate compilation result corresponding to the new resource of the application is obtained, the new intermediate compilation result is resource linked according to the link auxiliary information to obtain the new resource link result corresponding to the new resource. Furthermore, the first application package corresponding to the application can be obtained based on the merged result of the new resource link result and the historical resource link result corresponding to the historical resource compilation result, and the application compilation result of the application can be determined based on the first application package. In this embodiment, when a new intermediate compilation result is obtained, link auxiliary information is obtained according to the historical resource compilation result, resource linking is performed on the new intermediate compilation result separately, and the first application package corresponding to the application is obtained according to the merged result of the obtained new resource link result and the historical resource link result. When there are new resources in the application, resource linking can be performed on the intermediate compilation result of the newly added part separately, thereby reducing the number of intermediate compilation results that need to be processed during the resource linking process, avoiding repeated linking of linked resources, and shortening the resource linking time in the application compilation process while making full use of the historical resource linking results. At the same time, by using the historical resource compilation results to determine the link auxiliary information, it is possible to avoid conflicts between the content of the obtained new resource linking result and the content of the historical resource linking result, thereby improving the accuracy of independent linking of new resources, and effectively improving the application compilation efficiency when resources are updated in the application. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments of the present application or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying any creative work.

[0047] Figure 1 A schematic diagram of a flow chart of an application compilation method in one embodiment;

[0048] Figure 2 A schematic flow chart of steps in a compilation phase according to an embodiment;

[0049] Figure 3 A schematic diagram of the structure of a file format in one embodiment;

[0050] Figure 4 A schematic diagram of the structure of another file format in one embodiment;

[0051] Figure 5A flowchart of a compiling method for another application in an embodiment;

[0052] Figure 6 An internal structure diagram of a computer device in an embodiment. DETAILED DESCRIPTION

[0053] For the purpose, technical solutions and advantages of the present application to be clearer, further detailed description will be given in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application.

[0054] In an embodiment, as shown in Figure 1 a compiling method is provided, and the embodiment takes the method applied to a terminal as an example. It should be understood that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction of the terminal and the server. In the embodiment, the method includes the following steps:

[0055] S101, obtaining a historical resource compiling result obtained by a historical compiling process on an application, and obtaining link auxiliary information related to resource linking according to the historical resource compiling result.

[0056] The historical compiling process can be a compiling process performed on the resources of the application in the past. The application resources compiled by the historical compiling process are referred to as historical resources. The historical compiling process can be a complete compiling process, or a compiling stage in the complete compiling process. The compiling stage can convert source code and / or resource files written in a high-level programming language into a corresponding intermediate compiling result. The historical resource compiling result is a compiling result of the historical resources.

[0057] The link auxiliary information can be understood as additional information needed for reference in the resource linking process. The link auxiliary information can ensure the accuracy and integrity of the resource linking. Exemplarily, the link auxiliary information can include one or more of application information, resource dependency relationship, and system resource reference information corresponding to the application. The application information can include basic information of the application and resource information corresponding to the resources used to build the application. The resource dependency relationship can record the dependency relationship between different resources, such as a layout file referencing a string resource or a picture resource. The system resource reference information can indicate the resources referenced by the application and provided by the system.

[0058] In this step, the application to be compiled can be determined, and the historical compilation result corresponding to the application can be obtained. The application can be any application of the relevant resource file after historical compilation processing. In some examples, the application can be an application for which the relevant resource file has undergone a complete compilation process and obtained a corresponding executable application package, or the application can be an application for which an intermediate compilation result of the relevant resource file has been obtained.

[0059] Then, by analyzing the historical resource compilation result, link auxiliary information related to subsequent resource linking can be extracted. Specifically, in the resource linking process, the resource identifier and the reference relationship between the resources can be determined. In some embodiments, by analyzing the historical resource compilation result, information related to the resource representation and the resource application can be extracted therefrom, and the information can be used as link auxiliary information.

[0060] S102, when the newly added intermediate compilation result corresponding to the newly added resource of the application is obtained, the newly added intermediate compilation result is subjected to resource linking according to the link auxiliary information, and a newly added resource linking result corresponding to the newly added resource is obtained.

[0061] The newly added resource can be a resource that has undergone content changes. For example, the newly added resource can be a resource that has not been used in previous application compilation. For example, the application uses picture 1 and picture 2 in historical compilation processing, and picture 3 is added in resource updating, that is, picture 1, picture 2, and picture 3 are collectively used as resources of the application. The newly added resource can also be a resource used to update a previously used resource. For example, picture 1 and picture 2 are used in historical compilation processing, and picture 1' is used to update and replace picture 1 in resource updating. Picture 1' and picture 2 are used as resources of the application, where picture 1' is referred to as a newly added resource.

[0062] In a specific implementation, the newly added resource can be compiled separately to obtain a corresponding intermediate compilation result. For ease of distinction, the intermediate compilation result corresponding to the newly added resource is referred to as a newly added intermediate compilation result. In an example, the newly added intermediate compilation result can be a flat file corresponding to the newly added resource, which can be obtained by separately compiling the newly added resource. When the newly added intermediate compilation result is obtained, the newly added intermediate compilation result can be separately subjected to resource linking according to the link auxiliary information, and a resource linking result corresponding to the newly added resource can be obtained according to the resource linking result. For ease of distinction, the resource linking result corresponding to the newly added resource is referred to as a newly added resource linking result, and the resource linking result corresponding to the historical resource or the historical resource compilation result is referred to as a historical resource linking result. In an example, the resource linking result can be a resource directory, which can be understood as a folder and can be used to store various resources of the application. The resource directory is a structure used to organize and manage application resources, and provides a hierarchical way to store and find files.

[0063] In other words, in the present embodiment, the newly added intermediate compilation result can be separately resource-linked according to the link assistance information obtained from the historical resource compilation result without re-linking the historical resources (i.e. the resources used in the historical compilation process). On the one hand, by using the link assistance information determined according to the historical resource compilation result for resource linking, the content of the obtained newly added resource directory can be prevented from conflicting with the content of the historical resource directory. On the other hand, the full amount of intermediate compilation results (including the historical intermediate compilation result corresponding to the historical resources and the newly added intermediate compilation result corresponding to the newly added resources) does not need to be resource-linked, but the newly added intermediate compilation result of the newly added part of the resources can be separately resource-linked. Thus, the number of intermediate compilation results that need to be processed in the resource linking process can be reduced while ensuring the accuracy of the resource linking, the repeated linking of the already linked resources can be avoided, and the resource linking time can be shortened.

[0064] S103, according to the merging result of the newly added resource linking result and the historical resource linking result corresponding to the historical resource compilation result, obtaining a first application package corresponding to the application, and determining the application compilation result of the application according to the first application package.

[0065] In the present step, the newly added resource linking result can be merged with the historical resource linking result obtained after the historical compilation process to obtain a merging result. In some examples, the historical resource directory corresponding to the historical resource compilation result can be obtained, and then the historical resource directory and the newly added resource directory can be merged to obtain a merged resource directory, which can be used as the merging result.

[0066] Then, the application package corresponding to the application can be obtained according to the merging result, and the application compilation result of the application can be obtained according to the application package. In order to distinguish from other application packages in the present application, the application package obtained after the merging of the resource directory can be referred to as the first application package.

[0067] In the application compiling method, the historical resource compiling result obtained after the application is historically compiled can be acquired, the link auxiliary information related to resource linking can be acquired according to the historical resource compiling result, when the new intermediate compiling result corresponding to the new resource of the application is acquired, the new intermediate compiling result is subjected to resource linking according to the link auxiliary information, the new resource linking result corresponding to the new resource is obtained, and then, the first application program package corresponding to the application can be acquired according to the merging result of the new resource linking result and the historical resource linking result corresponding to the historical resource compiling result, and the application compiling result of the application can be determined according to the first application program package. In the embodiment, the link auxiliary information is acquired according to the historical resource compiling result when the new intermediate compiling result is acquired, the new intermediate compiling result is subjected to resource linking alone, the first application program package corresponding to the application is acquired according to the merging result of the new resource linking result and the historical resource linking result, the intermediate compiling result that needs to be processed in the resource linking process can be reduced when the new resource of the application exists, the linked resource is prevented from being repeatedly linked, the resource linking time in the application compiling process is shortened under the condition that the historical resource linking result is fully utilized, meanwhile, the content of the new resource linking result and the content of the historical resource linking result are prevented from being conflicted by utilizing the historical resource compiling result to determine the link auxiliary information, the accuracy of the independent linking of the new resource is improved, and therefore, the application compiling efficiency can be effectively improved when the resource of the application is updated.

[0068] In one exemplary embodiment, after the link auxiliary information related to resource linking is acquired according to the historical resource compiling result in step S101, the following steps can also be included:

[0069] The link auxiliary information is cached and kept in a cache state.

[0070] Correspondingly, before the new resource linking result corresponding to the new resource is obtained by subjecting the new intermediate compiling result to resource linking according to the link auxiliary information in step S102, the following steps can also be included:

[0071] The cached link auxiliary information is read every time the new intermediate compiling result corresponding to the new resource of the application is acquired.

[0072] In a specific implementation, the link auxiliary information can be pre-loaded and cached, and the cache state is maintained and cached all the time. In some examples, if the compiling application used for compiling the application has a process daemon mode, the daemon mode can be started, and in the daemon mode, the command does not exit after execution, so that the context used in the command execution process can be cached all the time without repeated initialization. Further, when the newly added intermediate compilation result corresponding to the newly added resource of the application is obtained each time, the cached link auxiliary information can be directly read.

[0073] In the embodiment, by caching the link auxiliary information and maintaining the cache state, the cached link auxiliary information can be directly read each time the newly added intermediate compilation result is obtained, and repeated initialization is avoided, so that the initialization time can be effectively saved and the compilation efficiency can be improved when the new resource is linked.

[0074] In an exemplary embodiment, in step S101, the link auxiliary information related to the resource linking can be obtained according to the historical resource compilation result, which can include the following steps:

[0075] According to the historical resource compilation result, the target application information related to the resource linking of the application is obtained; the software development kit corresponding to the application is obtained, and the system resource information corresponding to the system resource depended by the application is determined according to the software development kit; and the link auxiliary information related to the resource linking is obtained according to the target application information and the system resource information.

[0076] In actual application, on the one hand, the historical resource compilation result can be parsed, and the target application information related to the resource linking of the application can be obtained according to the parsing result.

[0077] On the other hand, the software development kit (Software Development Kit, SDK) corresponding to the application can be obtained, and the software development kit can be the software development kit corresponding to the operating system running the application. In actual application, the software development kit contains various resources provided by the operating system, and the developer can directly reference the system resource when developing the application. In addition, the code written by the developer in the application development can need to inherit the system class or interface provided by the operating system to implement various functions. Based on this, the system resource information corresponding to the system resource depended by the application can be determined through the software development kit. In some examples, taking the Android system as an example, the android.jar in the Android SDK declares the attributes, resources and the dependency relationship between the resources, and the system resource information containing the attributes, resources and the dependency relationship between the resources can be obtained by parsing the android.jar.

[0078] Further, the link auxiliary information related to the resource linking can be acquired according to the target application information and the system resource information.

[0079] In the embodiment, on one hand, by acquiring the target application information related to the resource linking of the application, the association of the internal resources of the application can be clearly understood, and on the other hand, by determining the system resource information on which the application depends according to the software development kit, the dependency relationship between the application and the system resource can be determined, and the link auxiliary information can be acquired by combining the target application information and the system resource information, thereby providing clear guidance for the resource linking process.

[0080] In one embodiment, in step S102, the resource linking of the new intermediate compilation result is performed according to the link auxiliary information, and the new resource linking result corresponding to the new resource is obtained, which can include the following steps:

[0081] According to the target application information and the system resource information, the resource identifiers corresponding to the new intermediate compilation results are determined, and the new intermediate compilation results are linked according to the resource identifiers corresponding to the new intermediate compilation results, thereby obtaining the new resource linking result corresponding to the new resource.

[0082] In the specific implementation, after the target application information and the system resource information are obtained, the reference relationship, the dependency relationship and other information between the new intermediate compilation results can be determined according to the target application information and the system resource information, and the new intermediate compilation results are identified and distributed in combination with the basic information of the application. Then, the mapping relationship between the resource identifiers and the file paths of the new intermediate compilation results can be determined, thereby realizing the resource linking of the new intermediate compilation results.

[0083] In the embodiment, the corresponding resource identifiers of the new intermediate compilation results can be accurately determined according to the target application information and the system resource information, thereby avoiding the linking errors caused by the ambiguous or incorrect resource identifiers when the new resources are linked separately.

[0084] In one embodiment, the target application information related to the resource linking of the application can be acquired according to the historical resource compilation result, which can include the following steps:

[0085] If the historical resource compilation result includes a second application package obtained after the historical compilation of the application, the resource identifier mapping table and the resource file are acquired from the second application package, the resource attribute is determined according to the resource file, and the target application information related to the resource linking of the application is determined according to the resource identifier mapping table and the resource attribute.

[0086] In actual application, the historical resource compilation result can include an application program package obtained through historical compilation processing corresponding to the application, for the convenience of distinguishing, the application program package is also called a second application program package.

[0087] In this embodiment, the compilation process of the application program package is introduced by taking a certain binary executable application as an example. For the application running in dependence on the Android operating system, the binary executable application can compile the resource files of the application. The compilation process of the binary executable application is composed of a compilation stage and a linking stage, which can compile the related source code and resource files provided by the developer into the final executable application program package.

[0088] In the compilation stage, the binary executable application can receive the source files written by the developer and generate intermediate editing results. For example, the developer can input the compilation instruction "compile -o. / build ${resource file path 1} ${resource file path 2}... ${resource file path n}", and the binary executable tool can generate intermediate products flat files such as resource file 1.flat, resource file 2.flat,..., and resource file n.flat. As shown in Figure 2 The binary executable application can read all file (i.e. resource file) inputs, then compile according to the file types of each file to obtain corresponding intermediate files flat and output, and the intermediate files can be named according to the specified naming rules when output, for example, the file name format of the intermediate file can be "directory name_file name.extension.flat".

[0089] In the linking stage, the binary executable application obtains all the flat files generated in the compilation stage to generate the final product. For example, the developer can input the linking instruction as shown below:

[0090] "link

[0091] -o ${resource file output directory} \

[0092] -I ${android.jar path} \

[0093] resource file 1.flat \

[0094] resource file 2.flat \ ...

[0096] resource file 3.flat \

[0097] --java ${java file output directory} \

[0098] --manifest ${manifest file output directory}".

[0099] In response to the above linking instruction, the binary executable application can perform the following processing: ① loading the configuration file AndroidManifest.xml of the application using the information loading function (such as LoadXml); ② extracting the application information (such as the package name) from the AndroidManifest.xml and setting the compiled package name; ③ setting the package name of the resource merging, for example, if the developer specifies the option of renaming the resource package name, the compiled package name can be set as the specified package name; ④ loading the resource dependencies and extracting the version information of the system framework if the relevant information exists; ⑤ initializing the resource table merger, for example, a TableMerger instance can be created for merging resources; ⑥ merging the input files, for example, the input file (i.e. flat file) list can be traversed to merge the input files; ⑦ traversing the overlay file list to merge the overlay files; ⑧ assigning resource identifiers (i.e. resource IDs) to the merged input files and overlay files, and generating a resource identifier mapping file according to the resource identifiers if the generation of the mapping file is specified; ⑨ verifying the resource identifiers, including verifying whether the static library is set with resource identifiers; and ⑩ adding the resource identifier mapping file to the symbol table. If the current mode is not only the merging mode, then link the resource references. Deduplicating the duplicate resources. Generating the resource directory and copying to the application package. Generating the Java classes according to the specified Java generation path. Through the above processing of each step, the resources.arsc file, n flat files each corresponding to a resource file, Java classes and AndroidManifest.xml can be obtained.

[0100] The resources.arsc file can adopt the ResourceTable format, and the structure of the format can be as follows: Figure 3As shown, including resource package (ResTablePackage), resource type (ResourceTable Type), resource item (ResourceEntry) and resource configuration information (ResourceConfigValue). Among them, each resource package corresponds to an application or library, containing the resource information in the package, the resource package header contains the package ID, the package name and other information; Resource item represents a specific resource item, which is the basic storage unit of resources. Each resource item corresponds to a specific resource in the application, such as a string, a picture or a layout file, etc.; Resource configuration information is used to represent the resource value under a specific configuration. In actual application, a resource may have multiple versions under different configurations, such as different languages, different screen resolutions, different device orientations, etc. Through resource configuration information, the specific resource value under a specific configuration can be stored and managed.

[0101] Exemplarily, the n resource files can adopt the RES_FILE format, and the structure of the format can be as shown in Figure 4 As shown, in each resource file, the file identification, version, and resource item quantity contained in the resource file of the resource file are included. For example, the file identification can take the value of 0x54504141, and the version and resource quantity can be represented by 4 bytes respectively. Of course, the resource file also includes n specific resource items belonging to the resource file, and each resource item includes resource type information, resource length information and resource data.

[0102] After the above compilation phase and linking phase processing, the application program package of the application can be obtained. It can be understood that by performing the above steps in advance, the second application program package of the application can be obtained.

[0103] If the second application program package is obtained, the resource identification mapping table and the resource file can be obtained from the second application program package, wherein the resource identification mapping table records the path mapping relationship between the resource identification and the resource file. In some examples, the resource identification mapping table can be a resources.arsc file, and the resource file can be each RES_FILE format resource file. Both of them can be added to the application program package in the application compilation process, so as to be read from the second application program package when the incremental resource needs to be compiled subsequently.

[0104] In the case that the resource identifier mapping table and the resource file are obtained, the resource attribute can be determined according to the resource file. The resource attribute can be understood as an attribute customized by the developer for the resource, such as the attributes of "color" and "text", which are related to the subsequent resource identifier allocation. In some examples, the resource attribute can be read from the resource file. For example, the resource attribute can be recorded by R.styleables declaration, which can be recorded in the resource file attrs.xml file, or if the application is an Android application, the R.styleables declaration can also be read from the Android application package (APK) virtual machine executable file (such as DEX file), and the styleables resource attribute can be additionally imported by command. Then, the resource identifier mapping table and the resource attribute can be determined as the target application information related to the resource linking.

[0105] In the embodiment, the source identifier mapping table and the resource file are obtained from the second application package obtained by the historical compilation processing, so that the target application information related to the resource linking can be quickly obtained based on the application package with high availability, and the acquisition efficiency of the target application information is effectively improved.

[0106] In another exemplary embodiment, the target application information related to the resource linking of the application is obtained according to the historical resource compilation result, including:

[0107] If the historical resource compilation result includes all the inventory intermediate compilation results of the application obtained by the historical compilation processing, the resource identifier mapping table and the resource attribute are obtained according to the analysis result of all the inventory intermediate compilation results; the target application information related to the resource linking of the application is determined according to the resource identifier mapping table and the resource attribute; and the resource identifier mapping table records the path mapping relationship between the resource identifier and the resource file.

[0108] In the specific implementation, all the inventory intermediate compilation results of the application obtained by the historical compilation processing can be obtained, wherein the inventory intermediate compilation result is an intermediate file obtained by the historical resource compilation of the application by the historical compilation processing. In some examples, the inventory intermediate compilation result is a compilation result obtained in the compilation stage in the compilation process, such as a flat file.

[0109] By analyzing all the inventory intermediate compilation results, the resource identifier mapping table and the resource attribute of each resource can be obtained by secondary parsing, and then the target application information related to the resource linking of the application can be determined according to the resource identifier mapping table and the resource attribute obtained by the parsing.

[0110] In the embodiment, by analyzing all inventory intermediate compilation results, reliable resource identifier mapping table and resource attributes can be accurately identified based on current analysis results, which helps to simplify processing steps and improve reliability of subsequent incremental resource linking.

[0111] In an exemplary embodiment, in step S103, the first application package corresponding to the application is obtained according to the merging result of the new resource directory and the historical resource directory corresponding to the historical resource compilation result, which can include the following steps:

[0112] The second application package obtained after the historical compilation of the application is obtained; the second application package includes the historical resource directory corresponding to the historical resource compilation result; the new resource directory is added to the second application package to obtain the updated first application package of the application.

[0113] In a specific implementation, the application package obtained by the historical compilation of the application can be obtained, and in order to distinguish, the application package is referred to as the second application package in the embodiment. It can be understood that the second application package includes the historical resource directory corresponding to the historical resource compilation result as a compiled and executable application package, so that the second application package can be normally run according to the historical resource directory when the second application package is executed.

[0114] Based on this, the newly obtained new resource directory can be added to the second application package in the embodiment, so that the updated second application package can be used as the first application package obtained by the compilation of the application after adding new resources.

[0115] In the embodiment, by adding the new resource directory to the second application package to obtain the first application package, only the resource directory corresponding to the changed resource can be accurately updated without affecting other unchanged parts, which not only retains the effective part of the historical compilation result, but also integrates the new resources, helps to maintain the integrity and stability of the application, and reduces compatibility problems and errors caused by large-scale recompilation or replacement.

[0116] In an exemplary embodiment, in step S103, the application compilation result of the application is determined according to the first application package, which can include the following steps:

[0117] If it is determined that the new resource identifier is not included in the new resource linking result, the application compilation result of the application is obtained according to the first application package and the historical resource index file corresponding to the historical resource compilation result; if it is determined that the new resource identifier is included in the new resource linking result, the new resource index file corresponding to the new resource is generated, and the application compilation result of the application is obtained according to the new resource index file, the historical resource index file and the first application package.

[0118] In the related art, a compiling application for compiling an application can automatically generate a resource index file, which can be R.java in the case of an Android system. The resource index file can record resource identifiers corresponding to all resources of the application, and can also record static constants corresponding to all resources (such as layouts, strings, pictures, etc.) of the application.

[0119] In actual applications, after obtaining the new resource linking result, new resource identifiers (for example, identifiers assigned to new resources that have not appeared before) can be added to the new resource linking result, or original resource identifiers (which are the same as the resource identifiers in the historical resource linking result) can be used (for example, the new resources updated from previously used resources can use the original resource identifiers).

[0120] In this embodiment, it can be determined whether the new resource linking result contains new resource identifiers, that is, new resource identifiers. The new resource identifiers refer to resource identifiers that have not appeared in the historical resource compilation result or the historical resource linking result. In some examples, it can be determined whether the new resource directory contains new resource identifiers according to the comparison result of the resource identifiers of the new resource linking result and the historical resource linking result, or it can be determined whether new resource identifiers are assigned to new resources in the resource linking process.

[0121] If it is determined that the new resource linking result does not contain new resource identifiers, the resource index file corresponding to the first application package and the historical resource compilation result can be used as the application compilation result of the application, wherein the resource index file corresponding to the historical resource compilation result becomes the historical resource index file, and the historical resource index file is the resource index file obtained in the previous historical compilation process.

[0122] If it is determined that the new resource linking result contains new resource identifiers, a resource index file corresponding to the new resource can be generated, that is, a new resource index file. Specifically, the resource index file can be generated separately for the new resource, and the new resource index file can only contain new resource identifiers. Then, the new resource index file, the historical resource index file, and the first application package can be used as the application compilation result of the application. The new resource index file and the historical resource index file can record resource identifiers of all resources in the first application package.

[0123] In the embodiment, on one hand, when the new resource link result does not contain the new resource identifier, the application compilation result is obtained directly according to the first application package and the historical resource index file, the existing historical resource index file is fully utilized, the unnecessary resource index file generation process is avoided, the compilation time and the consumption of computing resources are reduced, the compilation process is optimized, and the compilation efficiency is improved. In some examples, the compilation time consumption of 2 to 3 seconds can be saved through the processing. On the other hand, when the new resource link result contains the new resource identifier, the new resource index file is generated, and the application compilation result is obtained in combination with the historical resource index file and the first application package, the separate resource index for the new resource can be established, and the accuracy of the application compilation result is ensured.

[0124] In order for those skilled in the art to better understand the above steps, the embodiments of the present application are exemplarily illustrated by an example below, but it should be understood that the embodiments of the present application are not limited thereto.

[0125] As shown in Figure 5 the embodiments can include the following steps:

[0126] S501, an inclink command is pre-set. The inclink command can split the link stage into preloading and incremental linking. In a specific implementation, an inclinkCommand command can be added to implement it, which can inherit from the original LinkCommand. Subsequently, the application compilation method of the present application is realized by calling the command line.

[0127] S502, in response to the input inclink --load command, preloading is performed.

[0128] In actual application, if the application package (such as the second application package) obtained by the past compilation of the Android application is acquired, the APK file can be read first, the resource identifier mapping table (resources.arsc) is preloaded, and the R.styleables declaration is additionally exported from the APK DEX file, and the styleables information is imported through the command. In addition, the android.jar of the Android SDK can also be read, which declares the system resources and the attribute and dependency relationship of the system resources. In some examples, if the full flat file compiled previously is preloaded, the full flat file can be analyzed to obtain the resource identifier mapping table (resources.arsc) and the styleables information.

[0129] In the preloading process, the following processes can be performed: ① loading the application configuration file of the application, for example, the configuration file AndroidManifest.xml of an Android application can be loaded using the LoadXml function; ② extracting application information, specifically, extracting application information (such as package name) from AndroidManifest.xml and setting the compiled package name; ③ setting the package name for resource merging, if the developer specifies the option of renaming the resource package name, setting the compiled package name as the specified package name; ④ loading resource dependencies and extracting version information (if any) of the Android framework; ⑤ creating a TableMerger instance for merging resources.

[0130] In an example, the inclink instruction of the preloading part described above can be as follows:

[0131] “inclink

[0132] --load

[0133] --styleables ${styleables directory}

[0134] -o no_need_output_path_on_load

[0135] -I / Users / wormchen / Library / Android / sdk / platforms / android-30 / android.jar

[0136] --manifest no_need_manifest_on_load

[0137] ${apk path}”。

[0138] S503, continuously caching the information obtained by loading.

[0139] After preloading information such as resource identifier mapping table, resource file, and AndroidManifest.xml, the obtained information can be cached based on the process daemon mode to avoid releasing it after executing the inclink –load command.

[0140] S504, receiving newly added intermediate compilation results corresponding to newly added resources, performing incremental linking, and outputting the compilation results (such as the first application package).

[0141] In this step, through the inclink command, only the flat file corresponding to the changed resource is received, and all flat files are no longer input. Then, the flat file of the incremental resource is linked, and the compilation product is incrementally output. The process can specifically include the following processing: ① Incremental merging of input files: traverse the input file list and merge resources; ② Incremental merging of overlay files: traverse the overlay file list and merge resources; ③ Incremental allocation of resource identifiers: allocate resource identifiers to incremental resources and generate a resource identifier mapping table; ④ Incremental verification of resource identifiers: for static libraries, verify whether resource identifiers are set; ⑤ Incremental addition of symbol tables: add resource tables to the symbol table; ⑥ Incremental removal of resources that do not have default values: if no resources are specified to be removed, remove resources that do not have default values; ⑦ Incremental linking of references: if the current mode is not a merge-only mode, link resource references; ⑧ Incremental removal of duplicate resources: if no removal is specified, remove duplicate resources; ⑨ Incremental copying of generated directories: copy the generated directory to the application APK file (second application package); and ⑩ Incremental generation of Java classes: if the path for generating Java classes is specified, generate Java classes if there are new resource identifiers, and skip this step if there are no new resource identifiers.

[0142] Through the above processing, the execution time of resource compilation is effectively optimized. In some examples, the execution time of the linking stage is greatly reduced from 10-15s to 0.1-0.2s.

[0143] In some examples, the above linking stage can be implemented through the following instructions:

[0144] “inclink

[0145] -o ${resource output directory}

[0146] --output-to-dir

[0147] --java ${java output directory}

[0148] --manifest ${Manifest output directory}

[0149] ${intermediate product file 1} ${intermediate product file 2}...${intermediate product file n}”.

[0150] It should be understood that although the steps in the flowcharts related to the embodiments described above are shown in sequence according to the arrows, the steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, the execution of the steps is not strictly limited in sequence, and the steps can be executed in other orders. Moreover, at least some of the steps in the flowcharts related to the embodiments described above can include multiple steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of the steps or stages is not necessarily sequential, but can be alternately or alternately executed with at least part of other steps or stages.

[0151] In an exemplary embodiment, a computer device, which can be a terminal, has an internal structure diagram as shown in Figure 6 The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals in a wired or wireless manner. The wireless manner can be achieved through WIFI, mobile cellular network, near field communication (NFC) or other technologies. The computer program is executed by the processor to implement an application compilation method. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer overlaid on the display screen, or a key, trackball or touchpad arranged on the shell of the computer device, or an external keyboard, touchpad or mouse, etc.

[0152] Those skilled in the art can understand that Figure 6 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0153] In an embodiment, a computer device is provided, comprising a memory and a processor, the memory has stored therein a computer program, the processor implements the steps in the above method embodiments when executing the computer program.

[0154] In an embodiment, a computer readable storage medium is provided, having stored thereon a computer program, the computer program is executed by a processor to implement the steps in the above method embodiments.

[0155] In an embodiment, a computer program product is provided, comprising a computer program, the computer program is executed by a processor to implement the steps in the above method embodiments.

[0156] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant regulations.

[0157] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when executed, can include the processes of the above-mentioned embodiment methods. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. The non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. The volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, the RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., without being limited thereto.

[0158] The technical features of the above embodiments can be combined in any manner. To make the description concise, not all possible combinations of the technical features in the above embodiments are described, but as long as the combinations of the technical features do not exist contradictions, they should be considered as the scope of the present application.

[0159] The above-described embodiments are merely illustrative of several embodiments of the present application, and the description is relatively specific and detailed, but should not be understood as a limitation on the scope of the patent. It should be noted that for those skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the scope of the present application. Therefore, the scope of protection of the present application should be subject to the appended claims.

Claims

1. An application compilation method, characterized in that: The method comprises: Obtaining a historical resource compilation result obtained after the application has been historically compiled, and obtaining link auxiliary information related to resource linking based on the historical resource compilation result; When a new intermediate compilation result corresponding to the new resource of the application is obtained, performing resource linking on the new intermediate compilation result according to the link auxiliary information to obtain a new resource linking result corresponding to the new resource; A first application package corresponding to the application is obtained according to a combination result of the incremental resource link result and a historical resource link result corresponding to the historical resource compilation result, and an application compilation result of the application is determined according to the first application package.

2. The method according to claim 1, characterized in that The step of obtaining link auxiliary information related to resource linking according to the historical resource compilation result includes: According to the historical resource compilation result, obtaining target application information related to the application and resource linking; Obtaining a software development kit corresponding to the application, and determining system resource information corresponding to system resources that the application depends on based on the software development kit; According to the target application information and the system resource information, link auxiliary information related to resource linking is acquired.

3. The method according to claim 2, characterized in that The performing the resource linking on the newly added intermediate compilation result according to the link auxiliary information to obtain a newly added resource linking result corresponding to the newly added resource includes: Determining a resource identifier corresponding to each of the newly added intermediate compilation results according to the target application information and the system resource information; According to the resource identifier corresponding to each of the newly added intermediate compilation results, the resource linking is performed on the newly added intermediate compilation results to obtain a newly added resource linking result corresponding to the newly added resource.

4. The method according to claim 2, characterized in that The step of obtaining target application information related to the application and resource linking according to the historical resource compilation result includes: If the historical resource compilation result includes a second application package obtained after the application is historically compiled, obtaining a resource identification mapping table and a resource file from the second application package; The resource attributes are determined according to the resource file, and the target application information related to the application and resource linking is determined according to the resource identification mapping table and the resource attributes.

5. The method according to claim 2, characterized in that The step of obtaining target application information related to the application and resource linking according to the historical resource compilation result includes: If the historical resource compilation result includes all existing intermediate compilation results obtained after the application is historically compiled, then obtaining a resource identification mapping table and resource attributes based on analysis results of all existing intermediate compilation results; According to the resource identification mapping table and the resource attributes, the target application information related to the application and resource linking is determined.

6. The method according to claim 1, characterized in that After obtaining link auxiliary information related to resource linking according to the historical resource compilation result, the method further includes: Cache the link auxiliary information and keep it in a cached state; Before performing the resource linking on the newly added intermediate compilation result according to the link auxiliary information to obtain the newly added resource linking result corresponding to the newly added resource, the method further includes: Each time a new intermediate compilation result corresponding to a new resource of the application is obtained, the cached link auxiliary information is read.

7. The method according to claim 1, characterized in that The determining, according to the first application package, an application compilation result of the application includes: If it is determined that the newly added resource link result does not include a newly added resource identifier, obtaining the application compilation result of the application according to the first application package and the historical resource index file corresponding to the historical resource compilation result; If it is determined that the new resource link result contains a new resource identifier, a new resource index file corresponding to the new resource is generated, and the application compilation result of the application is obtained based on the new resource index file, the historical resource index file and the first application package.

8. The method according to any one of claims 1 to 7, characterized in that The acquiring, according to a merging result of the newly added resource directory and the historical resource link result corresponding to the historical resource compilation result, a first application package corresponding to the application includes: Obtaining a second application package obtained after the application is historically compiled; the second application package includes a historical resource link result corresponding to the historical resource compilation result; The resource-added link result is added to the second application package to obtain the first application package after the application is updated.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.

10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.