Distributed compiling method and device, electronic equipment and storage medium

By creating pseudo-files on the client to store the target files in the compilation results, the problem of high and low network load during the distributed compilation process is solved, and the effect of reducing network load and improving compilation efficiency is achieved.

CN119473308AActive Publication Date: 2025-02-18INST OF SOFTWARE - CHINESE ACAD OF SCI

Patent Information

Application Number
CN202510053148.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-14
Publication Date
2025-02-18
Estimated Expiration
2045-01-14

AI Technical Summary

Technical Problem

In the prior art, the problem of high network load and low efficiency during distributed compilation.

Method used

By creating a pseudo-file on the client, the pseudo-file contains the reconstruction method of the target file in the compilation result, avoiding the copying of the intermediate file between the client and the server, and directly performing file link operations on the server.

Benefits of technology

It effectively reduces the network load required for file transfer and improves the efficiency of distributed compilation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473308A_ABST
    Figure CN119473308A_ABST
Patent Text Reader

Abstract

The invention provides a distributed compiling method and device, electronic equipment and a storage medium, and belongs to the technical field of data processing.The method comprises the steps that a source code file is sent to a server side to be compiled and assembled, a compiling result returned by the server side is obtained, and the compiling result comprises information of a compiled target file; based on the compiling result, a corresponding pseudo file is created, and the pseudo file comprises a rebuilding method of the compiling result file; after pseudo files corresponding to all the compiling results are obtained, a link command is sent to a server side, and the link command indicates the server side to conduct file link operation on all the target files; and receiving the executable file returned by the server. According to the method and the device, the intermediate file is prevented from being copied for multiple times between the client and the server, so that the network load required by file transmission is reduced, and the distributed compiling efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a distributed compilation method, device, electronic device and storage medium. Background Art

[0002] Compilation is the process of using a compiler to translate a source program written in a source language into a binary language that can be recognized by a computer. The compilation process is mainly divided into four steps: preprocessing, compilation, assembly, and linking. Preprocessing is to process the preprocessing instructions in the source code, such as expanding header files, replacing macro definitions, deleting comments, etc., to obtain a preprocessed source code file in .i format; compilation is to perform a series of operations such as lexical analysis, syntax analysis, and semantic analysis on the preprocessed source code, generate intermediate code, and then convert it into assembly code to obtain an assembly file in .s format; assembly is to translate the assembly code into machine code to obtain a target file in .o format; linking is to merge multiple target files and possible library files together to generate the final executable file. When compiling large software, due to the insufficient performance of a single machine, it is often necessary to call multiple machines in parallel. In the current distributed compilation system, it is possible to distribute some steps to remote machines for operation, and send the compilation results back to the local machine for further processing.

[0003] Figure 1 It is a flow chart of the distributed compilation method in the prior art, such as Figure 1 As shown in the figure, the client is the machine responsible for coordinating work and proposing task requirements; the server is the machine responsible for the actual compilation process. The client sends the source code file to be compiled to the server. After the server completes the compilation and assembly, it returns the intermediate results (target files) to the client to help the client coordinate work. When the file is linked, the client sends these target files to the server to complete the file link operation. This method causes the intermediate files to be copied multiple times between the client and the server, increasing the network load and reducing the efficiency of distributed compilation.

[0004] Therefore, how to reduce the network load in the distributed compilation process and improve the efficiency of distributed compilation has become a technical problem that needs to be solved urgently. Summary of the invention

[0005] The present invention provides a distributed compilation method, device, electronic device and storage medium, which are used to solve the defects of high network load and low efficiency in the distributed compilation process in the prior art.

[0006] The present invention provides a distributed compilation method, which is applied to a client and includes the following steps: Sending the source code file to the server for compilation and assembly processing, obtaining a compilation result returned by the server, wherein the compilation result includes information of the compiled target file; Based on the compilation result, creating a pseudo file corresponding to the compilation result, wherein the pseudo file includes a method for reconstructing a target file obtained by the compilation result; After obtaining the pseudo files corresponding to all the compilation results, sending a link command to the server, wherein the link command is used to instruct the server to perform a file link operation on the target files corresponding to the compilation results; Receive the executable file returned by the server.

