Compilation method, storage medium and electronic device based on file differences
Through the compilation method based on file differences, the difference files are identified and compiled, which solves the problem of long compilation time in Android software development, achieves breakthrough optimization of compilation efficiency, and greatly reduces the time consumption.
Patent Information
- Application Number
- CN202111298956.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-04
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2041-11-04
AI Technical Summary
In existing technology, in Android software development, software compilation takes a long time, traditional optimization methods cannot achieve breakthrough efficiency optimization, and large-scale splitting of sub-projects will affect development efficiency.
A file difference-based compilation method is adopted. By obtaining the version identifiers of the current and previous compilation products, the difference file set is identified, and only the difference files are compiled and translated to generate the final product, bypassing the complete compilation process.
Significantly reduces compilation time, reducing it to less than 10% of the remaining time, thus avoiding the reduction in development efficiency and unnecessary time-consuming steps caused by large-scale splitting of sub-projects.
Smart Images

Figure CN114047919B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of computer networks, and in particular to a compilation method based on file differences. In addition, the present application also relates to related devices, electronic devices, and computer-readable storage media. Background Art
[0002] Compilation is an essential step in Android software development, and as software complexity increases, compilation time increases proportionally. For example, a project with one million lines of source code typically takes over 20 minutes to fully compile. Two common optimization methods are available. One is to break the project into several smaller projects and compile them in parallel to reduce compilation time. If the number of sub-projects is large enough, compilation time can be significantly reduced. However, increasing the number of sub-projects can also lead to increased difficulty managing the project and reduced development efficiency. Furthermore, the final compilation phase requires collecting and combining the intermediate products from each sub-project, which significantly increases compilation time and ultimately offsets some of the reductions achieved through compilation optimization. The second approach is to reduce overall compilation time by optimizing individual compilation steps, but the upper limit of optimization efficiency is relatively low, preventing breakthrough efficiency gains. Both traditional compilation optimization methods can reduce the overall compilation time to approximately 30%.
[0003] The content of this background technology description is only for facilitating understanding of the relevant technology in this field and is not regarded as an admission of the prior art. Summary of the Invention
[0004] Therefore, the present invention provides a compilation method based on file differences, which can achieve a breakthrough optimization of compilation efficiency without affecting the project structure as much as possible. The present invention provides a compilation method based on file differences, which includes the following steps:
[0005] Get the current file to be compiled;
[0006] Get the last compiled product file;
[0007] Identify the current file to be compiled and obtain the current version identifier;
[0008] Obtaining a previous version identifier and a previous final product file according to the previous compiled product file;
[0009] Comparing the current version identifier with the previous version identifier, and obtaining a difference file set from the current file to be compiled according to the comparison result;
[0010] Obtaining a final product file of the difference files according to the difference file set;
[0011] According to the difference file final product file and the previous final product file, the current compilation final product file is obtained.
[0012] In some embodiments of the present invention,
[0013] When the previous compilation product file is an initial compilation product file, obtaining the previous compilation product file includes:
[0014] Compile source code files into intermediate product files;
[0015] Translating the intermediate product file to generate a source code final product file;
[0016] Combining the source code final product file with the resource file to form the previous compilation product file;
[0017] When the previous compilation product file is not an initial compilation product file, obtaining the previous compilation product file includes:
[0018] The current compilation final product file obtained by the previous execution of the file difference-based compilation method is used as the previous compilation product file.
[0019] In some embodiments of the present invention, the source code file includes a plurality of source code sub-files; the previous compilation product file includes a previous compilation index table, and the previous compilation index table includes version number information and index names corresponding to the plurality of source code sub-files;
[0020] Compiling the source code file into an intermediate product file includes:
[0021] Compiling the multiple source code sub-files to generate multiple intermediate product sub-files;
[0022] The step of translating the intermediate product file into a source code final product file includes:
[0023] Translating the plurality of intermediate product sub-files to generate a plurality of source code final product sub-files;
[0024] The combining of the source code final product file and the resource file to form the previous compilation product file includes:
[0025] According to the multiple source code final product sub-files, obtaining version numbers and sub-file names corresponding to the multiple source code final product sub-files;
[0026] According to the resource file, obtain the version number and resource file name corresponding to the resource file;
[0027] The previous compilation index table is generated according to the version numbers and subfile names corresponding to the multiple source code final product subfiles and the version numbers and resource file names corresponding to the resource files.
[0028] In some embodiments of the present invention, the current file to be compiled includes a plurality of current source code sub-files and a plurality of current resource files;
[0029] The comparing the current version identifier with the previous version identifier and obtaining a difference file set from the current file to be compiled according to the comparison result includes:
[0030] Comparing the index name in the previous compilation index table with the file names of the multiple current source code sub-files and the multiple current resource files;
[0031] If the comparison result is the same and the previous version identifier corresponding to the index name is different from the current version identifier, then the current source code sub-file and / or current resource file with the same name as the index name in the current file to be compiled belongs to the difference file set.
[0032] In some embodiments of the present invention, obtaining a final product file of the difference files according to the difference file set includes:
[0033] Compiling the difference file set to generate a difference intermediate product file;
[0034] The difference intermediate product file is translated to generate the difference source code final product file.
[0035] In some embodiments of the present invention, obtaining the current compilation final product file according to the difference file final product file and the previous final product file includes:
[0036] Obtaining, from the previous final product file, a previous final product subfile corresponding to the difference file final product file;
[0037] Replace the previous final product sub-file with the final product file of the difference file;
[0038] According to the current version identifier corresponding to the final product file of the difference file, the previous compilation index table is updated to generate a current compilation index table.
[0039] In some embodiments of the present invention, before obtaining the current file to be compiled and the previous compiled product file, the following steps are included:
[0040] Source code change information in the multiple current source code sub-files is monitored, and version identifiers corresponding to the source code sub-files with source code changes are updated.
[0041] In some embodiments of the present invention, before obtaining the current file to be compiled and the previous compiled product file, the following steps are included:
[0042] Resource change information in the multiple current resource files is monitored, and version identifiers corresponding to the resource files with resource changes are updated.
[0043] In some embodiments of the present invention, compiling the source code file into the intermediate product file includes:
[0044] Get the source code sub-file length entered by the user;
[0045] Splitting the source code file according to the length of the source code sub-file to generate source code sub-files;
[0046] The intermediate product file is generated by compiling the source code sub-file.
[0047] In an embodiment of the present invention, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the program implements any file difference-based compilation method of the embodiment of the present invention.
[0048] In an embodiment of the present invention, an electronic device is provided, comprising: a processor and a memory storing a computer program, wherein the processor is configured to execute any file difference-based compilation method of the embodiments of the present invention when running the computer program.
[0049] The compilation method of the present invention combines the change information of the previous compilation product and the current file to be compiled, locates the changed sub-file according to the change information of the current file to be compiled, compiles and translates the sub-file to generate a final product sub-file, replaces this final product sub-file with the corresponding sub-file in the previous compilation product, and generates the current compilation product, bypassing the complete compilation process and directly generating the current compilation product, thereby achieving the effect of greatly improving the compilation speed, and can compress the complete compilation time to less than 10%.
[0050] Other optional features and technical effects of the embodiments of the present invention are partially described below, and partially can be understood by reading this document. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings. The elements shown are not limited to the scale shown in the drawings. The same or similar reference numerals in the drawings represent the same or similar elements, wherein:
[0052] Figure 1 An exemplary flow chart of a compiling method according to an embodiment of the present invention is shown;
[0053] Figure 2The steps of a hybrid algorithm of a compilation method based on file differences according to an embodiment of the present invention are shown;
[0054] Figure 3 Another exemplary flow chart of a compilation method based on file differences according to an embodiment of the present invention is shown;
[0055] Figure 4 An exemplary flow chart of obtaining a previous compilation product in a compilation method based on file differences according to an embodiment of the present invention is shown;
[0056] Figure 5 An exemplary flow chart of generating a previous compilation product in a compilation method based on file differences according to an embodiment of the present invention is shown;
[0057] Figure 6 An exemplary flow chart of obtaining a difference file set in a compilation method based on file differences according to an embodiment of the present invention is shown;
[0058] Figure 7 An exemplary flow chart of generating a final product file based on a set of difference files in a compilation method based on file differences according to an embodiment of the present invention is shown;
[0059] Figure 8 An exemplary flow chart of updating a current compilation index table in a compilation method based on file differences according to an embodiment of the present invention is shown;
[0060] Figure 9 An exemplary flow chart of splitting and generating source code sub-files in a compilation method based on file differences according to an embodiment of the present invention is shown;
[0061] Figure 10 A schematic structural diagram of a compiling device according to an embodiment of the present invention is shown;
[0062] Figure 11 A schematic diagram of an exemplary structure of an electronic device capable of implementing the method according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0063] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below in conjunction with specific embodiments and accompanying drawings. Here, the exemplary embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0064] In the present invention, "compiling" refers to converting one language into another with different syntax and level of abstraction, such as using the GCC compiler for compilation. "Translating" refers to converting one language into a different version or language of the same level of abstraction, such as using Babel to translate ES6 into ES5.
[0065] The embodiment of the present invention provides a compilation method based on file differences, which improves compilation efficiency. The compilation method in the embodiment of the present invention is introduced below.
[0066] The Android software compilation process consists of the following steps: a) compiling source code into intermediate products; b) translating these intermediate products into the final source code product; and c) combining the final source code product with other resources to form the complete software application. Step a generates one or more corresponding intermediate products, while step b collects and translates all these intermediate products, producing a final product file. The final product file is a physical file stored on disk.
[0067] Based on the above compilation process, an embodiment of the present invention provides a compilation method based on file differences, and the specific steps are as follows:
[0068] When it is determined that the source code change range between this compilation and the previous compilation is not the entire source code, only step a is executed on the changed source code to obtain the corresponding intermediate product. Using the same translation method as step b, the translated content is inserted into the final product of the previous compilation. This can obtain the same product result as the traditional method, but saves the time spent on executing step b as a whole.
[0069] The compilation environment of the compilation method in the embodiment of the present invention requires the use of source code management software with version control capabilities to manage source code and resource files. The compilation environment stores the final product file of the previous compilation. The use of source code management software with version control capabilities enables this solution to identify the scope of source code changes. During one compilation, this solution writes the unique identifier corresponding to the source code version into the final product. During the next compilation, the identifier is read from the final product of the previous compilation and matched with the current source code version to obtain the scope of changes. This solution only uses the previous compilation product as a dependency, reducing the number of dependencies.
[0070] like Figure 1 As shown, the compilation method provided by the embodiment of the present invention identifies the source code file and obtains the version identifier of this compilation; performs an extraction operation on the previous compilation product to obtain the source code version identifier of the previous compilation and the source code final product part; compares the current compilation version identifier with the source code version identifier of the previous compilation to obtain a corresponding set of difference source code files; uses a compilation tool to compile the difference source code file set to obtain an intermediate product file of the difference part; uses a translation tool to translate the intermediate product file of the difference part to obtain the final product of the difference part, and uses a mixing algorithm to mix the source code final product part and the final product of the difference part to obtain a final product.
[0071] The steps of the hybrid algorithm are as follows: Figure 2As shown, the differential source code products include file A differential product, file B differential product, and file C differential product, which replace file A product, file B product, and file C product in the final product of the previous compilation, and then update the index table based on the replaced file status to obtain the final product file.
[0072] The compilation method in the embodiment of the present invention solves the following technical problems that cannot be solved by existing technical methods:
[0073] 1. Large-scale splitting of sub-projects will affect development efficiency and cannot achieve ultimate optimization;
[0074] 2. The benefits of traditional process optimization are limited;
[0075] 3. The incremental compilation solution has many dependencies and some time-consuming steps cannot be avoided;
[0076] This solution does not require large-scale sub-project disassembly, thus avoiding problem 1. Based on incremental compilation, this solution completely avoids redundant time-consuming steps and can achieve maximum time reduction, thus avoiding problems 2 and 3.
[0077] In the best case, when only one line of source code is changed, this solution can achieve final product output in less than 30 seconds, which is significantly better than the minimum 60 seconds of other solutions.
[0078] This solution primarily addresses source code compilation optimization. Android software, in addition to source code, also includes image resources, text resources, and built-in executable file resources. The same approach described in this solution can be applied to incremental changes to other resources. By combining the previous compilation output with precise difference replacement, the final product can be quickly output.
[0079] like Figure 3 As shown, an embodiment of the present invention provides a compilation method based on difference files, comprising the following steps:
[0080] S110: Obtain the current file to be compiled.
[0081] In some embodiments, the current file to be compiled includes multiple current source code sub-files and multiple resource files.
[0082] The previous compilation product file in the embodiment of the present invention may be an initial compilation product file or an intermediate version compilation product file.
[0083] S120: Obtain the last compiled product file.
[0084] In some embodiments, the previous compilation product file is stored in the compilation environment, and the previous compilation product file can be obtained according to the index identifier.
[0085] In some implementations, such as Figure 4 As shown, when the previous compilation product file is an initial compilation product file, the step of obtaining the previous compilation file includes:
[0086] S121, compiling the source code file into an intermediate product file;
[0087] S122, translating the intermediate product file to generate a source code final product file;
[0088] S123: Combining the source code final product file with the resource file to form the previous compilation product file.
[0089] In some embodiments, when the previous compilation product file is not the initial compilation product file, that is, an intermediate version of the compilation product file, the final product file of the current compilation obtained by the previous execution of the file difference-based compilation method serves as the previous compilation product file. The final product file based on the previous compilation serves as the previous compilation product file. After each execution of the compilation method of this embodiment, the generated final product file of the current compilation is saved and called upon during subsequent compilation.
[0090] In some embodiments, multiple versions of the final product file can be saved, and the previous compiled product file can be obtained by the version number of each compilation. In other embodiments, the current compiled final product file can replace the previous compiled product file, or only one final product file is maintained, and each compilation is an update of the final product file, thereby reducing storage space.
[0091] In some embodiments, the source code file includes multiple source code sub-files; the previous compilation product file includes a previous compilation index table, and the previous compilation index table includes version number information and index names corresponding to the multiple source code sub-files; in an embodiment of the present invention, the source code file can be divided into multiple source code sub-files based on the actual file type. For example, there are main files, view files, and fun files under the source code directory, and the corresponding source code sub-files are main files, view files, and fun files; in some embodiments, the source code can also be split according to the length of the source code. For example, the main file can be split into main_a source code sub-file, main_b source code sub-file, and mian_c source code sub-file, the view file can be split into view_a source code sub-file and view_b source code sub-file, and the fun file can be split into fun_a source code sub-file and fun_b source code sub-file, so the multiple source code sub-files include main_a sub-file, main_b sub-file, main_c sub-file, view_a sub-file, view_b sub-file, fun_a sub-file, and fun_b sub-file.
[0092] Based on the multiple source code sub-files, the step S121 further includes:
[0093] The multiple source code sub-files are compiled to generate multiple intermediate product sub-files; for example, the source code file includes source code sub-file a, source code sub-file b and source code sub-file c, which are compiled to generate intermediate product sub-file a, intermediate product sub-file b and intermediate product sub-file c.
[0094] In some embodiments, step S121 further includes:
[0095] The multiple intermediate product sub-files are translated to generate multiple source code final product sub-files; for example, the intermediate product sub-file a, the intermediate product sub-file b and the intermediate product sub-file c are translated to generate source code final product sub-file a, source code final product sub-file b and source code final product sub-file c.
[0096] In some embodiments, as Figure 5 As shown, the step S123 further includes:
[0097] S1231. Obtain, based on the multiple source code final product subfiles, version numbers and subfile names corresponding to the multiple source code final product subfiles;
[0098] S1232. According to the resource file, obtain the version number and resource file name corresponding to the resource file;
[0099] S1233: Generate the previous compilation index table according to the version numbers and subfile names corresponding to the multiple source code final product subfiles and the version numbers and resource file names corresponding to the resource files.
[0100] In some embodiments, the version numbers of the source code final product sub-file a, the source code final product sub-file b, and the source code final product sub-file c are v1.1, v1.1, and v1.2, the name of the resource file is source file, the corresponding version number is v1.0, and the corresponding generated previous compilation index table is as follows.
[0101] File name Version number Source code final product sub-file a v1.1 Source code final product sub-file b v1.1 Source code final product sub-file c v1.2 source file v1.0
[0102] In an embodiment of the present invention, when a final product is generated, a corresponding index table is generated.
[0103] In the embodiment of the present invention, the steps of obtaining the current file to be compiled and obtaining the previous compiled product file can be executed independently or together.
[0104] S130: Identify the current source code file and obtain a current source code version identifier.
[0105] In some embodiments, the source code version identifier can be obtained from compilation software or management tools, and the compilation software can set a version number for each subfile in each source code file. In some embodiments, a source code file can be split into multiple subfiles, and the source code file can be located at a specific location code line. The code between the located code lines can be divided into a subfile, and the code added between the located code lines can be assigned to the current subfile. At the same time, changing the version number, deleting code, or modifying code will trigger a change in the version number.
[0106] S140: Obtain a previous version identifier and a previous final product file according to the previous compiled product file.
[0107] In some embodiments, the previous source code version identification information can be obtained from the index table. When the previous compiled product file includes multiple sub-files, the version identification of each sub-file, that is, the version number, can be obtained from the index table according to the name of the sub-file.
[0108] S150: Compare the current version identifier with the previous version identifier, and obtain a difference file set from the current file to be compiled according to the comparison result.
[0109] In some embodiments, each sub-file to be compiled has a version identification number. By comparing the version identification numbers, it is determined which source code sub-files have been changed to form a differential source code set.
[0110] In some embodiments, the current file to be compiled includes multiple current source code sub-files and multiple current resource files.
[0111] like Figure 6 As shown, the step of obtaining the difference file set includes:
[0112] S151, comparing the index name in the previous compilation index table with the file names of the multiple current source code sub-files and the multiple current resource files;
[0113] S152: If the comparison results are the same and the previous version identifier corresponding to the index name is different from the current version identifier, then the current source code sub-file and / or current resource file with the same name as the index name in the current file to be compiled belongs to the difference file set.
[0114] For example, the information of the compiled product files recorded in the previous compilation index table includes: the final product file main, version number v1.01; the final product file view, version number v1.02; the final product file fun, version number v1.01; and the final product resource file resource, version number v1.0. When the compilation method of the embodiment of the present invention is run at a certain time, the current file information to be compiled includes: the source code sub-file main, version number v1.01; the source code sub-file view, version number v1.03; the source code sub-file fun, version number v1.01; and the resource file resource, version number v1.0. After name comparison and version number comparison, the difference file is obtained as the view file, and the view file is compiled and translated to replace the final product file view in the previous compiled file, and the index table is updated, thus completing the compilation process. For example, when the compilation method of an embodiment of the present invention is run at a certain time, the current file information to be compiled includes: source code sub-file main, version number v1.01; source code sub-file view, version number v1.02; source code sub-file fun, version number v1.01; resource file resource, version number v1.01; after name comparison and version number comparison, the difference file is obtained as the resource file, the resource file is compiled and translated, the final product resource file resource in the previous compilation file is replaced, and the index table is updated, and the compilation process is completed.
[0115] S160: Obtain a final product file of the difference files according to the difference file set.
[0116] In some embodiments, as Figure 7 As shown, step S160 specifically includes the following steps:
[0117] S161, compile the difference file set to generate a difference intermediate product file;
[0118] S162: Translate the difference intermediate product file to generate the difference file final product file.
[0119] Only the difference files are compiled and translated, which saves a lot of time for repeated compilation and translation, thereby improving efficiency.
[0120] S170: Obtain a current compilation final product file according to the final product file of the difference file and the previous final product file.
[0121] Here, the previous final product file is replaced by the final product file, and the index table is updated, so that the compilation project can be completed with less overall time consumption.
[0122] In some embodiments, the specific process of step S170 is as follows: Figure 8 As shown, the steps to generate the final product file of the current compilation include:
[0123] S171. Obtaining, from the previous final product file, a previous final product sub-file corresponding to the difference file final product file;
[0124] S172, replacing the previous final product sub-file with the final product file of the difference file;
[0125] S173: Update the previous compilation index table according to the current version identifier corresponding to the final product file of the difference file to generate a current compilation index table.
[0126] In some embodiments, before obtaining the current file to be compiled and the previous compiled product file, the compilation method further includes:
[0127] S101: monitoring source code change information in the multiple current source code sub-files, and updating source code version identifiers corresponding to the source code sub-files with source code changes.
[0128] In some embodiments, before obtaining the current file to be compiled and the previous compiled product file, the compilation method also includes:
[0129] S102: Monitoring resource change information in the multiple current resource files, and updating version identifiers corresponding to resource files with resource changes.
[0130] The compilation environment software in the embodiment of the present invention can monitor the changes of source code or resources, so as to automatically update the version identification. In some embodiments, the version identification change can be performed in an incremental manner.
[0131] In order to meet the requirements of high-efficiency compilation, a single source code file can be split to improve the compilation and translation efficiency of a single difference file. When initially generating the previous compilation product file, the user can set the code length of a single compilation sub-file, locate the positioning code line, and treat the code between adjacent positioning code lines as a source code sub-file. Specifically, Figure 9 As shown, compiling the source code file into an intermediate product file also includes:
[0132] S1211. Obtain the source code sub-file length input by the user;
[0133] S1212, splitting the source code file according to the length of the source code sub-file to generate source code sub-files;
[0134] S1213: Compile and generate the intermediate product file according to the source code sub-file.
[0135] The compilation method of the present invention combines the previous compilation product and the change information of the current file to be compiled, locates the changed subfile, compiles and translates the subfile to generate a final product subfile, replaces the final product subfile with the corresponding subfile in the previous compilation product, and generates the current compilation product, bypassing the complete compilation process and directly generating the current compilation product, thereby greatly improving the compilation speed and compressing the complete compilation time to less than 10%.
[0136] In the embodiment of the present invention, Figure 10 , a file difference-based compilation device 1000 is shown, and the file difference-based compilation device 1000 includes:
[0137] The acquisition module 1010 is configured to acquire the current file to be compiled and the previous compilation product file;
[0138] An identification module 1020 is configured to identify the current file to be compiled and obtain a current version identifier;
[0139] The extraction module 1030 is configured to obtain a previous version identifier and a previous final product file according to the previous compilation product file;
[0140] The comparison module 1040 is configured to compare the current version identifier with the previous version identifier, and obtain a difference file set from the current file to be compiled according to the comparison result;
[0141] A generating module 1050 is configured to obtain a final product file of the difference files according to the difference file set;
[0142] The updating module 1060 is configured to obtain the current compiled final product file according to the difference file final product file and the previous final product file.
[0143] In some embodiments, when the previous compilation product file is an initial compilation product file, the previous compilation product file is generated by the following method:
[0144] Compile source code files into intermediate product files;
[0145] Translating the intermediate product file to generate a source code final product file;
[0146] The source code final product file is combined with the resource file to form the previous compilation product file.
[0147] In some embodiments, when the previous compilation product file is not the initial compilation product file, the final product file of the current compilation obtained by the previous execution of the file difference-based compilation method is used as the previous compilation product file. The final product file generated based on the previous compilation is used as the previous compilation product file.
[0148] In some embodiments, the source code file includes a plurality of source code sub-files; the previous compilation product file includes a previous compilation index table, and the previous compilation index table includes version number information and index names corresponding to the plurality of source code sub-files;
[0149] Compiling the source code file into an intermediate product file includes:
[0150] Compiling the multiple source code sub-files to generate multiple intermediate product sub-files;
[0151] The step of translating the intermediate product file into a source code final product file includes:
[0152] Translating the plurality of intermediate product sub-files to generate a plurality of source code final product sub-files;
[0153] The combining of the source code final product file and the resource file to form the previous compilation product file includes:
[0154] According to the multiple source code final product sub-files, obtaining version numbers and sub-file names corresponding to the multiple source code final product sub-files;
[0155] According to the resource file, obtain the version number and resource file name corresponding to the resource file;
[0156] The previous compilation index table is generated according to the version numbers and subfile names corresponding to the plurality of source code final product subfiles and the version numbers and resource file names corresponding to the resource files.
[0157] When generating the final product, a corresponding index table is generated.
[0158] In some embodiments, the version identifier can be obtained from compilation software or management tools.
[0159] In some embodiments, the previous version identification information may be obtained from the index table.
[0160] In some embodiments, the current file to be compiled includes a plurality of current source code sub-files and a plurality of current resource files;
[0161] The comparison module 1040 is specifically configured as follows:
[0162] Comparing the index name in the previous compilation index table with the file names of the multiple current source code sub-files and the multiple current resource files;
[0163] If the comparison results are the same and the previous source code version identifier corresponding to the index name is different from the current source code version identifier, then the current source code subfile and / or current resource file with the same name as the index name in the current source code file belongs to the difference file set.
[0164] In some embodiments, the generating module 1040 is specifically configured to:
[0165] Compiling the difference file set to generate a difference intermediate product file;
[0166] The difference intermediate product file is translated to generate the difference file final product file.
[0167] In some embodiments, the update module 1060 is specifically configured to:
[0168] Obtaining, from the previous final product file, a previous final product subfile corresponding to the difference file final product file;
[0169] Replace the previous final product sub-file with the final product file of the difference file;
[0170] According to the current version identifier corresponding to the final product file of the difference file, the previous compilation index table is updated to generate a current compilation index table.
[0171] In some embodiments, the compilation device 1000 further includes a monitoring module 1001. The monitoring module 1001 is configured to monitor source code change information in the multiple current source code sub-files and update the source code version identifiers corresponding to the source code sub-files with source code changes. The monitoring module 1001 can also be configured to monitor resource change information in the multiple current resource files and update the version identifiers corresponding to the resource files with resource changes.
[0172] In some embodiments, when generating the previous compilation product file, compiling the source code file into the intermediate product file includes:
[0173] Get the source code sub-file length entered by the user;
[0174] Splitting the source code file according to the length of the source code sub-file to generate source code sub-files;
[0175] The intermediate product file is generated by compiling the source code sub-file.
[0176] In some embodiments, the compiling device may combine features of the file difference-based compiling method of any embodiment, and vice versa, which will not be described in detail here.
[0177] In an embodiment of the present invention, an electronic device is provided, comprising: a processor and a memory storing a computer program, wherein the processor is configured to execute any file difference-based compilation method of the embodiments of the present invention when running the computer program.
[0178] Figure 11 A schematic diagram of an electronic device 1100 that can implement a method or implement an embodiment of the present invention is shown. In some embodiments, the method may include more or fewer electronic devices than shown. In some embodiments, the method may be implemented using a single electronic device or multiple electronic devices. In some embodiments, the method may be implemented using cloud-based or distributed electronic devices.
[0179] like Figure 11 As shown, the electronic device 1100 includes a central processing unit (CPU) 1101, which can perform various appropriate operations and processes according to the programs and / or data stored in the read-only memory (ROM) 1102 or the programs and / or data loaded from the storage part 1108 into the random access memory (RAM) 1103. CPU 1101 can be a multi-core processor or can include multiple processors. In some embodiments, CPU 1101 can include a general-purpose main processor and one or more special coprocessors, such as a graphics processing unit (GPU), a neural network processor (NPU), a digital signal processor (DSP), etc. In RAM 1103, various programs and data required for the operation of the electronic device 1100 are also stored. CPU 1101, ROM 1102 and RAM 1103 are connected to each other via a bus 1104. Input / output (I / O) interface 1105 is also connected to bus 1104.
[0180] The above-mentioned processor and memory are used together to execute the program stored in the memory. When the program is executed by the computer, it can implement the steps or functions of the high-resolution audio generation model training method, high-resolution audio generation method, and sound effect switching method described in the above-mentioned embodiments.
[0181] The following components are connected to the I / O interface 1105: an input section 1106 including a keyboard, mouse, touch screen, etc.; an output section 1107 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and speakers; a storage section 1108 including a hard disk; and a communication section 1109 including a network interface card such as a LAN card or a modem. The communication section 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to the I / O interface 1105 as needed. Removable media 1111, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 1110 as needed, so that computer programs read therefrom can be installed into the storage section 1108 as needed. Figure 11 Only some components are shown schematically, which does not mean that the computer system 1100 only includes Figure 11 Components shown.
[0182] In some embodiments, the electronic device 1100 refers to a mobile terminal, including a mobile phone, a car terminal, a smart TV, etc. Taking a mobile phone as an example, the electronic device 1100 also includes a display screen with a touch function, an external speaker, a gyroscope, a camera, a 4G / 5G antenna and other device modules.
[0183] The systems, devices, modules, or units described in the above embodiments may be implemented by a computer or its associated components. The computer may be, for example, a mobile terminal, a smartphone, a personal computer, a laptop computer, an in-vehicle human-computer interaction device, a personal digital assistant, a media player, a navigation device, a game console, a tablet computer, a wearable device, a smart TV, an Internet of Things system, a smart home, an industrial computer, a server, or a combination thereof.
[0184] Although not shown, in an embodiment of the present invention, a storage medium is provided, wherein the storage medium stores a computer program, and the computer program is configured to execute any file difference-based compilation method according to any embodiment of the present invention when executed.
[0185] Storage media in embodiments of the present invention include permanent and non-permanent, removable and non-removable items that can be used to store information using any method or technology. Examples of storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
[0186] The methods, programs, systems, and apparatuses of the embodiments of the present invention may be executed or implemented in a single or multiple networked computers, or may be practiced in a distributed computing environment. In the embodiments of this specification, in these distributed computing environments, tasks may be performed by remote processing devices connected via a communication network.
[0187] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, those skilled in the art will appreciate that the functional modules / units or controllers and related method steps described in the above embodiments may be implemented using software, hardware, or a combination of software / hardware.
[0188] Unless explicitly stated, the actions or steps of the methods, procedures, and methods described in accordance with the embodiments of the present invention do not have to be performed in a specific order and can still achieve the desired results. In some implementations, multitasking and parallel processing are also possible or may be advantageous.
[0189] In this document, multiple embodiments of the present invention are described, but for the sake of brevity, the description of each embodiment is not exhaustive, and the same or similar features or parts between the embodiments may be omitted. In this document, "one embodiment", "some embodiments", "example", "specific example", or "some examples" are intended to apply to at least one embodiment or example according to the present invention, but not all embodiments. The above terms do not necessarily mean to refer to the same embodiment or example. Those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are mutually contradictory.
[0190] While the exemplary systems and methods of the present invention have been specifically shown and described with reference to the foregoing embodiments, these are merely examples of the best modes for implementing the present systems and methods. Those skilled in the art will appreciate that various changes may be made to the embodiments of the systems and methods described herein when implementing the present systems and / or methods without departing from the spirit and scope of the present invention as defined in the appended claims.
Claims
1. A compilation method based on file differences, characterized in that: The compilation method comprises the following steps: Get the current file to be compiled; Get the last compiled product file; Identifying the current file to be compiled and obtaining a current version identifier, wherein the current file to be compiled includes a plurality of current source code sub-files and a plurality of current resource files; Obtaining a previous version identifier and a previous final product file according to the previous compilation product file, wherein the previous compilation product file includes a previous compilation index table, and the previous compilation index table includes version number information and index names corresponding to multiple source code sub-files; Comparing the current version identifier with the previous version identifier, and obtaining a difference file set from the current file to be compiled based on the comparison result, including: comparing the index name in the previous compilation index table with the file names of the multiple current source code sub-files and the multiple current resource files, and determining that if the comparison results are the same and the previous version identifier corresponding to the index name is different from the current version identifier, then the current source code sub-file and / or current resource file in the current file to be compiled that has the same name as the index name belongs to the difference file set; Obtaining a final product file of the difference files according to the difference file set; According to the difference file final product file and the previous final product file, the current compilation final product file is obtained, including: replacing the previous final product file with the final product file and updating the index table.
2. The compiling method according to claim 1, wherein: When the previous compilation product file is an initial compilation product file, obtaining the previous compilation product file includes: Compile source code files into intermediate product files; Translating the intermediate product file to generate a source code final product file; Combining the source code final product file with the resource file to form the previous compilation product file; When the previous compilation product file is not an initial compilation product file, the previous compilation product file includes: The current compilation final product file obtained by the previous execution of the file difference-based compilation method is used as the previous compilation product file.
3. The compiling method according to claim 2, wherein: The source code file includes multiple source code sub-files; Compiling the source code file into an intermediate product file includes: Compiling the multiple source code sub-files to generate multiple intermediate product sub-files; The step of translating the intermediate product file into a source code final product file includes: Translating the plurality of intermediate product sub-files to generate a plurality of source code final product sub-files; The combining of the source code final product file and the resource file to form the previous compilation product file includes: According to the multiple source code final product sub-files, obtaining version numbers and sub-file names corresponding to the multiple source code final product sub-files; According to the resource file, obtain the version number and resource file name corresponding to the resource file; The previous compilation index table is generated according to the version numbers and subfile names corresponding to the multiple source code final product subfiles and the version numbers and resource file names corresponding to the resource files.
4. The compiling method according to claim 1, wherein: The step of obtaining a final product file of the difference files according to the difference file set includes: Compiling the difference file set to generate a difference intermediate product file; The difference intermediate product file is translated to generate the difference source code final product file.
5. The compiling method according to claim 1, wherein: The obtaining of the current compiled final product file according to the difference file final product file and the previous final product file includes: Obtaining, from the previous final product file, a previous final product subfile corresponding to the difference file final product file; Replace the previous final product sub-file with the final product file of the difference file; According to the current version identifier corresponding to the final product file of the difference file, the previous compilation index table is updated to generate a current compilation index table.
6. The compiling method according to claim 1, wherein: Before obtaining the current file to be compiled and the previous compiled product file, the compilation method further includes: Source code change information in the multiple current source code sub-files is monitored, and version identifiers corresponding to the source code sub-files with source code changes are updated.
7. The compiling method according to claim 1, wherein: Before obtaining the current file to be compiled and the previous compiled product file, the compilation method further includes: Resource change information in the multiple current resource files is monitored, and version identifiers corresponding to the resource files with resource changes are updated.
8. The compiling method according to claim 2, wherein: Compiling the source code file into an intermediate product file includes: Get the source code sub-file length entered by the user; Splitting the source code file according to the length of the source code sub-file to generate source code sub-files; The intermediate product file is generated by compiling the source code sub-file.
9. A computer-readable storage medium having a computer program stored thereon, wherein: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
10. An electronic device, characterized in that: include: A processor and a memory storing a computer program, wherein the processor is configured to perform the method according to any one of claims 1 to 8 when running the computer program.
Citation Information
Patent Citations
Incremental package generation method, computer readable storage medium and server
CN107797819A
Compiling method, device and system
CN110673853A