Software construction method and device and related equipment
By executing build tasks in parallel in the resource pool and using multiple instances and distributed caching technology, the problem of long time-consuming software building on a single machine is solved and the efficiency of software development is improved.
Patent Information
- Application Number
- CN202310126681.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-16
- Publication Date
- 2024-08-23
AI Technical Summary
Building software on a single machine takes a long time, which affects software development efficiency. Especially when the software project has a large amount of code, the process of building targets one by one is time-consuming.
By using multiple instances in the resource pool to execute build tasks in parallel, obtain code files and dependency files, generate multiple build tasks, and build software based on the execution results, using technologies such as distributed caching, consistent hashing, and distributed file storage. Improve efficiency.
It effectively shortens the time it takes to build software, improves software development efficiency, and improves overall construction efficiency by executing multiple construction tasks in parallel.
Smart Images

Figure CN118535133A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus and related equipment for constructing software. Background Art
[0002] Building software refers to the process of converting source code into a software package through compilation, linking, packaging, etc., so as to achieve software development. In actual application scenarios, as the demand for software projects continues to increase, the amount of code in software projects will also increase, which makes it time-consuming to build software on a single machine, such as several hours or days, which seriously affects the efficiency of software development.
[0003] Therefore, how to improve the efficiency of building software has become an important technical issue that needs to be solved urgently. Summary of the invention
[0004] In view of this, the embodiment of the present application provides a method for building software, which is used to shorten the time required for building software, thereby improving software development efficiency. The present application also provides a corresponding apparatus, a computing device cluster, a computer-readable storage medium, and a computer program product.
[0005] In a first aspect, an embodiment of the present application provides a method for building software, which is applied to a first instance in a resource pool, where the first instance can be, for example, a host, a virtual machine, a container, etc. in the resource pool; in the process of building the software, the first instance obtains the code file of the software to be built from the code repository, and obtains the dependency files required to build the software from the dependency library, such as the Jar package required to build the software, etc.; then, the first instance generates multiple build tasks based on multiple targets in the code file, where different build tasks can include different targets to be built, and instructs multiple instances in the resource pool to execute multiple build tasks in parallel using the dependency files to obtain execution results corresponding to the multiple build tasks respectively, where the multiple instances may include the first instance or may not include the first instance, so that the first instance builds the software according to the execution results corresponding to the multiple build tasks respectively.
[0006] In this way, during the process of building the software, the first instance executes the construction process for multiple construction tasks including different targets in parallel. Compared with the method of building targets one by one on a single machine, this can effectively improve the construction efficiency for the multiple targets, thereby effectively improving the overall efficiency of building the software.
[0007] In a possible implementation, when the first instance obtains the code file, it may specifically perform distributed caching on the code file of the software to be built in the code warehouse, thereby improving the efficiency of the first instance in obtaining the code file, and further improving the overall efficiency of building the software.
[0008] Optionally, the first instance may cache the code file through consistent hashing, distributed file storage, or incremental update techniques, so as to improve the efficiency of the first instance in acquiring the code file.
[0009] In a possible implementation, when generating multiple build tasks, the first instance may specifically determine a compilation control file in the code file, such as a cmakelist file, a ninja file, etc., wherein the compilation control file includes multiple targets and dependency information of the multiple targets; then, the first instance generates multiple build tasks for the software to be built according to the compilation control file. In this way, the first instance can realize the generation of multiple build tasks according to the compilation control file.
[0010] In a possible implementation, the multiple targets involved in generating the multiple build tasks are all the targets defined in the compilation control file; or, the multiple targets involved in generating the multiple build tasks are targets that meet preset conditions in the compilation control file, where the preset conditions include preset types, costumer types, external project types, etc., or the preset conditions include preset identifiers, such as specified file names, etc. In actual applications, some or all of the targets in the compilation control file can be flexibly selected as needed to generate multiple build tasks, so as to achieve the purpose of accelerating software construction.
[0011] In a possible implementation, the first instance outputs a configuration interface, for example, a configuration interface that can be output to an external client, and the configuration interface can be presented to the user through the client, so that the first instance determines the preset condition in response to the user's configuration operation on the configuration interface for the preset condition. In this way, the user can flexibly select multiple targets that need to participate in the build acceleration on the configuration interface, thereby improving the flexibility of target selection during the software build process.
[0012] In a possible implementation, when the first instance instructs multiple instances in the resource pool to use dependent files to execute multiple build tasks in parallel, the multiple build tasks may be distributed to the multiple instances according to preset rules, and the multiple build tasks are executed in parallel by the multiple instances, and different instances execute different build tasks, so that the first instance can obtain the execution results corresponding to the multiple build tasks fed back by the multiple instances. In this way, the first instance can use multiple instances in the resource pool to accelerate the construction of multiple targets, thereby improving the overall efficiency of software construction.
[0013] In a possible implementation, when the first instance generates multiple build tasks, the multiple targets in the compilation control file may be grouped according to the number of the multiple instances or the directories to which the build products of the multiple targets belong, such as grouping one or more targets with build products in the same directory into a group, etc., so as to obtain multiple build tasks, wherein the target included in each build task is a group of targets among the multiple targets. In this way, after the multiple targets are grouped and built according to the directories to which the build products belong, the build efficiency for the multiple targets can be improved.
[0014] In a possible implementation, the compilation control file also includes other targets in addition to the multiple targets involved in generating multiple build tasks. Then, during the software build process, the first instance can also build other targets in the compilation control file, obtain local execution results, and build the software based on the local execution results and the execution results corresponding to the multiple build tasks. In this way, the first instance can complete the accelerated build of the software together with the other multiple instances in the resource pool.
[0015] In the second aspect, the embodiment of the present application provides a method for building software, the method comprising: obtaining a compilation control file in the code file of the software to be built, such as a cmakelist file, a ninja file, etc., the compilation control file includes multiple targets and dependency information of the multiple targets, and obtaining the dependency files required to build the software; then, generating multiple build tasks for the software according to the compilation control file, different build tasks in the multiple build tasks include different targets; then, executing the multiple build tasks in parallel, obtaining the execution results corresponding to the multiple build tasks respectively, and building the software according to the execution results corresponding to the multiple build tasks respectively. In this way, in the process of building the software, by executing the construction process in parallel for multiple build tasks including different targets, this can effectively improve the construction efficiency for the multiple targets compared to the method of building targets one by one on a single machine, so that the overall efficiency of building the software can be effectively improved.
[0016] In a third aspect, an embodiment of the present application further provides a software construction device, which includes various modules for executing the method of constructing software in the first aspect or any possible implementation of the first aspect.
[0017] In a fourth aspect, an embodiment of the present application further provides a software construction device, which includes various modules for executing the method of constructing software in the implementation described in the second aspect.
[0018] In a fifth aspect, the present application provides a computing device cluster, wherein the computing device includes at least one computing device, and the at least one computing device includes at least one processor and at least one memory; the at least one memory is used to store instructions, and the at least one processor executes the instructions stored in the at least one memory, so that the computing device cluster executes the method for building software in the above-mentioned first aspect or any possible implementation of the first aspect, or so that the computing device cluster executes the method for building software in the above-mentioned second aspect implementation. It should be noted that the memory can be integrated into the processor or can be independent of the processor. The at least one computing device may also include a bus. The processor is connected to the memory via a bus. The memory may include a readable memory and a random access memory.
[0019] In a sixth aspect, the present application provides a computer-readable storage medium, which stores instructions, and when the computer-readable storage medium is run on at least one computing device, it enables the at least one computing device to execute the method described in the first aspect or any one of the implementations of the first aspect, or enables the at least one computing device to execute the method of building software in the implementation of the second aspect.
[0020] In a fifth aspect, the present application provides a computer program product comprising instructions, which, when executed on at least one computing device, enables the at least one computing device to execute the method described in the first aspect or any one of the implementations of the first aspect, or enables the at least one computing device to execute the method for building software in the implementation of the second aspect.
[0021] Based on the implementations provided in the above aspects, this application can also be further combined to provide more implementations. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 A schematic diagram of an exemplary application scenario provided for an embodiment of the present application;
[0023] Figure 2 A flowchart of a method for constructing software provided in an embodiment of the present application;
[0024] Figure 3 A schematic diagram of a configuration interface provided in an embodiment of the present application;
[0025] Figure 4 A schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0026] Figure 5 A schematic diagram of the structure of a computing device cluster provided in an embodiment of the present application. DETAILED DESCRIPTION
[0027] The scheme in the embodiments provided in this application will be described below in conjunction with the drawings in this application.
[0028] Normally, during the process of software development, users (such as developers, etc.) usually need to perform processes such as compiling, linking, and packaging on the written source code in sequence to complete the software construction. Compiling refers to the process of using a compiler to translate the source code program written in the source language into a program code based on the target language, such as translating the source code written in high-level languages such as C and Java into a program code based on the machine language. Linking refers to the process of collecting various program codes and data parts and combining them into a single file. Packaging refers to the process of combining and compressing multiple code files into one file.
[0029] In actual application scenarios, the amount of code of the software developed by the user is large, and the number of targets to be built in the program code of the software is large. Among them, the target can be the name of the file to be built, or the name of the operation to be performed, which is used to indicate the purpose of the operation when executing the command (that is, to indicate what to do). Therefore, it takes a long time to execute the construction process such as compiling, linking, and packaging one by one for a large number of targets in the program code, resulting in a long time consumption for building software on a single machine, which affects the efficiency of user software development.
[0030] Based on this, the embodiment of the present application provides a method for building software to shorten the time required to build software, thereby improving software development efficiency. Figure 1 As shown, the method may be executed by an instance 101 in a resource pool 10, wherein the resource pool 10 includes a plurality of instances. Figure 1 The example 101, the example 102 and the example 103 are used as examples for exemplary description. For example, each instance in the resource pool 10 may include one or more of a host, a virtual machine, and a container in the resource pool 10, or may be an instance implemented in other ways, which is not limited thereto.
[0031] In the process of building software, instance 101 obtains the code file of the software to be built from code warehouse 201, and obtains the dependency file required to build the software from dependency library 202. Then, instance 101 generates multiple build tasks based on the obtained code files, wherein different build tasks include different targets to be built in the code files. Next, instance 101 instructs multiple instances in resource pool 10 to execute multiple build tasks in parallel using the dependency files, and obtains the execution results corresponding to the multiple build tasks respectively. Among them, the multiple instances participating in the parallel execution of multiple build tasks can be instance 102 and instance 103. Further, the multiple instances can also include instance 101, etc. Thus, instance 101 builds the software according to the execution results corresponding to the multiple build tasks respectively, thereby completing the software development. Since in the process of building software, instance 101 executes the construction process for the generated multiple build tasks in parallel, this can effectively improve the construction efficiency for the multiple targets compared to the method of building targets one by one on a single machine, thereby effectively improving the overall efficiency of building software.
[0032] For example, in the process of building software, multiple functional modules in the example 101 may collaborate to complete the software building process. Figure 1 As shown, the instance 101 may include a data acquisition module 1011, a generation module 1012, an execution module 1013, and a construction module 1014. The data acquisition module 1011 is used to acquire the code files of the software to be constructed, and acquire the dependent files required to construct the software, such as acquiring the code files from the code warehouse 201, acquiring the dependent files from the dependent library 202, etc. Then, the data acquisition module 1011 may provide the acquired code files to the generation module 1012, and provide the dependent files to the execution module 1013. The generation module 1012 generates multiple construction tasks based on multiple targets in the code files, and different construction tasks in the multiple construction tasks include different targets, and provides the multiple construction tasks to the execution module 1013. The execution module 1013 instructs multiple instances in the resource pool 10 to execute the multiple construction tasks in parallel using the dependent files, obtain corresponding execution results, and provide the execution results corresponding to the multiple construction tasks to the construction module 1014, obtain the execution results corresponding to the multiple construction tasks, and provide the multiple execution results to the construction module 1014. The construction module 1014 constructs the software to be developed according to the execution results corresponding to the multiple construction tasks, thereby completing the software development.
[0033] Furthermore, the instance 101 may also include other functional modules, such as a configuration module, etc. The configuration module is used to configure the construction process of the instance 101 accordingly, such as configuring the number of construction tasks executed in parallel, configuring the type of targets of the construction process executed in parallel, etc.
[0034] In actual application, after the instance 101 constructs the software, it can also add the software to the software library 203 for persistent storage, so that subsequent users can obtain the completed software from the software library 203.
[0035] As an example, the resource pool 10, code warehouse 201, dependency library 202 and software library 203 can be deployed in the cloud to provide cloud services for building software for users / tenants. Exemplarily, the cloud can be a public cloud, a private cloud, an edge cloud, etc., and multiple instances in the resource pool 10 can be implemented by a computing device or a computing device cluster in the cloud; the code warehouse 201, dependency library 202 and software library 203 can be implemented by a storage device or a storage device cluster in the cloud. In this way, cloud services for building software can be provided.
[0036] As another example, the resource pool 10, code warehouse 201, dependency library 202 and software library 203 can be deployed locally, so as to provide local software building services for users / tenants. Exemplarily, multiple instances in the resource pool 10 can be implemented by one or more computing devices on the user side; the code warehouse 201, dependency library 202 and software library 203 can be implemented by one or more storage devices on the user side.
[0037] The above-mentioned example 101 may be implemented by software, or may be implemented by hardware.
[0038] Instance 101, as an example of a software functional unit, may include code running on a computing instance. The computing instance may include at least one of a host, a virtual machine, and a container. Furthermore, the computing instance may be one or more. For example, instance 101 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one data center or multiple data centers with close geographical locations. Typically, a region may include multiple AZs.
[0039] Similarly, multiple hosts / virtual machines / containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, a VPC is set up in a region. For cross-region communication between two VPCs in the same region and between VPCs in different regions, a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.
[0040] As an example of a hardware functional unit, the instance 101 may include at least one computing device, such as a server, etc. Alternatively, the instance 101 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0041] The multiple computing devices included in instance 101 can be distributed in the same region or in different regions. The multiple computing devices included in instance 101 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in instance 101 can be distributed in the same VPC or in multiple VPCs. The above-mentioned multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[0042] Next, various non-limiting specific implementation methods in the process of building software are described in detail.
[0043] See also Figure 2 , is a flowchart of a method for building software in an embodiment of the present application. This method can be applied to the above Figure 1 The application scenario shown in FIG. 1 may also be applied to other applicable application scenarios. Figure 1 The application scenario shown is used as an example for explanation. Figure 2 The method for constructing software shown may specifically include:
[0044] S201: The data acquisition module 1011 acquires the code file of the software to be built from the code repository 201.
[0045] S202: The data acquisition module 1011 acquires the dependency files required to build the software from the dependency library 202.
[0046] In this embodiment, example 101 can be applied to a project using a build framework, which can be, for example, any one of a CMake build framework, a Gradle build framework, a Bazel build framework, and a Scons build framework, or other applicable build frameworks. Correspondingly, a project using a build framework can be, for example, an Android open-source project (AOSP), or a project derived from AOSP, such as Android, EMUI, MIUI, ColorOS, OriginOS, One UI, ZUI, Hydrogen OS, or other projects, such as an OpenHarmony project, an intelligent vehicle system used in a car, etc. In this embodiment, the build framework and project applied by example 101 are not limited.
[0047] In a possible implementation, the instance 101 may provide a client to the outside, and the client may be, for example, a web browser, or an application deployed on a user terminal, etc. In this way, the user may provide the instance 101 with an identifier of a code file of the software to be built, such as the name of the code file, etc., through the client, so that the data acquisition module 1011 may acquire the corresponding code file from the code warehouse 201 according to the identifier.
[0048] Furthermore, the user can provide the instance 101 with the identifier of the dependency file required to build the software through the client, so that the data acquisition module 1011 can obtain the corresponding dependency file from the dependency library 202 according to the identifier. The dependency file refers to the file required to be relied upon in the process of building the target, such as a Jar package, a software development kit (SDK), etc. In actual application, for software developed based on different programming languages, the instance 101 can use different dependency files to complete the software construction.
[0049] Furthermore, when acquiring code files, the data acquisition module 1011 may specifically perform distributed caching on the code files of the software to be built in the code warehouse 201, so as to accelerate the acquisition of code files, so as to improve the overall efficiency of software construction. Alternatively, the data acquisition module 101 may also accelerate the acquisition of code files based on technologies such as consistent hashing, distributed file storage, or incremental updates. Similarly, the data acquisition module 101 may also acquire the dependency files required to build the software from the dependency library 202 through technologies such as distributed caching, consistent hashing, distributed file storage, or incremental updates.
[0050] In actual application, the data acquisition module 1011 may also acquire the code files and dependent files in other ways, which is not limited in this embodiment.
[0051] After acquiring the code file, the data acquisition module 1011 may provide the code file to the generation module 1012 and provide the dependent file to the execution module 1013 .
[0052] S203: The generation module 1012 generates multiple build tasks based on multiple targets in the code file, and different build tasks in the multiple build tasks include different targets.
[0053] Exemplarily, a user may send a build command for a software project to instance 101 through a client, such as a Cmake command, a command of a Soong tool in an AOSP project, etc., so that instance 101 (specifically, generation module 1012) may generate a corresponding compilation control file in a construction framework, such as a cmakelist file, a ninja file, etc. Typically, a compilation control file defines multiple targets and indicates dependency information (dependencies) of the multiple targets, and the dependency information is used to indicate files or other targets required to generate the target, that is, the successful construction of target A requires the successful construction of other targets on which target A depends.
[0054] In addition, since building a target usually requires environment variables, where environment variables refer to some parameters used to specify the operating environment of the operating system, such as the location of a temporary folder and the location of a system folder, etc. Therefore, the data acquisition module 1011 can also acquire the environment variables required for building multiple targets in the compilation control file.
[0055] After acquiring the compilation control file, the generation module 1012 may generate multiple build tasks according to the compilation control file, where different build tasks in the multiple build tasks include different targets.
[0056] It is understandable that if each target in the compilation control file is constructed sequentially by a single machine, the serial construction process is time-consuming and affects the software construction efficiency. Therefore, the generation module 1012 can generate multiple construction tasks according to the targets and the dependencies of the targets defined in the compilation control file, so as to speed up the overall software construction efficiency by executing multiple construction tasks in parallel.
[0057] In the first implementation of generating a build task, the generation module 1012 can generate a target dependency information tree based on a compilation control file, and the target dependency information tree indicates the dependency relationship of multiple targets in a tree structure, including the dependency relationship between targets and other files on which the targets depend. Then, the generation module 1012 can generate multiple build tasks based on the target dependency information tree. Each build task can include a target, which is responsible for completing the construction of a target. In addition, the build task also indicates the files or other targets that the targets included in it need to depend on. In this way, for multiple targets defined in the compilation control file, the generation module 1012 can generate corresponding multiple build tasks.
[0058] In the second implementation method of generating a build task, the generation module 1012 can group multiple targets defined in the compilation control file according to the target dependency information tree corresponding to the compilation control file. Specifically, targets with direct or indirect dependencies can be grouped into the same group, and each group includes at least one target (targets without dependencies can be grouped separately). Thus, the generation module 1012 can generate multiple build tasks based on multiple groups, and each group is used to generate a build task.
[0059] When grouping multiple targets, the generating module 1012 may group the multiple targets according to the directories to which the build products of the multiple targets belong, and specifically may group one or more targets with build products in the same directory into one group. In actual scenarios, after grouping and building multiple targets according to the directories to which the build products belong, the building efficiency for the multiple targets may be improved.
[0060] Of course, the generation module 1012 may also group multiple targets based on other implementations. For example, the generation module 1012 may group targets belonging to the same project directory into the same group, and targets in different groups belong to different project directories. Alternatively, when multiple build tasks are executed in parallel by multiple clients, the generation module 1012 may also group them according to the number of clients. For example, when the number of clients is 3, the generation module 1012 may divide the multiple targets into 3 groups to generate 3 build tasks.
[0061] It is worth noting that the above-mentioned implementation methods of generating multiple build tasks are only some exemplary explanations. In actual application, multiple build tasks can be generated by combining the above-mentioned multiple implementation methods, or by adopting other applicable methods. This embodiment does not limit this.
[0062] In this embodiment, the multiple targets used to generate the build task can be all the targets in the compilation control file. Alternatively, the multiple targets used to generate the build task can also be some of the targets in the compilation control file. For example, the generation module 1012 can first filter out multiple targets that meet the preset conditions from the compilation control file, and generate multiple build tasks according to the multiple targets, while the remaining targets in the compilation control file do not meet the preset conditions.
[0063] Exemplarily, the above-mentioned preset conditions may be, for example, preset types or preset identifiers. For example, in the compilation control file generated under the Cmake framework, the preset type may specifically be a costumer type, an external project type, etc., that is, the generation module 1012 may filter out multiple targets belonging to the costumer type or the external project type. For another example, the preset identifier may specifically be a file name, etc., so that the generation module 1012 may filter out multiple targets matching the pre-specified file name from the compilation control file.
[0064] In actual application scenarios, before software construction, the user 200 can configure the above preset conditions. Specifically, the configuration module 105 in the example 101 can generate a configuration interface, for example, Figure 3 The configuration interface shown in FIG. 1 is output to the client so that the configuration interface is presented on the client. In this way, the user 200 can perform corresponding configuration operations on the configuration interface according to the preset conditions, such as selecting some types from the multiple candidate types presented as the preset types. Alternatively, the user 200 can Figure 3 The specified file name is input on the configuration interface shown, and the input file name is used as the above-mentioned preset identifier, or some file names are selected from the multiple file names presented as the above-mentioned preset identifier, etc. In this way, the configuration module 105 can determine the preset condition according to the configuration operation performed by the user 200, and provide the determined preset condition to the generation module 1012, so that the generation module 1012 can filter out multiple targets from the compilation control file according to the preset condition and generate corresponding multiple build tasks.
[0065] After generating multiple construction tasks, the generation module 1012 may provide them to the execution module 1013 .
[0066] S204: The execution module 1013 instructs multiple instances in the resource pool 10 to execute multiple construction tasks in parallel using the dependency files, and obtains execution results corresponding to the multiple construction tasks respectively.
[0067] Among them, the execution results corresponding to multiple build tasks may include not only information indicating the success or failure of the build task execution, but also the build product generated after the construction of the target in the build task is completed. The build product can be, for example, a group of files that implement one or more functions, specifically a jar package, a war package, etc., or it can be a group of ".o" format files, binary files, executable files, files with suffix extensions, etc., and there is no limitation on this.
[0068] In this embodiment, the overall efficiency of software construction is improved by executing multiple construction tasks in parallel.
[0069] In a possible implementation, the execution module 1013 may distribute multiple build tasks to multiple instances based on the number of multiple instances participating in the parallel execution of the build tasks, pre-set scheduling rules, or relevant information of the build tasks, and each instance may be responsible for executing one or more build tasks.
[0070] Exemplarily, when the execution module 1013 allocates the construction tasks according to the number of multiple instances participating in the parallel execution of the construction tasks, the construction tasks may be allocated to each instance as evenly as possible, that is, the number of construction tasks allocated to each instance may be as consistent as possible. For example, when the number of construction tasks is 10 and the number of instances is 5, each instance may be evenly allocated to 2 construction tasks for execution.
[0071] When the execution module 1013 assigns build tasks according to pre-set scheduling rules, the scheduling rules may be, for example, random assignment rules (i.e., each build task is randomly assigned to an instance), load balancing rules (i.e., the load generated after multiple instances are assigned to build tasks is as balanced as possible), etc., or other applicable rules.
[0072] When execution module 1013 distributes construction tasks according to the relevant information of construction tasks, the relevant information can be, for example, the dependency between the targets in different construction tasks. For example, assuming that multiple construction tasks are generated based on the target dependency information tree, the targets in some construction tasks may be the targets as leaf nodes on the target dependency information tree, and the targets in the remaining construction tasks are the upper nodes of the leaf nodes. At this time, execution module 1013 can distribute the construction tasks as the target of the leaf node to multiple instances for parallel execution when distributing construction tasks. After the execution of this part of the construction tasks is completed, multiple instances can feed back the feedback of the successful execution of the construction tasks to execution module 1013, so that execution module 1013 distributes the remaining construction tasks to multiple instances and continues to execute in parallel according to the dependency between the nodes on the target dependency information tree, so that multiple instances can continue to execute the remaining construction tasks using the execution results generated by the executed construction tasks. In this way, execution module 1013 and multiple instances can complete the execution of all construction tasks by cyclically executing the above-mentioned distribution and execution of the construction tasks, and obtain the execution results corresponding to all construction tasks respectively.
[0073] The above implementation methods of allocating construction tasks are only some exemplary explanations. In other embodiments, the construction tasks may be allocated by combining the above multiple implementation methods or using other applicable methods, which is not limited to this.
[0074] Furthermore, when assigning build tasks to multiple instances, the execution module 1013 may also send the dependency files required for executing the build tasks to each instance, so that each instance can use the dependency files to execute the assigned build tasks. Alternatively, the dependency files in the resource pool 10 can be shared by multiple instances, so that each instance can execute the build tasks based on the shared dependency files.
[0075] It is worth noting that each instance can be assigned to one or more build tasks at the same time. Among them, when each instance is assigned to multiple build tasks, the instance can use the dependency file to execute each build task in sequence. Among them, when the instance executes the build task, it specifically uses the dependency file to execute the build process for one or more targets included in the build task. The specific build operations performed on the target have relevant applications in the actual application scenario, which will not be elaborated here. Alternatively, each instance can execute multiple assigned build tasks in parallel. For example, multiple threads can be created inside each instance, and each thread can be responsible for processing a build task, so that after each instance is assigned to multiple build tasks, it can use multiple threads to execute the multiple assigned build tasks in parallel. In actual application, based on the dependencies between the targets in different build tasks, it can be determined whether to execute the build tasks serially / in parallel on the instance.
[0076] In this embodiment, when the targets in the multiple build tasks are all the targets defined in the compilation control file, the execution module 1013 may distribute all the build tasks to multiple instances for execution.
[0077] Alternatively, when the targets in multiple build tasks are partial targets defined in the compilation control file, the execution module 1013 can use partial targets as build tasks and assign them to multiple instances for execution, while the remaining targets in the compilation control file can be executed by the execution module 1013. At this point, instance 101 also participates in executing the build task. In actual application scenarios, due to the difference in computing power between instance 101 and the remaining instances, for different targets in the compilation control file, the efficiency of completing the build on instance 101 and other instances may be different, that is, the efficiency of instance 101 executing partial targets may be higher than the efficiency of the remaining instances executing the partial targets. Therefore, the execution module 1013 can assign partial targets in the compilation control file as build tasks to other multiple instances to complete the build according to the computing power requirements required for the execution target, while the remaining targets can be completed by instance 101, so as to further improve the software construction efficiency.
[0078] Exemplarily, when the compilation control file is specifically a cmakelist file, the targets in the multiple build tasks generated by the generation module 1012 are partial targets defined in the cmakelist file, such as being of a specified type (such as ExternalProject type, CustomTarget type, etc.) or being partial targets with a specified identifier, so that the remaining multiple instances in the resource pool 10 except instance 101 execute multiple build tasks in parallel, and instance 101 executes the remaining targets in the compilation control file. Moreover, in the process of allocating build tasks by the execution module 1013, each build task can include a target, and the execution module 1013 can allocate build tasks to multiple instances one by one according to the dependency relationship between the targets, so that the multiple instances construct the target as the upper node of the leaf node after constructing the target as the leaf node.
[0079] Alternatively, when the compilation control file is specifically a ninja file, and the targets in the multiple build tasks are some of the targets defined in the ninja file, then, when generating multiple build tasks, the generation module 1012 may also generate a new first ninja file and a second ninja file, and send the first ninja file and the multiple build tasks to multiple instances. Moreover, the build task assigned to each instance may include a group of targets with dependencies. In this way, the execution module 1013 may allocate multiple targets to be built to each instance at one time, without the need to allocate them one by one according to the execution results. Each instance executes the build task according to the first ninja file, and the targets in the multiple build tasks and the dependency information of the targets are defined in the first ninja file. At the same time, the execution module 1013 may execute the remaining targets in the compilation control file according to the second ninja file, and the remaining targets of the files in the original ninja and the dependency information of the targets are defined in the second ninja file.
[0080] After each instance executes each build task and generates the corresponding execution result, the execution result can be synchronized to other instances so that other instances can execute the build tasks assigned to the other instances based on the synchronized execution results. In this way, it can be avoided that when a dependency bottleneck occurs in a single instance node, the build efficiency of the remaining instances for the targets assigned to them is affected, thereby ensuring the overall build efficiency of the software. When instance 101 also executes the build operation of some targets, the remaining instances can also synchronize the execution results generated by executing the build tasks to instance 101.
[0081] After generating execution results corresponding to a plurality of construction tasks, the execution module 1013 may provide the execution results to the construction module 1014 .
[0082] S205: The construction module 1014 constructs the software according to the execution results corresponding to the multiple construction tasks.
[0083] Among them, the constructed software is the software that the user wants to develop.
[0084] In specific implementation, when the targets in multiple build tasks are some of the targets defined in the compilation control file, the build module 1014 can summarize the execution results corresponding to the multiple build tasks, and continue to complete the construction of the remaining targets in the compilation control file according to the summarized execution results, so as to complete the construction of all the targets in the compilation control file, thereby building the software. When the targets in multiple build tasks are all the targets defined in the compilation control file, the build module 1014 can obtain the construction result for the software by summarizing the execution results corresponding to each build task.
[0085] In this embodiment, since instance 101 executes the construction process for multiple construction tasks including different targets in parallel during the process of building the software, this can effectively improve the construction efficiency for the multiple targets compared to the method of building the targets one by one on a single machine, thereby effectively improving the overall efficiency of building the software.
[0086] It should be noted that Figure 2 The execution order of the steps shown in is only an implementation example and is not intended to be limiting. For example, in other possible implementations, the example 101 may first execute step S202 and then execute step S201, or execute step S201 and step S202 simultaneously.
[0087] In addition, in this embodiment, the division and functional description of each module in the example 101 are only used as an example. For example, in other embodiments, the data acquisition module 1011 can be used to execute any step in the above-mentioned method for constructing software. Similarly, the generation module 1012, the execution module 1013, and the construction module 1014 can all be used to execute any step in the above-mentioned method for constructing software. Moreover, the steps that the data acquisition module 1011, the generation module 1012, the execution module 1013, and the construction module 1014 are responsible for implementing can be specified as needed. The data acquisition module 1011, the generation module 1012, the execution module 1013, and the construction module 1014 respectively implement different steps in the method for constructing software to realize all the functions of the example 101.
[0088] Above Figure 1 as well as Figure 2 In the illustrated embodiment, the instance 101 (including the above-mentioned data acquisition module 1011, generation module 1012, execution module 1013, and construction module 1014) involved in the process of building the software may be software configured on a computing device or a computing device cluster, and by running the software on the computing device or computing device cluster, the computing device or computing device cluster may implement the functions of the above-mentioned instance 101. Below, based on the perspective of hardware device implementation, the instance 101 involved in the process of building the software is described in detail.
[0089] Figure 4 The schematic diagram of the structure of a computing device is shown. The above instance 101 can be deployed on the computing device. The computing device can be a computing device in a cloud environment (such as a server), or a computing device in an edge environment, or a terminal device, etc., which can be specifically used to implement the above Figure 1 The functions of the data acquisition module 1011, the generation module 1012, the execution module 1013, and the construction module 1014 in the illustrated embodiment.
[0090] like Figure 4As shown, computing device 400 includes processor 410, memory 420, communication interface 430 and bus 440. Processor 410, memory 420 and communication interface 430 communicate through bus 440. Bus 440 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 The communication interface 430 is used to communicate with the outside, for example, to obtain code files from the code warehouse, to obtain dependency files from the dependency library, etc.
[0091] Among them, the processor 410 can be a central processing unit (CPU), an application specific integrated circuit (ASIC), a graphics processing unit (GPU) or one or more integrated circuits. The processor 410 can also be an integrated circuit chip with signal processing capabilities. In the implementation process, the functions of each module in the example 101 can be completed by the hardware integrated logic circuit or software instructions in the processor 410. The processor 410 can also be a general processor, a digital signal processor (DSP), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, and can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. Among them, the general processor can be a microprocessor or the processor can also be any conventional processor, etc., and the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 420 , and the processor 410 reads the information in the memory 420 and completes part or all of the functions in the instance 101 in combination with its hardware.
[0092] The memory 420 may include a volatile memory, such as a random access memory (RAM), or a non-volatile memory, such as a read-only memory (ROM), a flash memory, a HDD, or a SSD.
[0093] The memory 420 stores executable codes, and the processor 410 executes the executable codes to execute the method executed by the aforementioned example 101.
[0094] Specifically, in implementing Figure 2 In the case of the embodiment shown, and Figure 2 In the embodiment shown, the data acquisition module 1011, the generation module 1012, the execution module 1013, and the construction module 1014 are implemented by software. Figure 2 The software or program code required for the functions of the data acquisition module 1011, the generation module 1012, the execution module 1013, and the construction module 1014 are stored in the memory 420. The interaction between the data acquisition module 1011 and other devices is realized through the communication interface 430. The processor is used to execute the instructions in the memory 420 to implement the method executed by the instance 101.
[0095] Figure 5 A schematic diagram of the structure of a computing device cluster is shown. Figure 5 The computing device cluster 50 shown includes multiple computing devices, and the above-mentioned instance 101 can be distributedly deployed on multiple computing devices in the computing device cluster 50. Figure 5 As shown, the computing device cluster 50 includes multiple computing devices 500 , each computing device 500 includes a memory 520 , a processor 510 , a communication interface 530 and a bus 540 , wherein the memory 520 , the processor 510 , and the communication interface 530 are communicatively connected to each other via the bus 540 .
[0096] The processor 510 may be a CPU, a GPU, an ASIC, or one or more integrated circuits. The processor 510 may also be an integrated circuit chip with signal processing capabilities. In the implementation process, some functions of the instance 101 may be completed by the hardware integrated logic circuit or software instructions in the processor 510. The processor 510 may also be a DSP, an FPGA, a general-purpose processor, other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, and may implement or execute some of the methods, steps, and logic block diagrams disclosed in the embodiments of the present application. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc., and the steps of the method disclosed in the embodiments of the present application may be directly embodied as a hardware decoding processor to be executed, or a combination of hardware and software modules in the decoding processor to be executed. The software module may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 520. In each computing device 500, the processor 510 reads the information in the memory 520, and in combination with its hardware, some functions of the instance 101 may be completed.
[0097] The memory 520 may include ROM, RAM, static storage device, dynamic storage device, hard disk (such as SSD, HDD), etc. The memory 520 may store program codes, for example, part or all of the program codes for implementing the data acquisition module 1011, part or all of the program codes for implementing the generation module 1012, part or all of the program codes for implementing the execution module 1013, part or all of the program codes for implementing the construction module 1014, etc. For each computing device 500, when the program code stored in the memory 520 is executed by the processor 510, the processor 510 executes part of the method executed by the instance 101 based on the communication interface 530, such as a part of the computing devices 500 may be used to execute the methods executed by the above-mentioned data acquisition module 1011 and the generation module 1012, and another part of the computing devices 500 may be used to execute the methods executed by the above-mentioned execution module 1013 and the construction module 1014. The memory 520 may also store data, for example: intermediate data or result data generated by the processor 510 during the execution process, for example, the above-mentioned code files, dependency files, constructed software, etc.
[0098] The communication interface 503 in each computing device 500 is used for external communication, such as interacting with other computing devices 500 .
[0099] The bus 540 may be a peripheral component interconnect standard bus or an extended industry standard architecture bus. For ease of representation, Figure 5The bus 540 in each computing device 500 is represented by only one thick line, but this does not mean that there is only one bus or one type of bus.
[0100] The plurality of computing devices 500 establish communication paths through a communication network to implement the functions of the instance 101. Any computing device may be a computing device (eg, a server) in a cloud environment, or a computing device in an edge environment, or a terminal device.
[0101] In addition, an embodiment of the present application also provides a computer-readable storage medium, which stores instructions. When the computer-readable storage medium is run on one or more computing devices, the one or more computing devices execute the methods executed by the various modules included in example 101 in the above embodiment.
[0102] In addition, the embodiment of the present application further provides a computer program product, and when the computer program product is executed by one or more computing devices, the one or more computing devices execute any of the aforementioned methods for constructing software. The computer program product may be a software installation package, and when any of the aforementioned methods for constructing software is required, the computer program product may be downloaded and executed on a computer.
[0103] It should also be noted that the device embodiments described above are merely schematic, 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 over 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. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0104] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances. This is just a way of distinguishing objects with the same attributes when describing the embodiments of this application.
[0105] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0106] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0107] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
Claims
1. A method for building software, characterized in that, The method is applied to a first instance in a resource pool, and the method comprises: The first instance obtains a code file of the software to be built from the code repository; The first instance obtains the dependency files required to build the software from the dependency library; The first instance generates a plurality of build tasks based on a plurality of targets in the code file, wherein different build tasks in the plurality of build tasks include different targets; The first instance instructs multiple instances in the resource pool to execute the multiple construction tasks in parallel using the dependency file to obtain execution results corresponding to the multiple construction tasks respectively; The first instance constructs the software according to the execution results corresponding to the multiple construction tasks.
2. The method according to claim 1, characterized in that The first instance obtains the code file of the software to be built from the code repository, including: The first instance performs distributed caching on code files of the software in the code warehouse.
3. The method according to claim 1 or 2, characterized in that: The first instance generates multiple build tasks based on multiple targets in the code file, including: The first instance determines a compilation control file in the code file, wherein the compilation control file includes a plurality of targets and dependency information of the plurality of targets; The first instance generates the multiple build tasks for the software according to the compilation control file.
4. The method according to claim 3, characterized in that The multiple targets are all targets defined in the compilation control file; Alternatively, the multiple targets are targets in the compilation control file that meet preset conditions, where the preset conditions include preset types or preset identifiers.
5. The method according to claim 4, characterized in that The method further comprises: The first instance outputs a configuration interface; The first instance determines the preset condition in response to a configuration operation performed by a user on the configuration interface for the preset condition.
6. The method according to any one of claims 3 to 5, characterized in that: The first instance instructs multiple instances in the resource pool to use the dependency file to execute the multiple construction tasks in parallel, and obtains execution results corresponding to the multiple construction tasks, including: The first instance distributes the multiple construction tasks to the multiple instances according to a preset rule, the multiple construction tasks are executed in parallel by the multiple instances, and different instances among the multiple instances execute different construction tasks; The first instance obtains execution results respectively corresponding to the multiple construction tasks fed back by the multiple instances.
7. The method according to any one of claims 3 to 6, characterized in that: The first instance generates multiple build tasks based on multiple targets in the code file, including: The first instance groups the multiple targets in the compilation control file according to the number of the multiple instances or the directories to which the build products of the multiple targets belong, to obtain the multiple build tasks, and the targets included in each build task are a group of targets among the multiple targets.
8. The method according to claim 6 or 7, characterized in that: The compilation control file also includes other targets in addition to the multiple targets; The first instance constructs the software according to the execution results corresponding to the multiple construction tasks, including: The first instance builds other targets in the compilation control file to obtain local execution results; The first instance constructs the software according to the local execution result and the execution results corresponding to the multiple construction tasks.
9. A method for building software, characterized in that, The method comprises: Obtaining a compilation control file in a code file of the software to be built and a dependency file required to build the software, wherein the compilation control file includes multiple targets and dependency information of the multiple targets; Generating a plurality of build tasks for the software according to the compilation control file, wherein different build tasks in the plurality of build tasks include different targets; Execute the multiple construction tasks in parallel to obtain execution results corresponding to the multiple construction tasks respectively; The software is constructed according to the execution results respectively corresponding to the multiple construction tasks.
10. A software construction device, characterized in that: The software construction device is applied to a first instance in a resource pool, and the software construction device includes: A data acquisition module is used to obtain the code files of the software to be built from the code warehouse, and obtain the dependency files required to build the software from the dependency library; A generation module, used for generating a plurality of build tasks based on a plurality of targets in the code file, wherein different build tasks in the plurality of build tasks include different targets; An execution module, used to instruct multiple instances in the resource pool to execute the multiple construction tasks in parallel using the dependency files, and obtain execution results corresponding to the multiple construction tasks respectively; The building module is used to build the software according to the execution results corresponding to the multiple building tasks.
11. The software construction device according to claim 10, characterized in that: The data acquisition module is used to perform distributed caching on the code files of the software in the code warehouse.
12. The software construction device according to claim 10 or 11, characterized in that: The generating module is used for: Determine a compilation control file in the code file, wherein the compilation control file includes multiple targets and dependency information of the multiple targets; The multiple build tasks are generated for the software according to the compilation control file.
13. The software construction device according to claim 12, characterized in that: The multiple targets are all targets defined in the compilation control file; Alternatively, the multiple targets are targets in the compilation control file that meet preset conditions, where the preset conditions include preset types or preset identifiers.
14. The software construction device according to claim 13, characterized in that: The software construction device also includes: The configuration module is used to output a configuration interface; and determine the preset condition in response to a user's configuration operation on the configuration interface for the preset condition.
15. The software construction device according to any one of claims 12 to 14, characterized in that: The execution module is used to: Distribute the multiple construction tasks to the multiple instances according to a preset rule, so that the multiple construction tasks are executed in parallel by the multiple instances, and different instances among the multiple instances execute different construction tasks; Obtain execution results respectively corresponding to the multiple construction tasks fed back by the multiple instances.
16. The software construction device according to any one of claims 12 to 15, characterized in that: The generation module is used to group the multiple targets in the compilation control file according to the number of the multiple instances or the directories to which the build products of the multiple targets belong, to obtain the multiple build tasks, and the targets included in each build task are a group of targets among the multiple targets.
17. The software construction device according to claim 15 or 16, characterized in that: The compilation control file also includes other targets in addition to the multiple targets; The building blocks are used to: Build other targets in the compilation control file to obtain local execution results; The software is constructed according to the local execution result and the execution results respectively corresponding to the multiple construction tasks.
18. A software construction device, characterized in that: The software construction device comprises: A data acquisition module, used to acquire a compilation control file in a code file of the software to be built and a dependency file required to build the software, wherein the compilation control file includes multiple targets and dependency information of the multiple targets; A generation module, used to generate a plurality of build tasks for the software according to the compilation control file, wherein different build tasks in the plurality of build tasks include different targets; An execution module, used to execute the multiple construction tasks in parallel and obtain execution results corresponding to the multiple construction tasks respectively; The building module is used to build the software according to the execution results corresponding to the multiple building tasks.
19. A computing device cluster, characterized in that: comprising at least one computing device, each computing device comprising a processor and a memory; The processor is configured to execute instructions stored in the memory, so that the computing device cluster executes the method according to any one of claims 1 to 9.
20. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, which, when executed on at least one computing device, enable the at least one computing device to perform the method according to any one of claims 1 to 9.
21. A computer program product comprising instructions, characterized in that When the method is executed on at least one computing device, the at least one computing device is caused to execute the method according to any one of claims 1 to 9.
Citation Information
Cited By
Gradle-based software RPM package construction method and system
CN120762733A
Method for software construction, apparatus, and related device
EP4657241A1
