Compiling method, compiling cache configuration method and device, electronic equipment and storage medium
By using the compiler cache tool in the integration tool pipeline to check and cache data matching the compilation request, the problem of low compilation efficiency in the integration tool pipeline is solved, and a more efficient compilation process and multi-user shared cache is achieved.
Patent Information
- Application Number
- CN202510084038.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-20
- Publication Date
- 2025-05-13
AI Technical Summary
In the integration tool pipeline, every time the software is developed, the full amount of the data required for the compilation is required, resulting in an increase in the build time and affecting the compilation efficiency.
By running the compiler cache tool corresponding to the integration tool pipeline on the server, check whether there is any compiled cache data in the shared directory that matches the compilation request. If so, it is backed up and cached into the pipeline, reducing the need for network bandwidth and CPU resources.
It reduces the demand for network bandwidth and CPU resources at each compilation time, improves compilation efficiency, and supports multiple users to compile the same compiled cached data.
Smart Images

Figure CN119987782A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software development, and in particular to a compilation method, a compilation cache configuration method, a device, an electronic device and a storage medium. Background Art
[0002] In the prior art, when an integrated tool pipeline (such as the Jenkins pipeline) is used to develop software, each time the software is compiled, the data required for the compilation needs to be fully built. This means that regardless of whether the code has changed, the data required for the entire project needs to be completely rebuilt, which increases the build time and affects the efficiency of software compilation. Summary of the invention
[0003] In view of this, the purpose of the embodiments of the present application is to provide a compilation method, a compilation cache configuration method, an apparatus, an electronic device and a storage medium, which can improve the problem of low compilation efficiency of the integrated tool pipeline during the software development process.
[0004] In order to achieve the above technical objectives, the technical solutions adopted in this application are as follows:
[0005] In a first aspect, an embodiment of the present application provides a compilation method, which is applied to a server, and the method includes:
[0006] Based on the received compilation request, running a compiler cache tool corresponding to an integrated tool pipeline, wherein the integrated tool pipeline is used for software development and has a compilation cache function;
[0007] Checking, by means of the compiler cache tool, whether there is cached compilation cache data matching the compilation request in the shared directory of the server, and if so, backing up and caching the compilation cache data in the integrated tool pipeline, wherein the compilation cache data includes a first intermediate file generated by the last compilation operation;
[0008] Through the integrated tool pipeline, a compile operation is performed on the compile cache data and the data corresponding to the compile request to obtain a compile result.
[0009] According to the above technical means, since the server has pre-stored corresponding intermediate files, it is not necessary to pull the data required for the entire project from the host machine or other devices every time the integrated tool pipeline is used for compilation, so engineers do not need to fully compile the existing intermediate files, reducing the demand for network bandwidth and CPU resources and improving compilation efficiency. At the same time, by backing up the intermediate files to the integrated tool pipeline, when there are multiple users accessing the same intermediate file, each user can compile based on the backed-up intermediate file in the corresponding pipeline, which can support multiple users to compile the same compilation cache data, thereby helping to improve compilation efficiency.
[0010] In combination with the first aspect, in some optional implementations, the method further includes:
[0011] When the compiling operation is completed, the compiling cache data in the cache directory of the shared directory is updated based on a second intermediate file obtained by performing a compiling operation on the compiling cache data and the data corresponding to the compiling request.
[0012] In combination with the first aspect, in some optional implementations, when the compile operation is completed, updating the compile cache data in the cache directory of the shared directory based on an intermediate file obtained by performing a compile operation on the compile cache data and the data corresponding to the compile request, includes:
[0013] When the compiling operation is completed, a second intermediate file obtained by performing the compiling operation on the compiling cache data and the data corresponding to the compiling request is added to a queue;
[0014] According to the second intermediate file in the queue, corresponding compilation cache data in the cache directory of the shared directory is updated.
[0015] In combination with the first aspect, in some optional implementations, the compile request carries a first identifier, and the compile cache data in the cache directory of the shared directory has a second identifier;
[0016] The step of checking, by the compiler cache tool, whether the shared directory of the server contains cached compilation cache data matching the compilation request, includes:
[0017] The compiler cache tool is used to detect whether the first identifier matches the second identifier, wherein if the first identifier matches the second identifier, it is determined that compilation cache data matching the compilation request is cached in the shared directory.
[0018] In conjunction with the first aspect, in some optional implementations, before running the compiler cache tool corresponding to the integrated tool pipeline, the method further includes:
[0019] Based on the received configuration instructions, a pre-created execution container is configured in the integrated tool pipeline so that the integrated tool pipeline has a compilation cache function, wherein the execution container is generated by an execution container image, and the execution container is configured with relevant parameters of the compiler cache tool, and the relevant parameters include the cache size and / or cache directory of the compiler cache tool.
[0020] In combination with the first aspect, in some optional implementations, the execution container includes a Docker container, and the integrated tool pipeline includes a Jenkins pipeline.
[0021] In combination with the first aspect, in some optional implementations, the method further includes:
[0022] At least one of the compilation results obtained based on the integrated tool pipeline is merged into the software program corresponding to the mainline compilation task through the integrated tool pipeline to obtain a merged software program.
[0023] In a second aspect, an embodiment of the present application provides a compile cache configuration method for configuring an integrated tool pipeline with a compile cache function in the above method, the method comprising:
[0024] Based on the received first creation instruction, create an execution container image, wherein the execution container image includes a preconfigured compiler cache tool;
[0025] Generate an execution container according to the execution container image, and configure relevant parameters of the compiler cache tool in the execution container, wherein the relevant parameters include a cache size and / or a cache directory of the compiler cache tool;
[0026] The execution container is configured in an integrated tool pipeline for software development so that the integrated tool pipeline has a compile cache function.
[0027] In conjunction with the second aspect, in some optional implementations, the number of the execution containers is N, where N is a natural number greater than or equal to 1;
[0028] After configuring the execution container in an integrated tool pipeline for software development, the method further includes:
[0029] All of the execution containers are mounted on a shared directory of the server, so that all of the cache directories are stored in the shared directory, and a communication connection is established between the server and a host machine where the cache directories are located.
[0030] According to the above technical means, by generating multiple execution containers and mounting them on a server shared directory, the method achieves effective management and optimization of compilation resources.
[0031] In conjunction with the second aspect, in some optional implementations, after configuring the execution container in an integrated tool pipeline for software development, the method further includes:
[0032] A compilation request is sent to the server so that the server runs the compiler cache tool corresponding to the integrated tool pipeline based on the compilation request, and checks through the compiler cache tool whether the compilation cache data matching the compilation request is cached in the shared directory of the server; if so, the compilation cache data is backed up and cached in the integrated tool pipeline, and a compilation operation is performed on the compilation cache data and the data corresponding to the compilation request through the integrated tool pipeline to obtain a compilation result; the compilation cache data includes a first intermediate file generated by the last compilation operation; when the compilation operation is completed, the server updates the compilation cache data in the cache directory of the shared directory based on a second intermediate file obtained by performing a compilation operation on the compilation cache data and the data corresponding to the compilation request.
[0033] In conjunction with the second aspect, in some optional implementations, after configuring the execution container in an integrated tool pipeline for software development, the method further includes:
[0034] If there is no compilation cache data matching the compilation request cached in the shared directory of the server, the data corresponding to the compilation request is sent to the server so that the integrated tool pipeline performs a compilation operation on the data corresponding to the compilation request to obtain a compilation result, and the intermediate files obtained during the compilation operation are stored in the cache directory corresponding to the shared directory as the compilation cache data.
[0035] In conjunction with the second aspect, in some optional implementations, after configuring the execution container in an integrated tool pipeline for software development, the method further includes:
[0036] In the integrated tool pipeline, a first script command is constructed based on a first task, wherein the first task is used to obtain a cache hit rate;
[0037] When the first script command is executed, a log file of the compiler cache tool is obtained, and a cache hit rate is obtained from the log file.
[0038] In conjunction with the second aspect, in some optional implementations, the method further includes:
[0039] In the integrated tool pipeline, a monitoring tool is constructed based on the second task, and the second task is used to display the cache hit rate on the user interface of the integrated tool pipeline. The monitoring tool is used to execute the first script command and send the acquired cache hit rate to the chart plug-in of the integrated tool pipeline to display the cache hit rate on the user interface of the integrated tool pipeline.
[0040] In conjunction with the second aspect, in some optional implementations, after configuring the execution container in the integrated tool pipeline, the method further includes:
[0041] In the integrated tool pipeline, based on the third task, construct a second script command, wherein the third task is used to clean up cache content in the cache directory;
[0042] When the second script command is executed, the compiler cache tool is controlled to clean up the cache content in the cache directory.
[0043] According to the above technical means, a script command for cleaning the cache is built on the integrated tool pipeline, which can regularly clean up expired or invalid compilation cache as needed, release storage space resources, and keep the compilation environment clean and efficient.
[0044] In conjunction with the second aspect, in some optional implementations, before creating the execution container image, the method further includes:
[0045] Based on the received second creation instruction, create an execution container text, where the execution container text includes a first text instruction and M second text instructions, where M is an integer greater than or equal to 1, the first text instruction includes tag information representing a version of the base image, and all the second text instructions are arranged in an execution order;
[0046] From a pre-established image library, an image corresponding to the tag information of the first text instruction is obtained as the base image, and a compiler cache tool is installed on the base image; wherein, upon receiving the first creation instruction, the base image executes the second text instructions in sequence according to the execution order to generate the execution container image, so that the generated execution container image is configured with the compiler cache tool.
[0047] In conjunction with the second aspect, in some optional implementations, the cache directories of each compiler cache tool are independent of each other.
[0048] According to the above technical means, the respective cache directories are independent of each other, ensuring the security and isolation of the data.
[0049] In combination with the second aspect, in some optional implementations, the cache directory is mounted as a volume.
[0050] According to the above technical means, it is possible to ensure that the cache data of the compiler cache tool is persisted between builds, so as to achieve cache reuse across builds.
[0051] In a third aspect, an embodiment of the present application proposes a compiling device, which is applied to a server, and the device includes:
[0052] A request response module, for running a compiler cache tool corresponding to an integrated tool pipeline based on a received compilation request, wherein the integrated tool pipeline is used for software development and has a compilation cache function;
[0053] a first checking module, configured to check, through the compiler cache tool, whether compile cache data matching the compile request is cached in the shared directory of the server, and if so, back up and cache the compile cache data in the integrated tool pipeline, wherein the compile cache data includes a first intermediate file generated by the last compile operation;
[0054] The compiling module is used to perform a compiling operation on the compiling cache data and the data corresponding to the compiling request through the integrated tool pipeline to obtain a compiling result.
[0055] In a fourth aspect, an embodiment of the present application proposes a compile cache configuration device, which is applied to a host machine and is used to configure an integrated tool pipeline with a compile cache function in the above method, and the device includes:
[0056] A creation module, configured to create an execution container image based on the received first creation instruction, wherein the execution container image includes a preconfigured compiler cache tool;
[0057] A first configuration module, configured to generate an execution container according to the execution container image, and configure relevant parameters of the compiler cache tool in the execution container, wherein the relevant parameters include a cache size and / or a cache directory of the compiler cache tool;
[0058] The second configuration module is used to configure the execution container in an integrated tool pipeline for software development so that the integrated tool pipeline has a compilation cache function.
[0059] In a fifth aspect, an embodiment of the present application proposes an electronic device, which includes a processor and a memory coupled to each other, wherein the memory stores a computer program, and when the computer program is executed by the processor, the electronic device executes the above-mentioned compilation method, or executes the above-mentioned compilation cache configuration method.
[0060] In a sixth aspect, an embodiment of the present application proposes a computer-readable storage medium, in which a computer program is stored. When the computer program runs on a computer, the computer executes the above-mentioned compilation method, or executes the above-mentioned compilation cache configuration method.
[0061] The invention adopting the above technical solution has the following advantages:
[0062] In the technical solution provided by the present application, since the server pre-stores the corresponding first intermediate file, there is no need to pull the data required for the entire project from the host machine or other devices each time the integrated tool pipeline is used for compilation, and there is no need to fully compile the existing first intermediate file, thereby reducing the demand for network bandwidth and CPU resources and improving compilation efficiency. At the same time, by backing up the first intermediate file to the integrated tool pipeline, when there are multiple users accessing the same intermediate file, each user can compile based on the backed-up first intermediate file in the corresponding pipeline, which can support multiple users to compile the same compilation cache data, thereby helping to improve compilation efficiency.
[0063] In the technical solution provided in the present application, by configuring a compiler cache tool in an execution container and configuring the execution container on an integrated tool pipeline, the compilation cache is applied in the integrated tool pipeline. This is beneficial to reducing compilation time, improving the efficiency and speed of software development, and improving the problem of increasing build time and affecting the efficiency of software compilation.
[0064] In the technical solution provided in the present application, by mounting all execution containers on a shared directory of the server, all containers share the same compilation cache, thereby improving the compilation efficiency of multiple users compiling at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] The present application may be further described by the non-limiting embodiments given in the accompanying drawings. It should be understood that the following drawings only illustrate certain embodiments of the present application and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, other relevant drawings may be obtained based on these drawings without creative effort.
[0066] Figure 1 A structural diagram of an electronic device provided in an embodiment of the present application.
[0067] Figure 2 This is a flowchart of the compilation cache configuration method provided in Example 1 of the present application.
[0068] Figure 3 A schematic diagram of the ccache synchronization mechanism in a distributed compilation environment provided in an embodiment of the present application.
[0069] Figure 4 An overall flow chart provided for an embodiment of the present application.
[0070] Figure 5 A schematic diagram of the ccache compilation process provided in an embodiment of the present application.
[0071] Figure 6 This is a block diagram of the compilation cache configuration device provided in Example 1 of the present application.
[0072] Figure 7 This is a flowchart of the compilation method provided in Example 2 of the present application.
[0073] Figure 8 This is a block diagram of the compilation device provided in Example 2 of the present application.
[0074] Icons: 100 - electronic device, 101 - processing module; 102 - storage module; 200 - compilation cache configuration device, 210 - creation module; 220 - first configuration module; 230 - second configuration module; 400 - compilation device, 410 - request response module; 420 - first checking module; 430 - compilation module; 440 - update module. DETAILED DESCRIPTION
[0075] The present application will be described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that in the drawings or descriptions, similar or identical parts use the same figure numbers, and the implementation methods not shown or described in the drawings are forms known to ordinary technicians in the relevant technical field. In the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0076] Example 1
[0077] Please refer to Figure 1 The embodiment of the present application provides an electronic device 100, which may include a processing module 101 and a storage module 102. The storage module 102 stores a computer program, and when the computer program is executed by the processing module 101, the electronic device can execute the corresponding steps in the following compilation cache configuration method. When executing the corresponding steps in the compilation cache configuration method, the electronic device 100 is a host machine.
[0078] In this embodiment, the processing module 101 may be an integrated circuit chip having signal processing capabilities. The above-mentioned processing module may be a general-purpose processor. For example, the processor may be a central processing unit (CPU), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, and may implement or execute the disclosed methods, steps and logic block diagrams in the embodiments of the present application.
[0079] The storage module 102 may be, but is not limited to, a random access memory, a read-only memory, a programmable read-only memory, an erasable programmable read-only memory, an electrically erasable programmable read-only memory, etc. It is understood that Figure 1 The electronic device structure shown in FIG. 1 is only a schematic diagram of a structure. The electronic device may also include Figure 1 More components are shown. Figure 1 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0080] It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the electronic device described above can refer to the corresponding process of each step in the following method, and will not be elaborated here.
[0081] Please refer to Figure 2 The present application provides a compilation cache configuration method, which can be applied to the above-mentioned electronic device. The electronic device can be used as a host machine, which can be but not limited to a personal computer, a laptop computer and other devices. The compilation cache configuration method can solve the problem that when the integrated tool pipeline is used to develop software, the build time will be increased and the software compilation efficiency will be affected.
[0082] The compilation cache configuration method may include the following steps:
[0083] Step 110, based on the received first creation instruction, create an execution container image, and the execution container image includes a preconfigured compiler cache tool. The container image in this embodiment can be a Docker image. The integrated tool pipeline can be a Jenkins pipeline. Among them, the Jenkins pipeline is a continuous integration and continuous delivery tool, which is an open source automation server software. It defines the build, test and deployment process of the entire software development process by means of code (usually Jenkinsfile), which can provide a flexible way to orchestrate the software delivery process.
[0084] Exemplarily, step 110 may be: the host receives and executes a control instruction for creating a Docker image to obtain a Docker image, the Docker image includes a preconfigured compiler cache tool, and the control instruction of step 110 may include environment variables, startup commands, port mappings, volume mounts, and network configurations of the Docker image. The control instruction may be generated by the host based on user manipulation, or issued by other devices.
[0085] Step 120: Generate an execution container according to the execution container image, and configure relevant parameters of the compiler cache tool in the execution container, wherein the relevant parameters include a cache size and / or a cache directory of the compiler cache tool.
[0086] Exemplarily, step 120 may also be: the host receives a control instruction for generating a Docker container according to a Docker image, generates a Docker container according to a Docker image, configures compiler cache tool related parameters in the Docker container, and the related parameters include cache size and / or cache directory. The control instruction may include log configuration, image cache and other parameters of the Docker container. The control instruction may be generated by the host based on user manipulation or issued by other devices. The cache size indicates the capacity of data that can be stored in the compiler cache tool, and the cache directory indicates the location where the cache content is stored in the server disk, wherein a communication connection is established between the server and the host.
[0087] Step 130 , the execution container is configured in an integrated tool pipeline for software development so that the integrated tool pipeline has a compilation cache function.
[0088] Exemplarily, step 130 may be that the host receives and executes a control instruction for configuring the Docker container in the Jenkins pipeline. The control instruction may be generated by the host based on user manipulation or issued by other devices.
[0089] Docker can be understood as a technology or tool for "loading" and "shipping" applications to different environments.
[0090] The following is a detailed description of the steps in the compilation cache configuration method, as follows:
[0091] Before step 110, this embodiment creates a Docker image by the following method, which may include:
[0092] When the host receives a control instruction for creating a Dockerfile, it defines a base image based on the control instruction, which includes the required parameters for installing ccache and the required compilation toolchain in the Dockerfile. The control instruction can be issued by the user or by other devices. For example, based on the control instruction, the host can install ccahce by pulling the source code and compiling it, or by downloading the software package.
[0093] After the host executes the control instruction, it creates a Dockerfile, builds a Docker image through the Dockerfile, and pushes the Docker image to the Docker repository. The control instruction can be issued by the user or by other devices. In this embodiment, the Docker text includes a first text instruction and M second text instructions, where M is an integer greater than or equal to 1. The first text instruction includes tag information representing the version of the base image, and all second text instructions are arranged in execution order.
[0094] The compiler cache tool used in this embodiment is ccahce, where ccahce is the name of the compiler cache tool. For example, when compiling a C file, add ccache before the compile command. If you compile the same source code again, ccache will first check whether there is the same compilation output in the cache. If it exists, the cached result is directly used to speed up the compilation speed.
[0095] In this embodiment, other compiler cache tools, such as sccache and clcache, may also be used. The following content of this embodiment mainly uses ccache as the compiler cache tool. Both sccache and clcache are open source compiler cache tools.
[0096] Dockerfile is a text file that can contain a series of commands and parameters for building a Docker image. Through Dockerfile, you can automatically define the image building process, including the selection of the base image, installation of dependencies, copying files, setting environment variables, exposing ports, defining startup commands, etc. The base image is specified in the Dockerfile through the FROM instruction, and subsequent instructions will be performed on this base image. The FROM instruction is used to specify the base image in the Dockerfile.
[0097] Dockerfile represents a file type specific to Docker technology. This file is used to define how to build a Docker image. In step 110, the Docker image is built according to the Dockerfile. The Docker image is static and contains everything needed to run the application, including code, libraries, dependencies, configuration files, etc.
[0098] From a pre-established image library, an image corresponding to the tag information of the first text instruction is obtained as a base image, and a compiler cache tool is installed on the base image; wherein, upon receiving the first creation instruction, the base image sequentially executes the second text instruction in the execution order to generate a Docker image, so that the generated Docker image is configured with the compiler cache tool. The tag information may be a version and a variable name of the base image.
[0099] In step 120, a Docker container is generated based on a Docker image, and a Docker image can generate multiple Docker containers. In Docker, an image is static, and it contains everything needed to run an application, including code, libraries, dependencies, configuration files, etc. A container is a dynamic instance that runs based on an image, and each container is independent and isolated. Through a Docker image, a user can create multiple containers to run the same application or service. These containers can share the same image, but each container has its own runtime environment and state, and does not interfere with each other.
[0100] Therefore, in this embodiment, multiple Docker containers are generated according to the Docker image, and relevant parameters of the compiler cache tool are configured in the Docker container, and the relevant parameters include cache size and cache directory.
[0101] In this embodiment, Figure 3 As shown, a namespace mechanism has been developed to support multiple projects and components. Each project uses an independent ccache cache directory to avoid cache conflicts between projects. The compiler cache tools of each Docker container are independent of each other. Each Docker container is responsible for the corresponding project, so that the compiler cache tool is only used to cache the corresponding project. This mechanism ensures that each project or component can use its own independent cache resources during the build and compilation process, thereby improving build efficiency and accuracy.
[0102] For example, ccache is a fast compiler cache tool that can cache compilation results to reduce the time of repeated compilation. In a multi-project, multi-component development environment, different projects or components may use the same source code files or libraries, but their compilation options and dependencies may be different. If all projects share the same ccache cache directory, cache conflicts and compilation errors may occur.
[0103] For example, a namespace mechanism can be developed to assign a unique namespace to each project or component. This namespace can be a directory path, an environment variable, or a configuration option to specify the ccache cache directory for the project or component. During the build and compile process, ccache will look up and store cache data based on this namespace, thereby ensuring that each project or component can use its own independent cache resources.
[0104] The implementation of this namespace mechanism may vary depending on the specific development environment and toolchain. For example, in some build systems, the ccache cache directory can be specified through configuration options. In a Docker container, the ccache cache directory can be set through environment variables or instructions in the Dockerfile.
[0105] Furthermore, if Figure 3 As shown, on the host machine, the host machine receives and executes a control instruction to mount all Docker containers on a shared directory on the server. The control instruction is generated by the host machine based on user manipulation, and can also be issued by other devices. For example, first, the host machine executes a control instruction for creating a shared directory on the server to store files that need to be shared. This directory will be used as a shared resource accessed by all Docker containers.
[0106] In this embodiment, there can be multiple Docker containers, and each Docker container corresponds to a Jenkins pipeline.
[0107] Exemplarily, for a distributed system, multiple Docker containers can share a ccache cache directory by mounting the same host directory to each Docker container, ensuring that the ccache cache data on different compilation nodes remains consistent, thereby reducing compilation time and improving compilation efficiency.
[0108] For example, multiple Docker containers can share the ccache cache directory by following these steps:
[0109] 1. The host receives the control instruction, and after executing the control instruction, the host creates a directory, which will be used as the storage location of the ccache cache. The control instruction is generated by the host based on user manipulation, and can also be issued by other devices.
[0110] 2. The host receives the control instruction for configuring the Docker container to mount the directory. After the host executes the instruction, it configures the Docker container to mount the directory. When the host starts the Docker container, the host's directory is mounted to a certain location in the container. The control instruction is generated by the host based on the user's operation and can also be issued by other devices.
[0111] 3. The host receives and executes the control instruction for configuring ccache to use the mounted directory, that is, within the container, ccache is configured to use the mounted cache directory.
[0112] This embodiment ensures that the cache data of ccache is persisted between builds in the Docker container to achieve cache reuse across builds.
[0113] In this embodiment, after mounting multiple Docker containers to the same shared directory, when two Jenkins pipelines or multiple Jenkins pipelines compile code based on the same source branch, they may access the same cache content. Although this will not report a compilation error, the second and subsequent users will not be able to use the cache content and can only compile in full, resulting in slower access and compilation speeds.
[0114] In step 130, all Docker containers are configured into the Jenkins pipeline, which is conducive to improving the efficiency of automated deployment and continuous integration.
[0115] Exemplarily, the configuration of the Docker container in the Jenkins pipeline can be implemented in the following way.
[0116] 1. The host receives and executes control commands for installing Docker-related plug-ins on the Jenkins pipeline on the host. The plug-in can help Jenkins interact with the Docker engine to manage and run Docker containers.
[0117] 2. The host receives and executes the control instructions for installing the Docker engine on the Jenkins pipeline to ensure that the Jenkins user has permission to access the Docker daemon.
[0118] 3. The host receives and executes the control instructions for the process of building the Docker container defined in the Jenkins file to specify how to build, test, and deploy the Docker container in the Jenkins file.
[0119] 4. The host receives and executes the trigger conditions set on the Jenkins pipeline. When the pipeline conditions are triggered, the Jenkins pipeline will automatically build, test and deploy the Docker container. The trigger condition can be to automatically trigger the pipeline when a new source code submission is detected.
[0120] As an optional implementation, after step 130, the method may further include the step of using a configured Jenkins pipeline with a cache function to perform a compilation operation. For example, the method may further include:
[0121] Send a compilation request to the server, so that the server runs the compiler cache tool corresponding to the Jenkins pipeline based on the compilation request, and checks whether the source code matching the compilation request is cached in the shared directory through the compiler cache tool. If so, the matching source code is backed up to the Jenkins pipeline;
[0122] Perform compilation based on the backed-up matching source code;
[0123] When the compilation operation is completed, the matching source code is updated according to the result of the compilation operation, and the updated matching source code is uploaded to the corresponding cache directory in the shared directory.
[0124] According to the above scheme, if there are multiple Jenkins pipelines accessing the same cache content at the same time, the cache content will be backed up to the corresponding Jenkins pipeline, so that each Jenkins pipeline can use the corresponding backup to implement compilation. When the compilation is completed, the matching source code can be updated according to the compilation result, and the updated matching source code can be uploaded to the corresponding cache directory in the shared directory. The method of uploading to the cache directory can be: placing the updated matching source code into a queue, and uploading the matching source code in the compiler cache tool queue to the corresponding cache directory in the shared directory in the order of placement. Thereby, multiple users can use the same cache content at the same time, which has the advantage of improving compilation efficiency.
[0125] Among them, the matching source code indicates the source code that meets the compilation request requirements. For example, if a code instruction to edit "get the current temperature in the cloud" is issued on the Jenkins pipeline, if there is a source code in the shared directory that can execute "get the current temperature in the cloud", then this source code is the "matching source code".
[0126] The result of the compilation operation represents the result of recompilation based on the matching source code. For example, when there is a matching source code, the user makes an update on the matching source code, such as adding or deleting lines of code, etc. The matching source code after adding or deleting lines of code represents the result of the compilation operation.
[0127] As an optional implementation, after configuring the execution container in the integrated tool pipeline for software development, the method further includes:
[0128] If there is no compilation cache data matching the compilation request cached in the shared directory of the server, the data corresponding to the compilation request is sent to the server so that the integrated tool pipeline performs a compilation operation on the data corresponding to the compilation request to obtain a compilation result, and the intermediate files obtained during the compilation operation are stored in the cache directory corresponding to the shared directory as the compilation cache data.
[0129] The data corresponding to the compilation request may be the relevant data that the host sends to the server and needs to be compiled. The compilation cache data stored in the cache directory corresponding to the shared directory can be reused in the next compilation operation.
[0130] After step 130, when a clear instruction is received, the Docker container is destroyed based on the received clear instruction to delete the intermediate files in the corresponding temporary storage area, thereby achieving the deletion of the intermediate files.
[0131] This embodiment further includes S140 after S130.
[0132] S140: The host receives and executes a control instruction, the control instruction is used to add a first script command, the first script command is based on a first task, and the first task can be used to obtain a cache hit rate. The first script command is executed on the Jenkins pipeline to count the cache hit rate of the compiler cache tool. The control instruction is generated by the host based on user manipulation, and can also be issued by other devices.
[0133] The cache hit ratio represents the ratio of the number of times data is read from the cache to the total number of reads. The cache hit ratio is a performance indicator used to evaluate the efficiency of a cache system.
[0134] For example, in S140, a scheduled task is set in the Jenkins pipeline on the host machine, which will execute a script command regularly (such as every day, every hour, etc.), and the script is responsible for collecting data. This scheduled task can be implemented through a cron job (on Linux / Unix systems) or a task scheduler (on Windows).
[0135] Exemplarily, the script is a data collection script, which is integrated with a first script command for performing necessary data collection operations, and for collecting log data, such as log files, from compiler cache tools. ccache.log usually contains log information of ccache (a compiler cache tool), which is very useful for analyzing compilation performance, cache hit rate, etc. After collecting the log file, the cache hit rate information in the log file is obtained and then sent to the chart plug-in to visualize the cache hit rate.
[0136] The above steps enable the development of a monitoring tool that can be run periodically to collect ccache cache hit rate data and then display this data on the Jenkins user interface.
[0137] In this embodiment, after S140, the method may further include S150.
[0138] S150: The host receives and executes a control instruction of the Jenkins pipeline to construct a second script command for cleaning the cache. After executing the second script command, cache cleaning can be achieved. The control instruction is generated by the host based on user manipulation, and can also be issued by other devices. The second script command is based on a second task, and the second task is used to display the cache hit rate on the user interface of the Jenkins pipeline.
[0139] For example, in the Jenkins pipeline on the host machine, a second script command for cleaning the cache can be executed by adding an additional build stage. This stage can be placed anywhere in the pipeline, but is usually placed before the build process to ensure that the build starts from a clean state, or after the build process to clean up cache data that is no longer needed.
[0140] In this embodiment, since it is necessary to implement cache cleaning inside the Docker container, the second script command can use the docker exec command to perform the cleaning operation. Environment variables and startup scripts can also be set through Dockerfile or docker-compose.yml to automatically clean up the cache when the container starts. Docker exec is to execute a command in a specified Docker container.
[0141] In this embodiment, in order to achieve persistence of cached data, this embodiment mounts the cache directory of the Docker container as a volume. This is because the Docker container is temporary and its file system is usually a writable layer. When the container is stopped or restarted, the data inside the container (including cached data) may be lost. This is a problem for applications that need to store data persistently, especially when this data is critical to the operation of the application.
[0142] Volumes are a way to persistently store container data in Docker. Volumes can mount directories in the host file system or other containers into containers. Using volumes, data can be persisted when the container is restarted or migrated to avoid data loss. In addition, volumes can also facilitate backup and recovery operations.
[0143] The main purpose of mounting the cache directory of a Docker container as a volume is to achieve persistence of cached data. The advantages are:
[0144] Data persistence: Even if the container is deleted or restarted, the cached data remains in the volume and will not be lost.
[0145] Data sharing: Multiple containers can share the same volume, thereby enabling the sharing and reuse of cached data.
[0146] Backup and recovery: Since volumes exist independently of the container lifecycle, volumes can be easily backed up and restored to protect the security of cached data.
[0147] For example, in Docker, you can use the docker volume create command to create a new volume, and then mount the volume to the container's cache directory through the docker run command. In this way, the cache directory in the container will be mounted to the volume named my cache volume, thereby achieving persistence of cached data.
[0148] Exemplarily, a compilation cache configuration method can also be implemented by the following steps:
[0149] 1. The host receives and executes the control instructions for creating a dedicated Docker image, and obtains the Docker image, which contains the pre-configured ccache and compilation tool chain. The control instructions of this step include the environment variables, startup commands, port mapping, volume mounting, and network configuration of the Docker image. The control instructions are generated by the host based on user manipulation, and can also be issued by other devices.
[0150] 2. The host receives and executes a control instruction for defining a build step in the Jenkins pipeline, which uses the above-mentioned Docker image as the build environment. The control instruction in this step includes the parameters and data required to build the Docker image in the Jenkins pipeline, including pipeline scripts, triggers (conditions that trigger the build, such as code submission, scheduled builds, etc.), node configuration (specify the Jenkins node that executes the build task, and ensure that the node has the resources and environment required to build the Docker image.) and credential management. The control instruction is generated by the host based on user manipulation, and can also be issued by other devices.
[0151] 3. The host receives the relevant parameter control instructions for configuring ccache in the Docker container. The relevant parameters of the control instructions include cache size, cache directory, cache strategy, etc. The control instructions are generated by the host based on user manipulation and can also be issued by other devices.
[0152] 4. The host receives the control instruction of the build script in the Jenkins pipeline, which is used to add the step of cleaning the ccache cache to ensure that old or invalid caches are cleaned up when necessary. The control instruction is generated by the host based on user manipulation and can also be issued by other devices.
[0153] 5. The host receives the control instruction for building the script in the Jenkins pipeline. In the script, add the step of counting the ccache cache hit rate to monitor the cache effect. The control instruction is generated by the host based on the user's operation, and can also be issued by other devices.
[0154] 6. The host receives control instructions for developing a monitoring tool on the Jenkins pipeline. The tool can run regularly and collect ccache cache hit rate data, and then display this data on the Jenkins user interface. The control instructions are generated by the host based on user operations, and can also be issued by other devices.
[0155] This solution can significantly reduce compilation time and improve build efficiency by pre-configuring Docker images and ccache; this solution's Docker containerization makes the build environment more lightweight and portable, while ccache's cache reuse reduces unnecessary compilation work and saves system resources; this solution can monitor ccache's cache hit rate in real time by developing monitoring tools, providing data support for optimizing the build process; this solution makes the definition of the Jenkins pipeline make the build process more flexible and configurable, and can easily add, modify, and delete build steps; this solution, combined with the Jenkins pipeline, provides strong support for continuous integration and continuous deployment, and helps to achieve an automated and efficient software development process.
[0156] like Figure 4 As shown, for example, integrating ccache through a Docker container in a Jenkins pipeline can be:
[0157] 1. The host receives a control instruction for creating a Dockerfile (Docker file) to define a base image. The control instruction includes the steps required to install ccache and the required compilation tool chain in the Dockerfile. The control instruction can be issued by the user or by other devices. Exemplarily, this step can install ccahce by pulling the source code and compiling it, or by downloading a software package. The control instruction is generated by the host based on the user's manipulation, and can also be issued by other devices.
[0158] 2. The host receives and executes the control instructions for building the Docker image. The host can use the command line interface to build the image and push it to the Docker repository. The control instructions include the environment variables, startup commands, port mapping, volume mounting, and network configuration of the Docker image. The control instructions are generated by the host based on user operations and can also be issued by other devices.
[0159] 3. The host receives and executes the control instructions for configuring ccache parameters, including cache size, cache directory, and cache policy. The control instructions are generated by the host based on user manipulation and can also be issued by other devices.
[0160] 4. To support multiple projects and components, a namespace mechanism has been developed. The host receives and executes control instructions that require each project to use an independent ccache cache directory to avoid cache conflicts between projects. The control instructions are generated by the host based on user operations and can also be issued by other devices.
[0161] 5. The host receives and executes the control instructions for building the Docker installation environment in the Jenkins pipeline. The control instructions are generated by the host based on user operations and can also be issued by other devices;
[0162] 6. The host receives and executes the control command to mount the shared directory of the server, ensuring that the ccache cache of the distributed system exists in the same location and that different docker containers are mounted in the same directory. The control command is generated by the host based on user manipulation and can also be issued by other devices.
[0163] 7. The host receives and executes the control instructions of the build script of the Jenkins pipeline. After executing the script, the ccache cache is added and cleaned. The control instructions are generated by the host based on user manipulation and can also be issued by other devices.
[0164] 8. The host receives and executes the control instructions of the build script of the Jenkins pipeline. After executing the script, the ccache cache hit rate statistics are added, including:
[0165] 8.1 Pull ccache.log data;
[0166] 8.2 Add a scheduled task to run the script in step 7 regularly;
[0167] 8.3 Use existing Jenkins plugins (such as the "Chart Plugin") to display data.
[0168] 9. The host receives and executes the control instruction to mount the cache directory of the Docker container as a volume to achieve the persistence of cache data. This embodiment adopts the method of mounting the server shared directory to ensure that the ccache cache data on different compilation nodes remains consistent. The control instruction is generated by the host based on the user's control, and can also be issued by other devices.
[0169] 10. The host receives and executes the control command of developing a monitoring tool, which can run regularly and collect ccache cache hit rate data, and display this data on the Jenkins user interface. The control command is generated by the host based on user operation, and can also be issued by other devices.
[0170] By adopting the method of this embodiment, Docker containers and ccache can be effectively used for compilation caching in the Jenkins pipeline, which can significantly reduce the compilation time and improve the efficiency of software development. For example, this method can be applied to the development of software projects such as intelligent driving software.
[0171] In this embodiment, by configuring the compiler cache tool in the Docker container and configuring the Docker container on the Jenkins pipeline, the compilation cache is applied in the Jenkins pipeline, which significantly reduces the compilation time, improves the efficiency and speed of software development, and solves the problems of slow compilation speed, slow release speed and low release efficiency of large projects.
[0172] In this embodiment, the Docker container is configured in the Jenkins pipeline to achieve automation and integration of the compilation process. Through the Jenkins pipeline, it is convenient to manage compilation tasks, monitor compilation progress and results, and integrate other automation tools and scripts to further improve development efficiency.
[0173] In this embodiment, by combining Docker and Jenkins, the method also realizes lightweight deployment and rapid migration of the compilation environment. Docker containers are highly portable and isolated, and can be easily deployed and run on different platforms and environments, while the Jenkins pipeline provides powerful automation and integration capabilities, making the entire compilation process more convenient and efficient. Jenkins is an open source continuous integration tool. After integrating the Docker container in Jenkins, the software compilation environment can be deployed to any server that supports Docker through Jenkins. At the same time, due to the lightweight and portability of the Docker container, the migration of the compilation environment becomes simple and fast.
[0174] In this embodiment, by generating multiple Docker containers and mounting them on a server shared directory, the method achieves effective management and optimization of compilation resources. All containers share the same compilation cache, but their respective cache directories are independent of each other, ensuring data security and isolation. At the same time, it also makes the compilation process more flexible and scalable, and can dynamically adjust the number and configuration of containers as needed, ensuring the effectiveness and security of compiler cache tools in multi-project and distributed compilation environments.
[0175] In this embodiment, a script command for counting compiler cache hit rate is added to the build script of the Jenkins pipeline, and a monitoring tool is built to display the statistical results on the user interface, so that the development team can monitor the usage and efficiency of the compilation cache in real time. This helps to promptly discover and solve potential compilation problems, optimize compilation strategies, and further improve compilation efficiency and quality.
[0176] In this embodiment, the intelligent driving software usually involves a complex compilation environment and dependencies. The use of Docker images can ensure that consistent compilation results are obtained in different development environments. The construction and testing process of the intelligent driving software is complex and frequent. Using Jenkins can automate this process and improve construction efficiency. At the same time, the compilation process of the intelligent driving software may be very time-consuming. Using ccache can significantly reduce the time for repeated compilation. Since the compilation process of the intelligent driving software may involve a large amount of code and dependencies, mounting the ccache cache directory to the persistent storage volume of the Docker container can ensure that the ccache cache data will not be lost between builds, thereby achieving cache reuse across builds.
[0177] Please refer to Figure 6 The present application also provides a compile cache configuration device 200, the compile cache device includes at least one software function module that can be stored in a storage module or fixed in an operating system (OS) in the form of software or firmware. The processing module is used to execute the executable module stored in the storage module, such as the software function module and computer program included in the compile cache device.
[0178] The compile cache device includes a creation module 210, a first configuration module 220 and a second configuration module 230, and the functions of each module may be as follows:
[0179] The creation module 210 is configured to create a Docker image based on the received first creation instruction, wherein the Docker image includes a preconfigured compiler cache tool;
[0180] The first configuration module 220 is configured to generate a plurality of Docker containers according to the Docker image, and configure relevant parameters of the compiler cache tool in the Docker container, wherein the relevant parameters include a cache size and / or a cache directory;
[0181] The second configuration module 230 is configured to configure all Docker containers in the Jenkins pipeline so that the Jenkins pipeline has a compilation cache function.
[0182] The first configuration module 220 generates a plurality of Docker containers according to the Docker image, and mounts all Docker containers on a server shared directory, ensuring that all cache directories are cached in the same location.
[0183] At the same time, the first configuration module 220 configures a cache directory for the compiler cache tool of each Docker container, and the cache directories are independent of each other. Exemplarily, the cache directory of each compiler cache tool is named differently, so that the cache data generated by the compiled data in the Docker container can be cached in the corresponding cache directory.
[0184] The second configuration module 230 adds a first script command for counting the cache hit rate of the compiler cache in the build script of the Jenkins pipeline. After the first script command is executed, the cache hit rate can be counted.
[0185] The second configuration module 230 is used to build a second script command for cleaning the cache in the Jenkins pipeline.
[0186] The compiler cache tool in this embodiment performs compilation according to the following method: Figure 5 As shown, specifically including:
[0187] Receive compilation requests;
[0188] Run the compiler cache tool to check whether there is source code cached that matches the compilation request;
[0189] If not, the source code input to the host machine after running the compiler cache tool is obtained and stored in the compiler cache tool, wherein the source code input to the host machine matches the compilation request.
[0190] If so, the source code matching the compilation request is returned without further compilation.
[0191] according to Figure 5 When a compilation request is started, the system will first check whether there is a cached version of the compilation request through ccache. ccache is a compilation cache tool that can cache the results of the compilation process, thereby saving time and resources in subsequent compilations. The following steps can be included
[0192] 1. Start compilation request: This is the starting point of the entire process, indicating that there is a compilation task that needs to be executed.
[0193] 2.ccache checks the cache: The system queries the ccache cache to see if there is a cached version that matches the current compilation request.
[0194] 3. Return the cached version during compilation: If there is a matching cached version in ccache, the system will directly use this cached version without recompiling the source code.
[0195] 4. Compile source code: If there is no matching cached version in ccache, the system will compile the source code.
[0196] 5. Store new compilation results in cache: After compiling the source code, the system will store the new compilation results in the ccache cache so that they can be reused in future compilation requests.
[0197] End compilation: This is the end point of the entire process, indicating that the compilation task has been completed.
[0198] The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed on a computer, the computer executes the compilation cache configuration method described in the above embodiment.
[0199] Example 2
[0200] This embodiment proposes a compilation method, which is applied to a server. It is understandable that when the electronic device 100 is used to implement each step of the compilation method, the electronic device 100 can be a server. The method described in Example 1 is used to configure the integrated tool pipeline with compilation cache function mentioned in this method, such as Figure 7 As shown, the method may specifically include the following steps:
[0201] S310: Based on the received compilation request, run a compiler cache tool corresponding to an integrated tool pipeline, where the integrated tool pipeline is used for software development and has a compilation cache function;
[0202] S320: Checking, by means of a compiler cache tool, whether there is cached compilation cache data matching the compilation request in the shared directory of the server, and if so, backing up and caching the compilation cache data in the integrated tool pipeline, wherein the compilation cache data includes a first intermediate file generated by the last compilation operation;
[0203] S330: Performing a compilation operation on the compilation cache data and the data corresponding to the compilation request through the integrated tool pipeline to obtain a compilation result.
[0204] It should be noted that, before step S310, the process of configuring the integrated tool pipeline can refer to the compile cache configuration method described in Example 1, which will not be repeated here.
[0205] The first intermediate file in this embodiment may include cache content stored in the shared directory last time, wherein the cache content is encapsulated in the first intermediate file.
[0206] In this embodiment, the server may determine whether the compilation cache data matching the compilation request is cached in the shared directory in the following manner.
[0207] The server detects whether the first identifier matches the second identifier through a compiler cache tool, wherein if the first identifier matches the second identifier, it is determined that the shared directory has cached compilation cache data matching the compilation request. The compilation request carries the first identifier, and the compilation cache data in the cache directory of the shared directory has the second identifier.
[0208] The first identifier and the second identifier can be the file names or variable names, or keywords of the compilation request and the compilation cache data, respectively. For example, if the compilation request carries the words "request to obtain gear information on the CAN bus", and the compilation cache data also carries the words "request to obtain gear information on the CAN bus", then the first identifier and the second identifier match.
[0209] In this embodiment, after step 330, this embodiment further includes the following method:
[0210] When the compilation operation is completed, the compilation cache data in the cache directory of the shared directory is updated based on the second intermediate file obtained by performing the compilation operation on the compilation cache data and the data corresponding to the compilation request. Based on this step, this embodiment updates the second intermediate file to the cache directory. The first intermediate file can be the compilation cache data in the cache directory updated to the shared directory last time, and the second intermediate file can be the intermediate file compiled based on the first intermediate file this time. For example, in order to realize a certain car machine function, the line of code is deleted or added on the basis of the first intermediate file, and the first intermediate file after deletion or addition is the second intermediate file.
[0211] In this embodiment, the method for updating the compilation cache data may be:
[0212] When the compilation operation is completed, a second intermediate file obtained by performing the compilation operation on the compilation cache data and the data corresponding to the compilation request is added to the queue; and the corresponding compilation cache data in the cache directory of the shared directory is updated according to the second intermediate file in the queue.
[0213] When there are multiple users compiling based on the same first intermediate file, each user will update the first intermediate file in different ways according to their own needs. Therefore, in this embodiment, the second intermediate file is added to the queue. The queue can write the second intermediate files to the shared directory according to the order of the time they are placed in the queue, thereby realizing the caching of all second intermediate files.
[0214] In this embodiment, several compilation results obtained based on the integrated tool pipeline are merged into the software program corresponding to the mainline compilation task through the integrated tool pipeline to obtain the merged software program. In this step, after each user obtains the compilation results based on the corresponding integrated tool pipeline based on their respective tasks, all the compilation results are merged into the software program corresponding to the mainline compilation task, so that the software program merges the compilation results of all integrated tool pipelines, thereby obtaining the merged software program.
[0215] This embodiment also proposes a compiling device 400, which is applied to a server, such as Figure 8 As shown, the device comprises:
[0216] The request response module 410 is used to run the compiler cache tool corresponding to the integrated tool pipeline based on the received compilation request, wherein the integrated tool pipeline is used for software development and has a compilation cache function;
[0217] The first checking module 420 is used to check whether there is compilation cache data matching the compilation request cached in the shared directory of the server through the compiler cache tool. If so, the compilation cache data is backed up and cached in the integrated tool pipeline. The compilation cache data includes the first intermediate file generated by the last compilation operation.
[0218] The compiling module 430 is used to perform a compiling operation on the compiling cache data and the data corresponding to the compiling request through the integrated tool pipeline to obtain a compiling result.
[0219] This embodiment further includes an update module 440, which is configured to update the compilation cache data in the cache directory of the shared directory based on the second intermediate file obtained by performing the compilation operation on the compilation cache data and the data corresponding to the compilation request when the compilation operation is completed. The update module 440 is also configured to add the second intermediate file obtained by performing the compilation operation on the compilation cache data and the data corresponding to the compilation request to a queue when the compilation operation is completed;
[0220] According to the second intermediate file in the queue, the corresponding compilation cache data in the cache directory of the shared directory is updated.
[0221] The embodiment of the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is run on a computer, the computer executes the compiling method described in the above embodiment.
[0222] Through the description of the above implementation methods, technical personnel in this field can clearly understand that the present application can be implemented by hardware, and can also be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each implementation scenario of the present application.
[0223] In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method can also be implemented in other ways. The apparatus and method embodiments described above are merely schematic, for example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a part of a module, a program segment or a code, and a part of the module, program segment or code contains one or more executable instructions for implementing the specified logical function. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of the boxes in the block diagram and / or the flowchart can be implemented by a dedicated hardware-based system that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions. In addition, each functional module in each embodiment of the present application can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part.
[0224] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A compiling method, characterized in that: Applied to a server, the method comprises: Based on the received compilation request, running a compiler cache tool corresponding to an integrated tool pipeline, wherein the integrated tool pipeline is used for software development and has a compilation cache function; Checking, by means of the compiler cache tool, whether there is cached compilation cache data matching the compilation request in the shared directory of the server, and if so, backing up and caching the compilation cache data in the integrated tool pipeline, wherein the compilation cache data includes a first intermediate file generated by the last compilation operation; Through the integrated tool pipeline, a compile operation is performed on the compile cache data and the data corresponding to the compile request to obtain a compile result.
2. The method according to claim 1, characterized in that: The method further comprises: When the compiling operation is completed, the compiling cache data in the cache directory of the shared directory is updated based on a second intermediate file obtained by performing a compiling operation on the compiling cache data and the data corresponding to the compiling request.
3. The method according to claim 2, characterized in that When the compiling operation is completed, updating the compiling cache data in the cache directory of the shared directory based on the intermediate file obtained by performing the compiling operation on the compiling cache data and the data corresponding to the compiling request, comprises: When the compiling operation is completed, a second intermediate file obtained by performing the compiling operation on the compiling cache data and the data corresponding to the compiling request is added to a queue; According to the second intermediate file in the queue, corresponding compilation cache data in the cache directory of the shared directory is updated.
4. The method according to claim 1, characterized in that: The compile request carries a first identifier, and the compile cache data in the cache directory of the shared directory has a second identifier; The step of checking, by the compiler cache tool, whether the shared directory of the server contains cached compilation cache data matching the compilation request, includes: The compiler cache tool is used to detect whether the first identifier matches the second identifier, wherein if the first identifier matches the second identifier, it is determined that compilation cache data matching the compilation request is cached in the shared directory.
5. The method according to claim 1, characterized in that Before running the compiler cache tool corresponding to the integrated tool pipeline, the method further includes: Based on the received configuration instructions, a pre-created execution container is configured in the integrated tool pipeline so that the integrated tool pipeline has a compilation cache function, wherein the execution container is generated by an execution container image, and the execution container is configured with relevant parameters of the compiler cache tool, and the relevant parameters include the cache size and / or cache directory of the compiler cache tool.
6. The method according to claim 5, characterized in that The execution container includes a Docker container, and the integrated tool pipeline includes a Jenkins pipeline.
7. The method according to any one of claims 1 to 6, characterized in that The method further comprises: At least one of the compilation results obtained based on the integrated tool pipeline is merged into the software program corresponding to the mainline compilation task through the integrated tool pipeline to obtain a merged software program.
8. A compilation cache configuration method, characterized in that: The method is applied to a host machine and configured to obtain an integrated tool pipeline with a compilation cache function in the method according to any one of claims 1 to 7, wherein the method comprises: Based on the received first creation instruction, create an execution container image, wherein the execution container image includes a preconfigured compiler cache tool; Generate an execution container according to the execution container image, and configure relevant parameters of the compiler cache tool in the execution container, wherein the relevant parameters include a cache size and / or a cache directory of the compiler cache tool; The execution container is configured in an integrated tool pipeline for software development so that the integrated tool pipeline has a compile cache function.
9. The method according to claim 8, characterized in that The number of the execution containers is N, where N is a natural number greater than or equal to 1; After configuring the execution container in an integrated tool pipeline for software development, the method further includes: All of the execution containers are mounted on a shared directory of the server, so that all of the cache directories are stored in the shared directory, and a communication connection is established between the server and a host machine where the cache directories are located.
10. The method according to claim 9, characterized in that After configuring the execution container in an integrated tool pipeline for software development, the method further includes: A compilation request is sent to the server so that the server runs the compiler cache tool corresponding to the integrated tool pipeline based on the compilation request, and checks through the compiler cache tool whether the compilation cache data matching the compilation request is cached in the shared directory of the server; if so, the compilation cache data is backed up and cached in the integrated tool pipeline, and a compilation operation is performed on the compilation cache data and the data corresponding to the compilation request through the integrated tool pipeline to obtain a compilation result; the compilation cache data includes a first intermediate file generated by the last compilation operation; when the compilation operation is completed, the server updates the compilation cache data in the cache directory of the shared directory based on a second intermediate file obtained by performing a compilation operation on the compilation cache data and the data corresponding to the compilation request.
11. The method according to claim 10, characterized in that After configuring the execution container in an integrated tool pipeline for software development, the method further includes: If there is no compilation cache data matching the compilation request cached in the shared directory of the server, the data corresponding to the compilation request is sent to the server so that the integrated tool pipeline performs a compilation operation on the data corresponding to the compilation request to obtain a compilation result, and the intermediate files obtained during the compilation operation are stored in the cache directory corresponding to the shared directory as the compilation cache data.
12. The method according to claim 8, characterized in that After configuring the execution container in an integrated tool pipeline for software development, the method further includes: In the integrated tool pipeline, a first script command is constructed based on a first task, wherein the first task is used to obtain a cache hit rate; When the first script command is executed, a log file of the compiler cache tool is obtained, and a cache hit rate is obtained from the log file.
13. The method according to claim 12, characterized in that The method further comprises: In the integrated tool pipeline, a monitoring tool is constructed based on the second task, and the second task is used to display the cache hit rate on the user interface of the integrated tool pipeline. The monitoring tool is used to execute the first script command and send the acquired cache hit rate to the chart plug-in of the integrated tool pipeline to display the cache hit rate on the user interface of the integrated tool pipeline.
14. The method according to claim 8, characterized in that After configuring the execution container in the integrated tool pipeline, the method further includes: In the integrated tool pipeline, based on the third task, construct a second script command, wherein the third task is used to clean up cache content in the cache directory; When the second script command is executed, the compiler cache tool is controlled to clean up the cache content in the cache directory.
15. The method according to claim 8, characterized in that Before creating the execution container image, the method further includes: Based on the received second creation instruction, create an execution container text, where the execution container text includes a first text instruction and M second text instructions, where M is an integer greater than or equal to 1, the first text instruction includes tag information representing a version of the base image, and all the second text instructions are arranged in an execution order; From a pre-established image library, an image corresponding to the tag information of the first text instruction is obtained as the base image, and a compiler cache tool is installed on the base image; wherein, upon receiving the first creation instruction, the base image executes the second text instructions in sequence according to the execution order to generate the execution container image, so that the generated execution container image is configured with the compiler cache tool.
16. The method according to claim 8, characterized in that The cache directories of each compiler cache tool are independent of each other.
17. The method according to claim 8, characterized in that The cache directory is mounted as a volume.
18. A compiling device, characterized in that: Applied to a server, the device comprises: A request response module, for running a compiler cache tool corresponding to an integrated tool pipeline based on a received compilation request, wherein the integrated tool pipeline is used for software development and has a compilation cache function; a first checking module, configured to check, through the compiler cache tool, whether compile cache data matching the compile request is cached in the shared directory of the server, and if so, back up and cache the compile cache data in the integrated tool pipeline, wherein the compile cache data includes a first intermediate file generated by the last compile operation; The compiling module is used to perform a compiling operation on the compiling cache data and the data corresponding to the compiling request through the integrated tool pipeline to obtain a compiling result.
19. A compilation cache configuration device, characterized in that: The device is applied to a host machine and configured to obtain an integrated tool pipeline with a compile cache function in the method according to any one of claims 1 to 7, the device comprising: A creation module, configured to create an execution container image based on the received first creation instruction, wherein the execution container image includes a preconfigured compiler cache tool; A first configuration module, configured to generate an execution container according to the execution container image, and configure relevant parameters of the compiler cache tool in the execution container, wherein the relevant parameters include a cache size and / or a cache directory of the compiler cache tool; The second configuration module is used to configure the execution container in an integrated tool pipeline for software development so that the integrated tool pipeline has a compilation cache function.
20. An electronic device, characterized in that: The electronic device includes a processor and a memory coupled to each other, wherein the memory stores a computer program. When the computer program is executed by the processor, the electronic device executes the method as described in any one of claims 1 to 7, or executes the method as described in any one of claims 8 to 17.
21. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed on a computer, the computer is enabled to execute the method according to any one of claims 1 to 7, or execute the method according to any one of claims 8 to 17.
Citation Information
Cited By
Cross-regional deployment compiled data management method, electronic equipment and medium
CN122470196A