CN117270864A - Code compiling method, device, equipment and storage medium - Google Patents

Code compiling method, device, equipment and storage medium Download PDF

Info

Publication number
CN117270864A
CN117270864A CN202311182951.0A CN202311182951A CN117270864A CN 117270864 A CN117270864 A CN 117270864A CN 202311182951 A CN202311182951 A CN 202311182951A CN 117270864 A CN117270864 A CN 117270864A
Authority
CN
China
Prior art keywords
compiling
information
code
target
compilation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311182951.0A
Other languages
Chinese (zh)
Inventor
方明敏
孙莉
孙宸豪
钱言佳
刘益彬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Unionpay Co Ltd
Original Assignee
China Unionpay Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Unionpay Co Ltd filed Critical China Unionpay Co Ltd
Priority to CN202311182951.0A priority Critical patent/CN117270864A/en
Publication of CN117270864A publication Critical patent/CN117270864A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • G06F8/63Image based installation; Cloning; Build to order
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The application discloses a code compiling method, device, equipment and storage medium, and belongs to the field of data processing. The method comprises the following steps: responding to a compiling request, distributing a physical compiling node for executing code compiling for the compiling request, wherein the compiling request comprises compiling preparation information of a functional module to be compiled; selecting a target dock mirror image matched with the compiling preparation information from a dock mirror image library through the allocated physical compiling node, and generating a container compiling environment by utilizing the target dock mirror image; acquiring a source code of a functional module to be compiled through a container compiling environment, and determining a target programming language function channel matched with compiling preparation information in a preset programming language database, wherein the source code comprises a compiling configuration file, and the compiling configuration file comprises compiling configuration information; and compiling the source code according to the compiling configuration information by utilizing the target programming language function channel to generate a target code package. According to the embodiment of the application, the efficiency of code compiling and the resource utilization rate of the physical compiling node can be improved.

Description

