A compiling method and an electronic device
By using pre-compiled binary files and API information, the source code of the target functional module can be directly compiled, solving the problems of long compilation time and low efficiency in the existing technology and achieving a more efficient compilation process.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUAWEI TECH CO LTD
- Filing Date
- 2024-06-14
- Publication Date
- 2026-07-24
AI Technical Summary
In existing technologies, the compilation process of functional modules requires processing a large amount of source code, resulting in excessively long compilation times and low efficiency, especially when module dependencies are complex.
By utilizing pre-compiled binary files and API information, and through the API dependencies between modules, the source code of the target functional module can be directly compiled, reducing the amount of source code processing and simplifying the compilation process.
It reduces the amount of compilation tasks, shortens compilation time, improves compilation efficiency, and lowers the requirements for storage space and computing performance.
Smart Images

Figure CN121143798B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a compilation method and an electronic device. Background Technology
[0002] The source code of a software system typically refers to the code written by developers. It describes all the functions and implementation methods of the software system. Source code can be written in one or more programming languages. It's important to understand that source code is not code that a machine can execute. To run a software system on a computer or other device, the source code needs to be compiled into machine-executable object code files, also known as binary files.
[0003] Software systems can be divided into different functional modules, each supporting the system in implementing its corresponding function. Currently, developers can test a specific function within the software system, which requires compiling the corresponding functional module separately.
[0004] When compiling a functional module in isolation, it is usually necessary to compile based on the source code of other functional modules that the module depends on. For example, if the dependencies between modules A, B, C, and D are: module A depends on module B, module B depends on module C, and module C depends on module D, then the compilation order would be: module D - module C - module B - module A. It is evident that compiling module A involves the source code of a large number of other modules. Due to the large volume of source code and the complexity of the compilation process, the compilation time can be excessive, thus impacting compilation efficiency. Summary of the Invention
[0005] This application provides a compilation method and an electronic device that can reduce the amount of compilation tasks, reduce compilation time, and improve compilation efficiency.
[0006] To achieve the above objectives, the embodiments of this application provide the following technical solutions:
[0007] Firstly, a compilation method is provided. In this method, firstly, the first source code of a first functional module to be compiled is obtained, wherein the first functional module is used to implement a first function. Then, based on the first source code, at least one binary file corresponding to at least one second functional module on which the first functional module depends, and at least one set of application programming interface (API) information corresponding to each of the at least one binary file, are obtained from a binary library. The second functional modules are different from the first functional module; the binary files are pre-compiled from the second source code used to implement the functions of the second functional modules, and the API information corresponding to the binary files is obtained during the pre-compilation of the second source code. Finally, based on the at least one binary file corresponding to each of the at least one second functional module and the at least one set of API information corresponding to each of the at least one binary file, the first source code is compiled to obtain the binary file corresponding to the first functional module.
[0008] In the above method, the binary library is a pre-configured data storage space. The binary files are pre-compiled, not generated during compilation. Thus, during the compilation of the first source code, only the binary files of the second functional modules that the first functional module depends on need to be processed, without needing to process the source code of the second functional modules that the first functional module depends on. This reduces the workload of compilation, reduces compilation time, and improves compilation efficiency. Furthermore, the compiled binary files all correspond to API information. Based on the binary file corresponding to the second functional module and its corresponding API information, the compilation of the first source code can be completed without further determining the functional modules that the second functional module depends on. This also simplifies the compilation process, further reducing compilation time and improving compilation efficiency.
[0009] In one possible implementation of the first aspect, a second functional module corresponds to a binary file; a binary file corresponds to a set of API information; the binary file corresponding to the second functional module includes header files and library files of at least one first API provided by the second functional module; the API information corresponding to the binary file includes API description information, which is used to indicate the path to obtain the header files and library files of each first API during the compilation of the first source code.
[0010] In this implementation, since the dependency relationship between modules is "API dependency", and the API information included in the binary file can indicate the "API dependency" between functional modules, the first source code can be compiled based on at least one binary file corresponding to at least one second functional module and at least one set of API information corresponding to at least one binary file, to obtain the binary file corresponding to the first functional module.
[0011] In one possible implementation of the first aspect, during the process of compiling the first source code to obtain the binary file corresponding to the first functional module based on at least one binary file corresponding to at least one second functional module and at least one set of API information corresponding to each of the at least one binary file, for each second functional module, the header file and library file of each first API provided by the second functional module can be obtained from the binary file based on the API description information corresponding to the binary file. Then, the first source code is compiled based on the header file and library file of each first API provided by each second functional module to obtain the binary file corresponding to the first functional module.
[0012] In this implementation, when compiling the first source code of the first functional module, the header file and library file of the API can be accurately obtained from the binary file according to the API description information, so as to compile the first source code.
[0013] In one possible implementation of the first aspect, the API information corresponding to the aforementioned binary file further includes description information of the second functional module corresponding to the binary file; the description information of the second functional module is used to indicate at least one first API provided by the second functional module.
[0014] In this way, based on the description information of the second functional module, one can intuitively understand the APIs that the second functional module can provide.
[0015] In one possible implementation of the first aspect, the method further includes: obtaining a first product based on at least one binary file corresponding to at least one functional module, wherein the first product includes at least one function implemented by at least one functional module, and the at least one functional module includes the first functional module.
[0016] In this implementation, there is no need to generate the binary files of each functional module in the product first, and then use the binary files of each functional module to generate the product image. Instead, the product image is obtained directly using the pre-compiled binary files of each functional module. This reduces the generation process of the binary files of each functional module and improves the compilation efficiency of the entire product image.
[0017] Secondly, a compilation method is provided. In this method, firstly, a second source code is obtained, which is used to implement the functionality corresponding to the second functional module. Then, based on the second source code, the corresponding binary file of the second functional module is compiled, and the API information corresponding to the binary file is obtained. Finally, the binary file corresponding to the second functional module and the corresponding API information are sent to a binary library. The binary library stores at least one binary file corresponding to at least one functional module and at least one set of API information corresponding to each binary file, for use in compiling the first source code of a first functional module that depends on at least one second functional module.
[0018] In this method, the binary file corresponding to the second functional module can be pre-compiled. In this way, the binary file of the second functional module can directly participate in the subsequent compilation process of the source code of other functional modules. During the compilation process of the source code of other functional modules, the binary file can be used to compile the source code, thereby reducing the amount of compilation tasks, reducing compilation time, and improving compilation efficiency.
[0019] In one possible implementation of the second aspect, the binary file corresponding to the second functional module includes header files and library files of at least one first API provided by the second functional module, wherein the API information corresponding to the binary file includes API description information, which is used to indicate the path to obtain the header files and library files of each API in at least one first API during the compilation of the first source code.
[0020] In this implementation, since the dependency relationship between modules is "API dependency", and the API information included in the binary file can indicate the "API dependency" between functional modules, the first source code can be compiled based on the binary file corresponding to at least one second functional module and the API information corresponding to the binary file to obtain the binary file corresponding to the first functional module.
[0021] In one possible implementation of the second aspect, the API information corresponding to the binary file further includes description information of the second functional module corresponding to the binary file; the description information of the second functional module is used to indicate at least one first API provided by the second functional module.
[0022] In this way, based on the description information of the second functional module, one can intuitively understand the APIs that the second functional module can provide.
[0023] In one possible implementation of the second aspect, the binary file corresponding to the second functional module also includes attribute information. This attribute information may indicate the name of the binary file, the set of files in the binary file involved in the product image packaging, the version information of the binary file, and the description information of the binary file, etc.
[0024] Thirdly, an electronic device is provided, including a memory and one or more processors; the memory is coupled to the processors; wherein the memory stores computer program code, the computer program code including computer instructions, which, when executed by the processor, cause the electronic device to perform a compilation method as described in the first aspect and any implementation thereof, or to perform a compilation method as described in the second aspect and any implementation thereof.
[0025] Fourthly, a computer-readable storage medium is provided, including computer instructions that, when executed on an electronic device, cause the electronic device to perform a compilation method as described in the first aspect and any implementation thereof, or to perform a compilation method as described in the second aspect and any implementation thereof.
[0026] Fifthly, a computer program product is provided that, when run on a computer, causes the computer to execute the compilation method described in the first aspect and any implementation thereof, or to execute the compilation method described in the second aspect and any implementation thereof.
[0027] The beneficial effects that the electronic device provided in the third aspect, the computer-readable storage medium provided in the fourth aspect, and the computer program product provided in the fifth aspect can achieve can be referred to the beneficial effects that can be achieved in the first aspect and any of its implementations, or to the beneficial effects that can be achieved in the second aspect and any of its implementations, which will not be repeated here. Attached Figure Description
[0028] Figure 1 This illustration shows a separate compilation of the modules provided in the embodiments of this application. Figure 1 ;
[0029] Figure 2 A schematic diagram of the compilation system provided in an embodiment of this application is shown;
[0030] Figure 3 A schematic diagram illustrating the storage content of the storage device provided in an embodiment of this application is shown;
[0031] Figure 4 This application illustrates a flowchart of the compilation method provided in an embodiment. Figure 1 ;
[0032] Figure 5This illustration shows a first device acquiring information according to an embodiment of this application. Figure 1 ;
[0033] Figure 6 This illustration shows a first device acquiring information according to an embodiment of this application. Figure 2 ;
[0034] Figure 7 This application illustrates a flowchart of the compilation method provided in an embodiment. Figure 2 ;
[0035] Figure 8 This application illustrates a flowchart of the compilation method provided in an embodiment. Figure 3 ;
[0036] Figure 9 This illustration shows a schematic diagram of the second device acquiring information according to an embodiment of this application;
[0037] Figure 10 The embodiments of this application provide the solution of this application and Figure 1 A diagram illustrating the differences between the options;
[0038] Figure 11 This application illustrates a flowchart of the compilation method provided in an embodiment. Figure 4 ;
[0039] Figure 12 A schematic diagram of the structure of an electronic device provided in an embodiment of this application is shown. Detailed Implementation
[0040] The technical solutions of the embodiments of this application will be described below with reference to the accompanying drawings. In the description of this application, unless otherwise stated, " / " indicates that the objects before and after are in an "or" relationship. For example, A / B can represent A or B. "And / or" in this application is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone, where A and B can be singular or plural. Furthermore, in the description of this application, unless otherwise stated, "multiple" refers to two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple. Furthermore, to facilitate a clear description of the technical solutions in the embodiments of this application, the terms "first" and "second" are used in the embodiments of this application to distinguish identical or similar items with substantially the same function and effect. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and that "first" and "second" are not necessarily different. Meanwhile, in the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is being used as an example, illustration, or description. Any embodiment or design scheme described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of terms such as "exemplary" or "for example" is intended to present related concepts in a concrete manner for ease of understanding.
[0041] Furthermore, the business scenarios described in the embodiments of this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided in the embodiments of this application. As those skilled in the art will know, with the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0042] Before introducing the main content of the embodiments of this application, some terms involved in the embodiments of this application will be explained first.
[0043] Source code refers to the complete code of a software system, including all program files, configuration files, library files, etc., involved in the software system. Source code is written by developers and describes all the functions and implementation methods of the software system. Source code is usually written in one or more programming languages, such as Java, C++, Python, etc. Source code is the core of software development; it contains all the details and logic of the software system and is its foundation. By reading and modifying source code, developers can customize and extend the software system to better meet specific needs and requirements. Software systems, such as operating systems, include... wait.
[0044] An application programming interface (API) is a computing interface used to define interactions between software and the types of calls or requests that can be made. It describes how to make calls or requests, the data formats to use, and the conventions to follow. The purpose of an API is to provide applications and developers with the ability to access a set of routines based on specific software or hardware, without needing access to the source code or understanding the details of the internal workings.
[0045] A cloud-based central warehouse refers to a centralized repository established in a cloud computing environment for storing, managing, and processing data. It can also be a cloud-based device or server. Cloud-based central warehouses achieve efficient data storage and management through cloud computing technology, providing flexible, reliable, and secure data storage services. They achieve high availability and fault tolerance through a distributed architecture, while supporting rapid data access and processing. Cloud-based central warehouses can meet various data storage needs of enterprises and individuals, including file storage, database storage, and object storage. They also provide data backup and recovery, data encryption, and security functions to ensure data security and reliability.
[0046] Compilation refers to the process of converting source code into object code (i.e., binary files). In computer science, source code is human-readable code written by developers, while object code is machine code that computers can execute. Compilation is typically performed using a compiler, a software tool that converts source code into object code and runs the corresponding program on a computer. The compilation process includes steps such as lexical analysis, syntax analysis, semantic analysis, code optimization, and code generation.
[0047] Software systems can be divided into different functional modules according to their functions, and each functional module supports the software system in implementing its corresponding function. For example, the camera function of a software system can be supported by a corresponding camera function module; the music function of a software system can be supported by a corresponding music function module. As another example, an operating system, as a software system, can have various subsystems as its functional modules, such as a multimedia subsystem to support the multimedia functions of the operating system, or an event notification subsystem to support event and notification management. Furthermore, a subsystem of an operating system can also be considered a software system, and its functional modules can be the various components that make up that subsystem; taking a graphics subsystem as an example, its functional modules can include window management components to support the window management functions of the graphics subsystem, and rendering components to support the rendering functions of the graphics subsystem. Finally, an application can also be considered a software system, and its functional modules can include activities, services, and notifications.
[0048] Currently, developers test the functionality of software systems before releasing them as official versions. Testing a specific function typically requires compiling the corresponding functional module separately to obtain a machine-executable binary file. This binary file is then run on an electronic device to test the functionality.
[0049] When compiling a specific functional module in isolation, it is usually necessary to compile it based on the source code of the other functional modules that it depends on. For an example, see [link to example]. Figure 1 As shown in (a), the dependencies between modules A, B, C, and D are as follows: module A depends on module B, module B depends on module C, and module C depends on module D. Therefore, the order of compiling the source code is module D - module C - module B - module A. That is, to compile module A, you must first compile modules D, C, and B in that order.
[0050] However, the source code is very large. According to the above compilation method, the compilation module or compilation device often needs to handle a large number of compilation tasks, and the compilation process is also relatively complex. This will make the compilation time longer and reduce the compilation efficiency.
[0051] In some other implementations, compilation can also be performed on a complete product; see [link to relevant documentation]. Figure 1As shown in (b), compiling a product may involve N modules. Since compiling each module individually corresponds to a large amount of compilation work, compiling a product requires an even larger amount of compilation work. Furthermore, if M products are to be compiled, approximately M*N modules need to be compiled, and the scale of the compilation work will be even larger, resulting in lower product compilation efficiency.
[0052] Furthermore, modifying the parameters of a functional module will trigger the recompilation of the source code of other functional modules that depend on that functional module during the compilation process, which makes the compilation process time-consuming and complex. Also, for the compilation module or compilation device, there are many modules that need to be compiled. If the compilation device performs parallel compilation, the performance requirements of the compilation device are relatively high.
[0053] Based on the above, this application provides a compilation method that can be applied to the compilation process of functional modules. During compilation, a pre-compiled binary file corresponding to the target functional module to be compiled and the API information corresponding to the binary file can be used to compile the source code of the target functional module, thereby obtaining a machine-executable binary file of the target functional module.
[0054] The aforementioned "pre-compiled binary file corresponding to the target functional module to be compiled" can be obtained by compiling the source code of other functional modules that the target functional module depends on. For example, "dependency" here can refer to API dependency. After compilation, the size of the binary file is much smaller than the size of the source code, and the binary files are independent of each other. Each binary file contains API information, which indicates all the APIs provided by the target functional module. In this way, the compilation of the target functional module can be completed using the binary file corresponding to the target functional module and its corresponding API information, without needing to compile based on a large amount of source code. This significantly reduces the workload, compilation time, and compilation efficiency.
[0055] In some embodiments, the above compilation method can be divided into two processes. The first process is to save the binary file in advance, and the second process is to compile the source code using the binary file.
[0056] In the first process, the source code corresponding to the function of the functional module is first obtained. Then, based on the source code, the corresponding binary file for the functional module is compiled, and the corresponding API information is obtained. Finally, the binary file corresponding to the functional module and its corresponding API information are sent to the binary library. Thus, the pre-compiled binary file and its corresponding API information are stored in the binary library. It can be understood that in the first process, the number of such functional modules can be P (P is a positive integer greater than or equal to 1). The source code corresponding to each of these P functional modules can be compiled separately to obtain the corresponding binary files (P files in total) and the corresponding API information (P sets) for each of these P binary files. Therefore, the binary library can store the pre-compiled P binary files and the P sets of API information corresponding to each of these P binary files.
[0057] It is understandable that the process of compiling the source code corresponding to each of the P functional modules in the first process to obtain P binary files can be performed by one device or by different devices respectively; for example, device a compiles the source code corresponding to each of the p1 functional modules to obtain p1 binary files and p1 sets of API information, and device b compiles the source code corresponding to each of the p2 functional modules to obtain p2 binary files and p2 sets of API information, where p1 + p2 = P.
[0058] In the second process, the first source code of the first functional module to be compiled can be obtained first, whereby the first functional module implements the first function. Then, based on the first source code, the binary files corresponding to the second functional modules that the first functional module depends on, and the corresponding API information of these binary files, are obtained from the binary library. The second functional modules are different from the first functional module. Finally, based on the binary files corresponding to the second functional modules and the corresponding API information, the first source code is compiled to obtain the binary file corresponding to the first functional module. It can be understood that the number of the aforementioned second functional modules can be Q (Q is a positive integer greater than or equal to 1), meaning that the aforementioned first functional module can depend on multiple second functional modules. Therefore, in the second process, based on the first source code, Q binary files corresponding to each of the Q second functional modules that the first functional module depends on, and Q sets of API information corresponding to each of these Q binary files, can be obtained from the binary library. Then, based on the first source code, the Q binary files, and the Q sets of API information, the binary file corresponding to the first functional module is compiled.
[0059] It is understood that in some embodiments, the aforementioned Q binary files may be a subset of the aforementioned P binary files, i.e., Q is less than or equal to P. In other words, in the first process, the binary library can be used to pre-store a large number of pre-compiled binary files corresponding to functional modules and pre-acquired API information. Therefore, in the second process, one or more required binary files and one or more corresponding API information can be directly obtained from the binary library on demand, facilitating the compilation of the source code of other functional modules that depend on one or more functional modules corresponding to those one or more binary files.
[0060] It is understood that, in some embodiments, the binary file and API information corresponding to the first functional module generated during the second process can also be further uploaded to the binary library to facilitate the subsequent compilation of the source code of other functional modules that depend on the first functional module.
[0061] In the above compilation method, the binary files used to compile the first source code are pre-compiled, rather than generated during the compilation process. This eliminates the need to use the source code of other functional modules to compile the first source code, reducing the workload, compilation time, and improving efficiency. Furthermore, the pre-compiled binary files all contain corresponding API information. Based on the binary file corresponding to the second functional module and its corresponding API information, the compilation of the first source code can be completed without further determining the functional modules that the second functional module depends on. This simplifies the compilation process, again reducing compilation time and improving efficiency.
[0062] For example, the dependencies between modules A, B, C, and D are as follows: module A depends on module B, module B depends on module C, and module C depends on module D. Then, using the compilation method described in this embodiment, the API information of module C (which module B depends on) and the API information of module D (which module C depends on) can be stored in the API information corresponding to the binary file of module B. In this way, when compiling the source code of module A, compilation can be performed directly based on the binary file of module B and its corresponding API information, thus eliminating the need to compile the source code of modules D, C, and B.
[0063] In this embodiment, the binary library is a pre-configured data storage space. In some examples, the binary library can be stored in the cloud as part of a cloud central repository. In other examples, the first device is used to implement the first process described above, and the second device is used to implement the second process. In this case, the binary library can be stored locally on the second device so that the second device can access the binary files and API information in the binary library as needed. Of course, the binary library can also be stored locally on the first device, and the second device can retrieve the binary files and API information from the first device when needed.
[0064] Furthermore, taking the second device used to implement the second process as an example, when compiling the source code of a functional module, the second device can process the binary files of other functional modules that the functional module depends on in parallel, without needing to process the source code of those other functional modules. Since the size of the binary file is smaller than the source code, and the second device does not need to perform the process of compiling the dependent functional modules from the source code into binary files, the storage space requirements and computing performance requirements of the second device will also be reduced.
[0065] Furthermore, when compiling a complete product, the product can be assembled using the binary files corresponding to the various functional modules involved. In this way, the product compilation process will not involve the compilation of a large amount of source code, thereby improving the efficiency of product compilation.
[0066] The compilation method provided in this application can be applied to a compilation system. See also... Figure 2 As shown, the compilation system may include a first device 201, a storage device 202, and a second device 203.
[0067] The first device 201 can compile the source code that implements one or more functions into binary files that are functional modules. A functional module can implement one function, a class of functions (multiple functions of the same type), or multiple functions that serve a specific business objective.
[0068] In some embodiments, the source code compiled by the first device 201 may be the source code of a product. This product may be a software system that implements one or more functions, such as an operating system, a subsystem of an operating system, an application, etc. This application embodiment does not impose specific limitations on this.
[0069] In some embodiments, when compiling source code, the first device 201 can parse the source code, analyze the dependencies between various functional modules, and obtain the binary file corresponding to each functional module based on the dependencies between various functional modules.
[0070] For example, taking "API dependency" as an example, the first device 201 can analyze module C, which module B depends on, and further analyze module D, which module C depends on. Then, the first device 201 compiles the API information provided by module C and the API information provided by module D into the file information of the binary file corresponding to module B.
[0071] For example, file information may include the attribute information of the binary file and the API information corresponding to the binary file.
[0072] Among them, the attribute information of the binary file is used to indicate or include the name of the binary file, the version information of the binary file, the description information of the binary file, etc.
[0073] The API information corresponding to the binary file indicates all APIs provided in the binary file, the folder corresponding to each API, the location of the files provided by that API within the folder, and the description file for each API. The API description file indicates the path to the files provided by the API within the binary file.
[0074] Furthermore, the information indicated by the attribute information and API information is stored in binary files.
[0075] For example, the file information corresponding to the binary file compiled by the first device 201 can be found in the following:
[0076] {module_name}
[0077] --assets
[0078] --innerapis
[0079] ----{api_name}
[0080] ------include
[0081] ------lib
[0082] ------api.config
[0083] module.json
[0084] LICENSE
[0085] README.md
[0086] Among these, {module_name}, assets, LICENSE, README.md, etc., can be part of the above attribute information. Innerapis, {api_name}, lib, includes, api.config, module.json, etc., can be part of the above API information.
[0087] In the attribute information,
[0088] {module_name} is used to indicate the name of the binary file. In some embodiments, the module name of the functional module corresponding to the binary file can be used instead of the name of the binary file.
[0089] The `assets` attribute indicates the collection of files in the binary file that are used in the product image packaging. This collection of files in the binary file is stored in the directory specified by `assets`.
[0090] LICENSE is used to indicate license information for binary files.
[0091] The README.md file contains descriptive information about the binary file, including its purpose and function. In some embodiments, README.md can also be used as a manual for the binary file.
[0092] In the API information,
[0093] Innerapis is a collection of all APIs provided by the functional module corresponding to the binary file. This collection of APIs is stored in the directory indicated by Innerapis within the binary file.
[0094] `{api_name}` indicates the name of the folder corresponding to the API, which is a subdirectory under `Innerapis` mentioned above. In some embodiments, the name of the API can be used instead of the name of the folder corresponding to the API. It can be understood that the number of `{api_name}` entries in the binary file corresponds to the number of APIs that the functional module corresponding to the binary file can provide.
[0095] Lib is used to indicate the folder where the library files provided by the API are stored, which is a subdirectory under {api_name} mentioned above.
[0096] Includes is used to indicate the folder where the header files provided by the API are stored, which is a subdirectory under {api_name} mentioned above.
[0097] The api.config file is used to indicate the description file of the API, and it is a sub-file under {api_name} mentioned above.
[0098] module.json is a description file that indicates the functional modules corresponding to the binary file. The description file indicates all the APIs that can be provided in the binary file, and can be regarded as a directory file of APIs, etc.
[0099] For another example, the definition of module.json can be seen in Table 1 below:
[0100] Table 1
[0101]
[0102]
[0103] For another example, taking the cjson module as an example, the contents of api.config can be seen as follows:
[0104] {
[0105] "name":"cjson",
[0106] "includes":["includes"],
[0107] "lib":"lib / libcjson.so",
[0108] "type":"shared_library"
[0109] }
[0110] Here, `name` indicates the name of the functional module, and "cjson" is the specific name; `includes` describes the path to the API header files; `lib` describes the path to the API binary (i.e., library files); and `type` indicates the type of the API, and "shared_library" is the specific type. During subsequent compilation, these two paths will be set in the compilation path to complete dependency compilation.
[0111] In some embodiments, API information may include API description information, which indicates the description file of the API, or the path to the file provided by the API in the binary file. API information may also include description information of the functional modules corresponding to the binary file, which indicates the description files of the functional modules, or all APIs that can be provided in the binary file.
[0112] In some embodiments, the attribute information of the binary file may also be used to indicate or include the compilation tool corresponding to the binary file, the form of the product to which the functional module corresponding to the binary file belongs, the binary file category, the binary file version number, etc.
[0113] For example, a binary file can be defined as follows:
[0114] Binary_M = Compiler name + Product type + Binary file category + Version number.
[0115] The product type can be used to indicate which type of product the functional module corresponding to the binary file is applied to, such as Linux. Form, Linux Form, etc.
[0116] And, for example, the definition of binary types can be seen in Table 2 below:
[0117] Table 2
[0118] For another example, the version number can be seen in Table 3 below:
[0119] Table 3
[0120]
[0121]
[0122] After obtaining the binary file and its corresponding file information, the first device 201 can send the binary file and its corresponding file information to the storage device 202.
[0123] It is understandable that the first device 201 compiles the functional modules of any product to obtain the binary files and API information corresponding to each functional module.
[0124] Storage device 202 can store binary products corresponding to at least one functional module, wherein the binary products include binary files and file information (such as attribute information, API information, etc.) corresponding to the binary files, and maintain these contents.
[0125] In some embodiments, storage device 202 may include a binary library, specifically storing the aforementioned binary products, etc. In other embodiments, storage device 202 may be a server, or a cloud central warehouse.
[0126] In some embodiments, storage device 202 can associate and store binary artifacts belonging to the same product, for example... Figure 3 As shown, storage device 202 is for Linux The corresponding folder exists in the format 1, for Linux. The corresponding folder exists in the same format. Folder 1 contains the Linux file. The configuration includes at least one functional module's corresponding binary file and its corresponding file information; folder 2 contains Linux. The binary file and corresponding file information for at least one functional module in the form.
[0127] In some embodiments, the storage device 202 may also store at least one compilation toolkit, which includes compilation tools, such as toolchains, that are relied upon when compiling source code. Different compilation toolkits may store different versions and types of compilation tools.
[0128] In some embodiments, the compiler toolkit is also stored in binary form in the aforementioned storage device 202.
[0129] In some embodiments, the above-described compilation system may include at least one first device 201, and each first device 201 may send the compiled binary file and corresponding file information to the storage device 202.
[0130] In other embodiments, when one or more functions of a product need to be modified, the developers need to modify the corresponding source code. In this case, the first device 201 will recompile the source code for the functional modules corresponding to the modified parts of the product's source code, thereby generating a new version of the binary file and corresponding file information. The first device 201 will also send the new version of the binary file and corresponding file information to the storage device 202.
[0131] The second device 203 includes a local central repository and compilation modules, etc.
[0132] In some embodiments, the second device 203 is also referred to as a local device, local environment, etc., the local central repository is also referred to as local storage, and the compilation module is also referred to as a "compilation framework".
[0133] The local central repository can store historical binary files and corresponding file information used when compiling the source code of the second device 203, or new versions of binary files and corresponding file information generated during the compilation process.
[0134] The compilation module is used to compile the first source code of the first functional module based on the binary file corresponding to at least one second functional module that the first functional module depends on and the file information corresponding to the binary file, thereby obtaining the binary file corresponding to the first functional module.
[0135] In some embodiments, since the dependency between modules is an "API dependency", and the API information included in the file information of the binary file can indicate the "API dependency" between functional modules, the compilation module can compile the first source code according to the binary file corresponding to at least one second functional module and the API information corresponding to the binary file, and obtain the binary file corresponding to the first functional module.
[0136] Developers can test the first functional module based on the compiled binary file, for example, by running the binary file on a test device (or a second device 203) to obtain test results.
[0137] It is understandable that in the process of obtaining the binary file corresponding to the first functional module, the compilation module will also obtain the file information corresponding to that binary file.
[0138] In other embodiments, the compilation module may also send the binary file corresponding to the compiled first functional module and the file information corresponding to the binary file to the storage device 202, so that when other functional modules that depend on the first functional module are compiled, they can also obtain the corresponding binary file and the corresponding file information.
[0139] Furthermore, in some embodiments, the compilation module can not only compile individual functional modules, but also package the compiled binary files of at least one functional module belonging to a product into a product image (i.e., the product in the local environment of the second device 203), thereby testing a complete product. In this process, it is unnecessary to first generate the binary files of each functional module in the product and then use those binary files to generate the product image. Instead, the product image is obtained directly using the pre-compiled binary files of each functional module. This reduces the generation process of the binary files for each functional module and improves the overall compilation efficiency of the product image.
[0140] In some embodiments, the compilation module may first obtain the first source code (also referred to as a "module repository") of the first functional module, and parse the first source code to obtain at least one second functional module that the first functional module depends on. The compilation module first determines whether the local central repository contains the binary file and API information corresponding to each second functional module. If the local central repository does not contain the binary file and API information corresponding to one or more second functional modules, the compilation module obtains the binary file and API information corresponding to one or more second functional modules from the storage device 202, and compiles the first source code by combining it with the API information corresponding to the binary file of the second functional module in the local central repository.
[0141] In addition, in some other embodiments, the compilation module will also save the binary files and corresponding API information obtained from the storage device 202 in a local central repository for use when compiling related functional modules next time, thereby improving compilation efficiency.
[0142] In some embodiments, if the local central repository contains binary files corresponding to one or more second functional modules and their corresponding API information, the compilation module also needs to determine whether the binary files in the central repository are the latest versions. If the binary files in the local central repository are not the latest versions, the compilation module will obtain the corresponding latest version binary files and their corresponding API information from the storage device 202.
[0143] In addition, in some other embodiments, the compilation module will also save the latest version of the binary file and the corresponding API information obtained from the storage device 202 to the local central repository, thereby updating the local central repository in a timely manner so that it can be used when compiling related functional modules next time, thereby improving the compilation efficiency.
[0144] In some embodiments, the local central repository may also store the compilation tools used during the compilation of the second device 203. The compilation module can obtain the compilation tools used to compile the first source code from the local central repository and use these compilation tools to obtain the binary file corresponding to the first functional module. If the local central repository does not contain the compilation tools used to compile the first source code, the compilation module obtains the corresponding compilation tools from the storage device 202.
[0145] In addition, in some other embodiments, the compilation module will also save the compilation tools obtained from the storage device 202 in a local central repository for use when compiling related functional modules next time, thereby improving compilation efficiency.
[0146] For example, the compilation module can parse the first source code to obtain the compilation tools used to compile the first source code. Alternatively, the compilation module can also obtain the compilation tools used to compile the first source code based on the attribute information of the binary files corresponding to at least one second functional module.
[0147] In some embodiments, different product forms may correspond to different devices, operating environments, etc. For example, the same software system may have a corresponding product form for a tablet computer and another corresponding product form for a mobile phone. The same functional module of a product may also have different source code in different product forms. Consequently, during compilation, the same functional module may be compiled into different binary files for different product forms. For example, the product form information included in the attribute information of the binary file can distinguish between different binary files.
[0148] In order to accurately compile the binary file for the target product form that the developer needs to test on the second device 203 side, the second device 203 can further determine at least one second functional module based on the current test requirements when compiling the first source code. These test requirements can indicate the product form to which the first functional module to be tested belongs. For example, the test requirements can be input by the developer to the second device 203 based on the actual test situation, or they can be pre-configured by the second device 203.
[0149] Understandably, the aforementioned compilation module integrates functions such as obtaining compilation tools, obtaining binary files, checking for updated binary file versions, resolving module dependencies, compiling module source code, and assembling product images.
[0150] Based on the foregoing Figure 2 When the compilation system shown implements the compilation method provided in the embodiments of this application, it can complete the compilation of the source code of a single functional module by using the binary file corresponding to the dependent functional module and the API information corresponding to the binary file. In this way, it is not necessary to process the source code of other functional modules that the functional module depends on, thereby reducing the amount of compilation tasks, reducing compilation time, and improving compilation efficiency.
[0151] Furthermore, the compiled binary files all correspond to API information. Based on the binary file corresponding to the second functional module and the API information corresponding to the binary file, the compilation of the first source code can be completed without further determining the functional modules that the second functional module depends on. This simplifies the compilation process, reduces compilation time, and improves compilation efficiency.
[0152] In addition, when compiling the source code of a functional module, the second device can process the binary files of other functional modules that the functional module depends on in parallel. Since the size of the binary file is smaller than that of the source code, and the second device does not need to perform the process of compiling the other functional modules it depends on from the source code into binary files, the storage space requirements and computing performance requirements of the second device will also be reduced.
[0153] Furthermore, the functional module compilation process uses pre-compiled binary files. After the parameters of a certain functional module are modified, the corresponding binary file is recompiled and saved to storage device 202. The second device 203 does not need to recompile according to the modified parameters of a certain functional module during the compilation process. The binary file it obtains is the pre-compiled binary file, so there will be no problem of compilation time caused by recompilation.
[0154] It is understood that the first device and the second device in the above embodiments can be devices with compilation and processing capabilities, such as host computers, servers, personal computers, and laptops. The first device and the second device can be the same or different.
[0155] In some possible application scenarios, taking the above compilation method applied to the first device as an example, see [link to relevant documentation]. Figure 4 As shown, the first device can perform the following steps S401-S403.
[0156] S401, The first device obtains the second source code.
[0157] The second source code is used to implement the functions corresponding to the second functional module. Furthermore, the second functional module belongs to a product, such as an operating system, a subsystem of the operating system, or an application. A product may include at least one second functional module. If the product is an operating system, then at least one second source code corresponding to each of the at least one second functional module may be the source code of a system project that constitutes the operating system.
[0158] Furthermore, in some embodiments, the second source code may be stored in the local storage space of the first device, and the first device retrieves the second source code from the storage space. Alternatively, the second source code may also be stored in a storage device, and the first device retrieves the second source code from the storage device.
[0159] S402. The first device compiles the binary file corresponding to the second functional module based on the second source code, and obtains the API information corresponding to the binary file.
[0160] It is understandable that when multiple second functional modules exist, the first device can compile the second source code for each second functional module. For example, see [link to example]. Figure 5 As shown, the product corresponding to the second source code includes functional module 1, functional module 2 and functional module 3. Then the first device can obtain binary file 1 corresponding to functional module 1, binary file 2 corresponding to functional module 2 and binary file 3 corresponding to functional module 3.
[0161] Accordingly, during the compilation of the second source code, based on the dependencies between various functional modules, the first device will also obtain the API information corresponding to the binary file corresponding to the second functional module. For example, see... Figure 6 As shown in (a) and (b), binary file 1 corresponds to API information 1, binary file 2 corresponds to API information 2, and binary file 3 corresponds to API information 3. It can be understood that the API information corresponding to a binary file can be stored within the binary file itself, or it can be stored as supplementary information within the binary file.
[0162] S403, The first device sends the binary file corresponding to the second functional module and the API information corresponding to the binary file to the binary library.
[0163] The binary library is used to store at least one binary file corresponding to at least one second functional module and at least one set of API information corresponding to at least one binary file.
[0164] In some embodiments, the binary library may reside in a storage device (such as a cloud central warehouse or cloud server), or it may reside locally on the compilation device used to compile the source code of the functional module.
[0165] In other embodiments, the functions that the first device can perform are the same as those described in the foregoing embodiments, and will not be repeated here.
[0166] In the above-described schemes S401-S403, the first device compiles the second source code to obtain the binary file corresponding to the second functional module and the API information corresponding to the binary file, and pre-saves the binary file corresponding to the second functional module and the API information corresponding to the binary file. In this way, the binary file of the second functional module can directly participate in the subsequent compilation process of the source code of other functional modules. For example, during the compilation of the source code of the first functional module, only the binary file of the second functional module that the first functional module depends on needs to be processed, without needing to process the source code of the second functional module that the first functional module depends on, thereby reducing the workload of compilation, reducing compilation time, and improving compilation efficiency.
[0167] In some potential application scenarios, taking the above compilation method applied to a second device as an example, the second device can compile the source code of a certain functional module to obtain the binary file of that functional module. For example, see... Figure 7 As shown, the second device can perform the following steps S701-S703.
[0168] S701, the second device obtains the first source code of the first functional module to be compiled.
[0169] The first functional module is used to implement the first function. The first function can be a function within the product to which the first functional module belongs.
[0170] In some embodiments, the first source code may be source code written by the developer using a second device; or, the first source code may be source code written by the developer using another device and then sent to the second device for compilation.
[0171] S702, the second device obtains from the binary library at least one binary file corresponding to at least one second functional module on which the first functional module depends, and at least one set of API information corresponding to at least one binary file, based on the first source code.
[0172] The second functional module is different from the first functional module.
[0173] In some embodiments, the second device may parse the first source code to analyze at least one second functional module on which the first functional module depends.
[0174] In some embodiments, when the binary library is located on a storage device, the second device can obtain the binary file corresponding to at least one second functional module and the corresponding API information from the storage device. When the binary library is located on the second device, the second device can directly obtain the binary file corresponding to at least one second functional module and the corresponding API information from its local storage, thereby saving the time the second device spends retrieving data from the storage device and improving compilation efficiency.
[0175] In other embodiments, a binary library can be set on both the storage device and the second device. Initially, the binary library on the second device may be empty, containing no binary files or corresponding API information. During the compilation process of the second device, the binary files and corresponding API information obtained from the storage device's binary library can be stored in the second device's local binary library.
[0176] Furthermore, when the second device compiles the first functional module, it can first determine whether the local binary library contains the binary file and corresponding API information for the second functional module that the first functional module depends on. If it does, it can directly obtain and use them. If the local binary library does not contain the binary file and corresponding API information for a certain second functional module, the second device will then obtain and use them from the binary library of the storage device. Additionally, the second device can save the binary file and corresponding API information obtained from the binary library of the storage device in its local binary library for use during subsequent compilation.
[0177] S703, the second device compiles the first source code based on at least one binary file corresponding to at least one second functional module and at least one set of API information corresponding to at least one binary file, to obtain the binary file corresponding to the first functional module.
[0178] In some embodiments, after obtaining the binary file corresponding to the first functional module, the second device can also obtain the API information corresponding to the binary file. See also... Figure 8 As shown, in step S801, the second device can also send the binary file corresponding to the first functional module and the corresponding API information to the binary library for storage. Thus, other devices used for compilation can also obtain the binary file corresponding to the first functional module and the corresponding API information from the binary library.
[0179] In some embodiments, the binary file corresponding to the second functional module may include header files and library files for at least one first API provided by the second functional module. Furthermore, the API information corresponding to the binary file may include API description information, which indicates the path to obtain the header files and library files of each first API during the compilation of the first source code. Therefore, when compiling the first source code, the second device can obtain the header files and library files of the dependent APIs based on the binary file corresponding to the API description information.
[0180] It is understood that the second functional module can provide at least one first API, which may include APIs provided by the second functional module itself, or APIs provided by some functional modules that the second functional module depends on, as well as other functional modules that these functional modules depend on.
[0181] For example, for each second functional module, the second device can obtain the header file and library file of each first API from the binary file based on the API description information in the API information corresponding to the binary file. Finally, the second device compiles the first source code based on the header file and library file of each first API provided by each second functional module to obtain the binary file corresponding to the first functional module.
[0182] Among them, see Figure 9 As shown, functional module 1 depends on functional modules 2, 3, and 4. Functional module 2 can provide three APIs, such as API... 21 API 22 API 23 Functional module 3 can provide 4 APIs, such as API 31 API 32 API 33 API34 Functional module 4 can provide two APIs, such as API 1. 41 API 42 The second device obtains the API from binary file 2 corresponding to functional module 2. 21 API 22 API 23 The header and library files are obtained from the binary file 3 corresponding to functional module 3, which contains the API. 31 API 32 API 33 API 34 The header and library files are obtained from the binary file 4 corresponding to functional module 4. 41 API 42 The header files and library files.
[0183] In the compilation process of the S701-S703 scheme described above, when compiling the first source code, only the binary files of the second functional modules that the first functional module depends on need to be processed, without needing to process the source code of the second functional modules that the first functional module depends on. This reduces the workload of compilation, reduces compilation time, and improves compilation efficiency. Furthermore, the compiled binary files all correspond to API information. Based on the binary files corresponding to the second functional modules and their corresponding API information, the compilation of the first source code can be completed without further determining the functional modules that the second functional modules depend on. This also simplifies the compilation process, further reducing compilation time and improving compilation efficiency.
[0184] See Figure 10 As shown, compared to Figure 1 Regarding the compilation process shown in (a) in the present application embodiment, when compiling the source code of module A, the compilation method can directly compile based on the binary file of module B and the API information corresponding to the binary file, which means that the process of compiling the source code of modules D, C and B is omitted.
[0185] Furthermore, when compiling the source code of a functional module, the second device can process the binary files of other functional modules that the functional module depends on in parallel, without needing to process the source code of those other functional modules. Since the binary files are smaller than the source code, and the second device does not need to perform the process of compiling the dependent functional modules from source code to binary files, the storage space and computing performance requirements of the second device are also reduced.
[0186] Furthermore, the functional modules use pre-compiled binary files during compilation. If the parameters of a functional module are modified, the corresponding binary file is recompiled and saved to the binary library. The second device does not need to recompile according to the modified parameters of a functional module during compilation. The binary file it obtains is the pre-compiled binary file, thus avoiding the compilation time problem caused by recompilation.
[0187] In some embodiments, the second device can not only compile individual functional modules, but also obtain a first product corresponding to at least one functional module based on at least one binary file corresponding to each compiled functional module. The first product includes at least one function implemented by the at least one functional module. Furthermore, it is understood that the first product can be a product image in a test environment or a publicly released official version of the product.
[0188] The following example uses the compilation terminal as the second device and the cloud central warehouse as the storage device to further illustrate the above embodiments. For example, see [link to example]. Figure 11 As shown, the compilation device includes compilation modules, module repositories (module source code), and a local central repository. Furthermore, compilation modules can be compiled using compilation tools.
[0189] The compilation terminal first generates compilation instructions. These instructions can be automatically generated by the second device or triggered by the developer on the second device.
[0190] The compilation module responds to the compilation instructions, parses the module's single-module, and obtains the binary files of the dependent functional modules when the module's single-module was compiled.
[0191] The compilation module determines whether the binary file of the functional module that the module depends on exists in the local central repository. The compilation module then obtains the result. If the result indicates that the binary file exists in the local central repository, the compilation module retrieves the corresponding binary file from the local central repository. If the result indicates that the binary file does not exist in the local central repository, or that a newer version of the binary file exists in the cloud central repository, the compilation module retrieves the binary file of the functional module that the module depends on from the cloud central repository.
[0192] The compilation module will install the binary files of the functional modules that the module's single-module depends on, obtained from the cloud central repository, onto the local compilation terminal and begin the formal compilation process for that module's single-module. Alternatively, the compilation module may begin the formal compilation process for that module's single-module after the binary files of the functional modules that the module's single-module depends on already exist in the local central repository.
[0193] The compilation module compiles the module's individual modules based on the obtained binary files, and the compiled binary files of the module's individual modules are obtained after compilation.
[0194] The compilation module installs the binary files of the module's single repository into the local central repository; that is, it saves the binary files of the module's single repository in the local central repository.
[0195] The compilation module can also retrieve at least one binary file that makes up the product from the local central repository and assemble the at least one binary file into a product image.
[0196] Whether a module is compiled into a single repository or a product image is assembled, the compilation terminal will display the corresponding result to indicate to the developers that the compilation process has ended.
[0197] As can be seen from the foregoing embodiments, by adopting the compilation method described in this application, the compilation terminal can complete the independent compilation of functional modules and the compilation of the complete product without using the full source code. Furthermore, when compiling using binary files, the workload is reduced, decreasing compilation time from over 30 minutes to less than 5 minutes, and the code download size for the compilation terminal is reduced from 100GB to less than 100MB, thereby significantly improving product development and testing efficiency.
[0198] In some embodiments, the first device and the second device in this application may also be the same device.
[0199] In some solutions, multiple embodiments of this application can be combined, and the combined solution can be implemented. Optionally, some operations in the processes of each method embodiment may be combined, and / or the order of some operations may be changed. Furthermore, the execution order between the steps of each process is merely exemplary and does not constitute a limitation on the execution order between steps; other execution orders are also possible. It is not intended to indicate that the execution order is the only possible order in which these operations can be performed. Those skilled in the art will conceive of various ways to reorder the operations described in the embodiments of this application. In addition, it should be noted that the process details involved in one embodiment of this application are also applicable to other embodiments in a similar manner, or different embodiments may be combined.
[0200] Furthermore, some steps in the method embodiments can be equivalently replaced with other possible steps. Alternatively, some steps in the method embodiments may be optional and can be deleted in certain use cases. Or, other possible steps may be added to the method embodiments.
[0201] Furthermore, the various method embodiments can be implemented individually or in combination.
[0202] It is understood that, in order to achieve the above functions, the aforementioned electronic device includes hardware and / or software modules corresponding to perform each function. Based on the algorithmic steps of the various examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered beyond the scope of this application.
[0203] This embodiment can divide the electronic device into functional modules according to the above method example. For example, each function can be divided into its own functional modules, or two or more functions can be integrated into one processing module. The integrated modules can be implemented in hardware. It should be noted that the module division in this embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.
[0204] This application also provides an electronic device, such as... Figure 12 As shown, the electronic device may include one or more processors 1201, memory 1202, and communication interface 1203. Exemplarily, the electronic device may be the first device, storage device, or second device as described in the foregoing embodiments; however, this application does not impose specific limitations on this.
[0205] The memory 1202, communication interface 1203, and processor 1201 are coupled together. For example, the memory 1202, communication interface 1203, and processor 1201 can be coupled together via bus 1204.
[0206] The communication interface 1203 is used for data transmission with other devices. The memory 1202 stores computer program code. The computer program code includes computer instructions, which, when executed by the processor 1201, cause the electronic device to perform the compilation method described in this embodiment.
[0207] The processor 1201 may be a processor or controller, such as a CPU, a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with this disclosure. The processor may also be a combination that implements computational functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0208] Bus 1204 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Bus 1204 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 12 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0209] This application also provides a computer-readable storage medium that includes computer instructions. When the computer instructions are executed on an electronic device, the electronic device performs the relevant method steps described in the above method embodiments.
[0210] This application also provides a computer program product that, when run on a computer, causes the computer to execute the relevant method steps described in the above method embodiments.
[0211] The electronic devices, computer-readable storage media, or computer program products provided in this application are all used to perform the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0212] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0213] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0214] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0215] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0216] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, in essence, or the part that contributes, or all or part of the technical solution, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0217] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A compilation method, characterized in that, include: Obtain the first source code of the first functional module to be compiled; The first functional module is used to implement the first function; Based on the first source code, at least one binary file corresponding to at least one second functional module on which the first functional module depends, and at least one application programming interface (API) information corresponding to each of the at least one binary file, are obtained from the binary library; wherein, the second functional module is different from the first functional module; the binary file is pre-compiled based on the second source code used to implement the functions of the second functional module, and the API information corresponding to the binary file is obtained during the pre-compilation process of the second source code; Based on at least one binary file corresponding to each of the at least one second functional module and at least one set of API information corresponding to each of the at least one binary file, the first source code is compiled to obtain the binary file corresponding to the first functional module.
2. The method according to claim 1, characterized in that, One second functional module corresponds to one binary file; one binary file corresponds to one set of API information; the binary file corresponding to the second functional module includes header files and library files of at least one first API provided by the second functional module; the API information corresponding to the binary file includes API description information, which is used to indicate the path to obtain the header files and library files of each first API during the compilation of the first source code.
3. The method according to claim 2, characterized in that, The step of compiling the first source code to obtain the binary file corresponding to the first functional module based on at least one binary file corresponding to each of the at least one second functional module and at least one set of API information corresponding to each of the at least one binary file includes: For one of the second functional modules, Based on the API description information in the API information corresponding to the binary file, obtain the header file and library file of each first API provided by the second functional module from the binary file; Based on the header and library files of each first API provided by each second functional module, the first source code is compiled to obtain the binary file corresponding to the first functional module.
4. The method according to claim 2 or 3, characterized in that, The API information corresponding to the binary file also includes the description information of the second functional module corresponding to the binary file; the description information of the second functional module is used to indicate at least one first API provided by the second functional module.
5. The method according to claim 1, characterized in that, The method further includes: A first product is obtained based on at least one binary file corresponding to at least one functional module; the first product includes at least one function implemented by the at least one functional module, and the at least one functional module includes the first functional module.
6. A compilation method, characterized in that, include: Obtain the second source code; The second source code is used to implement the functions corresponding to the second functional module; Based on the second source code, the binary file corresponding to the second functional module is compiled, and the application programming interface (API) information corresponding to the binary file is obtained; Send the binary file corresponding to the second functional module and the API information corresponding to the binary file to the binary library; wherein, the binary library is used to store at least one binary file corresponding to at least one second functional module and at least one set of API information corresponding to the at least one binary file, so as to compile the first source code of the first functional module that depends on the at least one second functional module.
7. The method according to claim 6, characterized in that, The binary file corresponding to the second functional module includes header files and library files of at least one first API provided by the second functional module; the API information corresponding to the binary file includes API description information, which is used to indicate the path to obtain the header files and library files of each API in the at least one first API during the compilation of the first source code.
8. The method according to claim 6 or 7, characterized in that, The API information corresponding to the binary file also includes the description information of the second functional module corresponding to the binary file; the description information of the second functional module is used to indicate the at least one first API provided by the second functional module.
9. An electronic device, characterized in that, The device includes a memory and one or more processors; the memory is coupled to the processors; wherein the memory stores computer program code, the computer program code including computer instructions, which, when executed by the processor, cause the electronic device to perform the compilation method as described in any one of claims 1-5, or to perform the compilation method as described in any one of claims 6-8.
10. A computer-readable storage medium, characterized in that, The computer instructions, when executed on an electronic device, cause the electronic device to perform the compilation method as described in any one of claims 1-5, or to perform the compilation method as described in any one of claims 6-8.
11. A computer program product, characterized in that, When the computer program product is run on a computer, the computer performs the compilation method as described in any one of claims 1-5, or performs the compilation method as described in any one of claims 6-8.
Citation Information
Patent Citations
Method and device for configuring parallel programming component
CN103605515A
Package file generation method and device for software project, equipment and storage medium
CN111880805A