Method, device, equipment, medium and product for generating software development kit
Patent Information
- Application Number
- CN202510353307.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2026-09-25
AI Technical Summary
[0019]本公开实施例提供的软件开发工具包的生成方法,针对不同的业务类型获取到对应的应用程序接口的定义文件,即,应用程序接口的定义文件与业务类型是对应的。在此基础上,对各个业务类型的定义文件进行解析,得到应用程序接口对应的第一数据结构信息,从定义文件中得到对应的第一数据结构信息。再利用第一数据结构信息以及代码生成模板,生成第一实现层代码与第一绑定层代码,再获取第一实现层代码的填充结果得到第二实现层代码,从而得到实现层的框架与实现。再将第二实现层代码与第一绑定层代码进行整合,得到软件开发工具包的发布信息。由于应用程序接口的定义文件是与业务类型对应的,而并不是整合在一个文件中,能够便于不同版本管理工具的管理,多人开发的修改。同时,对于代码的生成是结合从定义文件中解析出的第一数据结构信息以及代码生成模板得到的,避免小粒度的字符串拼接。该生成方法能够利用应用程序接口的定义文件的一次定义,生成软件开发工具包的发布信息中的所有内容,即实现了一次定义,多次生成。此外,该生成方法还还提供了一种原子化的代码生成过程。
Smart Images

