Software code construction method, system and equipment and storage medium
By reporting the developer's change code and build commands to the remote server for compilation and construction, the problem of local resource occupation and inconsistent results is solved, and an efficient and stable software code construction process is achieved.
Patent Information
- Application Number
- CN202411034854.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-11-01
AI Technical Summary
When developers compile code on local computers, they occupy a large amount of CPU and memory resources, resulting in performance degradation and affecting work efficiency. The operating systems and tool configurations of different developers are different, resulting in inconsistent code compilation results, especially in poor performance. Compilation failure may occur on the machine.
Report the developer's change code and build command to the remote server. The remote server obtains the baseline source code and compiles and builds it, generates the code construction results, and returns the progress and results to the local device to avoid occupancy of local resources and ensures the configuration environment. Consistent.
It improves the efficiency of the compilation and construction process, avoids the problem of inconsistent code building results on different machines, ensures that developers can handle other tasks, and at the same time use high-performance remote servers to compile, improving the efficiency and quality of software development.
Smart Images

Figure CN118885176A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a software code construction method, system, device and storage medium. Background Art
[0002] When developers are developing software, they usually use their own local development environment (i.e., their personal computers or physical servers) to write, compile, and package code. However, when developers compile code on their local computers, the compilation process may take up a lot of physical resources such as CPU and memory, causing the computer's performance to degrade, making it impossible for developers to perform other tasks on the same machine, affecting work efficiency. In addition, each developer may use different configuration environments such as the operating system, library version, and tool configuration locally, which may cause the same code to compile to different results on different developer machines. In addition, due to the limited performance of local computers, especially when developers are using machines with poor performance, the compilation and build process may be very slow, and may even fail to compile due to insufficient resources. Such performance and stability issues will affect the efficiency and quality of software development. Summary of the invention
[0003] Based on this, it is necessary to provide a software code construction method, system, device and storage medium for the above technical problems to solve at least one of the above technical problems.
[0004] The present invention provides a software code construction method, comprising:
[0005] The local device reports the developer's modified code and generated build commands to the remote server;
[0006] The remote server obtains the benchmark source code;
[0007] The remote server responds to the build command to compile and build the benchmark source code and the changed code reported by the local device to obtain a code building result.
[0008] Optionally, according to a software code building method provided by the present invention, the step of responding to the building command to build and compile the benchmark source code and the changed code reported by the local device to obtain a code building result includes:
[0009] The remote server integrates the reference source code and the changed code to obtain a target integrated code;
[0010] The remote server compiles and builds the target integration code in response to the build command to obtain a code build result corresponding to the target integration code.
[0011] Optionally, according to a software code construction method provided by the present invention, the step of reporting the changed code modified by the developer and the generated construction command to a remote server includes:
[0012] The local device obtains a base source code and a current version code, wherein the current version code is a code modified by a developer based on the base source code;
[0013] The local device compares the current version code with the reference source code to obtain the changed code;
[0014] The local device compresses the changed code, and reports the compressed changed code and the generated build command to the remote server.
[0015] Optionally, according to a software code construction method provided by the present invention, in response to the construction command, the base source code and the changed code reported by the local device are compiled and constructed, and after obtaining the code construction result, the method further comprises:
[0016] The remote server monitors the progress of the compilation build;
[0017] The remote server sends the building progress to the local device so that the developer can view the building progress.
[0018] Optionally, according to a software code construction method provided by the present invention, in response to the construction command, the base source code and the changed code reported by the local device are compiled and constructed, and after obtaining the code construction result, the method further comprises:
[0019] The remote server returns the code building result to the local device and sends a notification message, where the notification message is used to notify the developer to view the code building result.
[0020] Optionally, according to a software code construction method provided by the present invention, after returning the code construction result to the local device, the method further includes:
[0021] The local device obtains a test result corresponding to the code building result to determine whether to publish and deploy the code building result to a publishing environment according to the test result.
[0022] Optionally, according to a software code construction method provided by the present invention, before reporting the changed code modified by the developer and the generated construction command to the remote server, the method further includes:
[0023] The remote server determines a preset construction resource, wherein the construction resource refers to a computing resource on the remote server, which is used to execute a construction task of the software code.
[0024] The present invention also provides a software code construction system, comprising:
[0025] The local device is used to report the changed code and generated build commands modified by the developer to the remote server;
[0026] The remote server is used to obtain the benchmark source code;
[0027] The remote server is used to respond to the build command to compile and build the benchmark source code and the changed code reported by the local device to obtain a code building result.
[0028] The present invention also provides a computer device, comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein the processor implements the above-mentioned software code construction method when executing the computer-readable instructions.
[0029] The present invention also provides one or more readable storage media storing computer-readable instructions, and the computer-readable instructions implement the above-mentioned software code construction method when executed by a processor.
[0030] The software code construction method, system, device and storage medium mentioned above, the method includes: the local device reports the change code and the generated build command to the remote server; the remote server obtains the benchmark source code; the remote server responds to the build command to compile and build the benchmark source code and the change code reported by the local device to obtain the code construction result. The present invention reports the change code modified by the developer on the local device and the generated build command to the remote server, and then responds to the build command in the remote server to compile and build the benchmark source code and the change code reported by the local device, so that the hard disk medium resources of the developer are no longer occupied, and the developer can handle other matters during the packaging process. And the configuration environment of the packaging is consistent, avoiding the situation where the same code has inconsistent build results on different machines, and the performance of the server is usually better, which can improve the efficiency of the compilation and construction process. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0032] Figure 1 is a flowchart of a software code construction method in one embodiment of the present invention;
[0033] Figure 2 is a structural diagram of a software code construction system in one embodiment of the present invention;
[0034] Figure 3 is a schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0035] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments 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.
[0036] The terms used in one or more embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present invention. The singular forms of "a", "said" and "the" used in one or more embodiments of the present invention are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present invention refers to and includes any or all possible combinations of one or more associated listed items.
[0037] When developers are developing software, they usually use their own local development environment (i.e., their personal computers or physical servers) to write, compile, and package code. However, when developers compile code on their local computers, the compilation process may take up a lot of physical resources such as CPU and memory, causing the computer's performance to degrade, making it impossible for developers to perform other tasks on the same machine, affecting work efficiency. In addition, each developer may use different configuration environments such as the operating system, library version, and tool configuration locally, which may cause the same code to compile to different results on different developer machines. In addition, due to the limited performance of local computers, especially when developers are using machines with poor performance, the compilation and build process may be very slow, and may even fail to compile due to insufficient resources. Such performance and stability issues will affect the efficiency and quality of software development.
[0038] In view of the above problems, the present invention provides the following embodiments. In one embodiment, specifically, Figure 1 As shown, Figure 1FIG. 1 is a flow chart of a method for constructing software code in an embodiment of the present invention. The method for constructing software code in an embodiment of the present invention includes the following steps:
[0039] Step S11, the local device reports the changed code modified by the developer and the generated build command to the remote server;
[0040] It should be noted that changed code refers to all code modified by developers on local devices, including developer modifications to code, adding new features, or fixing known issues. Optionally, code changes are usually managed based on a version control system (such as Git) to ensure that code changes during the development process can be tracked, rolled back, and synchronized.
[0041] It should be noted that build commands are instructions for compiling and building software. Build commands are used to instruct the conversion of source code into executable binary files or deployment packages so that other developers or servers can run these codes. The build process may include steps such as compiling source code, linking library files, and packaging resource files.
[0042] Specifically, the local device loads and obtains the benchmark source code, and determines the current version code, wherein the current version code is the code modified by the developer based on the benchmark source code. Further, the current version code is compared with the benchmark source code to obtain the change code; in order to improve the efficiency of data transmission, the change code can be compressed, and the compressed change code and the generated build command are reported to the remote server. In a specific example, the git diff command can be used to obtain the changed content of the code. Optionally, the git diff command can compare two different states (usually the difference between the current working directory and the index, or the difference between the index and the latest submission) and display these differences. The output of the git diff command will be saved in the diff file in the current directory. Then the diff file is compressed, and the compressed change code and the generated build command are reported to the remote server.
[0043] Step S12, the remote server obtains the benchmark source code;
[0044] It should be noted that the benchmark source code is the source code submitted most recently to the current modified code. The benchmark source code is stored in the cloud and can be downloaded and obtained.
[0045] Step S13: the remote server responds to the build command to compile and build the benchmark source code and the changed code reported by the local device to obtain a code building result.
[0046] It should be noted that compilation refers to the process of converting source code into an executable software program or library. In software development, the written source code usually needs to go through a series of steps to become a final executable program.
[0047] Specifically, the remote server integrates the reference source code and the change code to obtain the target integration code, that is, the change code (such as developing new functions or fixing errors) made on the local device is applied to the reference source code. Then the remote server responds to the build command to compile and build the target integration code. Optionally, the code is compiled and built using appropriate build tools and commands. The specific build command may vary depending on the project and the build tool used. After the build is completed, the code build result corresponding to the target integration code is obtained, for example, an executable file, a library file, or an output file of other applications is generated.
[0048] In addition, in one embodiment of the present invention, in response to the build command, the base source code and the changed code reported by the local device are compiled and built, and after obtaining the code building result, the method further includes:
[0049] The remote server returns the code building result to the local device and sends a notification message, where the notification message is used to notify the developer to view the code building result.
[0050] Specifically, the remote server will return the code build results (for example, the generated executable file, library file, or packaged application) to the local device, and the remote server will send a notification message to the relevant developers to inform them of the status and results of the code build. The notification information can be sent via email, Slack message, or integrated into any communication tool used by the development team. After receiving the notification, the developer can view the build results, including test reports and logs. The developer decides whether to deploy the build results to the production or release environment based on the results of the build and test. If the test passes and there are no problems with the build, the developer can choose to deploy the new version of the software to the release environment.
[0051] The embodiment of the present invention, through the above scheme, includes: the local device reports the changed code and the generated build command to the remote server; the remote server obtains the benchmark source code; the remote server responds to the build command to compile and build the benchmark source code and the changed code reported by the local device to obtain the code building result. The present invention reports the changed code modified by the developer on the local device and the generated build command to the remote server, and then responds to the build command in the remote server to compile and build the benchmark source code and the changed code reported by the local device, which no longer occupies the hard disk media resources of the developer, and the developer can handle other matters during the packaging process. The packaging configuration environment is consistent, avoiding the situation where the same code has inconsistent build results on different machines, and the performance of the server is usually better, which can improve the efficiency of the compilation and construction process.
[0052] In one embodiment of the present invention, in response to the build command, building and compiling the benchmark source code and the changed code reported by the local device to obtain a code building result includes:
[0053] The remote server integrates the reference source code and the changed code to obtain a target integrated code; the remote server responds to the build command to compile and build the target integrated code to obtain a code build result corresponding to the target integrated code.
[0054] Specifically, the remote server downloads and obtains the base source code. Then, the base source code and the change code are integrated to ensure that the remote server has the latest integrated code version. After the integration is completed, the remote server responds to the build command to compile and build the target integrated code using an appropriate compiler or build tool according to the instructions of the build command, and outputs the code build result corresponding to the target integrated code, for example, outputs the output of all compilation, testing and other build steps.
[0055] The embodiment of the present invention is to execute the compilation and construction process of the code in the remote server, without occupying the hard disk medium resources of the developer. The developer can handle other matters during the code packaging process, and the packaging configuration environment is consistent, avoiding the situation where the same code is inconsistently built on different machines. In addition, the performance of the server is usually good, which can improve the efficiency of the compilation and construction process.
[0056] In one embodiment of the present invention, reporting the changed code modified by the developer and the generated build command to the remote server includes:
[0057] The local device obtains a benchmark source code and a current version code, wherein the current version code is a code modified by a developer based on the benchmark source code; the local device compares the current version code with the benchmark source code to obtain the changed code; the local device compresses the changed code, and reports the compressed changed code and the generated build command to the remote server.
[0058] Specifically, the developer obtains the baseline source code, which is the initial version or the latest stable version of the project. The current version code is the code modified by the developer based on the baseline source code. For example, the developer can check out or clone the code base from the version control system and develop and modify it locally. Then the current version code is compared with the baseline source code. For example, the developer uses the tool of the version control system (such as git diff) on the local device to compare the difference between the current version code and the baseline source code. This process will identify the specific changes made by the developer, thereby obtaining the changed code. Further, these changed codes are compressed and packaged into a compressed file. Compressing the changed code helps to reduce transmission time and resource consumption. The build command configured by the developer is obtained on the local device. The build command may include operation commands such as compiling code, running unit tests, generating documents, and packaging applications, which are used to instruct the remote server to compile and build the code. Further, the compressed changed code and the generated build command are uploaded to the remote server.
[0059] The embodiment of the present invention uploads the changed code and the generated build command to the remote server, so that the code can be compiled and built in the remote server without occupying the hard disk media resources of the developer. The developer can handle other matters during the code packaging process, and the packaged configuration environment is consistent, avoiding the situation where the same code has inconsistent build results on different machines. In addition, the performance of the server is usually good, which can improve the efficiency of the compilation and construction process.
[0060] In one embodiment of the present invention, in response to the build command, the base source code and the changed code reported by the local device are compiled and built, and after obtaining the code building result, the method further includes:
[0061] The remote server monitors the build progress of the compilation build; the remote server sends the build progress to the local device for developers to view the build progress.
[0062] Specifically, the remote server monitors the build progress of the entire compilation and build process. For example, when the remote server detects that the compilation and build progress has changed or reached a new stage, it will send the current build progress information to the developer's local device. After receiving the notification of the build progress, the developer can view the current build status, completed steps, steps being executed, and possible problems or error messages. It helps developers understand the compilation and build status of the project in real time and handle any potential build errors or abnormal situations in a timely manner. By monitoring and notifying the build progress, the development team can quickly feedback the build effect of code changes, helping to ensure that each build process goes smoothly as expected, thereby improving overall development efficiency and software quality.
[0063] In one embodiment of the present invention, before reporting the changed code modified by the developer and the generated build command to the remote server, the process further includes:
[0064] The remote server determines a preset construction resource, wherein the construction resource refers to a computing resource on the remote server, which is used to execute a construction task of the software code.
[0065] Specifically, before starting a build task, the remote server needs to determine the available build resources, where the build resources refer to the computing resources on the remote server, and the build resources include processor cores, memory, disk space, etc. These resources are used to execute the build task. Optionally, the maximum amount of resources that can be used by the build task can be pre-set to ensure that there is no resource competition or excessive consumption. Once the remote server determines the available build resources, it will start executing the software code build task according to the predefined build commands and configurations.
[0066] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0067] In one embodiment, a software code construction system is provided, and the software code construction system corresponds one-to-one to the software code construction method in the above embodiment. Figure 2 As shown, Figure 2 : is a schematic diagram of a software code construction system in one embodiment of the present invention, the software code construction system comprising:
[0068] The local device 21 is used for the local device to report the changed code modified by the developer and the generated build command to the remote server;
[0069] The remote server 22 is used to obtain the benchmark source code;
[0070] The remote server 22 is used to respond to the building command to compile and build the benchmark source code and the changed code reported by the local device to obtain a code building result.
[0071] The remote server 22 is also used for:
[0072] Integrate the reference source code and the changed code to obtain a target integrated code;
[0073] In response to the building command, the target integration code is compiled and built to obtain a code building result corresponding to the target integration code.
[0074] The local device 21 is also used for:
[0075] Obtaining a baseline source code and a current version code, wherein the current version code is a code modified by a developer based on the baseline source code;
[0076] Compare the current version code with the reference source code to obtain the changed code;
[0077] The changed code is compressed, and the compressed changed code and the generated build command are reported to the remote server.
[0078] The remote server 22 is also used for:
[0079] Monitor the build progress of the compilation build;
[0080] The building progress is sent to the local device so that the developer can view the building progress.
[0081] The remote server 22 is also used for:
[0082] The code building result is returned to the local device, and a notification message is issued, wherein the notification message is used to notify the developer to view the code building result.
[0083] The local device 21 is also used for:
[0084] The test result corresponding to the code building result is obtained to determine whether to publish and deploy the code building result to a publishing environment according to the test result.
[0085] The remote server 22 is also used for:
[0086] The remote server determines a preset construction resource, wherein the construction resource refers to a computing resource on the remote server, which is used to execute a construction task of the software code.
[0087] For the specific definition of the software code construction system, please refer to the definition of the software code construction method above, which will not be repeated here. Each module in the above-mentioned software code construction system can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0088] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 3 As shown, Figure 3 : is a schematic diagram of a computer device in one embodiment of the present invention. The computer device includes a processor, a memory, a network interface and a database connected by a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a readable storage medium and an internal memory. The readable storage medium stores an operating system, computer-readable instructions and a database. The internal memory provides an environment for the operation of the operating system and computer-readable instructions in the readable storage medium. The database of the computer device is used to store data involved in the software code construction method. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer-readable instructions are executed by the processor, a software code construction method is implemented. The readable storage medium provided in this embodiment includes a non-volatile readable storage medium and a volatile readable storage medium.
[0089] In one embodiment, a computer device is provided. The computer device may be a terminal device, and its internal structure diagram may be as follows: Figure 3 As shown. The computer device includes a processor, a memory, and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a readable storage medium. The readable storage medium stores computer-readable instructions. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer-readable instructions are executed by the processor, a software code construction method is implemented. The readable storage medium provided in this embodiment includes a non-volatile readable storage medium and a volatile readable storage medium.
[0090] In one embodiment, a computer device is provided, comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein the processor implements the steps of the software code construction method as described above when executing the computer-readable instructions. The method comprises: a local device reports the changed code modified by the developer and the generated construction command to a remote server; the remote server obtains a reference source code; the remote server responds to the construction command to compile and construct the reference source code and the changed code reported by the local device to obtain a code construction result.
[0091] In one embodiment, a readable storage medium is provided, the readable storage medium stores computer-readable instructions, and the computer-readable instructions are executed by the processor to implement the above-mentioned software code construction method steps. It can be understood by a person of ordinary skill in the art that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a non-volatile readable storage medium or a volatile readable storage medium. When the computer-readable instructions are executed, they may include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0092] Those skilled in the art will clearly understand that for the sake of convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the system can be divided into different functional units or modules to complete all or part of the functions described above.
[0093] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such 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, and should all be included in the protection scope of the present invention.
Claims
1. A software code construction method, characterized in that: include: The local device reports the developer's modified code and generated build commands to the remote server; The remote server obtains the benchmark source code; The remote server responds to the build command to compile and build the benchmark source code and the changed code reported by the local device to obtain a code building result.
2. The software code construction method according to claim 1, characterized in that: In response to the build command, the base source code and the changed code reported by the local device are built and compiled to obtain a code building result, including: The remote server integrates the reference source code and the changed code to obtain a target integrated code; The remote server compiles and builds the target integration code in response to the build command to obtain a code build result corresponding to the target integration code.
3. The software code construction method according to claim 1, characterized in that: The reporting of the changed code modified by the developer and the generated build command to the remote server includes: The local device obtains a base source code and a current version code, wherein the current version code is a code modified by a developer based on the base source code; The local device compares the current version code with the reference source code to obtain the changed code; The local device compresses the changed code, and reports the compressed changed code and the generated build command to the remote server.
4. The software code construction method according to claim 1, characterized in that: In response to the build command, the base source code and the changed code reported by the local device are compiled and built, and after obtaining the code building result, the method further includes: The remote server monitors the progress of the compilation build; The remote server sends the building progress to the local device so that the developer can view the building progress.
5. The software code construction method according to claim 1, characterized in that: In response to the build command, the base source code and the changed code reported by the local device are compiled and built, and after obtaining the code building result, the method further includes: The remote server returns the code building result to the local device and sends a notification message, where the notification message is used to notify the developer to view the code building result.
6. The software code construction method according to claim 5, characterized in that: After returning the code building result to the local device, the method further includes: The local device obtains a test result corresponding to the code building result to determine whether to publish and deploy the code building result to a publishing environment according to the test result.
7. The software code construction method according to claim 1, characterized in that: Before reporting the changed code modified by the developer and the generated build command to the remote server, the following is also included: The remote server determines a preset construction resource, wherein the construction resource refers to a computing resource on the remote server, which is used to execute a construction task of the software code.
8. A software code construction system, characterized in that: include: The local device is used to report the changed code and generated build commands modified by the developer to the remote server; The remote server is used to obtain the benchmark source code; The remote server is used to respond to the build command to compile and build the benchmark source code and the changed code reported by the local device to obtain a code building result.
9. A computer device comprising a memory, a processor, and computer-readable instructions stored in the memory and executed on the processor, characterized in that: When the processor executes the computer-readable instructions, the software code construction method according to any one of claims 1 to 7 is implemented.
10. A readable storage medium having computer readable instructions stored thereon, characterized in that: When the computer-readable instructions are executed by a processor, the software code construction method according to any one of claims 1 to 7 is implemented.
