Code compiling method and device
By comparing candidates and original shader codes, filtering out target function codes that only need to be compiled, solving the problem of redundant compilation in large projects and improving compilation efficiency.
Patent Information
- Application Number
- CN202510482624.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-17
- Publication Date
- 2025-07-18
AI Technical Summary
In page development, especially in large projects, the modification of shader code leads to a large amount of redundant compilation, wasting compilation resources, and affecting compilation efficiency.
By responsive to code modification instructions, obtain candidate compiled code and original code, compare differences, filter out target functional codes that only need to be compiled, and avoid redundant compilation.
It significantly reduces compilation time, reduces resource consumption, and improves compilation efficiency.
Smart Images

Figure CN120335818A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of computer technology, and particularly to a code compilation method. This specification also relates to a code compilation method and an apparatus. Background Art
[0002] With the development of computer technology, page rendering technology has evolved from the early Fixed-Function Pipeline to the current Programmable Rendering Pipeline, greatly enhancing the flexibility and expressiveness of graphics rendering. As the core component of the programmable rendering pipeline, the shader plays a crucial role. The shader not only determines the visual effects of the page, such as lighting, shadows, reflections, etc., but also directly affects the performance of page display and the user experience.
[0003] In page development, various types of shaders and various functions in the shaders are used. Especially in large page development projects, the quantity and scale of shaders used are very large. The resulting shader compilation scale grows geometrically with its quantity and scale, which has a huge impact on the machine specifications and processing time. In particular, after modifying some shader code, compiling all the affected shader code causes a large amount of shader code to be redundantly compiled, wasting compilation resources and affecting compilation efficiency. Therefore, there is an urgent need for an efficient code compilation solution. Summary of the Invention
[0004] In view of this, embodiments of this specification provide a code compilation method to solve the technical defects existing in the prior art. Embodiments of this specification also provide a code compilation apparatus, a computing device, a computer-readable storage medium, and a computer program product.
[0005] According to the first aspect of the embodiments of this specification, a code compilation method is provided, including: Responding to a code modification instruction, obtaining candidate compilation code and the original code of the candidate compilation code, where the candidate compilation code has an association relationship with the code modification instruction; Comparing the candidate compilation code with the original code to obtain a comparison result; According to the comparison result, screening out target compilation code from the candidate compilation code, where the target function code in the target compilation code is different from the original function code in the original code; Compiling the target compilation code to obtain a code compilation result.
[0006] According to the second aspect of the embodiments of this specification, a code compilation apparatus is provided, including: A first acquisition module, configured to acquire a candidate compiled code and the original code of the candidate compiled code in response to a code modification instruction, wherein the candidate compiled code has an associated relationship with the code modification instruction; A comparison module, configured to compare the candidate compiled code and the original code to obtain a comparison result; A screening module, configured to screen out a target compiled code from the candidate compiled codes according to the comparison result, wherein the target functional code in the target compiled code is different from the original functional code in the original code; A compilation module, configured to compile the target compiled code to obtain a code compilation result.
[0007] According to the third aspect of the embodiments of the present specification, a computing device is provided, including: a memory and a processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer programs / instructions are executed by the processor, the steps of the code compilation method provided in the first aspect are implemented.
[0008] According to the fourth aspect of the embodiments of the present specification, a computer-readable storage medium is provided, which stores computer programs / instructions. When the computer programs / instructions are executed by a processor, the steps of the code compilation method provided in the first aspect are implemented.
[0009] According to the fifth aspect of the embodiments of the present specification, a computer program product is provided, including computer programs / instructions. When the computer programs / instructions are executed by a processor, the steps of the code compilation method provided in the first aspect are implemented.
[0010] A code compilation method provided in the present specification, by responding to a code modification instruction, acquiring a candidate compiled code and the original code of the candidate compiled code, wherein the candidate compiled code has an associated relationship with the code modification instruction; comparing the candidate compiled code and the original code to obtain a comparison result; screening out a target compiled code from the candidate compiled codes according to the comparison result, wherein the target functional code in the target compiled code is different from the original functional code in the original code; compiling the target compiled code to obtain a code compilation result. By comparing the candidate compiled code and the original code of the candidate compiled code, the target compiled code with the actually changed functional code can be screened out from the candidate compiled codes, avoiding redundant compilation of the candidate compiled codes with unchanged functional codes, thereby significantly reducing the compilation time, and only compiling the target compiled code, reducing the consumption of compilation resources and further improving the compilation efficiency. Description of the Drawings
[0011] Figure 1 is a flowchart of a code compilation method provided by an embodiment of the present specification; Figure 2 It is a structural block diagram of a code compilation system provided by an embodiment of this specification; Figure 3 It is a flowchart of another code compilation system provided by an embodiment of this specification; Figure 4 It is a schematic structural diagram of a code compilation device provided by an embodiment of this specification; Figure 5 It is a structural block diagram of a computing device provided by an embodiment of this specification. Detailed implementation manners
[0012] In the following description, many specific details are set forth in order to provide a thorough understanding of this specification. However, this specification can be implemented in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the connotation of this specification. Therefore, this specification is not limited by the specific implementations disclosed below.
[0013] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms "a", "an", and "the" used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more of the associated listed items. The term "at least one" in one or more embodiments of this specification refers to "one or more", and "a plurality" refers to "two or more". The term "comprising" is an open description and should be understood as "including but not limited to", and other contents may also be included on the basis of the described contents.
[0014] It should be understood that although the terms first, second, etc. may be used in one or more embodiments of this specification to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first can also be called the second, and similarly, the second can also be called the first. Depending on the context, the word "if" as used herein can be interpreted as "when" or "while" or "in response to determining".
[0015] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data that have been authorized by the user or fully authorized by all parties. Moreover, the collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding operation entrances are provided for users to choose to authorize or reject.
[0016] First, the noun terms involved in one or more embodiments of the present invention are explained.
[0017] Shader: A program that runs on a Graphics Processing Unit (GPU) and is used to execute specific stages in the graphics rendering process. They play a crucial role in computer graphics, especially in the fields of three-dimensional (3D) rendering and image processing. Shaders can directly control attributes such as the color, texture, and lighting effects of the model surface, enabling developers to create very realistic or stylized visual effects.
[0018] Shader compilation: Shader compilation refers to the process of converting shader code written in a high-level shader language into low-level code or bytecode that can be executed by a Graphics Processing Unit (GPU).
[0019] Shader language code: The code format required to write shader programs on various platforms, mainly including the OpenGL Shading Language (GLSL) used in OpenGL, the High-Level Shading Language (HLSL) used in DirectX, SPIR-V, etc. Among them, SPIR-V is an intermediate representation format designed to serve as a bridge between different high-level shader languages and is used by application programming interfaces (APIs) such as Vulkan.
[0020] Machine language code: Machine language code, also known as machine code or machine code, is an instruction set that can be directly executed by computer hardware. It consists of binary digits (0 and 1), which represent the basic operations that a processor can understand and execute, such as arithmetic operations, logical operations, data transfer, control flow, etc.
[0021] Distributed Compilation: Distributed compilation is a technology used to improve the efficiency of the compilation process, especially when dealing with large projects or tasks that require high-performance computing. By distributing the compilation tasks to multiple machines for execution, the overall compilation time can be significantly reduced. This method is not only applicable to the regular compilation process of software projects but can also be applied to the compilation of shader code, especially when developing large games or graphics-intensive applications.
[0022] IncrediBuild: It is a tool that accelerates the development process and the code compilation process. It uses distributed computing technology to speed up the execution of compilation tasks or other code tasks, significantly shortening the execution process of originally time-consuming code tasks. It is particularly suitable for tasks that require a large amount of computing resources, such as code compilation, code construction, code testing, etc.
[0023] FastBuild: It is a high-performance, open-source distributed compilation system that accelerates the software project construction process by making full use of local and remote computing resources. FastBuild can significantly reduce the compilation time and is particularly suitable for large code compilation projects.
[0024] In this specification, a code compilation method is provided. This specification also relates to a code compilation device, a computing device, a computer-readable storage medium, and a computer program product, which will be described in detail one by one in the following embodiments.
[0025] See Figure 1 , Figure 1 which shows a flowchart of a code compilation method provided by an embodiment of this specification, specifically including the following steps: Step 102: In response to a code modification instruction, obtain the candidate compilation code and the original code of the candidate compilation code, where the candidate compilation code has an association relationship with the code modification instruction.
[0026] It should be noted that the code compilation method proposed in the embodiments of this specification can be applied to different code compilation scenarios, such as game application code compilation scenarios, financial application code compilation scenarios, shopping application code compilation scenarios, and so on. Taking the compilation of shader code in a game application code compilation scenario as an example, it may be to obtain candidate shader compilation code and the original code of the candidate shader compilation code in response to a shader code modification instruction. A code modification instruction refers to an instruction used to request a change to the code, and the change can be an update, deletion, addition, etc., which is not limited here. After modifying the code in response to the code modification instruction, the code affected by this modification is called candidate compilation code. Candidate compilation code, such as the modified code modified in response to the code modification instruction, or the code having an associated relationship with the modified code, for example, the code having an associated relationship such as a call relationship, a dependency relationship, or an inheritance relationship with the modified code. The original code of the candidate compilation code refers to the code before being affected by the code modification instruction. The associated relationship between the candidate compilation code and the code modification instruction represents the associated relationship between the candidate compilation code and the modified code. These associated relationships include but are not limited to call relationships, dependency relationships, and inheritance relationships. Taking the call relationship as an example, it may be that the entire modified code is called by the candidate compilation code or the modified call code included in the modified code is called by the candidate compilation code. Compared with the original code of the candidate compilation code, the candidate compilation code may be the code where the candidate call code has changed, or the code where the candidate function code has changed, or the code where both the candidate call code and the candidate function code have changed.
[0027] Exemplarily, taking the modified code "get int" as an example, the modified call code in the modified code "get int" is the modified code "get int" itself, and the code that calls "get int" is used as the candidate compilation code, and the original code of the candidate compilation code is obtained.
[0028] In practical applications, there are various ways to obtain the candidate compilation code and the original code of the candidate compilation code in response to the code modification instruction, which are specifically selected according to the actual situation, and the embodiments of this specification do not make any limitations on this. In one possible implementation manner of this specification, it may be to send a code acquisition request to the client in response to the code modification instruction, and receive the candidate compilation code and the original code of the candidate compilation code sent by the client in response to the code acquisition request. In another possible manner of this specification, it may be to determine the candidate compilation code and the original code of the candidate compilation code according to the modified code obtained by modifying based on the code modification instruction.
[0029] In an optional embodiment of this specification, the above-mentioned obtaining the candidate compilation code and the original code of the candidate compilation code in response to the code modification instruction may include the following steps: In response to a code modification instruction, obtain the modified code, where the modified code is the code obtained by modifying based on the code modification instruction. Determine the modified call code from the modified code, and based on the modified call code, obtain the candidate compilation code and the original code of the candidate compilation code, where the candidate compilation code includes the modified call code.
[0030] It should be noted that the modified code is the code obtained by modifying in response to the code modification instruction. The call code refers to a code block that can be called by other code to implement a specific function. Similarly, the modified call code refers to the code block in the modified code that can be called by other code to implement a specific function. Taking the compilation of shader code in the game code compilation scenario as an example, the call code can be understood as a macro. In the game code compilation scenario, a macro is a code construct that allows users to define a code snippet as an identifier for easy reuse and code writing simplification. Macros are usually used to perform code substitution. During the compilation or preprocessing stage of the code that calls the macro, the name of the macro will be replaced by the content it defines. Therefore, it is possible to determine whether other code is affected by the code modification instruction based on whether the modified call code is included in other code, and determine the other code affected by the modification as the candidate compilation code. The modified code may only include the modified call code, or it can be understood that the modified code itself is a macro. The modified code can also include the modified call code and the modified function code.
[0031] In practical applications, there are various ways to obtain the modified code in response to the code modification instruction, which are specifically selected according to the actual situation, and this specification embodiment does not make any limitations in this regard. In one possible implementation manner of this specification, it may be that the code modification instruction includes a patch, and the patch is directly used to perform operations such as adding, modifying, and deleting the code to obtain the modified code. In another possible way of this specification, it may be to use a code development tool to modify the code based on the code modification instruction to obtain the modified code.
[0032] Applying the solution of this specification embodiment, obtain the modified code according to the code modification instruction, determine the modified call code according to the modified code, that is, the code in the modified code that can be called by other code, and obtain the candidate compilation code according to the modified call code. Determine all the code affected by the code modification instruction according to the call relationship, ensure that all the code affected by the code modification instruction can be included in the candidate compilation code, ensure the comprehensiveness of the candidate compilation code, and avoid code omission.
[0033] Step 104: Compare the candidate compilation code and the original code to obtain a comparison result.
[0034] It should be noted that comparison refers to the process of comparing the candidate compiled code with the original code to determine the differences between the two. The comparison can be the comparison of the code differences between the candidate compiled code and the original code, or the comparison of the functional code differences between the candidate functional code of the candidate compiled code and the original functional code of the original code, or the comparison of the identification information differences between the candidate identification information of the candidate compiled code and the original identification information of the original code. The comparison result is the result determined according to the comparison, which can be that the two are the same or that the two are different, and is determined according to the specific situation. The embodiments of this specification do not make any limitations on this.
[0035] In practical applications, there are various ways to compare the candidate compiled code with the original code, which are specifically selected according to the actual situation. The embodiments of this specification do not make any limitations on this. In one possible implementation manner of this specification, it can be compared according to the line and column information or comment information in the code. In another possible implementation manner of this specification, a code comparison tool can be used to compare the code.
[0036] In an optional embodiment of this specification, the above-mentioned comparison of the candidate compiled code with the original code to obtain a comparison result may include the following steps: Extract the functional code in the candidate compiled code to obtain the candidate functional code, and extract the functional code in the original code to obtain the original functional code; Compare the candidate functional code with the original functional code to obtain a comparison result.
[0037] It should be noted that the functional code refers to the code in the code that does not include the call code. Similarly, the candidate functional code refers to the code in the candidate compiled code that does not include the call code, and the original functional code refers to the code in the original code that does not include the call code. For example, the code for deleting macros is determined as the functional code.
[0038] In practical applications, there are various ways to extract the functional code in the candidate compiled code to obtain the candidate functional code, which are specifically selected according to the actual situation. The embodiments of this specification do not make any limitations on this. In one possible implementation manner of this specification, the candidate functional code in the candidate compiled code can be directly extracted according to the comment information in the code. In one possible implementation manner of this specification, the candidate call code in the candidate compiled code can be deleted to obtain the candidate functional code. The implementation manner of "extracting the functional code in the original code to obtain the original functional code" is the same as that of "extracting the functional code in the candidate compiled code to obtain the candidate functional code", and the embodiments of this specification will not elaborate further.
[0039] Applying the solution of the embodiments of this specification, by extracting the functional codes in the candidate compilation code and the functional codes in the original code and comparing them, the code comparison conditions are made clearer, the screening results are more accurate, the codes to be compiled are more accurate and fewer in number, effectively reducing the ineffective workload of code compilation and improving the code compilation efficiency.
[0040] In an optional embodiment of this specification, the above-mentioned steps of extracting the functional codes in the candidate compilation code to obtain candidate functional codes and extracting the functional codes in the original code to obtain original functional codes may include the following steps: Determine candidate call codes from the candidate compilation code and determine original call codes from the original code; Delete the candidate call codes in the candidate compilation code to obtain candidate functional codes, and delete the original call codes in the original code to obtain original functional codes.
[0041] It should be noted that a call code refers to a code block that can be called by other codes to implement a specific function. Therefore, a candidate call code refers to a call code that is called in the candidate compilation code, and an original call code refers to a call code that is called in the original code. Thus, deleting the candidate call codes in the candidate compilation code can obtain candidate functional codes that do not contain call codes, and deleting the original call codes in the original code can obtain original functional codes that do not contain call codes. Taking the compilation of shader codes in the game code compilation scenario as an example, the call code can be understood as a macro, so the above process can be to determine the macros called in the candidate compilation code and the macros called in the original code, and delete the macros to obtain candidate functional codes and original functional codes.
[0042] In practical applications, there are various ways to determine candidate call codes from the candidate compilation code, which are specifically selected according to the actual situation, and the embodiments of this specification do not make any limitations in this regard. In a possible implementation manner of this specification, the candidate call codes in the candidate compilation code can be directly determined according to the comment information in the code. In another possible implementation manner of this specification, a call code static analysis tool is used to determine the candidate call codes from the candidate compilation code. The implementation manner of "determining candidate call codes from the candidate compilation code" is the same as that of "determining original call codes from the original code", and the embodiments of this specification will not elaborate further.
[0043] Applying the solution of the embodiments of this specification, by determining candidate call codes from the candidate compilation code and determining original call codes from the original code; deleting the candidate call codes in the candidate compilation code to obtain candidate functional codes, and deleting the original call codes in the original code to obtain original functional codes, the original functional codes and candidate functional codes can be accurately determined, ensuring the accuracy of the original functional codes and candidate functional codes.
[0044] In an alternative embodiment of this specification, before comparing the candidate compiled code and the original code to obtain a comparison result, the following steps may further be included: Verify the candidate compiled code to obtain a code verification result; Comparing the candidate compiled code and the original code to obtain a comparison result may further include the following steps: In the case where it is determined based on the code verification result that the candidate compiled code meets the code verification conditions, compare the candidate compiled code and the original code to obtain a comparison result.
[0045] It should be noted that verification is a process of checking the code to ensure whether the code meets the code verification conditions. The code verification result is the result obtained by verifying the code, which can indicate that the code meets the code verification conditions or indicate that the code does not meet the code verification conditions. The code verification conditions are specific verification rules or standards for the code, such as the code having no writing errors or no logical errors, etc. In practical applications, the code verification conditions can be added or deleted according to different code compilation requirements, that is, customized filtering of the candidate compiled code can be achieved to flexibly meet the needs of users. The embodiments of this specification do not make any limitations in this regard.
[0046] In practical applications, there are various implementation manners for verifying the candidate compiled code to obtain a code verification result, which are specifically selected according to the actual situation. The embodiments of this specification do not make any limitations in this regard. In a possible implementation manner of this specification, a code static analysis tool may be used to verify the candidate compiled code to obtain a code verification result. In another possible implementation manner of this specification, a code verification model may be used to verify the candidate compiled code to obtain a code verification result. The code verification model may be a pre-trained large model or a deep learning model trained based on sample compiled code and sample verification results of the sample compiled code.
[0047] Applying the solution of the embodiments of this specification, in the case where it is determined that the candidate compiled code meets the code verification conditions, comparing the candidate compiled code and the original code can avoid redundant comparison of candidate compiled codes that do not meet the code verification conditions, thereby improving the code compilation efficiency.
[0048] In an alternative embodiment of this specification, before extracting the functional code in the candidate compiled code to obtain candidate functional code and extracting the functional code in the original code to obtain original functional code, the following steps may further be included: Obtain the candidate identification information of the candidate compiled code and the original identification information of the original code; Extract the functional code from the candidate compiled code to obtain the candidate functional code, and extract the functional code from the original code to obtain the original functional code, which may include the following steps: In the case where the candidate identification information and the original identification information are different, extract the functional code from the candidate compiled code to obtain the candidate functional code, and extract the functional code from the original code to obtain the original functional code.
[0049] It should be noted that the identification information of the code is the unique identifier of the code content of the identification code, and the identification information of the code can be directly extracted from the code configuration file. Similarly, the candidate identification information of the candidate compiled code is extracted according to the candidate compiled code and is the unique identifier used to identify the code content of the candidate compiled code. Similarly, the original identification information of the original code is extracted according to the original code and is the unique identifier used to identify the code content of the original code. Since this identification information is extracted according to the code content, it can reflect the changes in the code content. Even a change to an individual code or symbol will cause the identification information to change. In practical applications, there are various ways to obtain the candidate identification information of the candidate compiled code, which are specifically selected according to the actual situation, and this specification embodiment does not make any limitations on this. In one possible implementation manner of this specification, the system-preinstalled command-line tool can be used to process the code to obtain the identification information. In another possible implementation manner of this specification, a third-party language library or a hash algorithm can be used to process the code to obtain the identification information. The method for obtaining the original identification information of the original code is similar to the method for obtaining the candidate identification information of the candidate compiled code described above, and the specific details can be seen in the above description and will not be elaborated here.
[0050] Further, in the case where the candidate identification information and the original identification information are the same, it is determined that the candidate compiled code does not need to be compiled.
[0051] Exemplarily, taking the shader code compilation in the game code compilation scenario as an example, the identification information of the code can be the hash value of the code. The hash value of the code is a unique identifier value with a fixed length generated by performing a hash operation on the code content. This value is obtained by the hash function through hash calculation on the input data and is usually a number or a string.
[0052] Applying the solution of the embodiments of this specification, first, the candidate identification information and the original identification information are judged. When the candidate identification information is different from the original identification information, the functional code in the candidate compilation code and the original functional code are further extracted for code comparison, so as to screen out the codes with the same identification information, that is, the codes with no code changes, during the identification information judgment stage. Then, for the codes with different candidate identification information and original identification information, the functional codes are extracted for code comparison, reducing the workload of extracting functional codes and code comparison, improving the code comparison efficiency, significantly reducing the compilation time, and further improving the compilation efficiency.
[0053] In an optional embodiment of this specification, after the above-mentioned extraction of the functional code in the candidate compilation code to obtain the candidate functional code and the extraction of the functional code in the original code to obtain the original functional code, the following steps may further be included: When the candidate functional code is the same as the original functional code, the candidate compilation code is determined as the updated original code, and the candidate identification information is determined as the updated original identification information.
[0054] Applying the solution of the embodiments of this specification, when the candidate functional code is the same as the original functional code, it indicates that the candidate compilation code does not need to be compiled. However, at this time, the candidate compilation code has changed compared with the original code. At this time, the original identification information of the original code needs to be matched and modified with the candidate compilation code. Therefore, the candidate compilation code is determined as the updated original code, and the candidate identification information is determined as the updated original identification information, so as to screen the target compilation code based on the updated original code and the updated original identification information during the next target compilation code screening, ensuring the accuracy of the screening process.
[0055] Step 106: According to the comparison result, screen out the target compilation code from the candidate compilation codes, where the target functional code in the target compilation code is different from the original functional code in the original code.
[0056] It should be noted that the target compilation code is the candidate compilation code screened out for actual compilation, that is, the candidate compilation code with different selected functional codes from the original functional code (the functional code included in the original code of the candidate compilation code) is determined as the target compilation code. The target functional code refers to the code in the target compilation code that does not include the call code.
[0057] In practical applications, there are various ways of screening, which are specifically selected according to the actual situation, and the embodiments of this specification do not make any limitations in this regard. In one possible implementation of this specification, it may be that after determining the comparison result, the target compilation code that meets the conditions is screened out according to the comparison result. In another possible implementation of this specification, it may be that a screening script is pre-configured, the comparison result is input into the screening script, and the screening script screens the candidate compilation code.
[0058] Step 108: Compile the target compilation code to obtain a code compilation result.
[0059] It should be noted that the code compilation result refers to the result obtained by compiling the target compilation code. There can be multiple target compilation codes, and there can also be multiple corresponding code compilation results.
[0060] In practical applications, there are various implementation ways to compile the target compilation code to obtain a code compilation result, which are specifically selected according to the actual situation, and the embodiments of this specification do not make any limitations in this regard. In one possible implementation of this specification, it may be to compile the target compilation code locally to obtain a code compilation result; in another possible implementation of this specification, it may be to call a distributed compilation platform to compile the target compilation code to obtain a code compilation result. Among them, when calling a distributed compilation platform to compile the target compilation code, each target compilation code can be sent to the distributed compilation platform separately, and the distributed compilation platform compiles each target compilation code in turn, or multiple target compilation codes can be added to the distributed compilation queue, and the distributed compilation queue is sent to the code compilation platform, and the code compilation platform performs batch compilation on multiple target compilation codes in the distributed compilation queue.
[0061] Applying the solution of this specification, by comparing the candidate compilation code with the original code of the candidate compilation code, the target compilation code with actual changes in the functional code can be screened out from the candidate compilation code, avoiding redundant compilation of candidate compilation codes with unchanged functional codes, thereby significantly reducing the compilation time. Moreover, only the target compilation code is compiled, reducing the consumption of compilation resources and further improving the compilation efficiency.
[0062] After testing, the code compilation method proposed in the embodiments of this specification can reduce 80,000 candidate compilation codes to 10,000 target compilation codes through screening. Compiling 80,000 candidate compilation codes takes 3 hours, while the compilation time for 10,000 target compilation codes can be shortened to within 1 hour, significantly reducing the compilation time and improving the compilation efficiency while ensuring the compilation quality.
[0063] Therefore, in an alternative embodiment of this specification, compiling the target compiled code to obtain the code compilation result may also include the following steps: Add the target compiled code to the distributed compilation queue; Call the distributed compilation platform to compile the distributed compilation queue to obtain the code compilation result.
[0064] It should be noted that distributed compilation refers to a compilation method in which the compilation task is divided into multiple sub-compilation tasks, and the multiple sub-compilation tasks are assigned to multiple devices to be independently executed for compilation, and the integrated compilation result is returned. The distributed compilation queue is used to provide one or more target compiled codes that support distributed compilation to the distributed compilation platform. Similarly, the distributed compilation platform is a platform that divides the task into multiple sub-compilation tasks, compiles the sub-compilation tasks on different devices, and integrates the compilation results. Exemplarily, the distributed compilation platform can be IncrediBuild, FastBuild, etc., which is specifically selected according to the actual situation, and the embodiments of this specification do not make any limitations in this regard.
[0065] In practical applications, there are various methods to add the code to the distributed compilation queue, which are specifically selected according to the actual situation, and the embodiments of this specification do not make any limitations in this regard. In a possible implementation manner of this specification, it may be to configure a continuous integration platform or a continuous deployment platform, and the platform automatically processes the code submission and adds it to the compilation queue. In another possible implementation manner of this specification, it may be to write an automated language script to automatically add the code to the compilation queue.
[0066] Applying the solution of the embodiments of this specification, after determining the target compiled code, the target compiled code can be added to the distributed compilation queue, and the distributed compilation platform is called for compilation. By means of joint compilation by multiple compilation ends, the compilation time is significantly reduced, and the compilation efficiency is further improved.
[0067] After testing, the code compilation method proposed in the embodiments of this specification can reduce the compilation time of 80,000 target compiled codes from more than 10 hours to within 3 hours through distributed compilation, significantly reducing the compilation time and improving the compilation efficiency while ensuring the compilation quality.
[0068] It is worth noting that the code compilation method provided in the embodiments of this specification is generally executed by the server. However, in other embodiments of this specification, the client can also have a similar function to the server, so as to execute the code compilation method provided in the embodiments of this specification. In other embodiments, the code compilation method provided in the embodiments of this specification can also be jointly executed by the client and the server.
[0069] Figure 2The block diagram of a code compilation system provided by an embodiment of this specification is shown. The code compilation system 200 may include a code screening unit 202 and multiple code compilation units 204; The code screening unit 202 is configured to, in response to a code modification instruction, obtain a candidate compilation code and the original code of the candidate compilation code. Among them, the candidate compilation code has an association relationship with the code modification instruction; compare the candidate compilation code with the original code to obtain a comparison result; according to the comparison result, screen out a target compilation code from the candidate compilation code. Among them, the target function code in the target compilation code is different from the original function code in the original code.
[0070] The code compilation unit 204 is configured to compile the target compilation code to obtain a code compilation result.
[0071] Among them, it may be that a single code compilation unit 204 compiles the target compilation code, or multiple code compilation units 204 implement distributed code compilation. It is specifically selected according to the actual situation, and the embodiments of this specification do not make any limitation on this.
[0072] See Figure 3 , Figure 3 The flowchart of another code compilation system provided by an embodiment of this specification is shown. The code compilation system may include a code screening unit and a distributed compilation platform; The code screening unit is used to, in response to a code modification instruction, obtain a candidate compilation code and the original code of the candidate compilation code; in the case where the candidate compilation code is the same as the original code, determine that the candidate compilation code does not need to be compiled; in the case where the candidate compilation code is different from the original code (it can be determined whether the candidate compilation code is the same as the original code by the candidate identification information of the candidate compilation code and the original identification information of the original code), determine a candidate call code from the candidate compilation code, and determine an original call code from the original code; delete the candidate call code in the candidate compilation code to obtain a candidate function code, and delete the original call code in the original code to obtain an original function code; in the case where the candidate function code is the same as the original function code, determine the candidate compilation code as the updated original code, and determine the candidate identification information as the updated original identification information; in the case where the candidate function code is different from the original function code, but the candidate compilation code does not meet the code verification condition, determine that the candidate compilation code does not need to be compiled; in the case where the candidate function code is different from the original function code, and the candidate compilation code meets the code verification condition, determine the candidate compilation code as the target compilation code; add the target compilation code to the distributed compilation queue, and the distributed compilation queue includes target compilation code 1,......, target compilation code n.
[0073] A distributed compilation platform for performing distributed compilation on target compilation codes 1,......, target compilation codes n to obtain code compilation results 1,......, code compilation results n.
[0074] Corresponding to the above method embodiment, this specification also provides a code compilation device embodiment. Figure 4 It shows a schematic structural diagram of a code compilation device provided by an embodiment of this specification. As Figure 4 shown, the device includes: A first acquisition module 402 configured to acquire a candidate compilation code and the original code of the candidate compilation code in response to a code modification instruction, wherein the candidate compilation code has an association relationship with the code modification instruction; A comparison module 404 configured to compare the candidate compilation code and the original code to obtain a comparison result; A screening module 406 configured to screen out a target compilation code from the candidate compilation codes according to the comparison result, wherein the target function code in the target compilation code is different from the original function code in the original code; A compilation module 408 configured to compile the target compilation code to obtain a code compilation result.
[0075] Optionally, the first acquisition module 402 is further configured to acquire a modified code in response to a code modification instruction, where the modified code is a code modified based on the code modification instruction; determine a modified call code from the modified code, and based on the modified call code, acquire the candidate compilation code and the original code of the candidate compilation code, wherein the candidate compilation code includes the modified call code.
[0076] Optionally, the comparison module 404 is further configured to extract the function code in the candidate compilation code to obtain a candidate function code, and extract the function code in the original code to obtain an original function code; compare the candidate function code and the original function code to obtain a comparison result.
[0077] Optionally, the comparison module 404 is further configured to determine a candidate call code from the candidate compilation code and determine an original call code from the original code; delete the candidate call code in the candidate compilation code to obtain a candidate function code, and delete the original call code in the original code to obtain an original function code.
[0078] Optionally, the code compilation device further includes a second acquisition module configured to acquire candidate identification information of the candidate compilation code and original identification information of the original code; Optionally, the comparison module 404 is further configured to, when the candidate identification information is different from the original identification information, extract the functional code in the candidate compilation code to obtain the candidate functional code, and extract the functional code in the original code to obtain the original functional code.
[0079] Optionally, the code compilation device further includes an update module, which is configured to, when the candidate functional code is the same as the original functional code, determine the candidate compilation code as the updated original code, and determine the candidate identification information as the updated original identification information.
[0080] Optionally, the code compilation device further includes a verification module, which is configured to verify the candidate compilation code to obtain a code verification result; Optionally, the comparison module 404 is further configured to, when it is determined based on the code verification result that the candidate compilation code meets the code verification condition, compare the candidate compilation code with the original code to obtain a comparison result.
[0081] Optionally, the compilation module 408 is further configured to add the target compilation code to the distributed compilation queue; call the distributed compilation platform to compile the distributed compilation queue to obtain a code compilation result.
[0082] The above is a schematic solution of a code compilation device according to this embodiment. It should be noted that the technical solution of this code compilation device and the technical solution of the above code compilation method belong to the same concept. For the details not described in detail in the technical solution of the code compilation device, reference can be made to the description of the technical solution of the above code compilation method. In addition, each component in the device embodiment should be understood as a functional module that must be established to implement each step of the program flow or each step of the method. Each functional module is not an actual functional division or separation limitation. The device defined by such a set of functional modules should be understood as mainly implementing the functional module architecture of the solution through the computer program recorded in the specification, rather than mainly implementing the entity device of the solution through hardware means.
[0083] Figure 5 The structural block diagram of a computing device provided by an embodiment of this specification is shown. The components of the computing device 500 include, but are not limited to, a memory 510 and a processor 520. The processor 520 is connected to the memory 510 through a bus 530, and the database 550 is used to store data.
[0084] The computing device 500 also includes an access device 540, which enables the computing device 500 to communicate via one or more networks 560. Examples of such networks include the Public Switched Telephone Network (PSTN), Local Area Network (LAN), Wide Area Network (WAN), Personal Area Network (PAN), or a combination of communication networks such as the Internet. The access device 540 may include one or more of any type of wired or wireless network interface (e.g., Network Interface Card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) wireless interface, a Worldwide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.
[0085] In one embodiment of the present specification, the above components of the computing device 500, as well as Figure 5 other components not shown, may also be connected to each other, for example, via a bus. It should be understood that Figure 5 the block diagram of the computing device shown is for illustrative purposes only and is not a limitation on the scope of the present specification. Those skilled in the art can add or replace other components as needed.
[0086] The computing device 500 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or Personal Computers (PCs). The computing device 500 can also be a mobile or stationary server.
[0087] Among them, the processor 520 is used to execute the computer-executable instructions of the code compilation method.
[0088] The above is a schematic solution of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the above code compilation method belong to the same concept. For the details not described in detail in the technical solution of the computing device, reference can be made to the description of the technical solution of the above code compilation method.
[0089] An embodiment of this specification also provides a computer-readable storage medium, which stores computer programs / instructions. When the computer programs / instructions are executed by a processor, they are used for the code compilation method.
[0090] The above is a schematic solution of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium and the technical solution of the above code compilation method belong to the same concept. For the details not described in detail in the technical solution of the storage medium, reference can be made to the description of the technical solution of the above code compilation method.
[0091] An embodiment of this specification also provides a computer program product, including computer programs / instructions. When the computer programs / instructions are executed by a processor, they are used for the code compilation method.
[0092] The above is a schematic solution of a computer program product according to this embodiment. It should be noted that the technical solution of this computer program product and the technical solution of the above code compilation method belong to the same concept. For the details not described in detail in the technical solution of the computer program product, reference can be made to the description of the technical solution of the above code compilation method.
[0093] The computer instructions include computer program code, and the computer program code can be in the form of source code, object code, executable file or some intermediate form, etc. The computer-readable medium can include: any entity or device that can carry the computer program code, recording medium, USB flash drive (USB flash drive), mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), electrical carrier signal, telecommunication signal, and software distribution medium, etc. It should be noted that the content included in the computer-readable medium can be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.
[0094] It should be noted that, for the foregoing method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations. However, those skilled in the art should know that this specification is not limited by the described action sequence, because according to this specification, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to this specification.
[0095] In the above embodiments, the descriptions of the respective embodiments have their own emphases. For parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0096] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The alternative embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation manners. Obviously, many modifications and variations can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of this specification, so that those skilled in the art can well understand and utilize this specification. This specification is only limited by the claims and their full scope and equivalents.
Claims
1. A code compilation method, characterized in that, Including: In response to a code modification instruction, obtain a candidate compiled code and the original code of the candidate compiled code, wherein the candidate compiled code has an association relationship with the code modification instruction; Compare the candidate compiled code with the original code to obtain a comparison result; According to the comparison result, screen out a target compiled code from the candidate compiled code, wherein the target function code in the target compiled code is different from the original function code in the original code; Compile the target compiled code to obtain a code compilation result.
2. The method according to claim 1, characterized in that, The comparing the candidate compiled code with the original code to obtain a comparison result includes: Extract the function code in the candidate compiled code to obtain a candidate function code, and extract the function code in the original code to obtain an original function code; Compare the candidate function code with the original function code to obtain a comparison result.
3. The method according to claim 2, wherein The extracting the function code in the candidate compiled code to obtain a candidate function code, and extracting the function code in the original code to obtain an original function code includes: Determine a candidate call code from the candidate compiled code, and determine an original call code from the original code; Delete the candidate call code in the candidate compiled code to obtain the candidate function code, and delete the original call code in the original code to obtain the original function code.
4. The method according to claim 2, wherein Before the extracting the function code in the candidate compiled code to obtain a candidate function code, and extracting the function code in the original code to obtain an original function code, it further includes: Obtain candidate identification information of the candidate compiled code and original identification information of the original code; The extracting the function code in the candidate compiled code to obtain a candidate function code, and extracting the function code in the original code to obtain an original function code includes: In the case where the candidate identification information is different from the original identification information, extract the function code in the candidate compiled code to obtain a candidate function code, and extract the function code in the original code to obtain an original function code.
5. The method according to claim 4, wherein After the extracting the function code in the candidate compiled code to obtain a candidate function code, and extracting the function code in the original code to obtain an original function code, it further includes: In the case where the candidate function code is the same as the original function code, determine the candidate compiled code as the updated original code, and determine the candidate identification information as the updated original identification information.
6. The method according to claim 1, wherein The responding to a code modification instruction to obtain a candidate compiled code and the original code of the candidate compiled code includes: In response to the code modification instruction, obtain a modified code, wherein the modified code is a code modified based on the code modification instruction; Determine a modified call code from the modified code, and based on the modified call code, obtain the candidate compiled code and the original code of the candidate compiled code, wherein the candidate compiled code includes the modified call code.
7. The method according to claim 1, characterized in that, The compiling the target compiled code to obtain a code compilation result includes: Add the target compiled code to the distributed compilation queue; Call the distributed compilation platform to compile the distributed compilation queue to obtain a code compilation result.
8. The method according to any one of claims 1 to 7, characterized in that Before comparing the candidate compiled code and the original code to obtain a comparison result, it further includes: Verify the candidate compiled code to obtain a code verification result; Comparing the candidate compiled code and the original code to obtain a comparison result includes: When it is determined based on the code verification result that the candidate compiled code meets the code verification conditions, compare the candidate compiled code and the original code to obtain a comparison result.
9. A code compilation device, characterized in that, It includes: A first acquisition module configured to, in response to a code modification instruction, acquire a candidate compiled code and the original code of the candidate compiled code, wherein the candidate compiled code has an association relationship with the code modification instruction; A comparison module configured to compare the candidate compiled code and the original code to obtain a comparison result; A screening module configured to screen out a target compiled code from the candidate compiled code according to the comparison result, wherein the target function code in the target compiled code is different from the original function code in the original code; A compilation module configured to compile the target compiled code to obtain a code compilation result.
10. A computing device, characterized in that, It includes: A memory and a processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer programs / instructions are executed by the processor, the steps of the method according to any one of claims 1 to 8 are implemented.
11. A computer-readable storage medium, characterized in that, It stores computer programs / instructions. When the computer programs / instructions are executed by the processor, the steps of the method according to any one of claims 1 to 8 are implemented.
12. A computer program product, characterized in that, It includes computer programs / instructions. When the computer programs / instructions are executed by the processor, the steps of the method according to any one of claims 1 to 8 are implemented.