Code compiling method, device, equipment and storage medium
Technical Field
The application belongs to the field of data processing, and particularly relates to a code compiling method, a device, equipment and a storage medium.
Background
Code compilation is a secondary production process that processes source code into object code. After the developer writes the source code of the functional module, a compiling manual is provided for a configuration manager, and the configuration manager manually writes a compiling script so as to compile the code. On one hand, configuration management personnel need to understand the compiling manual for the second time, and trial-and-error cost exists; on the other hand, code compiling may involve multiple factors such as programming language types and compiling environments, and the programming language types and compiling environments involved in code compiling of different functional modules may be different, and the difference may also cause a large trial-and-error cost, so that the code compiling efficiency is low.
Disclosure of Invention
The embodiment of the application provides a code compiling method, a device, equipment and a storage medium, which can improve the efficiency of code compiling.
In a first aspect, an embodiment of the present application provides a code compiling method, including: responding to the received compiling request, distributing a physical compiling node for executing code compiling for the compiling request, wherein the compiling request comprises compiling preparation information of a functional module to be compiled; selecting a target dock mirror image matched with the compiling preparation information from a preset dock mirror image library through the allocated physical compiling node, and generating a container compiling environment by utilizing the target dock mirror image; acquiring a source code of a functional module to be compiled through a container compiling environment, and determining a target programming language function channel matched with compiling preparation information in a preset programming language database, wherein the source code comprises a compiling configuration file, and the compiling configuration file comprises compiling configuration information; and compiling the source code according to the compiling configuration information by utilizing the target programming language function channel to generate a target code package.
In a second aspect, an embodiment of the present application provides a code compiling apparatus, including: the distribution module is used for responding to the received compiling request and distributing physical compiling nodes for executing code compiling for the compiling request, wherein the compiling request comprises compiling preparation information of the functional module to be compiled; the physical compiling module is used for selecting a target dock mirror image matched with compiling preparation information from a preset dock mirror image library, and generating a container compiling environment by utilizing the target dock mirror image; the source code is used for acquiring a source code of the functional module to be compiled through a container compiling environment, a target programming language function channel matched with compiling preparation information is determined in a preset programming language database, the source code comprises a compiling configuration file, and the compiling configuration file comprises compiling configuration information; and the target programming language function channel is used for compiling the source code according to the compiling configuration information to generate a target code package.
In a third aspect, an embodiment of the present application provides an electronic device, including: a processor and a memory storing computer program instructions; the processor, when executing the computer program instructions, implements the code compilation method of the first aspect.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium having stored thereon computer program instructions that, when executed by a processor, implement the code compiling method of the first aspect.
The embodiment of the application provides a code compiling method, device, equipment and storage medium, wherein a physical compiling node allocated for compiling requests can select a target dock mirror image corresponding to a compiling environment required by a functional module to be compiled from dock mirror image libraries covering various compiling environments, the target dock mirror image is utilized to generate a container compiling environment consistent with the compiling environment required by the functional module to be compiled, a target programming language function channel corresponding to the programming language of the functional module to be compiled is determined in a programming language database covering various programming languages, and source codes of the functional module to be compiled comprise compiling configuration files, wherein the compiling configuration files comprise compiling configuration information. In a container compiling environment, determining a compiling mode of the programming language by utilizing a target programming language function channel, and compiling source codes according to the compiling mode and compiling configuration information to generate a target code package. The whole code compiling process supports multiple programming languages and multiple compiling environments, and compiling elements required by the compiling process can be provided by compiling configuration information by adopting a container technology, so that different types of compiling tasks can be automatically, accurately and quickly completed, special compiling personnel are not required to manually compile codes, and the code compiling efficiency is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments of the present application will be briefly described, and it is possible for a person skilled in the art to obtain other drawings according to these drawings without inventive effort.
FIG. 1 is a flowchart of a code compiling method according to an embodiment of the present application;
FIG. 2 is a flowchart of a code compiling method according to another embodiment of the present application;
FIG. 3 is a schematic diagram of an example of flow logic of a code compiling method according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a code compiling apparatus according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Features and exemplary embodiments of various aspects of the present application are described in detail below to make the objects, technical solutions and advantages of the present application more apparent, and to further describe the present application in conjunction with the accompanying drawings and the detailed embodiments. It should be understood that the specific embodiments described herein are intended to be illustrative of the application and are not intended to be limiting. It will be apparent to one skilled in the art that the present application may be practiced without some of these specific details. The following description of the embodiments is merely intended to provide a better understanding of the present application by showing examples of the present application.
Code compilation is a secondary production process that processes source code into object code. After the developer writes the source code of the functional module, a compiling manual is provided for a configuration manager, and the configuration manager manually writes a compiling script so as to compile the code. On one hand, configuration management personnel need to understand the compiling manual for the second time, and trial-and-error cost exists; on the other hand, code compiling may involve multiple factors such as programming language types and compiling environments, and the programming language types and compiling environments involved in code compiling of different functional modules may be different, and the difference may also result in a large trial and error cost, so that the code compiling efficiency is low, and the whole compiling process needs to be maintained by a large amount of manpower and time, and is easy to generate errors.
The utility model provides a code compiling method, device, equipment and storage medium, can preset a dock mirror image library, the dock mirror image library can cover a plurality of elements required by compiling, support a plurality of programming languages, select a corresponding dock mirror image according to compiling preparation information of a functional module to be compiled to generate a corresponding container compiling environment, determine a function channel of a programming language of the functional module to be compiled in a preset programming language database covering a plurality of programming languages, analyze a compiling configuration file in a source code to obtain compiling configuration information, compile the source code according to the compiling configuration information by utilizing the function channel of the determined programming language, and generate a target code package. The whole code compiling process supports multiple programming languages and multiple compiling environments, various compiling elements are configured through compiling configuration files by adopting a container technology, different types of compiling tasks can be automatically, accurately and rapidly completed, special compiling personnel are not needed to manually compile codes, and the efficiency and the accuracy of code compiling are improved.
The following describes a code compiling method, a device, equipment and a storage medium provided by the application.
The first aspect of the present application provides a code compiling method, which can be applied to a code compiling scene of any iteration. The code compiling method may be executed by a code compiling apparatus, device, system, platform, or the like, and is not limited thereto. Fig. 1 is a flowchart of a code compiling method according to an embodiment of the present application, as shown in fig. 1, the code compiling method may include steps S101 to S104.
In step S101, in response to the received compiling request, a physical compiling node that performs compiling of the code is allocated for the compiling request.
The compilation request includes compilation preparation information for the functional module to be compiled. The compilation request may be initiated by a source code developer. The functional module to be compiled may implement a certain function, which may be, but is not limited to, a certain part of the functions in the application. The compile preparation information may embody some compile attribute information of the functional module to be compiled, for example, the compile preparation information may characterize, but is not limited to, a compile environment type, a programming language type, a compile required component, and the like of the compile functional module.
A physical compilation node is a physical hardware node for code compilation. Each compiling request is allocated with a physical compiling node, and code compiling indicated by the compiling request is carried out in the allocated physical compiling node. Different compiling requests can be distributed to different physical compiling node processes, and can also be distributed to the same physical compiling node process.
In some examples, the physical compilation node may be allocated for compilation requests according to a load of the physical compilation node. The load information of the physical compiling node can be obtained under the condition that the compiling request is received; and distributing physical compiling nodes with load represented by load information smaller than a preset load threshold value to the compiling request. The load information of the physical compiling node may characterize the load of the physical compiling node. The preset load threshold is a threshold for determining whether the physical compiling node is overloaded. The load of the physical compiling node is larger than or equal to a preset load threshold, which means that the load of the physical compiling node is overweight, so that the compiling efficiency is reduced; the load of the physical compiling node is smaller than the preset load threshold, which means that the load of the physical compiling node is lighter or in an idle state, and the compiling efficiency can be ensured by using the physical compiling node. The compiling task indicated by the compiling request may be processed at any one of the physical compiling nodes whose load represented by the load information is less than a preset load threshold. The least loaded physical compiling node represented by the load information can be selected to process the compiling task indicated by the compiling request.
The available physical compiling nodes can be automatically selected to execute the compiling tasks according to the load information of the physical compiling nodes, so that dynamic allocation is realized, and the resource utilization rate of the physical compiling nodes can be improved.
In step S102, a target dock mirror image matched with the compiling preparation information is selected from a preset dock mirror image library through the allocated physical compiling node, and a container compiling environment is generated by using the target dock mirror image.
The preset dock mirror library comprises a plurality of dock mirrors, each dock mirror may correspond to one compiling environment, for example, the dock mirror library may comprise, but is not limited to, dock mirrors supporting the compiling environment upel1.1-x86_64, dock mirrors supporting the compiling environment centos7-x86_64, dock mirrors supporting the compiling environment upel1.2-aarch64, and the like. The preset dock mirror library can cover the compiling environment of technology development. The compiling preparation information can comprise compiling environment types, and a dock mirror image matched with the compiling environment types in the compiling preparation information is selected from a dock mirror image library, wherein the dock mirror image is the target dock mirror image. And the container compiling environment generated by utilizing the target dock mirror image is consistent with the compiling environment type in the compiling preparation information.
In some examples, the code compilation process requires component-assisted compilation, and it may be determined whether the component is required for code compilation of the functional module to be compiled by including the compilation-required component information in the compilation preparation information. In the case where the compilation preparation information includes compilation-required component information, a component injection container compilation environment indicated by the compilation-required component information may be downloaded from a preset component database. The component database may overlay components that may be needed in the compilation process. The components indicated by the component information required for compilation are injected into the container compilation environment so that the components may function when compiled in the container compilation environment.
In some examples, one physical compilation node may generate multiple container compilation environments for multiple compilation requests, with the multiple container compilation environments being isolated from each other. The compilation request may include a first compilation request and a second compilation request, the source code corresponding to the first compilation request being different from the source code corresponding to the second compilation request, and correspondingly, the generated container compilation environment includes a container compilation environment corresponding to the first compilation request and a container compilation environment corresponding to the second compilation request. The container compiling environment corresponding to the first compiling request and the container compiling environment corresponding to the second compiling request compile the respective corresponding source codes in parallel, and herein, two container compiling environments are not limited to one physical compiling node in parallel, and a greater number of container compiling environments may be parallel, that is, the compiling request may further include a third compiling request, a fourth compiling request, and the like, and correspondingly, the generated container compiling environment may further include a container compiling environment corresponding to the third compiling request, a container compiling environment corresponding to the fourth compiling request, and the like. One physical compiling node can parallel a plurality of code compiling processes, and a docker mirror image library can cover various compiling environments required by development and compiling, so that a plurality of different container compiling environments in one physical compiling node can run in parallel. Compared with the technical scheme that only one compiling environment is configured by one physical compiling node without adopting a container technology, the scheme can enable the one physical compiling node to compile codes under various compiling environments through the container technology, can reduce the deployment quantity of the physical compiling nodes, and saves a large amount of hardware resources. For example, at present, 12 physical compiling nodes can be used to support the compiling tasks of a plurality of application function modules of the development center 4800, and compared with the technical scheme that one physical compiling node is only configured with one compiling environment, the hardware input cost can be saved by about 90%.
In step S103, the source code of the functional module to be compiled is acquired through the container compiling environment, and the target programming language function channel matched with the compiling preparation information is determined in the preset programming language database.
After writing the source code, the source code may be stored into a source code database by a developer. The source code may have a source code tag and the source code note may indicate the location of the source code in the source code database. The source code tag may also be provided in the compilation request. In some examples, source code in the source code database corresponding to the source code tag may be cloned into the container compilation environment according to the source code tag such that the container compilation environment obtains the source code.
The source code includes a compiled configuration file, and the compiled configuration file includes compiled configuration information. The compiling configuration information can comprise compiling elements required by the compiling process, and the compiling configuration information is injected into a container compiling environment through a compiling configuration file carried by source codes so as to be compiled according to the compiling configuration information in a subsequent process. In some examples, the compilation configuration file may be implemented as a build. Json file, through which the compilation configuration information is uniformly managed.
The preset programming language database can comprise a plurality of programming language function channels, and the compiling mode of the programming language can be determined through the programming language function channels. The programming language database may cover programming languages that may be involved in the compilation process, such as, but not limited to, java, C, npm, go, dart, python, etc. The compiling preparation information may include programming language type information, and a programming language function channel matched with the programming language type represented by the compiling preparation information may be searched in the programming language database, where the programming language function channel is a target programming language function channel.
In step S104, the source code is compiled according to the compiling configuration information by using the target programming language function channel, and a target code package is generated.
The compiling configuration information comprises compiling elements required by the compiling process, and the source codes are compiled according to the compiling configuration information by utilizing the target programming language function channel, so that the target code package meeting the programming language requirement and the compiling requirement can be obtained. The whole compiling process flow is unified and automatic, and the compiling efficiency and the compiling accuracy are high.
In some examples, after generating the object code package, the physical compilation node may be controlled to release the operating resources occupied by the compilation source code. The running resources can comprise central processing unit (Central Processing Unit, CPU) resources and memory resources, so that the running resources can be put into other compiling tasks for use, the utilization rate of the running resources is improved, and the setting number of physical compiling nodes can be reduced as much as possible under the condition that a large number of compiling tasks exist, so that hardware resources are saved.
In this embodiment of the present application, a physical compiling node allocated for a compiling request may select a target dock image corresponding to a compiling environment required by a functional module to be compiled from a dock image library covering multiple compiling environments, generate a container compiling environment consistent with the compiling environment required by the functional module to be compiled using the target dock image, determine a target programming language function channel corresponding to a programming language of the functional module to be compiled in a programming language database covering multiple programming languages, where a source code of the functional module to be compiled includes a compiling configuration file, and the compiling configuration file includes compiling configuration information. In a container compiling environment, determining a compiling mode of the programming language by utilizing a target programming language function channel, and compiling source codes according to the compiling mode and compiling configuration information to generate a target code package. The whole code compiling process supports multiple programming languages and multiple compiling environments, and compiling elements required by the compiling process can be provided by compiling configuration information by adopting a container technology, so that different types of compiling tasks can be automatically, accurately and quickly completed, special compiling personnel are not required to manually compile codes, and the efficiency and the accuracy of code compiling are improved.
According to the code compiling method in the embodiment of the application, the corresponding functions can be refined and regulated according to different compiling languages and compiling realization functions, the functions are modularized to form constituent functions of the programming language function channels, compiling configuration information and the like, and the modularized functions are flexibly combined by combining different characteristics of development programming languages to form the programming language function channels, compiling configuration files and the like, so that high reusability of each function in the compiling process is realized. No matter the initial compiling is performed for the first time or the new iteration is performed by the modification of the subsequent compiling method, a developer does not need to provide a compiling manual any more, the compiling method can be built and adjusted by self according to the standard requirements of different languages, the compiling time cost is saved, the configuration error caused by the understanding deviation of the compiling manual read by the compiler is avoided, and the compiling accuracy is improved.
In some embodiments, after compiling the source code, processes such as packaging, publishing, backup and the like may also be performed. Fig. 2 is a flowchart of a code compiling method according to another embodiment of the present application, and fig. 2 is different from fig. 1 in that step S104 in fig. 1 may be specifically detailed as step S1041 and step S1042, and the code compiling method shown in fig. 2 may further include steps S105 to S108.
In step S1041, the source code is compiled according to the compiling configuration information by using the target programming language function channel, and the file generated by compiling is distributed in the target directory indicated by the compiling configuration information.
The compiling configuration information may include a target directory indicating a release position of the compiled file. After compiling the generated file, the compiled file can be automatically released in the target directory.
In some examples, the compile configuration information includes programming language version information, compiler version information, environment variable information, custom script information, compile command information, and catalog information. The programming language version information may characterize a version of the programming language. The compiler version may characterize the version of the compiler. The environment variable information may indicate a variable of the required container compilation environment. The custom script information may indicate the custom script, e.g., the custom script information may indicate the location of the custom script, and thus the custom script. The custom script information may include post-compilation execution script information and/or pre-compilation execution script information, which may be set according to a specific scenario, a requirement, etc., where the post-compilation execution script indicated by the post-compilation execution script information is executed after the execution of the compilation command, and the pre-compilation execution script indicated by the pre-compilation execution script information is executed before the execution of the compilation command. The compile command information is used to indicate a compile command. The directory information is used for indicating a target directory of file release generated by compiling. The compiling configuration information may further include a pom file information, where the pom file information may indicate a pom file, where the pom file is a file unique to Java in a programming language, that is, where the pom file is a file unique to Java when the functional module to be compiled is a Java module, for example, the pom file information may indicate a location of the pom file, thereby indicating that the pom file is a compiled entry.
For example, the following table-shows the contents of an example compiled configuration file:
list one
Information content Compiling configuration information
”jdk”:”jdk1.8” Programming language version information
”mvn”:”mvn3.6” Compiler version information
”pom”:”acct-acc-parent/pom.xml” Pom file information
”prescript”:”” Pre-compilation execution script information
”buildExec”:”mvn clean package–D Tests-P prod” Compiling command information
”script”:”customized.sh” Executing script information after compiling
”deployList”:[”deploy”,”install”,”etc”] Catalog information
As shown in Table one, "jdk" represents the programming language version, jdk1.8 in this example; "mvn" means the compiler version, in this example version mvn3.6; "pom" means the location of the pom file. The position of the pom file in the example is under the acct-acc-parent sub-directory of the main directory; "prescript" means a custom script reserved before the maven compile command is compiled and the location of the custom script, in this example, the custom script does not need to be executed before the maven compile command is compiled, so the prescript field is empty; "buildexc" means the set maven compile command; "script" means a custom script to be executed after the maven compile command is compiled and its location, in this example, the relevant script needs to be executed, so the script field specifies that the name of the custom script is custom. "deleyist" indicates a directory or file to be released after compiling is completed and its location, in this example, three directories whose release contents are deploy, install, etc are specified and all located under the master directory.
The programming language version and the compiler version of the container compiling environment can be set according to the programming language version information and the compiler version information; setting an environment variable of the compiling environment of the container according to the environment variable information; analyzing and executing the custom script indicated by the custom script information; analyzing and executing the compiling command indicated by the compiling command information to generate a file; and publishing the generated file to a target directory indicated by the directory information. And setting a language version and a compiler version of the container compiling environment through compiling the compiling configuration information in the configuration file, analyzing and executing the custom script and the compiling command, thereby completing the compiling link.
In step S1042, the target directory and the files compiled under the target directory are packaged and compressed to obtain the target code package.
The target code package is a code package obtained by packing and compressing files compiled and generated under the target directory. The object code package may be provided to a tester or an operator.
In step S105, the object code package is added to a preset object code database.
The object code database is used for storing compiled and packed code packages. Adding the object code package to the object code database after generating the object code package can facilitate subsequent operations on the object code package in the object code database.
In step S106, a trigger tag is added to the object code packet.
The object code package needs to store a file transfer protocol specification directory for provision to the operator. The object code package also needs to be provided to the tester for testing. The trigger tag characterizes the object code package that needs to be provided to both the operation and maintenance party and the testing party.
In step S107, in the case where an object code packet having a trigger tag is detected, the object code packet is stored in the file transfer protocol designation directory, and a test notification message is sent.
The detection of an object code package with a trigger tag in the object code database may determine that the object code package needs to be provided to both the operator and the tester, may trigger the act of storing the object code in a file transfer protocol (File Transfer Protocol, FTP) specified directory, and trigger the act of sending a test notification message. A test notification may be sent to the tester device, the test notification message being used to notify testing of the target code package so that the tester can test the target code package in time. In some examples, the test notification message may include a file transfer protocol specified directory such that the test party obtains the object code package from the file transfer protocol specified directory. The test notification message may be implemented as a mail, a short message, a system message, etc., and is not limited herein.
In step S108, the target code package is backed up to a preset backup location.
The preset backup locations may be implemented as folders or other forms. The object code package in the backup location has a compile time and a compile number. After compiling the target code package, backing up the target code package to a backup position, so that the target code package can be obtained from the backup position in any subsequent time period, and traceability and auditability of the compiling process of the target code package are realized.
According to the embodiment of the application, an advanced DevOps concept is introduced, compiling elements can be structured in a development stage and stored together with source codes, so that each compiling configuration is associated with the source codes, different versions can be compiled in a plurality of times under the condition that development can be automatically adjusted and modified according to requirements, each compiling can generate an object code package, and each compiling process can be subjected to version management through backup, so that traceability and auditability of the compiling process are realized.
The integrated management of the configuration files is realized by compiling configuration files to integrate elements such as programming language version, compiler version, custom script, unified compiling command, issuing catalog and the like, standardizing processes such as code cloning, compiling, warehousing, packaging, issuing, backup and the like. In the production and development process, each iteration can be performed according to the flow, so that the conditions of increased maintenance cost and increased error rate of the functional module caused by different compiling and configuring modes are avoided.
In some embodiments, in the process of compiling the code, compiling the connection may require configuring user sensitive information such as account numbers and password information, or recording the user sensitive information in a log, so that hidden danger of information security leakage exists. In order to avoid information security leakage, under the condition that compiling the source code needs to call the user sensitive information, the user sensitive information can be vouched to obtain the vouch information, and the vouch information is provided. The credential information no longer comprises user sensitive information, and plaintext of the user sensitive information cannot appear in the code or logs generated in the compiling process, so that information security is ensured.
For ease of understanding, the following describes flow logic of the code compiling method in the embodiment of the present application by way of illustration. Fig. 3 is a schematic diagram of an example of flow logic of a code compiling method according to an embodiment of the present application, as shown in fig. 3, a product developer 21 may perform unified management on iterations (such as iteration 1 to iteration 10) of a functional module, and in each iteration, a developer 211 may submit source code to a source code database 22. The preset dock mirror image library 23 stores mirrors of various operating systems, where the operating systems can be used as compiling environments, as shown in fig. 3, the operating systems corresponding to the mirrors 1 to 6 are different, each mirror image in the dock mirror image library 23 can generate a container compiling environment, and the mirrors 1 to 6 respectively correspond to the container compiling environments 1 to 6. The component database 24 may inject components into the container compilation environment when the compilation requires component assistance. Code cloning, compiling, packaging, publishing, backup and the like can be performed in a container compiling environment. After the above steps, the object code package 25 can be obtained.
A second aspect of the present application provides a code compiling apparatus. Fig. 4 is a schematic structural diagram of a code compiling apparatus according to an embodiment of the application, and as shown in fig. 4, the code compiling apparatus 300 may include an allocation module 301 and a physical compiling module 302.
The allocation module 301 may be configured to allocate a physical compiling node for performing code compiling for a compiling request in response to a received compiling request, the compiling request including compiling preparation information of a functional module to be compiled.
The physical compiling module 302 may be configured to select a target dock image matching with compiling preparation information from a preset dock image library, and generate a container compiling environment by using the target dock image; the source code can be used for acquiring a source code of the functional module to be compiled through a container compiling environment, a target programming language function channel matched with compiling preparation information is determined in a preset programming language database, the source code comprises a compiling configuration file, and the compiling configuration file comprises compiling configuration information; and the method can be used for compiling the source code according to the compiling configuration information by utilizing the target programming language function channel to generate a target code package.
In this embodiment of the present application, a physical compiling node allocated for a compiling request may select a target dock image corresponding to a compiling environment required by a functional module to be compiled from a dock image library covering multiple compiling environments, generate a container compiling environment consistent with the compiling environment required by the functional module to be compiled using the target dock image, determine a target programming language function channel corresponding to a programming language of the functional module to be compiled in a programming language database covering multiple programming languages, where a source code of the functional module to be compiled includes a compiling configuration file, and the compiling configuration file includes compiling configuration information. In a container compiling environment, determining a compiling mode of the programming language by utilizing a target programming language function channel, and compiling source codes according to the compiling mode and compiling configuration information to generate a target code package. The whole code compiling process supports multiple programming languages and multiple compiling environments, and compiling elements required by the compiling process can be provided by compiling configuration information by adopting a container technology, so that different types of compiling tasks can be automatically, accurately and quickly completed, special compiling personnel are not required to manually compile codes, and the efficiency and the accuracy of code compiling are improved.
In some embodiments, the physical compilation module 302 may be specifically configured to: compiling the source code according to the compiling configuration information by utilizing the target programming language function channel, and releasing the file generated by compiling in a target directory indicated by the compiling configuration information; and packaging and compressing the target directory and files compiled under the target directory to obtain the target code package.
In some examples, the compile configuration information includes programming language version information, compiler version information, environment variable information, custom script information, compile command information, and catalog information. The physical compilation module 302 may be specifically configured to: setting a programming language version and a compiler version of a container compiling environment according to the programming language version information and the compiler version information; setting an environment variable of the compiling environment of the container according to the environment variable information; analyzing and executing the custom script indicated by the custom script information; analyzing and executing the compiling command indicated by the compiling command information to generate a file; and publishing the generated file to a target directory indicated by the directory information.
In some examples, the compiling configuration information further includes a pom file information, which may indicate a pom file, which is a file specific to the programming language for Java, i.e., a file specific to the functional module to be compiled when the functional module is a Java module. The custom script information includes post-compilation execution script information and/or pre-compilation execution script information.
In some embodiments, the source code has a source code tag. The physical compilation module 302 may be specifically operable to: and cloning the source code corresponding to the source code label in the source code database to the container compiling environment according to the source code label.
In some embodiments, the physical compilation module 302 may also be configured to: adding the object code package into a preset object code database; adding a trigger tag to the object code package; and under the condition that the object code packet with the trigger label is detected, storing the object code packet into a file transfer protocol designated directory, and sending a test notification message, wherein the test notification message is used for notifying the test of the object code packet.
In some embodiments, the physical compilation module 302 may also be configured to: and backing up the target code package to a preset backup position, wherein the target code package under the backup position has compiling time and compiling numbers.
In some embodiments, the allocation module 301 may be specifically configured to: load information of the physical compiling module 302 is obtained; the load information is assigned to the compilation request to characterize a load less than a pre-set load threshold to the physical compilation module 302.
The physical compilation module 302 may also be configured to: and compiling the source code according to the compiling configuration information by utilizing the target programming language function channel to generate a target code packet, and then releasing the operation resources occupied by the compiling source code.
In some embodiments, the compilation requests include a first compilation request and a second compilation request, the container compilation environments include a container compilation environment corresponding to the first compilation request and a container compilation environment corresponding to the second compilation request, and the container compilation environment corresponding to the first compilation request and the container compilation environment corresponding to the second compilation request compile respective corresponding source code in parallel.
In some embodiments, the physical compilation module 302 may also be configured to: under the condition that compiling the source code needs to call the user sensitive information, the user sensitive information is vouchered to obtain the vouchered information, and the vouchered information is provided.
In some embodiments, the physical compilation module 302 may also be configured to: after the container compiling environment is generated by utilizing the target dock mirror image, in the case that compiling preparation information comprises compiling required component information, downloading a component indicated by the compiling required component information from a preset component database and injecting the component into the container compiling environment.
In some embodiments, the allocation module may be implemented as an allocation device, the physical compiling module may be implemented as a physical compiling node, and the code compiling device 300 may also be implemented by a code compiling system including the allocation device and a plurality of physical compiling nodes, and details of the disclosure may be referred to in the related description of the foregoing embodiments, which is not repeated herein.
The third aspect of the application also provides an electronic device. Fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 5, the electronic device 400 includes a memory 401, a processor 402, and a computer program stored on the memory 401 and executable on the processor 402.
In some examples, the processor 402 described above may include a Central Processing Unit (CPU), or an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), or may be configured to implement one or more integrated circuits of embodiments of the present application.
Memory 401 may include Read-Only Memory (ROM), random-access Memory (Random Access Memory, RAM), magnetic disk storage media devices, optical storage media devices, flash Memory devices, electrical, optical, or other physical/tangible Memory storage devices. Thus, in general, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software comprising computer-executable instructions and when the software is executed (e.g., by one or more processors) it is operable to perform the operations described with reference to the code compilation method in accordance with embodiments of the present application.
The processor 402 runs a computer program corresponding to the executable program code by reading the executable program code stored in the memory 401 for realizing the code compiling method in the above embodiment.
In some examples, electronic device 400 may also include communication interface 403 and bus 404. As shown in fig. 5, the memory 401, the processor 402, and the communication interface 403 are connected to each other by a bus 404 and perform communication with each other.
The communication interface 403 is mainly used to implement communication between each module, device, unit and/or apparatus in the embodiments of the present application. Input devices and/or output devices may also be accessed through communication interface 403.
Bus 404 includes hardware, software, or both, coupling the components of electronic device 400 to one another. By way of example, and not limitation, bus 404 may include an accelerated graphics port (Accelerated Graphics Port, AGP) or other graphics Bus, an enhanced industry standard architecture (Enhanced Industry Standard Architecture, EISA) Bus, a Front Side Bus (FSB), a HyperTransport (HT) interconnect, an industry standard architecture (Industry Standard Architecture, ISA) Bus, an Infiniband interconnect, a Low Pin Count (LPC) Bus, a memory Bus, a micro channel architecture (Micro Channel Architecture, MCa) Bus, a peripheral component interconnect (Peripheral Component Interconnect, PCI) Bus, a PCI-Express (PCI-E) Bus, a serial advanced technology attachment (Serial Advanced Technology Attachment, SATA) Bus, a video electronics standards association local (Video Electronics Standards Association Local Bus, VLB) Bus, or other suitable Bus, or a combination of two or more of these. Bus 404 may include one or more buses, where appropriate. Although embodiments of the present application describe and illustrate a particular bus, the present application contemplates any suitable bus or interconnect.
The fourth aspect of the present application further provides a computer readable storage medium, on which computer program instructions are stored, where the computer program instructions, when executed by a processor, may implement the code compiling method in the foregoing embodiments, and achieve the same technical effects, and in order to avoid repetition, are not described herein in detail. The computer readable storage medium may include a non-transitory computer readable storage medium, such as Read-Only Memory (ROM), random access Memory (Random Access Memory, RAM), magnetic disk or optical disk, and the like, but is not limited thereto.
The embodiments of the present application provide a computer program product, where when instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the code compiling method in the foregoing embodiments, and the same technical effects can be achieved, so that repetition is avoided, and no further description is given here.
It should be understood that, in the present specification, each embodiment is described in an incremental manner, and the same or similar parts between the embodiments are all referred to each other, and each embodiment is mainly described in a different point from other embodiments. For an apparatus embodiment, a device embodiment, a computer readable storage medium embodiment, a computer program product embodiment, the relevant points may be found in the description of method embodiments. The present application is not limited to the specific steps and structures described above and shown in the drawings. Those skilled in the art may, after appreciating the spirit of the present application, make various changes, modifications and additions, or change the order between steps. Also, a detailed description of known method techniques is omitted here for the sake of brevity.
Aspects of the present application are described above with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions/acts specified in the flowchart and/or block diagram block or blocks. Such a processor may be, but is not limited to being, a general purpose processor, a special purpose processor, an application specific processor, or a field programmable logic circuit. It will also be understood that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware which performs the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Those skilled in the art will appreciate that the above-described embodiments are exemplary and not limiting. The different technical features presented in the different embodiments may be combined to advantage. Other variations to the disclosed embodiments can be understood and effected by those skilled in the art in view of the drawings, the description, and the claims. In the claims, the term "comprising" does not exclude other means or steps; the word "a" does not exclude a plurality; the terms "first," "second," and the like, are used for designating a name and not for indicating any particular order. Any reference signs in the claims shall not be construed as limiting the scope. The functions of the various elements presented in the claims may be implemented by means of a single hardware or software module. The presence of certain features in different dependent claims does not imply that these features cannot be combined to advantage.