[0007] According to a distributed compilation method provided by the present invention, after creating a pseudo file corresponding to the compilation result based on the compilation result, the method further includes: After receiving a first calling instruction for the pseudo file, the following steps are performed, wherein the first calling instruction is an instruction for instructing to open a specified file in a specified manner: If the first calling instruction indicates to open the pseudo file in a first manner, then after the real target file is restored based on the reconstruction method in the pseudo file, the real target file is opened in the first manner, wherein the first manner refers to writing in a manner required by the write operation when performing a write operation after opening the designated file; If the first calling instruction instructs to open the pseudo file in a second manner, after restoring the real target file based on the reconstruction method in the pseudo file, the real target file is opened in the second manner, wherein the second manner is to create a new file when opening the designated file if the designated file does not exist; If the first calling instruction indicates to open the pseudo file in a third way, an error message is returned, wherein the third way is to call the directory file if the designated file is a directory file, otherwise an error message is returned; If the first calling instruction indicates to open the pseudo file in a fourth manner, the pseudo file is deleted, a new real target file is created, and then the real target file is opened. The fourth manner is to truncate the length of the specified file to zero bytes when opening the specified file.

[0008] According to a distributed compilation method provided by the present invention, after creating a pseudo file corresponding to the compilation result based on the compilation result, the method further includes: After receiving the second call instruction for the pseudo file, returning the status information of the pseudo file, the status information including the file type, creation time, access time, modification time, file size and user information; Among them, the second calling instruction is an instruction for obtaining status information of a specified file, the file type is a common file, the file size is the file size of a target file corresponding to the pseudo file, and the user information is user information of the target file corresponding to the pseudo file.

[0009] According to a distributed compilation method provided by the present invention, after creating a pseudo file corresponding to the compilation result based on the compilation result, the method further includes: After receiving the third calling instruction for the pseudo file, the following steps are performed, wherein the third calling instruction is an instruction for instructing to set the size of the specified file to a specified value: If the specified value is zero, an empty real target file is created after deleting the pseudo file; If the specified value is not zero, after the real target file is restored based on the reconstruction method in the pseudo file, the real target file is truncated or extended.

[0010] According to a distributed compilation method provided by the present invention, the sending of a link command to the server includes: If the real target file corresponding to the compilation result is not stored, sending the link command to the server; If a real target file corresponding to any one of all the compilation results is stored, the real target file and the link command are sent to the server, so that the server performs a file link operation based on the real target file.

[0011] The present invention also provides a distributed compilation method, which is applied to a server and comprises the following steps: After receiving the source code file sent by the client, compile and assemble the source code file to obtain and store the target file compiled and assembled based on the source code file; After receiving the link command sent by the client, performing a file link operation on the corresponding target file to obtain an executable file; The executable file is returned to the client.

[0012] The present invention also provides a distributed compilation device, comprising the following modules: A file sending module is used to send the source code file to the server for compilation and assembly processing to obtain the compilation result returned by the server, wherein the compilation result includes information of the compiled target file; a pseudo-file creating module is used to create a pseudo-file corresponding to the compilation result based on the compilation result, wherein the pseudo-file includes a reconstruction method of the compiled target file; a command sending module is used to send a link command to the server after obtaining the pseudo-files corresponding to all the compilation results, wherein the link command is used to instruct the server to perform a file link operation on the target files corresponding to all the compilation results; a receiving module is used to receive the executable file returned by the server; or, the following modules are included: The compiling module is used to: after receiving the source code file sent by the client, compile and assemble the source code file to obtain and store the target file compiled and assembled based on the source code file; the linking module is used to: after receiving the linking command sent by the client, perform a file linking operation on the corresponding target file to obtain an executable file; the sending module is used to: return the executable file to the client.

[0013] 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 computer program, any of the above-mentioned distributed compilation methods is implemented.

[0014] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the distributed compilation method described in any one of the above is implemented.

[0015] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the distributed compilation method described above is implemented.

[0016] The distributed compilation method, device, electronic device and storage medium provided by the present invention send the source code file to the server for compilation and assembly processing, obtain the compilation result returned by the server, the compilation result includes the information of the target file obtained by compiling and assembling the source code file; based on the compilation result, create a pseudo file corresponding to the target file of the compilation result, the pseudo file includes the reconstruction method of the target file corresponding to the compilation result; after obtaining the pseudo files of the target files corresponding to all the compilation results, send a link command to the server, the link command is used to instruct the server to perform a file link operation on the target files corresponding to all the compilation results; receive the executable file returned by the server. In general, the client only needs to know whether the intermediate file exists, and the time, size and other information of these intermediate files to complete the coordination work, and the client does not need to actually read the file content. Therefore, the present invention creates a file type of pseudo file. In the distributed compilation process, the client receives the information of the target file sent by the server and generates a pseudo file, so that scheduling and coordination can be performed without transmitting the entire real target file, avoiding multiple copies of the intermediate file between the client and the server, effectively reducing the network load required for file transmission, and improving the efficiency of distributed compilation. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] 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.