Figure CN122816623A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and specifically to methods, apparatus, devices, media, and products for generating software development kits. Background Technology
[0002] When releasing a business framework's Software Development Kit (SDK), it's generally necessary to isolate the definition and implementation of the Application Programming Interface (API) to ensure compatibility between different versions of the SDK and different versions of the business framework. Therefore, a method for generating an SDK is needed to meet the development requirements of the SDK. Summary of the Invention
[0003] In view of this, the present disclosure provides a method, apparatus, device, medium and product for generating software development kits to solve the problem of generating software development kits.
[0004] In a first aspect, this disclosure provides a method for generating a software development kit, the method comprising:
[0005] Obtain the definition file of the application programming interface corresponding to the software development kit, wherein the definition file corresponds to the business type;
[0006] The definition files of each of the aforementioned business types are parsed to obtain the first data structure information corresponding to the application interface;
[0007] Based on the first data structure information and the code generation template, generate the first implementation layer code and the first binding layer code;
[0008] Obtain the code padding result for the first implementation layer code to obtain the second implementation layer code;
[0009] Based on the integration result of the second implementation layer code and the first binding layer code, the release information of the software development kit is obtained.
[0010] Secondly, this disclosure provides a software development kit (SDK) generation apparatus, the apparatus comprising:
[0011] The acquisition module is used to acquire the definition file of the application interface corresponding to the software development kit, and the definition file corresponds to the business type;
[0012] The parsing module is used to parse the definition files of each of the aforementioned business types to obtain the first data structure information corresponding to the application interface;
[0013] The code generation module is used to generate the first implementation layer code and the first binding layer code based on the first data structure information and the code generation template.
[0014] The code acquisition module is used to acquire the code filling results for the first implementation layer code to obtain the second implementation layer code;
[0015] The code integration module is used to obtain the release information of the software development kit based on the integration result of the second implementation layer code and the first binding layer code.
[0016] Thirdly, this disclosure provides an electronic device, including: a memory and a processor, which are communicatively connected to each other. The memory stores computer instructions, and the processor executes the computer instructions to perform the method for generating a software development kit according to the first aspect or any corresponding embodiment described above.
[0017] Fourthly, this disclosure provides a computer-readable storage medium storing computer instructions for causing a computer to execute the software development kit generation method of the first aspect or any corresponding embodiment thereof.
[0018] Fifthly, this disclosure provides a computer program product, including computer instructions for causing a computer to execute a method for generating a software development kit according to the first aspect or any corresponding embodiment thereof.
[0019] The software development kit (SDK) generation method provided in this disclosure obtains corresponding application programming interface (API) definition files for different business types, meaning the API definition files correspond to the business types. Based on this, the definition files for each business type are parsed to obtain the first data structure information corresponding to the API. Then, using the first data structure information and a code generation template, first implementation layer code and first binding layer code are generated. The filling result of the first implementation layer code is then obtained to obtain second implementation layer code, thus obtaining the framework and implementation of the implementation layer. Finally, the second implementation layer code and the first binding layer code are integrated to obtain the release information of the SSD. Since the API definition files correspond to the business types, rather than being integrated into a single file, it facilitates management by different version control tools and modifications by multiple developers. Simultaneously, the code generation combines the first data structure information parsed from the definition files with the code generation template, avoiding fine-grained string concatenation. This generation method can generate all the content in the SSD release information using only one definition of the API definition file, achieving one definition and multiple generation. Furthermore, this generation method also provides an atomic code generation process. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the specific embodiments or related technologies of this disclosure, the accompanying drawings used in the description of the specific embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart illustrating a method for generating a software development kit according to an embodiment of the present disclosure;
[0022] Figure 2 This is a flowchart illustrating another method for generating a software development kit according to an embodiment of the present disclosure;
[0023] Figure 3 This is a schematic diagram illustrating the parsing of a definition file according to an embodiment of this disclosure;
[0024] Figure 4 This is a flowchart illustrating a method for generating another software development kit according to an embodiment of the present disclosure;
[0025] Figure 5 This is a schematic diagram of the code generation process according to an embodiment of the present disclosure;
[0026] Figure 6This is a schematic diagram of the code optimization process according to an embodiment of the present disclosure;
[0027] Figure 7 This is a schematic diagram generated according to the atomic code of the embodiments of this disclosure;
[0028] Figure 8 This is a structural block diagram of a software development kit generation apparatus according to an embodiment of the present disclosure;
[0029] Figure 9 This is a schematic diagram of the hardware structure of an electronic device according to an embodiment of this disclosure. Detailed Implementation
[0030] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0031] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.
[0032] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the software or hardware, such as the electronic device, application, server, or storage medium performing the operations of this disclosed technical solution, based on the prompt message.
[0033] As an optional but non-limiting implementation, in response to a user's active request, sending a prompt message to the user can be done via a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0034] It is understood that the above notification and user authorization process are merely illustrative and do not constitute a limitation on the implementation of this disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of this disclosure.
[0035] It is understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and related provisions.
[0036] In related technologies, SDKs are typically generated by defining APIs using Extensible Markup Language (XML) and then using Python-based string concatenation scripts to generate the code. However, this approach requires assembling the API definitions into a single file, which is inconvenient for version control tools and limits its use in scenarios involving multiple developers and diverse content. Furthermore, generating code using string concatenation is time-consuming and difficult to format, resulting in a lengthy SDK development cycle.
[0037] Based on this, this disclosure provides an SDK generation method. For different business types, corresponding application programming interface (API) definition files are obtained; that is, the API definition files correspond to the business types. On this basis, the definition files for each business type are parsed to obtain the first data structure information corresponding to the API. The first data structure information and a code generation template are then used to generate first implementation layer code and first binding layer code. The population result of the first implementation layer code is then obtained to obtain second implementation layer code, thus obtaining the framework and implementation of the implementation layer. Finally, the second implementation layer code and the first binding layer code are integrated to obtain the software development kit (SDK) release information.
[0038] According to an embodiment of this disclosure, a method for generating a software development kit is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0039] This embodiment provides a method for generating a software development kit, which can be used in electronic devices, such as computers. Figure 1 This is a flowchart of a data transmission method according to an embodiment of the present disclosure, such as... Figure 1 As shown, the process includes the following steps:
[0040] Step S101: Obtain the definition file of the application programming interface corresponding to the software development kit.
[0041] The definition file corresponds to the business type.
[0042] The SDK connects to the outside world via APIs, meaning that the access party calls the SDK through the APIs to implement corresponding functions. The API definition file corresponds to the business type; different businesses have their own corresponding definition files. These business types include, but are not limited to, windows, message boxes, panels, etc. An SDK developed for a single business scenario may include multiple business types, requiring a definition file for each type.
[0043] The definition file describes the API definition corresponding to this business type, including but not limited to the data structure type, its data structure group, methods, and the parameters and return values of each method. If the business scenario involves multiple developers, different developers can provide corresponding definition files for different business types, thus avoiding frequent editing of the same file.
[0044] The specific content and number of definition files provided are determined based on business requirements, and no restrictions are imposed here. The descriptions in the definition files can be in XML, YAML, or other formats.
[0045] Step S102: Parse the definition files of each business type to obtain the first data structure information corresponding to the application interface.
[0046] For each business type's definition file, the content described in the definition file is parsed to abstract the first data structure information. As described above, the definition file includes the data structure type and methods, etc. During the parsing process, these need to be organized into the form of the first data structure information to facilitate subsequent code generation.
[0047] The definition file can be parsed in several ways, such as through data serialization and deserialization to obtain the first data structure information, or through semantic analysis of the definition file. No specific method for parsing the definition file is specified here.
[0048] The first data structure information can be used to characterize the data structure representation of the methods in the definition file, as well as the data structure representation of the remaining definition information.
[0049] Since the definition files are provided separately for different business types, and the data structures within the same SDK definition file are related, it is necessary to correlate the parsing results of each business type's definition file after parsing them. This ensures that the resulting first data structure information includes the relationships between the data structures. These relationships include, but are not limited to, dependencies and references.
[0050] Step S103: Based on the first data structure information and the code generation template, generate the first implementation layer code and the first binding layer code.
[0051] The API generation process typically involves an implementation layer and a binding layer. Specifically, the implementation layer is responsible for the API's concrete implementation, including but not limited to business logic processing, database interaction, etc. The binding layer is used to expose the functionality of the implementation layer to the API access party, and may also include input / output format conversion, exception handling, etc.
[0052] Code generation templates provide code frameworks, such as separate frameworks for the implementation layer and the binding layer. Furthermore, since the binding layer interfaces with API access providers, and these providers may use various languages, the binding layer can also provide code in multiple languages to facilitate integration by users from different languages. Accordingly, the code framework provided by the binding layer can include frameworks in multiple languages, offering corresponding access layer code frameworks for different languages.
[0053] After processing in step S102, the first data structure information is obtained. This information is then combined with a code generation template to generate the first implementation layer code and the first binding layer code. Based on the code generation template and the first data structure information, the code is automatically filled in to obtain the first implementation layer code and the first binding layer code.
[0054] It should be noted that the first implementation layer code generated at this time does not include the actual implementation. The API implementer will need to fill in the API implementation logic according to the generated code definition.
[0055] Step S104: Obtain the code filling result for the first implementation layer code to obtain the second implementation layer code.
[0056] In the above description, the first implementation layer code does not include the implementation itself; the code completion result here is used to represent the implementation of the implementation layer. The code completion result can be input interactively based on the first implementation layer code, or it can be obtained from other methods and filled into the first implementation layer code. Of course, other methods can also be used to obtain the code completion result for the first implementation layer code; no limitations are imposed on them here.
[0057] After filling in the code for the first implementation layer, we get the implementation layer code containing the implementation, which is the second implementation layer code.
[0058] Step S105: Based on the integration result of the second implementation layer code and the first binding layer code, the release information of the software development kit is obtained.
[0059] When releasing an SDK to the public, it is necessary to integrate the second implementation layer code and the first binding layer code. That is, the code needs to be encapsulated before release to obtain the SDK release information.
[0060] The release information may include the SDK library, a loading library for loading the SDK library, and API documentation, etc. The SDK library represents the specific implementation of the SDK, so the second implementation layer code can be encapsulated within it. The loading library is used to load the SDK library; simultaneously, since the binding layer is used to include the functionality of the implementation layer for API access parties, the first binding layer code can be encapsulated within the loading library.
[0061] It should be noted that the API documentation is automatically generated based on code descriptions and API definitions, and is used to describe interfaces or methods related to loading the SDK.
[0062] The software development kit (SDK) generation method provided in this embodiment facilitates management by different version control tools and allows for modifications by multiple developers because the application programming interface (API) definition files correspond to specific business types, rather than being integrated into a single file. Furthermore, the code generation combines the first data structure information parsed from the definition file with the code generation template, avoiding fine-grained string concatenation. This generation method can generate all the content in the SSD release information using only one definition of the API definition file, achieving "define once, generate multiple times." In addition, this generation method also provides an atomic code generation process.
[0063] This embodiment provides a method for generating a software development kit, which can be used in electronic devices, such as computers. Figure 2 This is a flowchart of a data transmission method according to an embodiment of the present disclosure, such as... Figure 2 As shown, the process includes the following steps:
[0064] Step S201: Obtain the definition file of the application programming interface corresponding to the software development kit.
[0065] The definition file corresponds to the business type. See details. Figure 1 Step S101 of the illustrated embodiment will not be described again here.
[0066] Step S202: Parse the definition files of each business type to obtain the first data structure information corresponding to the application interface.
[0067] Specifically, step S202 includes:
[0068] Step S2021: For each business type's definition file, load the contents of the definition file as dictionary information.
[0069] For each business type's definition file, its content is processed separately; that is, the content of the definition file is loaded as dictionary information. The dictionary information represents the content of the definition file in the form of key-value pairs. For example, a parsing tool can be used to parse the definition files of each business type, first loading the content as dictionary information, and then converting it into a data structure representation.
[0070] Step S2022: Convert the dictionary information into second data structure information.
[0071] For each business type's definition file, the obtained dictionary information is converted into second data structure information. For example, if the data structures obtained from each definition file are represented as data structure 1 to data structure N, then data structure 1 to data structure N are referred to as second data structure information. It should be noted that the data structures in the obtained second data structure information are independent and do not represent any relationship between them.
[0072] For example, Figure 3 The process of parsing definition files is illustrated. First, the contents of each definition file are loaded as dictionary information. Then, the dictionary information is converted into a strongly typed data structure to obtain the second data structure information.
[0073] Step S2023: Merge the second data structure information corresponding to all business types to obtain the first data structure information.
[0074] Since all business types belong to the same SDK, all the second data structure information needs to be merged before subsequent code generation. The merging methods include, but are not limited to, analyzing the dependencies or references between the individual data structures in the second data structure information, and integrating the independent data structures into a first data structure information with a relational representation based on these dependencies or references.
[0075] In some optional implementations, step S2023 above includes: performing dependency analysis based on the second data structure information corresponding to all business types to obtain first data structure information with dependencies.
[0076] For the second data structure information of all business types, the dependencies are derived sequentially to merge all the second data structure information, resulting in the first data structure information with dependencies. Subsequently, during the code generation process, code for specific data structure types is generated according to the dependency order. The code generation part is based on pre-built data type code templates.
[0077] When fusing the information of the second data structure, the dependencies in the second data structure information are combined to obtain the information of the first data structure with the representation of dependencies, thus realizing the correlation between data structures.
[0078] Step S203: Based on the first data structure information and the code generation template, generate the first implementation layer code and the first binding layer code. See details... Figure 1 Step S103 of the illustrated embodiment will not be described again here.
[0079] Step S204: Obtain the code padding result for the first implementation layer code to obtain the second implementation layer code. See details... Figure 1 Step S104 of the illustrated embodiment will not be described again here.
[0080] Step S205: Based on the integration result of the second implementation layer code and the first binding layer code, the release information of the software development kit is obtained. See details... Figure 1 Step S105 of the illustrated embodiment will not be described again here.
[0081] The software development kit (SDK) generation method provided in this embodiment first loads the contents of each definition file as dictionary information, and then converts it into a data structure to obtain second data structure information. Based on this, the second data structure information for all business types is merged to obtain first data structure information. This method integrates the contents of all definition files, ensuring the comprehensiveness and accuracy of the first data structure information.
[0082] This embodiment provides a method for generating a software development kit, which can be used in electronic devices, such as computers. Figure 4 This is a flowchart of a data transmission method according to an embodiment of the present disclosure, such as... Figure 4 As shown, the process includes the following steps:
[0083] Step S401: Obtain the definition file of the application programming interface corresponding to the software development kit.
[0084] The definition file corresponds to the business type. See details. Figure 1 Step S101 of the illustrated embodiment will not be described again here.
[0085] Step S402: Parse the definition files for each business type to obtain the first data structure information corresponding to the application programming interface. See details... Figure 2 Step S201 of the illustrated embodiment will not be described again here.
[0086] Step S403: Based on the first data structure information and the code generation template, generate the first implementation layer code and the first binding layer code.
[0087] The first data structure information includes the data structure type. During the code generation process, corresponding code generation templates are used to generate code for the implementation layer and the binding layer, respectively. Based on this, step S403 includes:
[0088] Step S4031: Based on the first data structure information and the code generation template of the implementation layer, call the code framework corresponding to the type of the data structure to generate the initial implementation layer code.
[0089] The first implementation layer code includes header files in the first language.
[0090] The code generation template for the implementation layer can define the code framework for the implementation layer, such as header files, code architecture, etc. By calling the code generation template, an initial code is obtained. Then, combined with the code framework corresponding to the data structure type in the first data structure information, the initial code is filled in to generate the initial implementation layer code.
[0091] There are corresponding code frameworks for different types of data structures. Specifically, in the first data structure information, the code frameworks of the corresponding data structure types are called sequentially according to their dependency order to generate code.
[0092] For example, data structure types include, but are not limited to, enumerations, structs, interfaces, components, and pass-by-value. Based on the dependencies in the first data structure information, the corresponding code frameworks are called sequentially.
[0093] Figure 5 The diagram illustrates the code generation process. Specifically, the first data structure information is obtained by dependency deduction of the second data structure information. Based on this, code is generated using the code framework corresponding to the different data structure types to obtain the initial implementation layer code.
[0094] Step S4032: Optimize the format of the initial implementation layer code based on the implementation layer format template to obtain the first implementation layer code.
[0095] The generated initial implementation layer code may contain formatting errors. Therefore, the initial implementation layer code is optimized using an implementation layer format template, conforming to the code format specified by the template to obtain the first implementation layer code. The format template is used to characterize the code format.
[0096] For example, Figure 6 The diagram illustrates the code optimization process. Specifically, the generated initial implementation layer code is optimized according to the format template to obtain the first implementation layer code.
[0097] Step S4033: Based on the first data structure information and the first language code generation template and the second language code generation template of the binding layer, call the code framework corresponding to the type of the data structure to generate the initial binding layer code.
[0098] The method for generating the initial binding layer code is similar to that for generating the initial implementation layer code. The difference is that the binding layer needs to provide access to multiple languages. Therefore, in the initial binding layer code, the first language code generation template and the second language code generation template of the binding layer are used to generate the first language initial binding layer code and the second language initial binding layer code, respectively.
[0099] Step S4034: Optimize the format of the initial binding layer code based on the format template of the binding layer to generate the first binding layer code.
[0100] The first binding layer code includes binding layer code for the first language and binding layer code for the second language.
[0101] The code formatting optimization methods for the binding layer are similar to those for the implementation layer described above, and will not be repeated here. The difference is that the formatting template used for the implementation layer is corresponding to the implementation layer, while the formatting template used for the binding layer is corresponding to the binding layer.
[0102] Step S404: Obtain the code filling result for the first implementation layer code to obtain the second implementation layer code.
[0103] In some optional implementations, step S404 above includes:
[0104] Step a1: Display the code of the first implementation layer.
[0105] Step a2: In response to the code padding instruction for the first implementation layer code, the implementation code and symbol binding logic of the implementation layer are obtained to obtain the second implementation layer code. The second implementation layer code includes symbol binding logic in both the first and second languages. The second language is used to achieve compatibility of interfaces across multiple binary program modules.
[0106] After generating the first implementation layer code, it can be displayed on the interface. Users interact with this code to generate code completion instructions, thereby obtaining the implementation code and symbol binding logic of the implementation layer. Note that, as described above, the first implementation layer code does not contain the concrete implementation; the implementation is completed interactively.
[0107] Furthermore, symbol binding logic is provided through an interactive method. Specifically, the symbol binding logic included in the second implementation layer code also corresponds to both the first and second languages; that is, it includes symbol binding logic for both the first and second languages. The second language is used to achieve compatibility of the Application Binary Interface (ABI) across multiple binary program modules.
[0108] For example, the first language is C++, and the second language is C. Since C++ cannot provide cross-ABI multi-access compatibility, it needs to be downgraded to C; that is, there is a C++ downgrade to C. In other words, the first implementation layer code is described in C++, while the first binding layer code includes C binding layer code.
[0109] Furthermore, since the access party uses both C and C++ styles, C++ binding layer code also needs to be generated at the binding layer.
[0110] In the second implementation layer code, there is also a symbol binding process between C and C++, that is, the symbol binding logic of C and the symbol binding logic of C++ are obtained during the code filling process.
[0111] The code filling of the first implementation layer is achieved through interactive methods. In addition, since the implementation layer is described in the first language, and the first language is difficult to provide interface compatibility between binary program modules, the symbol binding logic of the second language is used to realize the processing of the first language to the second language, ensuring that the access party can access the application development kit regardless of whether it uses the first language or the second language.
[0112] Step S405: Based on the integration result of the second implementation layer code and the first binding layer code, the release information of the software development kit is obtained.
[0113] Specifically, step S405 includes:
[0114] Step S4051: Generate application interface documentation based on the second implementation layer code and the first binding layer code.
[0115] The API documentation (SDK loader API) is obtained by analyzing the code of the second implementation layer and the code of the first binding layer, which describes the interfaces or methods related to loading the SDK.
[0116] Step S4052: Encapsulate the second implementation layer code and the binding layer code of the second language to generate the implementation library of the software development kit.
[0117] Since the second language can be compatible with multiple access points across ABIs, the second implementation layer code and the second language binding layer code are encapsulated to obtain the SDK implementation library.
[0118] Continuing with the previous example, the SDK Library includes four files: the implementation layer C++ header file (C++header), the implementation layer C++ source file (C++source), the binding layer C header file (C header), and the binding layer C source file (Csource).
[0119] Step S4053: Encapsulate the binding layer code of the first language to generate a loading library for the software development kit.
[0120] The information released includes application programming interface (API) documentation, implementation libraries, and loading libraries.
[0121] The binding layer code in the first language is encapsulated into an SDK loader library to meet the access scenarios of different access parties.
[0122] Continuing with the previous example, the SDK loader Library includes two files: the binding layer C++ header file and the binding layer C++ source file.
[0123] Based on the description above, the SDK release information, consisting of 7 files, was generated by defining the API once.
[0124] The software development kit (SDK) generation method provided in this embodiment, for the implementation layer, utilizes its corresponding code generation template to call the code framework corresponding to different data structure types to generate initial implementation layer code. Based on this, the initial implementation layer code is formatted to ensure uniform code formatting and facilitate unified maintenance. Since access parties may use both a first language and a second language style, the binding layer code includes binding layer code in both languages to meet the access requirements of different access parties. The API documentation is generated using the second implementation layer code and the first binding layer code. Based on a single API definition, the API documentation, implementation library, and loading library in the release information can be generated.
[0125] In some optional implementations, the above-described method for generating a software development kit further includes:
[0126] Step b1: If it is necessary to add access to a third language, then generate the third binding layer code of the third language based on the first data structure information and the third language code generation template of the binding layer.
[0127] Step b2: Optimize the format of the third binding layer code based on the binding layer's format template to generate binding layer code in the third language.
[0128] Step b3: Add the third-language binding layer code to the software development kit's loading library to update the release information.
[0129] If the access party uses a third language, then the access method for that third language needs to be provided. Accordingly, third-language binding layer code needs to be added. The specific method for generating the binding layer code is similar to that described above, except that the third-language binding layer code is generated based on the third-language code generation template, then its format is optimized, and the optimized binding layer code is added to the SDK's loading library. The release information is then updated, and subsequent access parties using the third language can then call the SDK.
[0130] When there is a need to integrate a third language, the third language binding layer code can be generated directly using the third language code generation template of the binding layer. After optimizing the format, the binding layer code of the third language can be obtained. No changes need to be made to the implementation layer code, which has strong scalability.
[0131] As a specific application embodiment of this disclosure, Figure 7 This diagram illustrates atomic code generation. In this example, the first language is C++, and the second language is C. It generates code by parsing the API definition and through four sub-processes. These four sub-processes include implementation layer generation, binding layer C, binding layer C++, and deployment.
[0132] The implementation layer generates C++ functions, but the automatically generated code does not include implementations. The API implementer needs to fill in the API implementation logic according to the generated code definitions. The binding layer (C) generates C functions and implementations for symbol binding. The binding layer (C++) generates C++ functions and implementations for user symbol binding. The API (C++) generates a C++ version of the API header file and corresponding documentation comments (API documentation).
[0133] The implementation layer C++ header, implementation layer C++ source, binding layer C header, and binding layer C source are encapsulated into an SDK Library. The binding layer C++ header and binding layer C++ source are encapsulated into an SDK loader Library. The API documentation is encapsulated into an SDK loader API.
[0134] This embodiment also provides a software development kit (SDK) generation apparatus, which is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0135] This embodiment provides a software development kit (SDK) generation apparatus, such as... Figure 8 As shown, it includes:
[0136] The acquisition module 801 is used to acquire the definition file of the application interface corresponding to the software development kit. The definition file is corresponding to the business type.
[0137] The parsing module 802 is used to parse the definition files of each business type to obtain the first data structure information corresponding to the application interface.
[0138] The code generation module 803 is used to generate the first implementation layer code and the first binding layer code based on the first data structure information and the code generation template.
[0139] The code acquisition module 804 is used to obtain the code filling results for the first implementation layer code to obtain the second implementation layer code.
[0140] The code integration module 805 is used to obtain the release information of the software development kit based on the integration results of the second implementation layer code and the first binding layer code.
[0141] In some alternative implementations, the parsing module 802 includes:
[0142] The loading unit is used to load the contents of the definition files for each business type into dictionary information.
[0143] The conversion unit is used to convert dictionary information into second data structure information.
[0144] The fusion unit is used to fuse the second data structure information corresponding to all business types to obtain the first data structure information.
[0145] In some alternative implementations, the fusion unit includes:
[0146] The analysis subunit is used to analyze the dependencies based on the second data structure information corresponding to all business types, and obtain the first data structure information with dependencies.
[0147] In some optional implementations, the first data structure information includes the type of the data structure, and the code generation module 803 includes:
[0148] The first code generation unit is used to call the code framework corresponding to the type of the data structure based on the first data structure information and the code generation template of the implementation layer, and generate the initial implementation layer code. The first implementation layer code includes the header file of the first language.
[0149] The first code optimization unit is used to optimize the format of the initial implementation layer code based on the format template of the implementation layer to obtain the first implementation layer code.
[0150] In some alternative implementations, the code acquisition module 804 includes:
[0151] The code display unit is used to display the code of the first implementation layer.
[0152] The instruction response unit is used to respond to the code filling instruction for the first implementation layer code to obtain the implementation code and symbol binding logic of the implementation layer, so as to obtain the second implementation layer code. The second implementation layer code includes the symbol binding logic of the first language and the symbol binding logic of the second language. The second language is used to implement the compatibility of the interface between multiple binary program modules.
[0153] In some alternative implementations, the code generation module 803 includes:
[0154] The second code generation unit is used to generate initial binding layer code by calling the code framework corresponding to the type of the data structure based on the first data structure information and the first language code generation template and the second language code generation template of the binding layer.
[0155] The second code optimization unit is used to optimize the format of the initial binding layer code based on the format template of the binding layer to generate the first binding layer code, which includes the binding layer code of the first language and the binding layer code of the second language.
[0156] In some alternative implementations, the code integration module 805 includes:
[0157] The document generation unit is used to generate application interface documents based on the second implementation layer code and the first binding layer code.
[0158] The first encapsulation unit is used to encapsulate the second implementation layer code and the binding layer code of the second language to generate the implementation library of the software development kit.
[0159] The second encapsulation unit is used to encapsulate the binding layer code of the first language, generate the loading library of the software development kit, and publish information including application interface documentation, implementation library and loading library.
[0160] In some alternative implementations, the software development kit (SDK) generation apparatus further includes:
[0161] A new code module is added to generate third-level binding layer code for the third language based on the first data structure information and the third-level binding layer code generation template. If a third language needs to be added, the third binding layer code for the third language will be generated.
[0162] The format optimization module is used to optimize the format of the third binding layer code based on the format template of the binding layer, and generate binding layer code in a third language.
[0163] The update module is used to add third-language binding layer code to the software development kit's loading library to update release information.
[0164] The further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above. For the beneficial effects of the software development kit generation device, please refer to the description of the corresponding beneficial effects of the software development kit generation method, which will not be repeated here.
[0165] This disclosure also provides an electronic device having the above-described features. Figure 8 The apparatus shown is for generating a software development kit.
[0166] Please see Figure 9 , Figure 9 This is a schematic diagram of the structure of an electronic device provided in an optional embodiment of this disclosure, such as... Figure 9As shown, the electronic device includes one or more processors 10, memory 20, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise as required. The processors can process instructions executed within the electronic device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple electronic devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 9 Take a processor 10 as an example.
[0167] Processor 10 may be a central processing unit, a network processor, or a combination thereof. Processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.
[0168] The memory 20 stores instructions executable by at least one processor 10 to cause at least one processor 10 to perform the method shown in the above embodiments.
[0169] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the electronic device. Furthermore, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 20 may optionally include memory remotely located relative to the processor 10, and these remote memories may be connected to the electronic device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0170] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0171] The electronic device also includes a communication interface 30 for communicating with other devices or communication networks.
[0172] This disclosure also provides a computer-readable storage medium in which the methods described in this disclosure can be implemented in hardware or firmware, or implemented as recordable on a storage medium, or implemented as computer code originally stored on a remote storage medium or a non-transitory machine-readable storage medium and subsequently stored on a local storage medium after being downloaded over a network. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium may be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium may also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code that, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.
[0173] A portion of this disclosure can be applied to computer program products, such as computer program instructions, which, when executed by a computer, can invoke or provide methods and / or technical solutions according to this disclosure through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, and installation package files. Accordingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions; the computer compiling the instructions and then executing the corresponding compiled program; the computer reading and executing the instructions; or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.
[0174] Although embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A method for generating a software development kit, characterized in that, The method includes: Obtain the definition file of the application programming interface corresponding to the software development kit, wherein the definition file corresponds to the business type; The definition files of each of the aforementioned business types are parsed to obtain the first data structure information corresponding to the application interface; Based on the first data structure information and the code generation template, generate the first implementation layer code and the first binding layer code; Obtain the code padding result for the first implementation layer code to obtain the second implementation layer code; Based on the integration result of the second implementation layer code and the first binding layer code, the release information of the software development kit is obtained.
2. The method according to claim 1, characterized in that, The step of parsing the definition files of each of the aforementioned business types to obtain the first data structure information corresponding to the application interface includes: For each of the aforementioned business types, the contents of the definition files are loaded as dictionary information. Convert the dictionary information into second data structure information; The second data structure information corresponding to all the business types is fused to obtain the first data structure information.
3. The method according to claim 2, characterized in that, The process of fusing the second data structure information corresponding to all the aforementioned business types to obtain the first data structure information includes: Based on the second data structure information corresponding to all the business types, the dependency relationship is analyzed to obtain the first data structure information with dependency relationship.
4. The method according to claim 1, characterized in that, The first data structure information includes the type of data structure. Based on the first data structure information and the code generation template, the first implementation layer code is generated, including: Based on the first data structure information and the code generation template of the implementation layer, the code framework corresponding to the type of the data structure is called to generate the initial implementation layer code, wherein the first implementation layer code includes header files of the first language; The initial implementation layer code is optimized based on the format template of the implementation layer to obtain the first implementation layer code.
5. The method according to claim 4, characterized in that, The step of obtaining the code padding result for the first implementation layer code to obtain the second implementation layer code includes: Display the code of the first implementation layer; In response to a code padding instruction for the first implementation layer code, the implementation code and symbol binding logic of the implementation layer are obtained to obtain the second implementation layer code. The second implementation layer code includes symbol binding logic of a first language and symbol binding logic of a second language. The second language is used to implement compatibility of interfaces across multiple binary program modules.
6. The method according to claim 5, characterized in that, Based on the first data structure information and the code generation template, the first binding layer code is generated, including: Based on the first data structure information and the first language code generation template and the second language code generation template of the binding layer, the code framework corresponding to the type of the data structure is called to generate the initial binding layer code; The initial binding layer code is formatted and optimized based on the format template of the binding layer to generate the first binding layer code, which includes binding layer code in the first language and binding layer code in the second language.
7. The method according to claim 6, characterized in that, The integration result based on the second implementation layer code and the first binding layer code yields the release information of the software development kit, including: Based on the second implementation layer code and the first binding layer code, an application interface document is generated; The second implementation layer code and the binding layer code of the second language are encapsulated to generate the implementation library of the software development kit; The binding layer code of the first language is encapsulated to generate the loading library of the software development kit. The release information includes the application programming interface document, the implementation library, and the loading library.
8. The method according to any one of claims 1 to 7, characterized in that, The method further includes: If it is necessary to add access to a third language, then based on the first data structure information and the third language code generation template of the binding layer, the third binding layer code of the third language is generated. The format of the third binding layer code is optimized based on the format template of the binding layer to generate the binding layer code of the third language; The binding layer code of the third language is added to the loading library of the software development kit to update the release information.
9. A software development kit (SDK) generation apparatus, characterized in that, The device includes: The acquisition module is used to acquire the definition file of the application interface corresponding to the software development kit, and the definition file corresponds to the business type; The parsing module is used to parse the definition files of each of the aforementioned business types to obtain the first data structure information corresponding to the application interface; The code generation module is used to generate the first implementation layer code and the first binding layer code based on the first data structure information and the code generation template. The code acquisition module is used to acquire the code filling results for the first implementation layer code to obtain the second implementation layer code; The code integration module is used to obtain the release information of the software development kit based on the integration result of the second implementation layer code and the first binding layer code.
10. An electronic device, characterized in that, include: A memory and a processor are communicatively connected, the memory stores computer instructions, and the processor executes the computer instructions to perform the method for generating a software development kit according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a computer to execute the method for generating a software development kit according to any one of claims 1 to 8.
12. A computer program product, characterized in that, It includes computer instructions for causing a computer to execute the method for generating a software development kit according to any one of claims 1 to 8.