Claims (14)

1. A code compiling method, comprising:
responding to a received compiling request, distributing a physical compiling node for executing code compiling for the compiling request, wherein the compiling request comprises compiling preparation information of a functional module to be compiled;
selecting a target dock mirror image matched with the compiling preparation information from a preset dock mirror image library through an allocated physical compiling node, and generating a container compiling environment by using the target dock mirror image;
acquiring source codes of the functional modules to be compiled through the container compiling environment, and determining target programming language function channels matched with the compiling preparation information in a preset programming language database, wherein the source codes comprise compiling configuration files, and the compiling configuration files comprise compiling configuration information;
and compiling the source code according to the compiling configuration information by utilizing the target programming language function channel to generate a target code package.
2. The method of claim 1, wherein invoking the target programming language function channel, compiling the source code according to the compiling configuration information, generating a target code package, comprises:
Compiling the source code according to the compiling configuration information by utilizing the target programming language function channel, and publishing a file generated by compiling in a target directory indicated by the compiling configuration information;
and packaging and compressing the target directory and files compiled and generated under the target directory to obtain the target code package.
3. The method of claim 2, wherein the compiled configuration information includes programming language version information, compiler version information, environment variable information, custom script information, compilation command information, and catalog information,
compiling the source code according to the compiling configuration information, and publishing the file generated by compiling in a target directory indicated by the compiling configuration information, wherein the compiling comprises the following steps:
setting a programming language version and a compiler version of the container compiling environment according to the programming language version information and the compiler version information;
setting the environment variable of the compiling environment of the container according to the environment variable information;
analyzing and executing the custom script indicated by the custom script information;
analyzing and executing the compiling command indicated by the compiling command information to generate a file;
And publishing the generated file to the target directory indicated by the directory information.
4. The method of claim 3, wherein the compiled configuration information further comprises pom file information;
the custom script information includes post-compilation execution script information and/or pre-compilation execution script information.
5. The method of claim 1, wherein the source code has a source code tag,
the obtaining, by the container compiling environment, the source code of the functional module to be compiled includes:
and cloning source codes corresponding to the source code labels in a source code database to the container compiling environment according to the source code labels.
6. The method of claim 1, further comprising, after the generating the object code package:
adding the target code package to a preset target code database;
adding a trigger tag to the object code package;
and under the condition that the target code packet with the trigger tag is detected, storing the target code packet into a file transfer protocol designated directory, and sending a test notification message, wherein the test notification message is used for notifying the test of the target code packet.
7. The method as recited in claim 1, further comprising:
and backing up the target code package to a preset backup position, wherein the target code package under the backup position has compiling time and compiling numbers.
8. The method of claim 1, wherein the step of determining the position of the substrate comprises,
the allocating a physical compiling node for executing code compiling for the compiling request comprises the following steps:
load information of a physical compiling node is obtained;
distributing physical compiling nodes with the load represented by the load information smaller than a preset load threshold value for the compiling request;
after compiling the source code according to the compiling configuration information by using the target programming language function channel to generate a target code package, the method further comprises the following steps:
and controlling the physical compiling node to release the operation resources occupied by compiling the source codes.
9. The method of claim 1, wherein the compilation request comprises a first compilation request and a second compilation request, the container compilation environment comprises the container compilation environment corresponding to the first compilation request and the container compilation environment corresponding to the second compilation request, and the container compilation environment corresponding to the first compilation request and the container compilation environment corresponding to the second compilation request compile the respective source code in parallel.
10. The method as recited in claim 1, further comprising:
under the condition that compiling the source code needs to call the user sensitive information, the user sensitive information is vouchered to obtain the vouchered information, and the vouchered information is provided.
11. The method of claim 1, further comprising, after said generating a container compilation environment with said target dock image:
in the case that the compiling preparation information includes compiling required component information, downloading a component indicated by the compiling required component information from a preset component database and injecting the component into the container compiling environment.
12. A code compiling apparatus, comprising:
the distribution module is used for responding to the received compiling request and distributing physical compiling nodes for executing code compiling for the compiling request, wherein the compiling request comprises compiling preparation information of a functional module to be compiled;
the physical compiling module is used for selecting a target dock mirror image matched with the compiling preparation information from a preset dock mirror image library, and generating a container compiling environment by using the target dock mirror image; the source code is used for acquiring source codes of the functional modules to be compiled through the container compiling environment, a target programming language function channel matched with the compiling preparation information is determined in a preset programming language database, the source codes comprise compiling configuration files, and the compiling configuration files comprise compiling configuration information; and compiling the source code according to the compiling configuration information by utilizing the target programming language function channel to generate a target code package.
13. An electronic device, comprising: a processor and a memory storing computer program instructions;
the processor, when executing the computer program instructions, implements a code compiling method according to any one of claims 1 to 11.
14. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon computer program instructions, which when executed by a processor, implement the code compiling method according to any of claims 1 to 11.
CN202311182951.0A 2023-09-13 2023-09-13 Code compiling method, device, equipment and storage medium Pending CN117270864A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311182951.0A CN117270864A (en) 2023-09-13 2023-09-13 Code compiling method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311182951.0A CN117270864A (en) 2023-09-13 2023-09-13 Code compiling method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117270864A true CN117270864A (en) 2023-12-22

