A QT application compilation method and device based on Docker image
Through the QT application compilation method based on Docker images, cross-compilation tools are used to generate multi-platform applications and executable files on any machine, which solves the problems of dispersed compilation environment and high resource consumption in the existing technology, and realizes convenient compilation. Environmental management and maintenance.
Patent Information
- Application Number
- CN202110304331.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-22
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2041-03-22
AI Technical Summary
In the existing technology, application compilation needs to rely on a large number of physical machines on different platforms, resulting in a dispersed compilation environment, which is not conducive to maintenance.
Using the QT application compilation method based on Docker images, by obtaining the QT build tools corresponding to the target platform, obtaining or creating images containing build tools for different platforms from the preset Docker images, cross-compiling, and generating applications suitable for the target platform Program executable file.
Application executable files suitable for different platforms can be compiled without relying on a large number of physical machines, which simplifies compilation environment management, improves maintenance convenience and integration, and reduces physical hardware resource requirements.
Smart Images

Figure CN113064595B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a QT application compiling method and device based on Docker image. Background Art
[0002] Applications on different platforms need to compile the application source code in the environment of the platform to obtain the application executable file. In the prior art, when an application is released on a certain platform, it is necessary to find a physical machine that carries the platform, and then compile the application source code on the physical machine to obtain the application executable file, or temporarily build the platform, and then compile the application source code in the built platform. However, this compilation method in the prior art requires a lot of physical hardware resources to support it, and the compilation environment is relatively scattered.
[0003] It can be seen that the prior art needs to rely on a large number of physical machines of different platforms to implement the compilation process of the application source code, and the compilation environment is relatively scattered, which is not conducive to maintenance. Summary of the invention
[0004] The present invention provides a QT application compilation method and device based on Docker image, which is used to solve the defects in the prior art that a large number of physical machines of different platforms are needed to realize the compilation process of application source code, the compilation environment is relatively scattered, and it is not conducive to maintenance. By deploying the Docker image to any machine, application executable files suitable for different platforms can be compiled without relying on a large number of physical machines, which facilitates the management of the compilation environment.
[0005] The present invention provides a QT application compilation method based on Docker image, comprising:
[0006] Obtaining a target platform for publishing the QT application and the QT application source code corresponding to the QT application;
[0007] Obtaining a QT build tool corresponding to the target platform from a preset Docker image; wherein the QT build tool is used to generate a configuration file for guiding the QT application source code to cross-compile;
[0008] The QT application source code is compiled based on the QT construction tool corresponding to the target platform to generate an application executable file suitable for the target platform.
[0009] According to the present invention, a QT application compilation method based on a Docker image is provided. On the basis of the above, before obtaining the QT build tool corresponding to the target platform from the preset Docker image, it also includes:
[0010] Obtain a pre-created Docker image containing QT build tools corresponding to different platforms, and deploy the obtained Docker image to the machine where the QT application source code is to be compiled.
[0011] According to the present invention, a QT application compilation method based on Docker image is provided. On the basis of the above, before obtaining the pre-created Docker image containing the QT build tools corresponding to different platforms, it also includes:
[0012] Create a Docker image and copy the QT source code of the graphical user interface program development framework QT to the created Docker image;
[0013] The QT source code is compiled using cross-compilation tools for different platforms to obtain QT building tools corresponding to different platforms.
[0014] According to the present invention, a QT application compilation method based on Docker image is provided. On the basis of the above, the QT source code is compiled using cross-compilation tools of different platforms to obtain QT construction tools corresponding to different platforms, including:
[0015] The version information of the QT source code pre-configured for the target platform is obtained, and the QT source code matching the version information is compiled by cross-compilation tools of different platforms to obtain QT building tools of different versions corresponding to different platforms.
[0016] According to the present invention, a QT application compilation method based on Docker image is provided, which further includes:
[0017] Place the QT build tools for different platforms in different directories in the Docker image;
[0018] The QT building tool corresponding to any platform includes a program building tool compiled based on QT source codes with different version information.
[0019] According to the present invention, a QT application compilation method based on Docker image is provided. On the basis of the above, after the application source code corresponding to each application to be released is compiled by the preset Docker image, the preset Docker image is destroyed.
[0020] According to the present invention, a QT application compilation method based on Docker image is provided. On the basis of the above, the target platform includes at least one of the following:
[0021] MIPS platform, ARM platform, X86 platform, Alnha platform.
[0022] The present invention also provides a QT application compilation device based on Docker image, comprising:
[0023] A first acquisition module is used to acquire a target platform for publishing a QT application and a QT application source code corresponding to the QT application;
[0024] A second acquisition module is used to acquire a QT build tool corresponding to the target platform from a preset Docker image; wherein the QT build tool is used to generate a configuration file for guiding the QT application source code to cross-compile;
[0025] The compiling module is used to compile the QT application source code based on the QT building tool corresponding to the target platform to generate an application executable file suitable for the target platform.
[0026] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any of the above-mentioned QT application compilation methods based on Docker images are implemented.
[0027] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the above-described QT application compilation methods based on Docker images.
[0028] The present invention provides a QT application compilation method and device based on Docker image, in which a program cross-compilation tool corresponding to different platforms is included in the Docker image. When a certain QT application source code needs to be published on any target platform, the QT target program construction tool and cross-compilation tool corresponding to the target platform can be obtained only through the Docker image. Then based on the target program construction tool, the cross-compilation tool customizes and exposes the QT compilation environment of the target platform, and compiles the application executable file suitable for the target platform. The Docker image can be run on any machine with a Docker container installed, so by deploying the Docker image to any machine, the application executable file suitable for different platforms can be compiled, without relying on a large number of physical machines with different architectures, which is convenient for the management of the compilation environment. In addition, the Docker image has good encapsulation, consistency, easy maintenance, and easy integration into the CI project, and will not affect the operation of other businesses on the machine where it is located during operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0030] Figure 1 This is one of the flow charts of the QT application compilation method based on Docker image provided by the present invention;
[0031] Figure 2 This is the cross-compilation docker image production and Qt application cross-compilation flow chart provided by the present invention;
[0032] Figure 3 It is a schematic diagram of the Qt application cross-compilation process for multiple platforms provided by the present invention;
[0033] Figure 4 A schematic diagram of a docker image production method for cross-compiling and publishing Qt applications provided by the present invention;
[0034] Figure 5 It is a schematic diagram of the Qt application cross-compilation process provided by the present invention;
[0035] Figure 6 It is one of the structural block diagrams of the QT application compilation device based on Docker image provided by the present invention;
[0036] Figure 7 It is a schematic diagram of the physical structure of the electronic device provided by the present invention; DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0038] Taking the Linux system as an example, there are currently two methods for compiling and publishing applications: Method 1: Use a Linux physical machine to compile and publish applications; Method 2: Use the QT cross-compilation tool chain built directly on the Linux system to compile and publish applications. However, according to research, these two methods have the following problems, as shown in Table 1:
[0039] Table 1
[0040]
[0041]
[0042] It can be seen that the main disadvantage of method 1 is that it requires a lot of physical hardware resources to support it, and because the compilation environment is relatively scattered, it is not suitable for building an automated compilation and release project for multiple platforms. Method 2 uses cross-compilation technology, which makes it easier to centrally manage the compilation tool chains of each platform, and is suitable for building an automated compilation and release project for multiple platforms. However, its integration is poor, which increases the difficulty of environment migration, construction and maintenance.
[0043] In response to the above problems, Figure 1 A schematic diagram of a QT application compilation method based on a Docker image provided in this embodiment, which is implemented by any machine, see Figure 1 , the method comprising:
[0044] Step 101: Obtain a target platform for publishing a QT application and a QT application source code corresponding to the QT application;
[0045] Step 102: Obtain a QT build tool corresponding to the target platform from a preset Docker image; wherein the QT build tool is used to generate a configuration file for guiding the QT application source code to cross-compile;
[0046] Step 103: Compile the QT application source code based on the QT building tool corresponding to the target platform to generate an application executable file suitable for the target platform.
[0047] Among them, the program cross-compilation tool is usually generated based on compiling the QT source code.
[0048] Step 101 may specifically include: obtaining a target platform for publishing the application, a QT version, and an application source code corresponding to the application.
[0049] Step 102 can be specifically as follows: customizing and exposing a complete set of QT application building tools and program cross-compilation tools corresponding to the target platform from the preset Docker image as the program cross-compilation tools for the target platform; wherein the program building tools are used to build the QT application to generate a Makefile, and the cross-compilation tools are used to cross-compile the application source code in the target platform.
[0050] Regarding Docker, this embodiment is introduced as follows: Docker is currently the most popular Linux container solution, providing a simple and easy-to-use container interface. As an open source container technology, it can quickly create a lightweight, portable container. As an emerging virtualization technology, it can deliver and deploy faster, combine and expand more flexibly, and manage simply. Docker packages the application and the dependent files of the program, or a series of production tools, into an image file. By running this packaged image, a virtual container will be generated, and the application runs in this virtual container, just like running on a real server. Packaging the runtime environment or tools of the application in this way helps to achieve the convenience of application deployment, the flexibility of application test environment construction, and the speed of cross-platform migration. After the application is packaged into a container image, it can run in any environment, including physical servers, virtual machines, public clouds, private clouds, etc. Due to the characteristics of Docker such as application runtime environment packaging and container lightweight, Docker technology is used in more and more scenarios. Especially in the scenarios of application migration, packaging, and compilation across CPU architectures, by running the container image of the packaged application compilation environment, you can quickly start the application compilation environment and compile the executable program for the corresponding CPU architecture.
[0051] The present embodiment provides a QT application compilation method based on Docker image, in which a program cross-compilation tool corresponding to different platforms is included in the Docker image. When a certain QT application source code needs to be published on any target platform, the QT target program construction tool and cross-compilation tool corresponding to the target platform can be obtained only through the Docker image. Then based on the target program construction tool, the cross-compilation tool customizes the QT compilation environment of the target platform, and compiles the application executable file suitable for the target platform. The Docker image can be run on any machine with a Docker container installed, so the application executable file suitable for different platforms can be compiled by deploying the Docker image to any machine, without relying on a large number of physical machines with different architectures, which is convenient for the management of the compilation environment. In addition, the Docker image has good encapsulation, consistency, easy maintenance, and is easy to integrate into the CI project, and it will not affect the operation of other businesses on the machine where it is located during operation.
[0052] Specifically, this embodiment uses the excellent characteristics of docker container, which is lightweight, portable, and can be quickly deployed, combined with the advantages of QT cross-compilation technology. A docker container image that integrates QT cross-compilation tool chains for multiple platforms is implemented, which supports rapid migration and deployment, and can customize the QT compilation environment of a specified architecture and a specified version according to parameters when creating a container. The Docker image has good integration and can be used as an engineering component for automatic compilation and release of QT applications.
[0053] Further, based on the above embodiments, before obtaining the QT build tool corresponding to the target platform from the preset Docker image, it also includes:
[0054] Obtain a pre-created Docker image containing QT build tools corresponding to different platforms, and deploy the obtained Docker image to the machine where the QT application source code is to be compiled.
[0055] It should be noted that the generated Docker image is usually stored on a certain machine. When the application source code needs to be compiled through any machine, the stored Docker image can be deployed to the machine, and then the Docker image can be run through the machine to realize the compilation process of the application source code.
[0056] In this embodiment, any machine can deploy the Docker image to compile the application source code for easy management.
[0057] Further, on the basis of the above embodiments, after the application source code corresponding to each application to be released is compiled by using the preset Docker image, the preset Docker image is destroyed.
[0058] In this embodiment, when the compilation of the application source code is completed, the Docker image pair can be destroyed to release the space occupied by the Docker image and avoid the impact of the existence of the Docker image on the machine.
[0059] Further, based on the above embodiments, the target platform includes at least one of the following:
[0060] MIPS platform, ARM platform, X86 platform, Alnha platform.
[0061] Figure 2 The cross-compilation docker image production and Qt application cross-compilation flow chart provided in this embodiment are as follows: Figure 3 For a schematic diagram of the cross-compilation process of Qt applications for multiple platforms provided in this embodiment, see Figure 2 and Figure 3 , after determining the target platform for the application to be released, the compilation tool corresponding to the platform can be obtained from the Docker image, and then a compilation environment for compiling the application source code on the target platform is constructed, thereby realizing the compilation process of the application source code. When the target platform is the X86 platform, the compilation tool chain (i.e., program cross-compilation tool) of the X86 platform and the specified QT version is enabled, and a compilation environment of the specified QT version for the X86 platform is established according to the environment variables, and the compilation task is executed to generate an executable program on the target machine. When the target platform is the ARM platform, the compilation tool chain of the ARM platform and the specified QT version is enabled, and a compilation environment of the specified QT version for the ARM platform is established according to the environment variables, and the compilation task is executed to generate an executable program on the target machine. When the target platform is the MIPS platform, the compilation tool chain of the MIPS platform and the specified QT version is enabled, and a compilation environment of the specified QT version for the MIPS platform is established according to the environment variables, and the compilation task is executed to generate an executable program on the target machine.
[0062] Among them, Figure 2 As shown, the Docker (CentOS7) image installation obtains the cross-compilation software for each platform (with built-in gcc / g++ cross-compilation tools):
[0063] yum install binutils-mips64-linux-gnu gcc-c++-mips64-linux-gnu gcc-mips64-linux-gnu;
[0064] yum install binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu gcc-c++-aarch64-linux-gnu;
[0065] yum install binutils-x86_64-linux-gnu gcc-c++-x86_64-linux-gnu gcc-x86_64-linux-gnu.
[0066] Regarding the creation of the Docker image, further, based on the above embodiments, before obtaining the pre-created Docker image containing the QT build tool corresponding to different platforms, it also includes:
[0067] Create a Docker image and copy the QT source code of the graphical user interface program development framework QT to the created Docker image;
[0068] The QT source code is compiled using cross-compilation tools for different platforms to obtain QT building tools corresponding to different platforms.
[0069] The QT build tool may be, for example, qmake, etc. Specifically, the QT build tool generates a configuration file Makefile for guiding the cross-compilation of the QT application source code.
[0070] The QT build tool may include a gcc compilation tool chain or a g++ compilation tool chain.
[0071] Regarding QT, it should be noted that QT is a cross-platform C++ graphical user interface library that provides developers with the functions required to build graphical user interfaces. It is widely used to develop graphical user interface programs and can also be used to develop non-graphical user interface (such as command line interface) programs. QT is completely object-oriented, easy to expand, and allows true component programming. QT supports all UNIX systems, including Linux systems, WinNT / Win2k, Windows platforms, smartphone systems Android, iOS, WinPhone, embedded systems QNX, VxWorks, etc. QT also has the following advantages. (1) Excellent cross-platform features; (2) Object-oriented; (3) Rich API interfaces; (4) Support for 2D / 3D graphics rendering and OpenGL; (5) A large amount of detailed development documentation; (6) XML support.
[0072] In this embodiment, a Docker image is created that can compile application source code applicable to different platforms. The created Docker image can be used to compile the application source code based on the machine on which the Docker image is deployed.
[0073] Further, based on the above embodiments, the QT source code is compiled using cross-compilation tools of different platforms to obtain QT construction tools corresponding to different platforms, including:
[0074] The version information of the QT source code pre-configured for the target platform is obtained, and the QT source code matching the version information is compiled by cross-compilation tools of different platforms to obtain QT building tools of different versions corresponding to different platforms.
[0075] Since different platforms may use QT source codes corresponding to different version information, matching the corresponding QT source code with version information can generate a program cross-compilation tool that better matches the target platform.
[0076] Furthermore, based on the above embodiments, it also includes:
[0077] Place the QT build tools for different platforms in different directories in the Docker image;
[0078] The QT building tool corresponding to any platform includes a program building tool compiled based on QT source codes with different version information.
[0079] In this embodiment, the QT cross-compilation tools corresponding to different platforms are placed in different directories in the Docker image, so as to facilitate the query of the QT cross-compilation tool.
[0080] Figure 4 This is a flow chart of the Docker image production method for cross-compiling and publishing Qt applications provided in this embodiment. Figure 4 , the method comprising:
[0081] S1. Pull the Linux CentOS7 base image from the docker image repository (other distributions can also be selected); download the source code of the required Qt versions from the Qt official website.
[0082] S2. Create and start a CentOS7 container on the host machine; enter the container, replace the domestic software source, and install basic auxiliary tools (such as tar, vim, etc.).
[0083] S3. Install the cross-compilation tool software of mips64el, arm64, and X86_64 from the software source, and finally configure and obtain the gcc / g++ cross-compilation tool chain on each target platform.
[0084] S4. Copy the source code of each version of Qt into the container; customize the qmake.conf file of each platform (mips64el, arm64, X86_64) in turn, and specify its cross-compilation tool chain.
[0085] S5. Compile the Qt source code in sequence according to the parameters, and finally obtain the required multiple platforms and multiple versions of the Qt build tool qmake. Different platforms and versions of Qt build tools are located in different directories.
[0086] S6. Delete useless auxiliary tool software, source code, etc.; test environment variables to ensure that the Qt build tools and gcc / g++ cross-compilation tool chains of each platform are accessible and executable; test the build, cross-compilation and release of Qt applications for each platform to ensure that they can run on physical machines; add a customized shell script for the environment when the container is started.
[0087] S7. Exit the container, save the changes, and export the image. On the host system, write a unified arch_version_env.list environment configuration file for the compilation environment of each platform and Qt version. Its content includes the target platform in the container, the build tool of the target Qt version, and the path and name of the gcc / g++ cross-compilation tool chain for each platform.
[0088] In S4, copy the source code of each version of Qt into the container; customize the qmake.conf file of each platform (mips64el, arm64, X86_64) in turn, and specify its cross-compilation tool chain. The qmake.conf configuration for each platform is as follows:
[0089] mips64el qt cross compiler qmake.conf configuration
[0090]
[0091]
[0092] aarch64 qt cross compiler qmake.conf configuration
[0093]
[0094] X86_64qt cross compiler qmake.conf configuration
[0095]
[0096]
[0097] Specifically, on a Linux system with a docker container installed, by loading the target image, you can obtain a QT cross-compilation and release tool for multiple Linux platforms and multiple QT versions. This implementation method has the following advantages:
[0098] 1. Good environment adaptability. The resource utilization rate of the compilation and release environment is high, and it can be deployed and used only on a Linux physical machine or virtual machine environment with a docker container installed; that is, there is no need to specify the physical machine compilation environment of the target architecture, which saves the cost of physical hardware resources.
[0099] 2. Good portability. The image is created once and deployed everywhere. At the same time, the environmental consistency and standardization of the container life cycle are guaranteed. This prevents the QT compilation environment on the physical machine / virtual machine from being unable to be used normally due to system damage, and the consistency of the environment is difficult to guarantee in such a scenario.
[0100] 3. Good integration. This method is suitable for building QT application automated compilation and release projects for multiple platforms, which can simplify the program and reduce the coupling between the compilation tool and the automation project.
[0101] 4. It has good usability and convenience. When building a QT project, you only need to pass in the target platform to be released, and then enable multiple containers to mount the project directory in parallel, so that you can compile and release executable programs for multiple platforms at one time.
[0102] 5. This method will not affect the physical / virtual machine environment. Containers have good resource isolation and restriction capabilities, and can accurately allocate CPU, memory and other resources to applications to ensure that they will not affect other applications in the system.
[0103] 6. Low maintenance cost. With good encapsulation, it can avoid damage to the compilation environment due to erroneous operations, thus greatly reducing maintenance costs, and the container has good version control.
[0104] Figure 5 This is a schematic diagram of the Qt application cross-compilation process provided in this embodiment, see Figure 5 The process includes cross-compiling the QT application code (i.e., application source code) based on the Pro file, Makefile, etc. in the Docker image to obtain executable files suitable for different platforms, and then running them on different platforms.
[0105] Specifically, this embodiment uses docker container technology to encapsulate QT cross-compilation tools for multiple platforms and multiple versions for Linux systems, and produces docker images that support compiling and publishing QT applications for specified platforms and specified versions; it also supports automated batch compilation and publishing of applications for multiple target platforms and specified QT versions. This method encapsulates docker containers, so it has all the advantages of containers, good integration and mobility; it has good isolation and has little impact on the host system; it has good version management support, which makes the maintenance cost of the tool low; it has good mobility, it can be built once and run everywhere, and it can ensure the consistency and standardization of the environment; the use of cross-compilation further reduces the demand for physical hardware.
[0106] The basic process of this method is as follows:
[0107] The container image integrates cross-compilation tools for multiple platforms and multiple QT versions. According to the compilation requirements, the required compilation environment is enabled when the container is created: that is, the complete compilation tool for the specified platform and QT version.
[0108] The method provided in this embodiment achieves the following technical effects:
[0109] First, it can be deployed and used on a Linux physical machine or virtual machine environment with a docker container installed, and has good environmental adaptability. That is, it no longer needs to rely on the physical machine compilation environment of the specified target architecture, which saves the cost of physical hardware resources.
[0110] Second, the image is created once and deployed everywhere. There is no need to build it repeatedly, which greatly ensures the consistency and standardization of the environment.
[0111] Third, it is suitable for building QT application automated compilation and release projects for multiple platforms, which can simplify the program and reduce the coupling between the compilation tool and the automated project. Compiling and releasing programs for multiple platforms does not require manual compilation on multiple physical machines.
[0112] Fourth, you can compile and publish executable programs for multiple platforms at one time, which improves efficiency by eliminating the need to manually execute multiple times.
[0113] Fifth, it has good resource isolation and restriction capabilities, ensuring that it will not affect other applications of the system and will not affect the physical machine / virtual machine environment.
[0114] Sixth, the maintenance cost is low. Because of its good encapsulation, it can avoid the damage to the compilation environment due to erroneous operations, thus greatly reducing the maintenance cost, and the container has good version control.
[0115] Figure 6 For a structural diagram of the QT application compilation device based on Docker image provided in this embodiment, see Figure 6 The QT application compiling device based on Docker image includes a first acquisition module 601, a second acquisition module 602 and a compiling module 603, wherein:
[0116] The first acquisition module 601 is used to acquire the target platform for publishing the QT application and the QT application source code corresponding to the QT application;
[0117] A second acquisition module 602 is used to acquire a QT build tool corresponding to the target platform from a preset Docker image; wherein the QT build tool is used to generate a configuration file for guiding the QT application source code to cross-compile;
[0118] The compiling module 603 is used to compile the QT application source code based on the QT building tool corresponding to the target platform to generate an application executable file suitable for the target platform.
[0119] The QT application compilation device based on Docker image provided in this embodiment is applicable to the QT application compilation method based on Docker image provided in the above embodiments, which will not be repeated here.
[0120] This embodiment provides a QT application compilation device based on Docker image, in which program cross-compilation tools corresponding to different platforms are included in the Docker image. When a certain application source code needs to be published on any target platform, the target program cross-compilation tool corresponding to the target platform can be obtained only through the Docker image. Then, the compilation environment of the target platform is constructed based on the target program cross-compilation tool, and the application executable file suitable for the target platform is compiled. The Docker image can be run on any machine with the Docker container installed, so by deploying the Docker image to any machine, the application executable file suitable for different platforms can be compiled, without relying on a large number of physical machines, which is convenient for the management of the compilation environment. In addition, the Docker image has good encapsulation, is easy to maintain, and will not affect the operation of other businesses on the machine where it is located during operation.
[0121] According to the present invention, a QT application compilation device based on a Docker image is provided. On the basis of the above, before obtaining the QT build tool corresponding to the target platform from the preset Docker image, it also includes:
[0122] Obtain a pre-created Docker image containing QT build tools corresponding to different platforms, and deploy the obtained Docker image to the machine where the QT application source code is to be compiled.
[0123] According to the present invention, a QT application compilation device based on Docker image is provided. On the basis of the above, before obtaining the pre-created Docker image containing the QT building tools corresponding to different platforms, it also includes:
[0124] Create a Docker image and copy the QT source code of the graphical user interface program development framework QT to the created Docker image;
[0125] The QT source code is compiled using cross-compilation tools for different platforms to obtain QT building tools corresponding to different platforms.
[0126] According to the present invention, a QT application compilation device based on Docker image is provided. On the basis of the above, the QT source code is compiled using cross-compilation tools of different platforms to obtain QT construction tools corresponding to different platforms, including:
[0127] The version information of the QT source code pre-configured for the target platform is obtained, and the QT source code matching the version information is compiled by cross-compilation tools of different platforms to obtain QT building tools of different versions corresponding to different platforms.
[0128] According to the present invention, a QT application compilation device based on Docker image is provided, which, on the basis of the above, also includes:
[0129] Place the QT build tools for different platforms in different directories in the Docker image;
[0130] The QT building tool corresponding to any platform includes a program building tool compiled based on QT source codes with different version information.
[0131] According to the present invention, a QT application compilation device based on Docker image is provided. On the basis of the above, after the application source code corresponding to each application to be released is compiled by the preset Docker image, the preset Docker image is destroyed.
[0132] According to the present invention, a QT application compilation device based on Docker image is provided. On the basis of the above, the target platform includes at least one of the following:
[0133] MIPS platform, ARM platform, X86 platform, Alnha platform.
[0134] Figure 7 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 7 As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730 and a communication bus 740, wherein the processor 710, the communication interface 720 and the memory 730 communicate with each other through the communication bus 740. The processor 710 may call the logic instructions in the memory 730 to execute the QT application compilation method based on the Docker image, and the method includes:
[0135] Obtaining a target platform for publishing the QT application and the QT application source code corresponding to the QT application;
[0136] Obtaining a QT build tool corresponding to the target platform from a preset Docker image; wherein the QT build tool is used to generate a configuration file for guiding the QT application source code to cross-compile;
[0137] The QT application source code is compiled based on the QT construction tool corresponding to the target platform to generate an application executable file suitable for the target platform.
[0138] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0139] On the other hand, the present invention further provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, and when the program instructions are executed by a computer, the computer can execute a QT application compilation method based on a Docker image, the method comprising:
[0140] Obtaining a target platform for publishing the QT application and the QT application source code corresponding to the QT application;
[0141] Obtaining a QT build tool corresponding to the target platform from a preset Docker image; wherein the QT build tool is used to generate a configuration file for guiding the QT application source code to cross-compile;
[0142] The QT application source code is compiled based on the QT construction tool corresponding to the target platform to generate an application executable file suitable for the target platform.
[0143] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to execute a QT application compilation method based on a Docker image, the method comprising:
[0144] Obtaining a target platform for publishing the QT application and the QT application source code corresponding to the QT application;
[0145] Obtaining a QT build tool corresponding to the target platform from a preset Docker image; wherein the QT build tool is used to generate a configuration file for guiding the QT application source code to cross-compile;
[0146] The QT application source code is compiled based on the QT construction tool corresponding to the target platform to generate an application executable file suitable for the target platform.
[0147] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0148] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0149] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A QT application compilation method based on Docker image, characterized in that: include: Obtaining a target platform for publishing the QT application and the QT application source code corresponding to the QT application; Obtaining a QT build tool and a cross-compilation tool corresponding to the target platform from a preset Docker image; wherein the QT build tool is used to generate a configuration file for guiding the QT application source code to cross-compile; and the Docker image contains cross-compilation tools corresponding to different platforms; Compile the QT application source code based on the QT build tool and cross-compilation tool corresponding to the target platform to generate an application executable file suitable for the target platform; Before obtaining the QT build tool corresponding to the target platform from the preset Docker image, it also includes: Obtain a pre-created Docker image containing QT build tools corresponding to different platforms, and deploy the obtained Docker image to a machine to compile the QT application source code; before obtaining the pre-created Docker image containing QT build tools corresponding to different platforms, it also includes: Create a Docker image and copy the QT source code of the graphical user interface program development framework QT to the created Docker image; The QT source code is compiled using cross-compilation tools for different platforms to obtain QT building tools corresponding to different platforms.
2. The QT application compilation method based on Docker image according to claim 1, characterized in that: The QT source code is compiled using cross-compilation tools of different platforms to obtain QT construction tools corresponding to different platforms, including: The version information of the QT source code pre-configured for the target platform is obtained, and the QT source code matching the version information is compiled by cross-compilation tools of different platforms to obtain QT building tools of different versions corresponding to different platforms.
3. The QT application compilation method based on Docker image according to claim 1, characterized in that: Also includes: Place the QT build tools for different platforms in different directories in the Docker image; The QT building tool corresponding to any platform includes a program building tool compiled based on QT source codes with different version information.
4. The QT application compilation method based on Docker image according to claim 1, characterized in that: After the application source code corresponding to each application to be released is compiled by using the preset Docker image, the preset Docker image is destroyed.
5. The QT application compilation method based on Docker image according to claim 1, characterized in that: The target platform includes at least one of the following: MIPS platform, ARM platform, X86 platform, Alnha platform.
6. A QT application compilation device based on Docker image, characterized in that: include: A first acquisition module is used to acquire a target platform for publishing a QT application and a QT application source code corresponding to the QT application; A second acquisition module is used to acquire a QT build tool and a cross-compilation tool corresponding to the target platform from a preset Docker image; wherein the QT build tool is used to generate a configuration file for guiding the QT application source code to cross-compile; and the Docker image contains cross-compilation tools corresponding to different platforms; A compiling module, used to compile the QT application source code based on the QT building tool and cross-compilation tool corresponding to the target platform to generate an application executable file suitable for the target platform; Before obtaining the QT build tool corresponding to the target platform from the preset Docker image, it also includes: Obtain a pre-created Docker image containing QT build tools corresponding to different platforms, and deploy the obtained Docker image to a machine where the QT application source code is to be compiled; Before getting the pre-built Docker images containing QT build tools for different platforms, also include: Create a Docker image and copy the QT source code of the graphical user interface program development framework QT to the created Docker image; The QT source code is compiled using cross-compilation tools for different platforms to obtain QT building tools corresponding to different platforms.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the QT application compilation method based on the Docker image are implemented as described in any one of claims 1 to 5.
8. A non-transitory readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the QT application compilation method based on the Docker image are implemented as described in any one of claims 1 to 5.