[0018] Figure 1 It is a flow chart of a distributed compilation method in the prior art; Figure 2 This is one of the flow charts of the distributed compilation method provided by the present invention; Figure 3 This is the second flow chart of the distributed compilation method provided by the present invention; Figure 4 It is a schematic diagram of the calling process of the pseudo file by the operating system provided by the present invention; Figure 5 This is the third flow chart of the distributed compilation method provided by the present invention; Figure 6 It is one of the structural schematic diagrams of the distributed compilation device provided by the present invention; Figure 7 This is the second structural diagram of the distributed compilation device provided by the present invention; Figure 8It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0019] 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.

[0020] It should be noted that in the description of the embodiments of the present invention, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "include one..." do not exclude the existence of other identical elements in the process, method, article or device including the elements. The orientation or position relationship indicated by the terms "upper", "lower" and the like is based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention. Unless otherwise clearly specified and limited, the terms "installed", "connected" and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be directly connected, or indirectly connected through an intermediate medium, or it can be a connection between two elements. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0021] The terms "first", "second", etc. in the present invention are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present invention can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of the same type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" means at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0022] Combine the following Figure 2-Figure 8 The distributed compilation method, device, electronic device and storage medium provided by the embodiments of the present invention are described.

[0023] Figure 2 This is one of the flow charts of the distributed compilation method provided by the present invention, such as Figure 2 As shown, the distributed compilation method is applied to the client, and the method may include the following steps: S210, sending the source code file to the server for compilation and assembly processing, and obtaining a compilation result returned by the server, wherein the compilation result includes information of the compiled target file; S220, based on the compilation result, creating a pseudo file corresponding to the compilation result, wherein the pseudo file includes a method for reconstructing the target file obtained by the compilation; S230, after acquiring the pseudo files corresponding to all the compilation results, sending a link command to the server, wherein the link command is used to instruct the server to perform a file link operation on the target files corresponding to all the compilation results; S240, receiving the executable file returned by the server.

[0024] It should be noted that the execution subject of the distributed compilation method provided in the embodiment of the present invention can be a server, a computer device, such as a tablet computer, a laptop computer, a PDA, an ultra-mobile personal computer (UMPC), a netbook, etc.

[0025] In S210, the information of the target file may include but is not limited to the hash value, file time, file size and other information of the target file; wherein the hash value of the file is a string of fixed length generated by processing the file content through a specific algorithm (such as a hash function), and this string of characters can be regarded as the "fingerprint" of the file, which is used to verify the integrity and uniqueness of the file; the file time may include but is not limited to the creation time of the file.

[0026] In some embodiments, the client directly sends the source code file to the server, and the server preprocesses, compiles and assembles the source code file.

[0027] In other embodiments, what the client sends to the server is a preprocessed source code file, and the server only needs to compile and assemble the received file.

[0028] In S210, the client sends the source code file to the server, and the server compiles and assembles the source code file to obtain a target file with a .o suffix, and then returns information of the target file, that is, the compilation result, to the client.

[0029] It is understandable that a source code file may be compiled multiple times using different compilers and multiple combinations of compilation options. Here, the compilation result is information about a target file obtained by compiling a specified source code file using a specified compiler and compilation options.

[0030] In S220, after obtaining the compilation result corresponding to the source code file, the client creates a corresponding pseudo file according to the compilation result. The pseudo file stores the hash value, file time, file size and other information of the real target file, and also stores the method for rebuilding the real target file to ensure that the real target file can be restored when the client needs to use the target file.

[0031] In an embodiment of the present invention, a pseudo file exists on the disk and corresponds to another real file (target file), and the corresponding file can be rebuilt in a specified manner. Pseudo files are a new type of file, so they need to be specially processed at the operating system level: when trying to read the file content, the operating system is responsible for restoring the pseudo file to a real file through one or more operations, such as downloading, while retaining the file's time information, etc.; when restoring the file, the stored file hash value is used as a reference to require or require that the hash value of the restored result file matches the stored hash value; the deletion operation of the pseudo file is consistent with that of an ordinary file, that is, when deleting a file, the pseudo file is directly deleted; if other files are used to overwrite the pseudo file, they are directly overwritten.

[0032] In the embodiment of the present invention, the method for reconstructing the pseudo file may include but is not limited to downloading through the network or generating through a local specific method. When the pseudo file reconstruction method adopts the network download method, the pseudo file stores the network address for downloading the real target file; when the pseudo file reconstruction method adopts the local specific method for generating, the pseudo file stores the commands and parameters required to generate the real target file.