Family

ID=89209776

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311182951.0A Pending CN117270864A (en) 2023-09-13 2023-09-13 Code compiling method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117270864A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117472336A (en) * 2023-12-28 2024-01-30 芯瞳半导体技术(山东)有限公司 Code generating device based on program API, method, equipment and medium thereof

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117472336A (en) * 2023-12-28 2024-01-30 芯瞳半导体技术(山东)有限公司 Code generating device based on program API, method, equipment and medium thereof
CN117472336B (en) * 2023-12-28 2024-04-12 芯瞳半导体技术(山东)有限公司 Code generating device based on program API, method, equipment and medium thereof

Similar Documents

Publication Publication Date Title
CN110187914B (en) Application development method, system and device
CN110704061B (en) Running method and device for deploying and delivering payment pieces based on micro-services
CN108319460B (en) Method and device for generating application program installation package, electronic equipment and storage medium
CN109725911A (en) A kind of multi-environment project dispositions method, device, storage medium and processor
WO2022016848A1 (en) Method and apparatus for performing application deployment according to service role
US20200310789A1 (en) Method for creating hyperledger fabric network, controller and storage medium
US11113050B2 (en) Application architecture generation
US20100241904A1 (en) Model-based testing of an application program under test
CN111399840B (en) Module development method and device
CN117270864A (en) Code compiling method, device, equipment and storage medium
CN108733553A (en) Configuration method, the device and system of test device based on docker
CN112114896A (en) Plug-in framework and method for service function expansion
CN111949513A (en) Configuration file loading method and device, electronic equipment and readable storage device
CN112579099A (en) Code deployment method and device, storage medium and electronic equipment
CN114327484A (en) Multi-architecture supporting K8S integration and deployment method, system and storage medium
CN112748905B (en) Method and device for initializing and calling basic library, electronic equipment and storage medium
CN112230918A (en) Web end development method using iframe embedded webpage
CN116382694A (en) Method for improving compiling speed of Maven engineering in container environment
CN110806891A (en) Method and device for generating software version of embedded equipment
CN114791884A (en) Test environment construction method and device, storage medium and electronic equipment
CN114201174A (en) Construction method and device of hybrid mobile application, electronic equipment and storage medium
CN112052035B (en) Version group package method and device based on bank back line system
CN113934405A (en) Plug-in processing method, device, equipment, storage medium and computer program product
CN112667491A (en) Function test method and device of virtual machine
CN112559444A (en) SQL (structured query language) file migration method and device, storage medium and equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination