Container-based program compilation method, device, electronic device and storage medium
By using the compilation tools and environment simulator in the root file system in the container, the problems of large resource occupation and low efficiency during the compilation process are solved, isolation and cross-compilation of parallel compilation of multiple applications are realized, and resource utilization is improved.
Patent Information
- Application Number
- CN202111509678.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-10
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2041-12-10
AI Technical Summary
The existing technology has problems such as large resource usage, low compilation efficiency, and difficulty in changing the compilation environment during the compilation process. Especially during cross-compilation and parallel compilation of multiple applications, interference and resource waste are prone to occur.
Using a container-based program compilation method, by obtaining the root file system in the target container, the file system contains compilation tools and a compilation environment simulator to simulate the compilation environment of the system architecture used by the application, and compile it in the container to achieve Cross-compilation and resource isolation.
It realizes parallel compilation of multiple applications without interfering with each other, reduces resource occupation, improves compilation efficiency, and allows flexible tailoring of compilation functions to suit needs.
Smart Images

Figure CN114168151B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a container-based program compilation method, device, electronic device and storage medium. Background Art
[0002] When compiling an application (also called a software package), the software package is usually compiled based on a local host or a virtual machine. During the compilation process, some resources or programs (also called dependent packages) that the software package depends on need to be pre-installed in the local environment or virtual machine environment, and then the compilation tool is called to compile the software package based on the pre-installed resources or programs to obtain the corresponding executable code or program. Summary of the invention
[0003] The embodiment of the present application provides a container-based program compilation method, device, electronic device and storage medium to solve the problems existing in the related technologies. The technical solution is as follows:
[0004] In a first aspect, an embodiment of the present application provides a container-based program compilation method, comprising:
[0005] In response to a compilation request of an application, based on a system architecture to which the application is applied, obtaining a target container that can be used to compile the application; wherein the target container includes a root file system that can compile the application, and the root file system includes at least a compilation tool and a compilation environment simulator required by the application;
[0006] porting the application to the target container;
[0007] In the target container, using a compilation environment simulator in the root file system, simulating a compilation environment having a system architecture identical to the system architecture to which the application is applied;
[0008] In the target container, the application is deployed in the compilation environment, and the application deployed in the compilation environment is compiled using a compilation tool required by the application in the root file system.
[0009] In a second aspect, an embodiment of the present application provides a container-based program compilation device, including:
[0010] A container acquisition module, configured to respond to a compilation request of an application and, based on a system architecture to which the application is applied, acquire a target container that can be used to compile the application; wherein the target container includes a root file system that can compile the application, and the root file system includes at least a compilation tool and a compilation environment simulator required by the application;
[0011] A program transplantation module, used for transplanting the application program into the target container;
[0012] A compilation environment simulation module, used to simulate, in the target container, a compilation environment with a system architecture identical to that to which the application is applied, using a compilation environment simulator in the root file system;
[0013] A compiling module is used to deploy the application in the compilation environment in the target container, and compile the application deployed in the compilation environment using a compiling tool required by the application in the root file system.
[0014] In a third aspect, an embodiment of the present application provides an electronic device, comprising: at least one processor, and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the container-based program compilation method in any embodiment of the present application.
[0015] In a fourth aspect, an embodiment of the present application provides a non-transitory computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the container-based program compilation method in any embodiment of the present application is implemented.
[0016] The advantages or beneficial effects of the above technical solution include at least:
[0017] In the technical solution provided in the present application, based on the system architecture to which the application is applied, the corresponding target container is obtained, and the target container contains a root file system that can be used to compile the application, and this root file system contains the compilation tools and compilation environment required by the application. In this way, not only can the cross-compilation of applications applied to different system architectures be achieved, but also, by adopting the container isolation method, multiple containers can be run on the host at the same time, and multiple applications can be compiled in parallel, and the compilation of multiple applications does not interfere with each other. On the other hand, by transplanting the root file system into the container, not only can the effects of cross-compilation and isolated compilation be achieved, but also the root file system occupies resources, and the compilation function that meets the needs can be freely tailored.
[0018] The above summary is for illustrative purposes only and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments and features described above, further aspects, embodiments and features of the present application will be readily apparent by reference to the accompanying drawings and the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the multiple drawings represent the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings only depict some embodiments disclosed in the present application and should not be regarded as limiting the scope of the present application.
[0020] Figure 1 is a flowchart of a container-based program compilation method according to the first embodiment of the present application;
[0021] Figure 2 is a flowchart of a container-based program compilation method according to a second embodiment of the present application;
[0022] Figure 3 is a structural block diagram of a container-based program compiling device according to a third embodiment of the present application;
[0023] Figure 4 is a structural block diagram of a container-based program compiling device according to a fourth embodiment of the present application;
[0024] Figure 5 The present invention is a structural block diagram of an electronic device that can implement the container-based program compilation method of an embodiment of the present application. DETAILED DESCRIPTION
[0025] In the following, only some exemplary embodiments are briefly described. As those skilled in the art will appreciate, the described embodiments may be modified in various ways without departing from the spirit or scope of the present application. Therefore, the drawings and descriptions are considered to be exemplary and non-restrictive in nature.
[0026] In the same system, compiling multiple applications in parallel may interfere with each other, resulting in compilation errors. In order to achieve the effect of compilation isolation, a virtual machine or container is generally used for compilation. However, the virtual machine occupies a large amount of system resources and it is not easy to change the compilation tool. For this reason, the embodiment of the present application uses a container for compilation. On the one hand, the effect of compilation isolation can be achieved, and on the other hand, resource occupation is reduced and resource utilization is improved.
[0027] However, to implement cross-compilation in a container, generally some cross-compiled applications are ported to the container, but these cross-compiled applications occupy too many resources, making the container inefficient during the compilation process.
[0028] To this end, the present application provides a container-based program compilation solution that can both achieve cross-compilation and improve compilation efficiency.
[0029] Figure 1A flowchart of a container-based program compilation method according to the first embodiment of the present application is shown.
[0030] As shown in 1, the method may include:
[0031] S110, in response to a compilation request of the application, based on the system architecture to which the application is applied, obtaining a target container that can be used to compile the application; wherein the target container includes a root file system that can compile the application, and the root file system includes at least a compilation tool and a compilation environment simulator required by the application;
[0032] S120, porting the application to a target container;
[0033] S130, in the target container, using a compilation environment simulator in the root file system to simulate a compilation environment having a system architecture identical to the system architecture to which the application is applied;
[0034] S140, deploying the application in a compilation environment in the target container, and compiling the application deployed in the compilation environment using a compilation tool required by the application in the root file system.
[0035] Among them, the compilation (compilation, compile) of the application includes two meanings, the process of generating a target program from a source program compiled from a source language using a compiler and the action of generating a target program using a compiler. The embodiment of the present application can provide a corresponding compiler for application to a processor, and the processor can execute the compilation method provided by the embodiment of the present application when running the compiler. The working process of the compiler translating a source program into a target program can be divided into five stages: lexical analysis, syntax analysis, semantic checking and intermediate code generation, code optimization, and target code generation. In layman's terms, compilation is to convert code into machine code that can be executed by a machine, and translate a program compiled in a certain programming language into an executable code or program described in a binary language that can be recognized by a computer.
[0036] In some embodiments, the application can be parsed to obtain information about the application. The application can also be parsed using a parsing tool. For example, an architecture parsing tool is used to parse the application to obtain the system architecture to which the application is applied. A compilation dependency package parsing tool is used to parse the application to obtain a compilation dependency package list of the application. Based on the compilation dependency package list, the compilation dependency package of the application can be obtained and deployed in a container. During compilation, the application can be compiled based on the compilation dependency package.
[0037] The above parsing process can be completed in the container or outside the container.
[0038] In some embodiments, for different system architectures, corresponding containers may be pre-configured. After receiving a compilation request for an application, a container corresponding to the system architecture of the application is obtained, and the obtained container is used as a target container.
[0039] In some embodiments, when a compilation request for an application is received, a target container that can be used to compile the application is created based on the system architecture to which the application is applied.
[0040] Exemplarily, the above step S110, based on the system architecture to which the application is applied, obtaining a target container that can be used to compile the application, may include:
[0041] Create a new container and use it as the target container for the application.
[0042] Based on the system architecture to which the application is applied, obtaining a root file system on which the application can be compiled;
[0043] Migrate the root filesystem into the target container.
[0044] In some embodiments, if there is a first container that can be used to compile the application, it is determined whether it is in an idle state. If it is in an idle state, the first container is determined as the target container of the application. If it is in a working state and its remaining working time meets the set time requirement, the first container is determined as the target container of the application. If it is in a working state and the remaining working time of the first container does not meet the set time requirement, a new container is created.
[0045] Exemplarily, the above-mentioned creation of a new container may include:
[0046] Based on the system architecture to which the application is applied, searching for a corresponding first container; wherein the first container includes a root file system that can compile the application, and the root file system included in the first container includes a compilation tool required by the application and a compilation environment simulator corresponding to the system architecture to which the application is applied;
[0047] When the first container is in a working state and the remaining working time of the first container does not meet the set time requirement, a new container is created.
[0048] Since the newly created container is empty, a suitable root file system needs to be configured. Based on the system architecture to which the application is applied, the root file system for compiling the application can be obtained and the root file system can be transplanted into the container.
[0049] In some embodiments, root file systems corresponding to different system architectures may be pre-selected and configured based on different system architectures. For example, a root file system that can be used to compile applications for the X86 architecture may be pre-configured, and a root file system that can be used to compile applications for the ARM architecture (Acorn RISC Machine) may be pre-configured. When a compilation request for an application is received, the corresponding root file system may be obtained based on the system architecture to which the application is applied, and the root file system may be transplanted into the target container. In this way, the corresponding target container may be obtained.
[0050] In some embodiments, for different applications, when a compilation request for the application is received, a suitable root file system may be constructed based on the type of the application and its system architecture.
[0051] In some embodiments, an initialized root file system or a root file system that has been used in the past can be provided, and the root file system can be modified to obtain the root file system required by the application program, so as to conveniently improve the resource utilization efficiency of the system.
[0052] Exemplarily, the obtaining of the root file system for compiling the application based on the system architecture to which the application is applied may include:
[0053] Determine the compilation tools and compilation environment simulator required by the application based on the system architecture to which the application is applied;
[0054] Based on the compilation tools and compilation environment simulator required by the application, the root file system of the application is modified.
[0055] In this example, the compilation tool required by the application can be determined based on the format of the application. For example, an application in dpkg format can use a compilation tool that can compile applications in dpkg format. The compilation tools required for applications in different formats can be different or the same. If there are some compilation tools that can compile applications in multiple different formats, these multiple different formats include dpkg format, and they can also be determined as the compilation tools required by the application.
[0056] In the case of multiple compilation tools, a compilation tool that can compile the application and whose compilation efficiency meets the set requirements can be selected. In some embodiments, it is also possible to determine whether the compilation tool is the compilation tool required by the application based on the utilization frequency of the compilation tool.
[0057] In this exemplary embodiment, the compilation environment simulator required by the application can be determined based on the system architecture to which the application is applied. The compilation environment simulators required by applications of different system architectures may be the same or different. For example, for applications applied to the X86 architecture, a simulator that can simulate the compilation environment of the X86 architecture can be used; for applications applied to the ARM architecture, a simulator that can simulate the compilation environment of the ARM architecture can be used. If there are some simulators that can simulate the compilation environments of multiple different system architectures, they can also be selected as the simulators required by the application.
[0058] When there are multiple simulators, you can choose a simulator that can compile a compilation environment that is the same as the system architecture used by the application and the effect of the compilation environment applied to the compilation meets the set requirements.
[0059] After determining the compilation tools and compilation environment simulator required by the application, the root file system can be modified based on these determined tools, or a new root file system can be created. The created new root file system needs to include the compilation tools and compilation environment simulator required by the above determined application.
[0060] Exemplarily, the compilation tool and the compilation environment simulator required by the application program modify the root file system of the application program, including at least one of the following:
[0061] In the case that the root file system of the application does not include the compilation tool required by the application, adding the compilation tool required by the application to the root file system;
[0062] In a case where the root file system includes a compilation tool not required by the application, deleting the compilation tool not required by the application in the root file system;
[0063] In the case that the root file system does not include the compilation environment simulator required by the application, the compilation environment simulator required by the application is added to the root file system.
[0064] In this example, the modification tool of the root file system can be called to modify the root file system as described above. The initial root file system can provide some commonly used compilation tools for applications, such as gcc (GNU Compiler Collection), crypt (an encryption function), ACL (Access Control Lists), debconf (a software package configuration management system), libc library (a function library standard), etc. Then, the initial root file system is modified, which can improve the efficiency of obtaining a suitable root file system.
[0065] In some embodiments, if the existing root file system meets the requirements of the application program, the root file system can be directly obtained. For the root file system that meets the requirements of the application program, it includes the compilation tool and the compilation environment simulator required by the application program.
[0066] Of course, you can still modify this root file system, for example, delete unnecessary tools and replace them with more efficient compilation tools and compilation environment simulators.
[0067] In some embodiments, the root file systems corresponding to applications of different system architectures may be different. For applications, a root file system may be configured for each system architecture, and the root file system may include a compilation environment simulator of the corresponding system architecture. For example, the root file systems of the X86 architecture and the ARM architecture may be configured respectively, the root file system of the X86 architecture includes a simulator that can simulate the compilation environment of the X86 architecture, and the root file system of the ARM architecture includes a simulator that can simulate the compilation environment of the ARM architecture.
[0068] Therefore, in some embodiments, corresponding root file systems may be configured in advance for applications of different system architectures. When a compilation request for an application is received, the root file system corresponding to the system architecture to which the application is applied is obtained.
[0069] In some embodiments, a root file system may be configured for multiple system architectures. The root file system may include multiple simulators. Each simulator may compile a compilation environment for a set system architecture. The applicable system architectures of the compilation environments compiled by different simulators may be different.
[0070] In some embodiments, a root file system can be configured for multiple system architectures, and the root file system can include one or more cross-compilation environment simulators, each of which can compile compilation environments of at least two set system architectures. For example, cross-compilation environment simulator A can compile a compilation environment for an X86 architecture, and can also compile a compilation environment for an ARM architecture.
[0071] Therefore, in some embodiments, in the above step S130, in the target container, using the compilation environment simulator in the root file system to simulate a compilation environment whose system architecture is the same as the architecture of the system to which the application is applied may include:
[0072] Based on the system architecture to which the application is applied, obtain the corresponding compilation environment simulator in the root file system;
[0073] The obtained compilation environment simulator is used to simulate a compilation environment whose system architecture is the same as the system architecture to which the application is applied.
[0074] In some embodiments, the compilation environment module obtained in the root file system may only compile a compilation environment of one system architecture, where the system architecture is the system architecture to which the application is applied.
[0075] In some embodiments, the obtained compilation environment simulator can compile compilation environments of multiple different system architectures, and the multiple different system architectures at least include the system architecture that the application is applied to. In this example, the root file system can use a compilation environment simulator to implement cross-simulation of multiple compilation environments.
[0076] In the above step S130, after the compilation environment is constructed, the application can be parsed to obtain the compilation dependency package of the application. Then, the compilation dependency package of the application is obtained and deployed in the compilation environment. At the same time or before or after the deployment of the dependency package, the application can also be deployed in the compilation environment. In this way, in the compilation environment, the compilation tool in the root file system can be used to compile the application based on the compilation dependency package of the application, and the compilation result of the application can be obtained, which includes the executable code of the application.
[0077] In some embodiments, when the application has been compiled and the compilation result of the application has been submitted, the target container is destroyed, thereby achieving the effect of releasing resources.
[0078] In some embodiments, it is not necessary to destroy the target container immediately after the compilation is completed. A certain time can be reserved, and during this time, if the corresponding application requests compilation, the target container can be used for compilation, further improving the utilization efficiency of the container.
[0079] Exemplarily, the above-mentioned destroying the target container may include:
[0080] In the target container, deleting all data and information related to the compilation process of the application except the root file system;
[0081] When the target container is in an idle state for a time period that satisfies a set time requirement after the application program has been compiled, the target container is destroyed.
[0082] In this example, while the container is waiting for the next application to be compiled, all data and information related to the compilation process of the previous application in the container can be deleted, but the root file system is retained. In this way, some resources can be released and the resource utilization of the container can be improved.
[0083] Figure 2A block diagram showing a container-based program compiling method according to a second embodiment of the present disclosure.
[0084] like Figure 2 As shown, the host receives an instruction to start the work and starts working using the CPU and memory resources of the host. At the same time as the host is started, a cross-compilation execution program that can execute the container-based program compilation method provided in the embodiment of the present application can also be started. Alternatively, when a start request for the cross-compilation execution program is received, the cross-compilation execution program is started.
[0085] Call the container management tool, which can create, run, and destroy tools. Use the container management tool to create a container. Execute the cross-compiled executable program in the container.
[0086] The cross-compilation executor responds to the compilation request of the application and transplants the application into the container. The cross-compilation parser is called to parse the application and obtain the version information of the application, such as the system architecture, format, creation date, etc. to which it is applied. The compilation dependency list of the application is also obtained. The compilation dependency package of the application can be obtained according to the compilation dependency list of the application, and the obtained compilation dependency package can be transplanted into the container. Two different parsing methods can also be used to parse the version information and the compilation dependency list of the application respectively. These two different parsing methods can be expressed in different programming languages. In some embodiments, these two different parsing methods can also be integrated together and expressed in the same programming language.
[0087] The cross-compilation execution program can obtain the root file system that can compile the application based on the version information of the application, such as the system architecture to which the application is applied. This root file system is also called a lightweight compilation system because its composition structure is relatively simple and occupies less host resources. In this example, the lightweight compilation system can provide compilation functions for multiple applications applied to different system architectures, so it can also be called a lightweight cross-compilation system.
[0088] The cross-compilation execution program obtains a cross-compilation environment simulator from the lightweight cross-compilation system and transplants the cross-compilation environment simulator to the container. In the container, the cross-compilation environment simulator is used to simulate a compilation environment that is the same as the system architecture to which the application is applied.
[0089] The cross-compilation executor obtains the compilation dependency packages of the application according to the compilation dependency list of the application, and deploys the compilation dependency packages in the compilation environment.
[0090] The cross-compilation executor also deploys the application in the compilation environment, and then uses the compilation tool in the lightweight cross-compilation system to compile the application based on the compilation dependency package deployed in the compilation environment.
[0091] After obtaining the executable code of the application, the container can be destroyed to release resources.
[0092] In this example, the combination of container and root file system can be used to not only implement isolated compilation and cross-compilation of applications of multiple different system architectures, but also reduce the resources occupied by the compilation tools and improve compilation efficiency.
[0093] Figure 3 A block diagram of a container-based program compiling device according to a third embodiment of the present application is shown.
[0094] like Figure 3 As shown, the container-based program compilation device may include:
[0095] The container acquisition module 310 is used to respond to the compilation request of the application and, based on the system architecture to which the application is applied, acquire a target container that can be used to compile the application; wherein the target container includes a root file system that can compile the application, and the root file system includes at least a compilation tool and a compilation environment simulator required by the application;
[0096] A program transplantation module 320, used to transplant the application program into the target container;
[0097] A compilation environment simulation module 330 is used to simulate, in the target container, a compilation environment with a system architecture identical to that to which the application is applied, using a compilation environment simulator in the root file system;
[0098] The application compiling module 340 is used to deploy the application in the compilation environment in the target container, and compile the application deployed in the compilation environment using the compilation tool required by the application in the root file system.
[0099] Figure 4 FIG. 4 is a block diagram of a container-based program compilation device according to a fourth embodiment of the present application. Figure 4As shown, the device includes a container acquisition module 410, a program transplantation module 420, a compilation environment simulation module 430, an application compilation module 440, and a container destruction module 450. Among them, the container acquisition module 410, the program transplantation module 420, the compilation environment simulation module 430, and the application compilation module 440 have the same functions as the container acquisition module 310, the program transplantation module 320, the compilation environment simulation module 330, and the application compilation module 340 in the above embodiment, and will not be described in detail here.
[0100] In some embodiments, Figure 4 As shown, the container acquisition module 410 includes:
[0101] A container creation unit 411 is used to create a new container and use the new container as a target container of the application;
[0102] A root file system acquisition unit 412, configured to acquire a root file system capable of compiling the application based on the system architecture to which the application is applied;
[0103] A root file system transplantation unit is used to transplant the root file system into the target container.
[0104] In some embodiments, the container creation unit 411 is used to:
[0105] Based on the system architecture to which the application is applied, searching for a corresponding first container; wherein the first container includes a root file system capable of compiling the application, and the root file system included in the first container includes a compilation tool required by the application and a compilation environment simulator corresponding to the system architecture to which the application is applied;
[0106] When the first container is in a working state and the remaining working time of the first container does not meet a set time requirement, a new container is created.
[0107] In some embodiments, the apparatus further comprises:
[0108] The container destroying module 450 is configured to destroy the target container when the application has been compiled and the compilation result of the application has been submitted.
[0109] In some embodiments, the container destruction module 450 includes:
[0110] A deleting unit 451, configured to delete, in the target container, all data and information related to the compilation process of the application except the root file system;
[0111] The destroying unit 452 is configured to destroy the target container if the time during which the target container is in an idle state meets a set time requirement after the application program has been compiled.
[0112] In some embodiments, the root file system obtaining unit 412 is used to:
[0113] Determine the compilation tool and compilation environment simulator required by the application based on the system architecture to which the application is applied;
[0114] Based on the compilation tool and the compilation environment simulator required by the application, the root file system of the application is modified.
[0115] In some embodiments, the compilation environment simulation module 430 includes:
[0116] The simulator acquisition unit 431 is used to acquire a corresponding compilation environment simulator in the root file system based on the system architecture to which the application is applied;
[0117] The simulator working unit 432 is used to use the obtained compilation environment simulator to simulate a compilation environment having a system architecture that is the same as the system architecture to which the application is applied.
[0118] The functions of each module in each device in the embodiments of the present application can be found in the corresponding description in the above method, and will not be repeated here.
[0119] According to an embodiment of the present application, the present application also provides an electronic device and a readable storage medium.
[0120] Figure 5 A schematic block diagram of an example electronic device 500 that can be used to implement an embodiment of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or required herein.
[0121] like Figure 5As shown, the device 500 includes a computing unit 501, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 502 or a computer program loaded from a storage unit 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the device 500 can also be stored. The computing unit 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0122] A number of components in the device 500 are connected to the I / O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the device 500 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0123] The computing unit 501 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 501 performs the various methods and processes described above, such as a container-based program compilation method. For example, in some embodiments, a container-based program compilation method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 500 via ROM 502 and / or a communication unit 509. When the computer program is loaded into RAM 503 and executed by the computing unit 501, one or more steps of the container-based program compilation method described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to perform a container-based program compilation method by any other appropriate means (e.g., by means of firmware).
[0124] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0125] The program code for implementing the method of the present application can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, implements the functions / operations specified in the flow chart and / or block diagram. The program code can be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0126] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0127] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0128] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0129] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0130] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the expected results of the technical solution disclosed in this application can be achieved, and this document is not limited here.
[0131] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.
Claims
1. A container-based program compilation method, It is characterized in that include: In response to a compilation request of an application, based on a system architecture to which the application is applied, obtaining a target container that can be used to compile the application; wherein the target container includes a root file system that can compile the application, and the root file system includes at least a compilation tool and a compilation environment simulator required by the application; porting the application to the target container; In the target container, using a compilation environment simulator in the root file system, simulating a compilation environment having a system architecture identical to the system architecture to which the application is applied; In the target container, deploy the application in the compilation environment, and compile the application deployed in the compilation environment using a compilation tool required by the application in the root file system; The obtaining, based on the system architecture to which the application is applied, a target container that can be used to compile the application comprises: Creating a new container, and using the new container as a target container for the application; Based on the system architecture to which the application is applied, obtaining a root file system for compiling the application, where different system architectures correspond to different root file systems; The root file system is transplanted into the target container.
2. The method according to claim 1, It is characterized in that The step of creating a new container comprises: Based on the system architecture to which the application is applied, searching for a corresponding first container; wherein the first container includes a root file system that can compile the application, and the root file system included in the first container includes the application Required compilation tools and a compilation environment simulator corresponding to the system architecture to which the application is applied; When the first container is in a working state and the remaining working time of the first container does not meet a set time requirement, a new container is created.
3. The method according to claim 1 or 2, It is characterized in that The method further comprises: When the application has been compiled and the compilation result of the application has been submitted, the target container is destroyed.
4. The method according to claim 3, It is characterized in that The destroying the target container comprises: In the target container, deleting all data and information related to the compilation process of the application except the root file system; The target container is idle for a set period of time after the application is compiled. If required, destroy the target container.
5. The method according to claim 1, It is characterized in that The step of obtaining a root file system capable of compiling the application based on the system architecture to which the application is applied comprises: Determine the compilation tool and compilation environment simulator required by the application based on the system architecture to which the application is applied; Based on the compilation tool and the compilation environment simulator required by the application, the root file system of the application is modified.
6. The method according to claim 1, It is characterized in that The method of simulating, in the target container, a compilation environment simulator in the root file system to generate a compilation environment having a system architecture identical to that of the system to which the application is applied, includes: Based on the system architecture to which the application is applied, obtaining a corresponding compilation environment simulator in the root file system; The obtained compilation environment simulator is used to simulate a compilation environment having a system architecture identical to the system architecture to which the application is applied.
7. A container-based program compilation device, It is characterized in that include: A container acquisition module, configured to respond to a compilation request of an application and, based on a system architecture to which the application is applied, acquire a target container that can be used to compile the application; wherein the target container includes a root file system that can compile the application, and the root file system includes at least a compilation tool and a compilation environment simulator required by the application; A program transplantation module, used for transplanting the application program into the target container; A compilation environment simulation module, used to simulate, in the target container, a compilation environment with a system architecture identical to that to which the application is applied, using a compilation environment simulator in the root file system; A compiling module, configured to deploy the application in the compilation environment in the target container, and compile the application deployed in the compilation environment using a compiling tool required by the application in the root file system; The container acquisition module includes: A container creation unit, used to create a new container and use the new container as a target container of the application; A root file system acquisition unit, used for acquiring a root file system for compiling the application based on the system architecture to which the application is applied, where different system architectures correspond to different root file systems; A root file system transplantation unit is used to transplant the root file system into the target container.
8. The device according to claim 7, It is characterized in that The container creation unit is used for: Based on the system architecture to which the application is applied, searching for a corresponding first container; wherein the first container includes a root file system capable of compiling the application, and the root file system included in the first container includes a compilation tool required by the application and a compilation environment simulator corresponding to the system architecture to which the application is applied; When the first container is in a working state and the remaining working time of the first container does not meet a set time requirement, a new container is created.
9. The device according to claim 7 or 8, It is characterized in that The device also includes: The container destroying module is used to destroy the target container when the application has been compiled and the compilation result of the application has been submitted.
10. The device according to claim 9, It is characterized in that The container destruction module comprises: a deleting unit, configured to delete, in the target container, all data and information related to the compilation process of the application except the root file system; The destroying unit is used to destroy the target container if the time for which the target container is in an idle state meets a set time requirement after the application program has been compiled.
11. The device according to claim 7, It is characterized in that The root file system acquisition unit is used for: Determine the compilation tool and compilation environment simulator required by the application based on the system architecture to which the application is applied; Based on the compilation tool and the compilation environment simulator required by the application, the root file system of the application is modified.
12. The device according to claim 7, It is characterized in that The compilation environment simulation module includes: A simulator acquisition unit, configured to acquire a corresponding compilation environment simulator in the root file system based on the system architecture to which the application is applied; The simulator working unit is used to use the obtained compilation environment simulator to simulate a compilation environment whose system architecture is the same as the system architecture to which the application is applied.
13. An electronic device, It is characterized in that include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.
14. A non-transitory computer-readable storage medium storing computer instructions, It is characterized in that When the computer instructions are executed by a processor, the method according to any one of claims 1 to 6 is implemented.