[0033] In S230 , after determining that all pseudo files already exist, the client sends a link command to the server, instructing the server to perform a file link on the corresponding target file.

[0034] It is understandable that the link command contains information such as the hash value and file name of the file to be linked.

[0035] In S240, the server uses the stored target file to link and generate an executable file according to the link command notified by the client, and then returns it to the client.

[0036] Optionally, after obtaining the executable file, the client deletes the corresponding pseudo file to release cache resources.

[0037] Figure 3This is the second flow chart of the distributed compilation method provided by the present invention, such as Figure 3 As shown, the process of the distributed compilation method provided by the present invention is described below by taking the need to compile two source code files 1.c and 2.c as an example.

[0038] like Figure 3 As shown, taking C language as an example, the client sends two source code files 1.c and 2.c to the server, and the server compiles and assembles them to obtain two target files 1.o and 2.o, and saves the two target files in the local cache; The server informs the client through the network that the compilation is complete, and the client obtains information about the two target files, including file size, file hash value, file time, etc. This information is usually no larger than 1000 bytes (1KB), while the actual target file is usually millions of bytes (several MB) to hundreds of millions of bytes (hundreds of MB); The client creates pseudo files 1.o and 2.o based on the compilation results received from the server; The client finds that 1.o and 2.o are both ready, and determines that 1.o and 2.o are both local pseudo files. There is no need to send the target file to the server, but only needs to send the link command to the server; After receiving the link command, the server takes out the two target files 1.o and 2.o from the local cache, links the two target files 1.o and 2.o into an executable program a.exe according to the link command, and returns a.exe to the client; After receiving the executable file a.exe returned by the server, the client can delete the pseudo file 1.o and the pseudo file 2.o.

[0039] It should be noted that although Figure 3 The process shown in the figure is that the client first sends 1.c to the server, and then sends 2.c to the server after obtaining 1.o returned by the server. However, in the actual implementation process, there is no strict time limit for sending source code files and receiving compilation results. For example, the client can send multiple source code files to the server at one time, and then obtain multiple compilation results returned by the server; the client can also send part of the source code files to the server first, and after obtaining the compilation results returned by the server, send another part of the source code files to the server.

[0040] The distributed compilation method provided by the embodiment of the present invention sends the source code file to the server for compilation and assembly processing, obtains the compilation result returned by the server, and the compilation result includes the information of the target file obtained by the compilation; based on the compilation result, creates a pseudo file corresponding to the compilation result, and the pseudo file includes the compilation result and the reconstruction method of the target file; after obtaining the pseudo files corresponding to all the compilation results, sends a link command to the server, and the link command is used to instruct the server to perform a file link operation on the target files corresponding to all the compilation results; and receives the executable file returned by the server. In general, the client only needs to know whether the intermediate file exists, and the time, size and other information of these intermediate files to complete the coordination work, and the client does not need to actually read the file content. Therefore, the present invention creates a file type of pseudo file. In the distributed compilation process, the client receives the information of the target file sent by the server and generates a pseudo file, thereby scheduling and coordinating without transmitting the entire real target file, avoiding multiple copies of the intermediate file between the client and the server, effectively reducing the network load required for file transmission, and improving the efficiency of distributed compilation.

[0041] In an optional embodiment, after creating a pseudo file corresponding to the compilation result based on the compilation result, the method further includes: After receiving a first calling instruction for the pseudo file, the following steps are performed, wherein the first calling instruction is an instruction for instructing to open a specified file in a specified manner: If the first calling instruction indicates to open the pseudo file in a first manner, then after the real target file is restored based on the reconstruction method in the pseudo file, the real target file is opened in the first manner, wherein the first manner refers to writing in a manner required by the write operation when performing a write operation after opening the designated file; If the first calling instruction instructs to open the pseudo file in a second manner, after restoring the real target file based on the reconstruction method in the pseudo file, the real target file is opened in the second manner, wherein the second manner is to create a new file when opening the designated file if the designated file does not exist; If the first calling instruction indicates to open the pseudo file in a third way, an error message is returned, wherein the third way is to call the directory file if the designated file is a directory file, otherwise an error message is returned; If the first calling instruction indicates to open the pseudo file in a fourth manner, the pseudo file is deleted, a new real target file is created, and then the real target file is opened. The fourth manner is to truncate the length of the specified file to zero bytes when opening the specified file.

[0042] In the embodiment of the present invention, the manner of the write operation requirement may include but is not limited to appending content to the end of the specified file, inserting content into the specified file, replacing content in the specified file, and the like.

[0043] In the embodiment of the present invention, the first call instruction is an open system call, which is used to open or create a file. When the open system call is performed on a pseudo file, different modifications are performed for different modes in the open system call: 1) The first mode is O_APPEND mode. When the O_APPEND flag is set, the kernel automatically moves the file pointer to the end of the file before each write operation to ensure that all newly written data is appended to the existing content.

[0044] In the embodiment of the present invention, the O_APPEND mode is processed as read, that is, after the real file is restored, it is opened according to the requirements of open.

[0045] 2) The second mode is O_CREAT mode. The O_CREAT flag indicates that if the file under the specified path does not exist, try to create the file.

[0046] In the embodiment of the present invention, the O_CREAT mode is processed according to the reading, that is, after the real file is restored, it is opened according to the requirements of open.

[0047] 3) The third mode is O_DIRECTORY mode. The O_DIRECTORY flag is used to ensure that the provided path points to a directory rather than a regular file. If the path is not a directory, the open() call will fail and return the corresponding error code.

[0048] In the embodiment of the present invention, for the O_DIRECTORY mode, an error is reported according to the common file type, that is, the real file is not allowed to be a directory (folder).

[0049] 4) The fourth mode is O_TRUNC mode. The function of the O_TRUNC flag is to truncate the length of an existing file to zero bytes when opening it. That is to say, once this flag is set and the file is successfully opened, the original content in the file will be cleared.

[0050] In the embodiment of the present invention, for the O_TRUNC mode, the pseudo file is directly deleted, and a new ordinary file is created and opened as required.

[0051] In an optional embodiment, if the hash value of the restored file does not match the hash value stored in the pseudo file when restoring the file, corresponding measures can be taken according to the configuration information, such as the following measures can be taken according to the configuration: directly report an error, or retry recovery / creation, or accept different file contents, or take other related measures.

[0052] The distributed compilation method provided by the embodiment of the present invention modifies the opening mode of the pseudo file to ensure the normal reading of the pseudo file content.

[0053] In an optional embodiment, after creating a pseudo file corresponding to the compilation result based on the compilation result, the method further includes: After receiving the second call instruction for the pseudo file, returning the status information of the pseudo file, the status information including the file type, creation time, access time, modification time, file size and user information; Among them, the second calling instruction is an instruction for obtaining status information of a specified file, the file type is a common file, the file size is the file size of a target file corresponding to the pseudo file, and the user information is user information of the target file corresponding to the pseudo file.

[0054] In the embodiment of the present invention, the second call instruction is a stat system call, which is used to obtain file or file system object status information. When the stat system call is performed on the pseudo file, the corresponding fields return the following information respectively: 1) The file type is returned as a normal file; 2) Creation time, access time, and modification time return the creation time, access time, and modification time of the record respectively; 3) File size, returns the file size of the actual target file recorded; 4) User information, returns the user information of the real target file.

[0055] The distributed compilation method provided by the embodiment of the present invention modifies the state acquisition method of the pseudo file to ensure that the state information of the pseudo file is normally acquired for the pseudo file.

[0056] In an optional embodiment, after creating a pseudo file corresponding to the compilation result based on the compilation result, the method further includes: After receiving the third calling instruction for the pseudo file, the following steps are performed, wherein the third calling instruction is an instruction for instructing to set the size of the specified file to a specified value: If the specified value is zero, an empty real target file is created after deleting the pseudo file; If the specified value is not zero, after the real target file is restored based on the reconstruction method in the pseudo file, the real target file is truncated or extended.

[0057] In the embodiment of the present invention, the third call instruction is the truncate series system call instruction. The truncate series system call is a set of tools for adjusting the file size, which allows a program to truncate a file to a specified length. When the truncate system call is performed on a pseudo file, different methods are used based on the truncation length: 1) When the specified value is zero, that is, the truncation length is 0, the existing pseudo-file is directly deleted, and a new empty file is created; or the pseudo-file is converted into a normal file inside the operating system and its content is cleared, and the length is set to zero; 2) When the specified value is not zero, that is, when the truncation length is another length, the file content is restored first, and then the restored file is truncated or extended according to the specified value.

[0058] Figure 4 It is a schematic diagram of the calling process of the pseudo file provided by the operating system of the present invention, such as Figure 4 As shown, after opening a file, first determine whether the file is a pseudo file. If it is not a pseudo file, directly open the file as a normal file and truncate it; If it is a pseudo file, determine whether it is truncated to 0. If it is truncated to 0, delete the pseudo file directly and create a new empty file; If the truncation value is not 0, the hash value, file time, reconstruction method and other information in the pseudo file are read, and the real target file is reconstructed based on this information and the pseudo file is deleted. Then, the real target file is opened and truncated as a normal file.

[0059] The distributed compilation method provided by the embodiment of the present invention modifies the truncation method of the pseudo file to ensure that the pseudo file is truncate normally.

[0060] It should be noted that other system calls related to files are processed in the same way as ordinary files.

[0061] In an optional embodiment, sending a link command to the server includes: If the real target file corresponding to the compilation result is not stored, sending the link command to the server; If a real target file corresponding to any one of all the compilation results is stored, the real target file and the link command are sent to the server, so that the server performs a file link operation based on the real target file.

[0062] Specifically, when the client needs to read or modify the content of the target file corresponding to the pseudo file, the pseudo file is restored to obtain the real target file, and the pseudo file is overwritten with the real target file before reading or modifying it. The compilation system on the client determines that all pseudo files / target files are ready and starts to perform the link operation. The linker informs the server of the required command, file name and corresponding hash value. If the linker finds that the file to be linked is not a pseudo file but a real target file, the real target file is sent to the server together, so that the server uses the real target file received from the client for linking, instead of using the target file previously cached, thereby ensuring that after the client modifies the target file, the modified file is used to complete the link operation.

[0063] like Figure 3 As shown in the figure, still taking the example of the client sending two source code files 1.c and 2.c to the server, after the client receives the compilation result returned by the server and generates pseudo files 1.o and 2.o, if the client needs to read or modify the content of 1.o or 2.o, it will download it to the local computer to overwrite the pseudo file, and then read or modify it; The software compilation system on the client sees that both 1.o and 2.o already exist, and starts to perform the link operation: the linker informs the server of the required command, file name, and corresponding hash value. If the linker finds that 1.o or 2.o is not a pseudo file, it sends it to the server together; The server takes out the relevant target files 1.o and 2.o from the cache according to the file name and hash value notified by the client; if the server receives the 1.o or 2.o file sent by the client, it uses the received file for linking instead of the file in the cache; The server uses 1.o and 2.o according to the command line informed by the client, links and generates the executable program a.exe, and sends it to the client.

[0064] The distributed compilation method provided by the embodiment of the present invention avoids multiple copies of intermediate files between the client and the server. When other programs modify the intermediate files, the modified files can still be sent to the server, ensuring that the server uses the modified target files to generate the correct executable files.

[0065] The following describes the distributed compilation method of the server provided by the embodiment of the present invention.

[0066] Figure 5 This is the third flow chart of the distributed compilation method provided by the present invention, such as Figure 5 As shown, the distributed compilation method may include: S510, after receiving the source code file sent by the client, compile and assemble the source code file to obtain and store a target file compiled and assembled based on the source code file; S520, after receiving the link command sent by the client, performing a file link operation on the corresponding target file to obtain an executable file; S530: Return the executable file to the client.

[0067] According to the distributed compilation method provided by the embodiment of the present invention, after the server compiles and assembles the source code file to obtain the target file, the server stores the target file locally, and after receiving the link command sent by the client, directly uses the local target file for linking without obtaining the target file from the client, thereby avoiding multiple copying of intermediate files between the client and the server, reducing network load, and improving file compilation efficiency.

[0068] It should be noted that the distributed compilation method on the server provided in the embodiment of the present invention and the distributed compilation method on the client described above can refer to each other, and the specific implementation methods are not described in detail here.

[0069] The following describes a distributed compiling device provided by an embodiment of the present invention. The distributed compiling device described below and the distributed compiling method described above can refer to each other.

[0070] Figure 6 is one of the structural diagrams of the distributed compilation device provided by the present invention, such as Figure 6 As shown, the distributed compilation device may include but is not limited to: The file sending module 610 is used to send the source code file to the server for compilation and assembly processing, and obtain the compilation result returned by the server, wherein the compilation result includes information of the compiled target file; The pseudo file creation module 620 is used to: create a pseudo file corresponding to the compilation result based on the compilation result, wherein the pseudo file includes a method for reconstructing the target file obtained by the compilation; The command sending module 630 is used to: after acquiring the pseudo files corresponding to all the compilation results, send a link command to the server, wherein the link command is used to instruct the server to perform a file link operation on the target files corresponding to all the compilation results; The receiving module 640 is used to receive the executable file returned by the server.

[0071] It should be noted that the distributed compilation device provided in the embodiment of the present invention can execute the distributed compilation method of the client described in any of the above embodiments during specific operation, which will not be described in detail in this embodiment.

[0072] Figure 7 This is the second structural diagram of the distributed compilation device provided by the present invention. Figure 7 As shown, the distributed compilation device may include but is not limited to: The compiling module 710 is used to: after receiving the source code file sent by the client, compile and assemble the source code file, obtain and store the target file compiled and assembled based on the source code file; The link module 720 is used to: after receiving the link command sent by the client, perform a file link operation on the corresponding target file to obtain an executable file; The sending module 730 is used to return the executable file to the client.

[0073] It should be noted that the distributed compilation device provided in the embodiment of the present invention can execute the distributed compilation method of the server side described in any of the above embodiments during specific operation, which will not be described in detail in this embodiment.

[0074] Figure 8 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 8 As shown, the electronic device may include: a processor 810, a communication interface 820, a memory 830 and a communication bus 840, wherein the processor 810, the communication interface 820 and the memory 830 communicate with each other through the communication bus 840. The processor 810 may call the logic instructions in the memory 830 to execute the distributed compilation method, which includes: sending the source code file to the server for compilation and assembly processing, obtaining the compilation result returned by the server, the compilation result including the information of the compiled target file; based on the compilation result, creating a pseudo file corresponding to the compilation result, the pseudo file including the reconstruction method of the compiled target file; after obtaining the pseudo files corresponding to all the compilation results, sending a link command to the server, the link command is used to instruct the server to perform a file link operation on the target files corresponding to all the compilation results; receiving the executable file returned by the server; or, including: After receiving the source code file sent by the client, compile and assemble the source code file to obtain and store the target file compiled and assembled based on the source code file; after receiving the link command sent by the client, perform a file link operation on the corresponding target file to obtain an executable file; and return the executable file to the client.

[0075] In addition, the logic instructions in the above-mentioned memory 830 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 this understanding, the technical solution of the present invention is essentially 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 to enable 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.

[0076] On the other hand, the present invention further provides a computer program product, the computer program product includes a computer program, the computer program can be stored on a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the distributed compilation method provided by the above methods, the method includes: sending a source code file to a server for compilation and assembly processing, obtaining a compilation result returned by the server, the compilation result including information of a compiled target file; based on the compilation result, creating a pseudo file corresponding to the compilation result, the pseudo file including a reconstruction method of the compiled target file; after obtaining the pseudo files corresponding to all the compilation results, sending a link command to the server, the link command is used to instruct the server to perform a file link operation on the target files corresponding to all the compilation results; receiving an executable file returned by the server; or, including: After receiving the source code file sent by the client, compile and assemble the source code file to obtain and store the target file compiled and assembled based on the source code file; after receiving the link command sent by the client, perform a file link operation on the corresponding target file to obtain an executable file; and return the executable file to the client.

[0077] On the other hand, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the processor executes the distributed compilation method provided by the above methods, the method comprising: sending a source code file to a server for compilation and assembly processing, obtaining a compilation result returned by the server, the compilation result including information of a compiled target file; based on the compilation result, creating a pseudo file corresponding to the compilation result, the pseudo file including a reconstruction method of the compiled target file; after obtaining the pseudo files corresponding to all the compilation results, sending a link command to the server, the link command being used to instruct the server to perform a file link operation on the target files corresponding to all the compilation results; receiving an executable file returned by the server; or comprising: After receiving the source code file sent by the client, compile and assemble the source code file to obtain and store the target file compiled and assembled based on the source code file; after receiving the link command sent by the client, perform a file link operation on the corresponding target file to obtain an executable file; and return the executable file to the client.

[0078] 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.

[0079] 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, 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.

[0080] 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 distributed compilation method, characterized in that: Applied to the client, including: Sending the source code file to the server for compilation and assembly processing, obtaining a compilation result returned by the server, wherein the compilation result includes information of the compiled target file; Based on the compilation result, creating a pseudo file corresponding to the compilation result, wherein the pseudo file includes a method for reconstructing the target file obtained by the compilation; After obtaining the pseudo files corresponding to all the compilation results, sending a link command to the server, wherein the link command is used to instruct the server to perform a file link operation on the target files corresponding to all the compilation results; Receive the executable file returned by the server.

2. The distributed compilation method according to claim 1, characterized in that: After creating a pseudo file corresponding to the compilation result based on the compilation result, the method further includes: After receiving a first calling instruction for the pseudo file, the following steps are performed, wherein the first calling instruction is an instruction for instructing to open a specified file in a specified manner: If the first calling instruction indicates to open the pseudo file in a first manner, then after the real target file is restored based on the reconstruction method in the pseudo file, the real target file is opened in the first manner, wherein the first manner refers to writing in a manner required by the write operation when performing a write operation after opening the designated file; If the first calling instruction instructs to open the pseudo file in a second manner, after restoring the real target file based on the reconstruction method in the pseudo file, the real target file is opened in the second manner, wherein the second manner is to create a new file when opening the designated file if the designated file does not exist; If the first calling instruction indicates to open the pseudo file in a third way, an error message is returned, wherein the third way is to call the directory file if the designated file is a directory file, otherwise an error message is returned; If the first calling instruction indicates to open the pseudo file in a fourth manner, the pseudo file is deleted, a new real target file is created, and then the real target file is opened. The fourth manner is to truncate the length of the specified file to zero bytes when opening the specified file.

3. The distributed compilation method according to claim 1, characterized in that: After creating a pseudo file corresponding to the compilation result based on the compilation result, the method further includes: After receiving the second call instruction for the pseudo file, returning the status information of the pseudo file, the status information including the file type, creation time, access time, modification time, file size and user information; Among them, the second calling instruction is an instruction for obtaining status information of a specified file, the file type is a common file, the file size is the file size of a target file corresponding to the pseudo file, and the user information is user information of the target file corresponding to the pseudo file.

4. The distributed compilation method according to claim 1, characterized in that: After creating a pseudo file corresponding to the compilation result based on the compilation result, the method further includes: After receiving the third calling instruction for the pseudo file, the following steps are performed, wherein the third calling instruction is an instruction for instructing to set the size of the specified file to a specified value: If the specified value is zero, an empty real target file is created after deleting the pseudo file; If the specified value is not zero, after the real target file is restored based on the reconstruction method in the pseudo file, the real target file is truncated or extended.

5. The distributed compilation method according to any one of claims 2 to 4, characterized in that: The sending of a link command to the server includes: If the real target file corresponding to the compilation result is not stored, sending the link command to the server; If a real target file corresponding to any one of all the compilation results is stored, the real target file and the link command are sent to the server, so that the server performs a file link operation based on the real target file.

6. A distributed compilation method, characterized in that: Applied to the server, including: After receiving the source code file sent by the client, compile and assemble the source code file to obtain and store the target file compiled and assembled based on the source code file; After receiving the link command sent by the client, performing a file link operation on the corresponding target file to obtain an executable file; The executable file is returned to the client.

7. A distributed compilation device, characterized in that: include: The file sending module is used to send the source code file to the server for compilation and assembly processing, and obtain the compilation result returned by the server, wherein the compilation result includes information of the compiled target file; A pseudo file creation module, used to: create a pseudo file corresponding to the compilation result based on the compilation result, wherein the pseudo file contains a method for reconstructing the target file obtained by the compilation; A command sending module, used for: after acquiring the pseudo files corresponding to all the compilation results, sending a link command to the server, wherein the link command is used to instruct the server to perform a file link operation on the target files corresponding to all the compilation results; A receiving module, used to: receive the executable file returned by the server; or, including: The compiling module is used to: after receiving the source code file sent by the client, compile and assemble the source code file to obtain and store the target file compiled and assembled based on the source code file; the linking module is used to: after receiving the linking command sent by the client, perform a file linking operation on the corresponding target file to obtain an executable file; the sending module is used to: return the executable file to the client.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the distributed compilation method according to any one of claims 1 to 5 is implemented, or the distributed compilation method according to claim 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the distributed compilation method according to any one of claims 1 to 5 is implemented, or the distributed compilation method according to claim 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the distributed compilation method according to any one of claims 1 to 5 is implemented, or the distributed compilation method according to claim 6 is implemented.

Citation Information

Patent Citations

  • A distributed computing system deployed across devices

    CN109343937A

  • Continuous integration method, and continuous integration method and system based on distributed compiling

    CN111580802A

  • Compiling method, electronic equipment and computer readable storage medium

    CN111880802A

  • Distributed compiling system and method

    CN113254022A

  • Distributed compiling method and device and storage medium

    CN114185550A

Cited By

  • Binary file linking method and device, equipment, storage medium and program product

    CN119718334A

  • Executable program generation method and device and electronic equipment

    CN121349469A

  • Executable program generation method and device, and electronic device

    CN121349469B