WO2020173128A1 - 软件开发工具包的生成方法、装置及终端设备 - Google Patents

软件开发工具包的生成方法、装置及终端设备 Download PDF

Info

Publication number
WO2020173128A1
WO2020173128A1 PCT/CN2019/117180 CN2019117180W WO2020173128A1 WO 2020173128 A1 WO2020173128 A1 WO 2020173128A1 CN 2019117180 W CN2019117180 W CN 2019117180W WO 2020173128 A1 WO2020173128 A1 WO 2020173128A1
Authority
WO
WIPO (PCT)
Prior art keywords
interface
sdk
source code
interface information
filled
Prior art date
Application number
PCT/CN2019/117180
Other languages
English (en)
French (fr)
Inventor
薛雷
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2020173128A1 publication Critical patent/WO2020173128A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/447Target code generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Definitions

  • This application belongs to the field of software development technology, and in particular relates to a method, device, and terminal device for generating a software development kit.
  • the embodiments of the present application provide a method, device, and terminal device for generating a software development kit to solve the technical problem of low efficiency of SDK generation in the prior art.
  • the first aspect of the embodiments of the present application provides a method for generating a software development kit SDK, including: [0007] obtaining source code of an application program;
  • the target interface information corresponding to each item to be filled in the SDK template is obtained from the interface information, and the target interface information is compiled according to a preset programming language and then filled into all the SDK templates. In the items to be filled, the SDK programming file is generated.
  • a second aspect of the embodiments of the present application provides an apparatus for generating a software development kit SDK, including:
  • a source code obtaining unit for obtaining source code of an application program
  • the extraction unit is used to analyze the source code and extract the interface information of the application programming interface
  • the template obtaining unit is configured to obtain an SDK template corresponding to a preset programming language, where the SDK template includes items to be filled;
  • the filling unit is configured to obtain target interface information corresponding to each item to be filled in the SDK template from the interface information, and compile the target interface information according to a preset programming language and fill it in Among the items to be filled in the SDK template, an SDK programming file is generated.
  • a third aspect of the embodiments of the present application provides a terminal device, including a memory and a processor.
  • the memory stores computer-readable instructions that can run on the processor, and the processor executes all When the computer-readable instructions are described, the following steps are implemented:
  • the target interface information corresponding to each item to be filled in the SDK template is obtained from the interface information, and the target interface information is compiled according to a preset programming language and then filled into all the SDK templates. In the items to be filled, the SDK programming file is generated.
  • a fourth aspect of the embodiments of the present application provides a computer-readable storage medium, where the computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the following steps are implemented:
  • the interface information is filled into the SDK template to form the SDK programming file, because the content definition in the SDK template is defined strictly in accordance with the program's grammatical specification Therefore, the efficiency of SDK generation can be improved, and labor costs can be reduced.
  • FIG. 1 is a specific implementation flowchart of a method for generating a software development kit provided by an embodiment of the present application
  • FIG. 2 is a specific implementation flowchart of step 102 of a method for generating a software development kit provided by an embodiment of the present application
  • FIG. 3 is another specific implementation flowchart of step 102 of a method for generating a software development kit provided by an embodiment of the present application
  • FIG. 4 is a specific implementation flow diagram of another method for generating a software development kit provided by an embodiment of the present application.
  • FIG. 5 is a schematic structural diagram of an apparatus for generating a software development kit provided by an embodiment of the application;
  • FIG. 6 is a schematic structural diagram of another apparatus for generating a software development kit according to an embodiment of the present application
  • FIG. 7 is a schematic diagram of a terminal device provided by an embodiment of the present application.
  • FIG. 1 shows an implementation process of a method for generating a software development kit provided by an embodiment of the present application.
  • the process of the generating method includes steps S101 to S104.
  • the generating method is suitable for a situation where an SDK is automatically generated for an API of an application program.
  • the method for generating the software development kit is executed by the generation device of the software development kit.
  • the generation device of the software development kit is configured in the terminal device and can be implemented by software and/or hardware.
  • the specific implementation principle of each step is as follows.
  • S101 Obtain source code of an application program.
  • the application program includes a web page application and a terminal application, and is a target object that needs to generate a software development kit. Obtain the source code of the application and switch the source code to the appropriate version to provide a data basis for subsequent analysis.
  • obtaining the source code of the application program includes: downloading the source code of the application program at a pre-configured application source code hosting address through Git.
  • Git API Application programs that can be installed on terminal devices, and their source codes are all managed by Git.
  • the Git API is encapsulated and integrated into the tool.
  • the tool can be an independent application for generating software development kits, or it can be a function of an application that can generate software development kits.
  • the target object In the configuration file of the tool, the target object is pre-configured, that is, the application program of the software development kit to be generated.
  • the source code hosting address of the program, during the tool operation, the tool can be used to automatically download the required application source code.
  • S102 parse the source code, and extract interface information of the application programming interface.
  • the source code is parsed to extract the interface information of the API, thereby subsequently generating the SDK.
  • the interface information includes but is not limited to: interface name, interface request parameter information, and interface response parameter information.
  • the interface request parameter information includes but is not limited to: parameter name and parameter type.
  • Interface response parameter information includes but is not limited to: response parameter name, response parameter type, and complex type parameter information (that is, a new type composed of multiple basic type fields).
  • step 102 includes steps 201 to 204.
  • S201 Compile the source code to generate Java bytecode.
  • the source code is compiled to generate Java bytecode, which is a form of data loaded into the computer memory, and further analysis of the class requires this step as a basis.
  • the source code needs to be compiled into bytecode before the Java virtual machine (jvm) can recognize the class structure. If the source code is not compiled, there is no difference between the source code and the ordinary text file, and the jvm cannot obtain it. The information in it.
  • S202 Load the Java bytecode using a Java class loader, and reserve classes that comply with preset rules.
  • the Java Classloader is a part of the Java Runtime Environment, and is responsible for dynamically loading Java classes into the memory space of the Java virtual machine.
  • the Java class loader is used to load Java classes into the Java virtual machine.
  • the virtual machine does not include a rule library.
  • the rule library is a separate module defined in this tool for class filtering and is used to load java classes in the class loader.
  • the Java classes that meet the preset rules are filtered according to the rules in the rule base.
  • a rule base is needed to specify which types of information need to be extracted, so as to ensure that restricted information is not External exposure, another convenience, follow-up If there is a change in the generation rules, you only need to update the rule base without rewriting the code.
  • S203 Determine the category of the reserved class.
  • the categories of the reserved classes include, but are not limited to, request parameter classes, response parameter classes, and interface definition classes. Based on different classification rules, analyze which category the reserved class belongs to,
  • the class name must end with Request, and all request parameter classes inherit from the Request class. Therefore, the classification can be judged by the class name or the inheritance relationship. classification.
  • the class name must end with Response, and all response parameter classes inherit from the Response class, so the classification is judged by the class name.
  • S204 Extract interface information of each category used to describe the application programming interface based on the reflection mechanism.
  • the reflection mechanism means that in the running state, for any class, all attributes and methods of this class can be known, and for any object, any one of its methods can be called.
  • the reflection mechanism of the Java language is the function of dynamically acquiring information and dynamically calling object methods.
  • the interface information of each category used to describe the API is extracted through the reflection mechanism.
  • extract the complete information item describing the API the complete information item includes interface name, interface request parameter name, interface request parameter type, whether the interface request parameter is a mandatory parameter, interface response parameter name, interface response parameter type, and interface response The enumeration type associated in the parameter, the object type associated in the interface response parameter, the interface version, etc.
  • step 205 is further included, and each category is used to describe the interface information of the application programming interface in the form of simple Java objects. Store and form structured interface information.
  • the interface information of an API will be described in the form of a json string and stored in the manner of a simple Java object to form structured interface information.
  • the complete information items include: interface name, interface request parameter name, interface request parameter type, whether the interface request parameter is a required parameter, interface response parameter name, interface response parameter type, enumeration type associated with interface response parameter, interface response
  • the associated object type and interface version in the parameters are organized and stored in the form of json strings, it is very easy to deserialize them into simple Java objects to form structured interface information. Examples are as follows:
  • S103 Obtain an SDK template corresponding to a preset programming language, where the SDK template includes items to be filled.
  • file templates are prepared in advance for SDKs of different programming languages, that is, corresponding SDK templates are preset for different programming languages.
  • corresponding SDK templates are preset for different programming languages.
  • the programming language is the programming language used when the software development kit is called, and the programming language can be C language, C++ language, Java language, go language, python language, or nodejs language, etc.
  • the SDK template of which preset programming language is obtained can be provided by the user who uses the software development kit of this application, that is, provided by the user who uses this tool, or can be the default programming language of the system, or by the user
  • the programming language for custom settings can be one or multiple. This application does not specifically limit this. When it is necessary to generate SDKs in multiple programming languages, the SDK templates corresponding to the multiple programming languages are obtained respectively, so as to generate corresponding SDKs respectively.
  • variable part of the SDK template is the item to be filled in the SDK template, which is the part that needs to be filled according to the interface information of the API; the immutable part is the fixed content of the SDK template.
  • the SDK template is described in the manner of functions, while the Java language, the SDK template is described in the manner of object classes.
  • SDK templates described in different programming languages can be generated in advance, and the corresponding SDK templates can be called according to the programming language determined by the user or the default programming language during operation. Regardless of whether the C language uses a function description or Java uses an object class description, the items to be filled are left for filling in interface information, and the "items to be filled" are the variable part of the software development kit template.
  • the function name, function entity and function parameters are used as the items to be filled, and other symbols (such as "$ ⁇ ⁇ ", etc.) or keywords (such as "name” or “Module”, etc.) is written in the SDK template in advance, and in the subsequent step 104, fill in the name included in the interface information into the function name that needs to be filled in, and fill in the instruction into the function entity that needs to be filled in.
  • the external names of the parameters included in the instruction parameters are filled with the function parameters that need to be filled in.
  • the object class is used for description, then the object class name, the function entities included in the object class, function parameters, etc.
  • step 104 the name included in the interface information is filled in.
  • Fill in part of the object class name fill in the instruction into the function entity included in the part of the object class that needs to be filled, and fill in the external name of the parameter included in the instruction parameter into the function parameter included in the part of the object class that needs to be filled in.
  • the SDK templates of other languages are similar, but the grammatical rules of each language are different, so I won't list them all here.
  • S104 Obtain target interface information corresponding to each item to be filled in the SDK template from the interface information, and compile the target interface information according to a preset programming language and fill it into the SDK template Among the items to be filled in, an SDK programming file is generated.
  • step 102 the API interface information is extracted, and the SDK template is obtained in step 103. Therefore, in step 104, the interface information is compiled according to the preset programming language and filled into the items to be filled in the SDK template to generate the SDK Programming files.
  • step 104 is the process of generating SDK programming files.
  • the interface information required to generate the SDK can be extracted.
  • the overall structure and content of the SDK have been determined. Fill the interface information extracted in the previous step into the SDK template that has been prepared
  • the extracted interface information such as request parameter class and response parameter class, etc.
  • the extracted interface information are mapped to the items to be filled in the SDK template, so as to fill in the SDK. Template.
  • step 105 is further included: compiling and verifying the SDK programming files in different operating systems to generate SDKs for different operating systems.
  • the SDK programming file is added to different operating systems developed in various languages, that is, the compilation verification is performed in different development environments, and SDs for different operating systems are generated.
  • the method further includes: saving the SDK in the preset saving path of the SDK for downloading by the user equipment.
  • the SDK saving path may also be obtained in advance, and the compiled SDK is saved in the SDK saving path.
  • the SDK saving path may be a disk path, a network path, or a memory card path.
  • the SDK generation method proposed in the embodiments of this application is essentially the process of generating code through code. After this application extracts the API interface information, it fills these interface information into the new file formed by the SDK template, which is new Because the content definition in the SDK template is strictly defined in accordance with the grammatical specification of the program, the efficiency of generating the SDK can be improved, and the labor cost can be reduced.
  • FIG. 5 shows a structural block diagram of a device for generating a software development kit provided by an embodiment of the present application. For ease of description, only The part related to the embodiment of this application.
  • the device for generating the software development kit includes:
  • the source code obtaining unit 51 is configured to obtain the source code of the application program
  • the extraction unit 52 is configured to analyze the source code and extract interface information of the application programming interface
  • the template obtaining unit 53 is configured to obtain an SDK template corresponding to a preset programming language, where the SDK template includes items to be filled;
  • the filling unit 54 is configured to obtain target interface information corresponding to each item to be filled in the SDK template from the interface information, and compile the target interface information according to a preset programming language and fill it into In the items to be filled in the SDK template, an SDK programming file is generated.
  • the extraction unit 52 is specifically configured to:
  • the extraction unit 52 is further configured to:
  • the interface information of each category used to describe the application programming interface is stored in the form of simple Java objects to form structured interface information.
  • the interface information includes at least: interface name, interface request parameter information, and interface response parameter information.
  • the source code obtaining unit 51 is specifically configured to:
  • the device for generating the software development kit further includes a compiling unit 55, and the compiling unit 55 is used to compile and verify the SDK programming files in different operating systems to Generate SDK for different operating systems.
  • the SDK generation method proposed in the embodiments of this application is essentially the process of generating code through code. After this application extracts the API interface information, it fills these interface information into the new file formed by the SDK template, which is new Because the content definition in the SDK template is strictly defined in accordance with the grammatical specification of the program, the efficiency of generating the SDK can be improved, and the labor cost can be reduced.
  • FIG. 7 is a schematic diagram of a terminal device provided by an embodiment of the present application.
  • the terminal device 7 of this embodiment includes: a processor 70, a memory 71, and computer-readable instructions 72 stored in the memory 71 and running on the processor 70, such as an SDK generation program .
  • the processor 70 executes the computer-readable instructions 72
  • the steps in the above embodiments of the method for generating each software development kit are implemented, such as steps 101 to 104 shown in FIG. 1.
  • the processor 70 executes the computer-readable instructions 72
  • the functions of the modules/units in the foregoing device embodiments are implemented, for example, the functions of the units 51 to 54 shown in FIG. 5
  • the computer-readable instruction 72 may be divided into one or more modules/units, and the one or more modules/units are stored in the memory 71 and executed by the processor 70 execute to complete this application.
  • the one or more modules/units may be a series of calculations capable of completing specific functions
  • a machine-readable instruction instruction segment which is used to describe the execution process of the computer-readable instruction 72 in the terminal device 7.
  • the terminal device 7 may be a computing device such as a server, a desktop computer, a notebook, a palmtop computer, and a cloud server.
  • the terminal device may include, but is not limited to, a processor 70 and a memory 71.
  • FIG. 7 is only an example of the terminal device 7 and does not constitute a limitation on the terminal device 7. It may include more or less components than shown in the figure, or a combination of certain components, or different components.
  • the terminal device may also include an input/output device, a network access device, a bus, and the like.
  • the so-called processor 70 may be a central processing unit (Central Processing Unit, CPU), or may be other general-purpose processors, digital signal processors (Digital Signal Processors, DSPs), and application specific integrated circuits (Application Specific Integrated Circuits, ASIC), ready-made programmable gate array
  • CPU Central Processing Unit
  • DSPs Digital Signal Processors
  • ASIC Application Specific Integrated Circuits
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
  • the memory 71 may be an internal storage unit of the terminal device 7, such as a hard disk or memory of the terminal device 7.
  • the memory 71 may also be an external storage device of the terminal device 7, for example, a plug-in hard disk, a smart memory card (Smart Media Card,
  • the memory 71 may also include both an internal storage unit of the terminal device 7 and an external storage device.
  • the memory 71 is used to store the computer readable instructions and other programs and data required by the terminal device.
  • the memory 71 can also be used to temporarily store data that has been output or will be output.
  • Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory may include random access memory (RAM) or external cache memory.
  • RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Channel (Synchlink) DRAM (SLDRAM), memory bus (Rambus), direct RAM (RDRAM), direct memory bus dynamic RAM (DRDR AM), and memory bus dynamic RAM (RDRAM), etc.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed to multiple networks Unit. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
  • the integrated module/unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, this application Please implement all or part of the process in the above-mentioned embodiment method, or it can be completed by instructing relevant hardware through computer-readable instructions.
  • the computer-readable instructions can be stored in a computer-readable storage medium. When the instructions are executed by the processor, they can implement the steps of the foregoing method embodiments

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

一种软件开发工具包的生成方法、装置、终端设备、及计算机可读存储介质,其中,所述方法包括:获取应用程序的源代码(S101);对所述源代码进行解析,并提取出应用程序编程接口的接口信息(S102);获取预设编程语言对应的SDK模板,所述SDK模板包括待填充项(S103);从所述接口信息中获取与所述SDK模板中每个所述待填充项对应的目标接口信息,将所述目标接口信息按照预设编程语言编译后填充至所述SDK模板的所述待填充项中,生成SDK编程文件(S104)。通过上述方式提高了生成SDK的效率,降低了人工成本。

Description

软件幵发工具包的生成方法、 装置及终端设备
[0001] 本申请要求于 2019年 2月 27日提交中国专利局、 申请号为 201910145901.2、 发明 名称为“软件开发工具包的生成方法、 装置及终端设备”的中国专利申请的优先权 , 其全部内容通过引用结合在本申请中。
技术领域
[0002] 本申请属于软件开发技术领域, 尤其涉及一种软件开发工具包的生成方法、 装 置及终端设备。
背景技术
[0003] 在应用程序, 包括客户端应用程序和网页应用程序, 上线之后, 为了支持用户 以更加丰富的方式接入和使用该应用程序, 开发商通常会对外提供不同语言版 本的软件开发工具包 (Software Development Kit, SDK) 。
[0004] 当应用程序中增加了新的功能或新的特性后, 需要将新增部分的应用程序编程 接口 (Application Programming Interface, API) 编写成不同语言的 SDK, 以实现 与应用程序的同步更新。 然而, 开发 SDK的过程包含着大量的重复工作, 过程 也十分枯燥, 并且手动编写 SDK的过程需要耗费开发人员大量时间。 与此同时 , 每次系统特性的发生改变, 都需要对 SDK的相关接口进行更新, 系统中的接 口的变化, 同步到多语言版本的 SDK中需投入多倍的工作量。
发明概述
技术问题
[0005] 有鉴于此, 本申请实施例提供了一种软件开发工具包的生成方法、 装置及终端 设备, 以解决现有技术存在的生成 SDK效率低下的技术问题。
问题的解决方案
技术解决方案
[0006] 本申请实施例的第一方面提供了一种软件开发工具包 SDK的生成方法, 包括: [0007] 获取应用程序的源代码;
[0008] 对所述源代码进行解析, 并提取出应用程序编程接口的接口信息; [0009] 获取预设编程语言对应的 SDK模板, 所述 SDK模板包括待填充项;
[0010] 从所述接口信息中获取与所述 SDK模板中每个所述待填充项对应的目标接口信 息, 将所述目标接口信息按照预设编程语言编译后填充至所述 SDK模板的所述 待填充项中, 生成 SDK编程文件。
[0011] 本申请实施例的第二方面提供了一种软件开发工具包 SDK的生成装置, 包括:
[0012] 源代码获取单元, 用于获取应用程序的源代码;
[0013] 提取单元, 用于对所述源代码进行解析, 并提取出应用程序编程接口的接口信 息;
[0014] 模板获取单元, 用于获取预设编程语言对应的 SDK模板, 所述 SDK模板包括待 填充项;
[0015] 填充单元, 用于从所述接口信息中获取与所述 SDK模板中每个所述待填充项对 应的目标接口信息, 将所述目标接口信息按照预设编程语言编译后填充至所述 S DK模板的所述待填充项中, 生成 SDK编程文件。
[0016] 本申请实施例的第三方面提供了一种终端设备, 包括存储器以及处理器, 所述 存储器中存储有可在所述处理器上运行的计算机可读指令, 所述处理器执行所 述计算机可读指令时, 实现如下步骤:
[0017] 获取应用程序的源代码;
[0018] 对所述源代码进行解析, 并提取出应用程序编程接口的接口信息;
[0019] 获取预设编程语言对应的 SDK模板, 所述 SDK模板包括待填充项;
[0020] 从所述接口信息中获取与所述 SDK模板中每个所述待填充项对应的目标接口信 息, 将所述目标接口信息按照预设编程语言编译后填充至所述 SDK模板的所述 待填充项中, 生成 SDK编程文件。
[0021] 本申请实施例的第四方面提供了一种计算机可读存储介质, 所述计算机可读存 储介质存储有计算机可读指令, 所述计算机可读指令被处理器执行时实现如下 步骤:
[0022] 获取应用程序的源代码;
[0023] 对所述源代码进行解析, 并提取出应用程序编程接口的接口信息;
[0024] 获取预设编程语言对应的 SDK模板, 所述 SDK模板包括待填充项; [0025] 从所述接口信息中获取与所述 SDK模板中每个所述待填充项对应的目标接口信 息, 将所述目标接口信息按照预设编程语言编译后填充至所述 SDK模板的所述 待填充项中, 生成 SDK编程文件。
发明的有益效果
有益效果
[0026] 本申请实施例中, 通过源代码提取到 API的接口信息后, 将这些接口信填充到 S DK模板形成 SDK编程文件, 由于 SDK模板中的内容定义是严格按照程序的语法 规范定义的, 因而可以提高生成 SDK的效率, 减少了人工成本。
对附图的简要说明
附图说明
[0027] 为了更清楚地说明本申请实施例中的技术方案, 下面将对实施例或现有技术描 述中所需要使用的附图作简单地介绍, 显而易见地, 下面描述中的附图仅仅是 本申请的一些实施例, 对于本领域普通技术人员来讲, 在不付出创造性劳动性 的前提下, 还可以根据这些附图获得其他的附图。
[0028] 图 1是本申请实施例提供的一种软件开发工具包的生成方法的具体实现流程图
[0029] 图 2是本申请实施例提供的一种软件开发工具包的生成方法的步骤 102的一种具 体实现流程图;
[0030] 图 3是本申请实施例提供的一种软件开发工具包的生成方法的步骤 102另一种具 体实现流程图;
[0031] 图 4是本申请实施例提供的另一种软件开发工具包的生成方法的具体实现流程 图;
[0032] 图 5是本申请实施例提供的一种软件开发工具包的生成装置的结构示意图; [0033] 图 6是本申请实施例提供的另一种软件开发工具包的生成装置的结构示意图; [0034] 图 7是本申请实施例提供的终端设备的示意图。
发明实施例
本发明的实施方式 [0035] 为了说明本申请所述的技术方案, 下面通过具体实施例来进行说明。
[0036] 需要说明的是, 在不冲突的情况下, 本申请中的实施例及实施例中的特征可以 相互组合。 下面将参考附图并结合实施例来详细说明本申请。
[0037] 为了使本技术领域的人员更好地理解本申请方案, 下面将结合本申请实施例中 的附图, 对本申请实施例中的技术方案进行清楚, 完整地描述, 显然, 所描述 的实施例仅仅是本申请一部分的实施例, 而不是全部的实施例。 基于本申请中 的实施例, 对于本领域普通技术人员来讲, 在不付出创造性劳动性的前提下, 所获得的所有其他实施例, 都应当属于本申请保护的范围。
[0038] 以下描述中, 为了说明而不是为了限定, 提出了诸如特定系统结构、 技术之类 的具体细节, 以便透彻理解本申请实施例。 然而, 本领域的技术人员应当清楚 , 在没有这些具体细节的其它实施例中也可以实现本申请。 在其它情况中, 省 略对众所周知的系统、 装置、 电路以及方法的详细说明, 以免不必要的细节妨 碍本申请的描述。
[0039] 图 1示出了本申请实施例提供的软件开发工具包的生成方法的实现流程, 该生 成方法流程包括步骤 S101至 S104 该生成方法适用于针对应用程序的 API自动生 成 SDK的情形。 该软件开发工具包的生成方法由软件开发工具包的生成装置执 行, 所述软件开发工具包的生成装置配置于终端设备, 可由软件和 /或硬件实现 。 各步骤的具体实现原理如下。
[0040] S101 , 获取应用程序的源代码。
[0041] 其中, 应用程序包括网页应用和终端应用, 为需要生成软件开发工具包的目标 对象。 获取应用程序源代码, 并将源代码切换到合适的版本上, 为后续的分析 工作提供数据基础。
[0042] 在本申请实施例中, 获取应用程序的源代码包括: 通过 Git在预先配置好的应 用程序源代码托管地址下载所述应用程序的源代码。
[0043] 可安装于终端设备的应用程序, 它们的源代码均使用 Git进行管理。 将 Git的 API 进行了封装并集成在工具中, 该工具可以是独立的用于生成软件开发工具包的 应用程序, 也可以是某个应用程序具备的可生成软件开发工具包的功能, 在该 工具的配置文件中, 预先配置好目标对象, 即待生成软件开发工具包的应用程 序的源代码托管地址, 在工具运行过程中, 利用工具可以自动的下载所需的应 用程序源代码。
[0044] S102, 对所述源代码进行解析, 并提取出应用程序编程接口的接口信息。
[0045] 其中, 对源代码进行解析, 提取出 API的接口信息, 从而后续生成 SDK。
[0046] 接口信息包括但不限于: 接口名称、 接口请求参数信息、 和接口响应参数信息 。 接口请求参数信息包括但不限于: 参数名称和参数类型。 接口响应参数信息 包括但不限于: 响应参数名称、 响应参数类型、 和复杂类型参数信息 (即由多 个基础类型字段组合而成的新类型) 。
[0047] 可选地, 如图 2所示, 作为本申请一实施例, 步骤 102包括步骤 201至 204。
[0048] S201 , 对所述源代码进行编译, 生成 Java字节码。
[0049] 其中, 对源代码进行编译生成 Java字节码, Java字节码是一种数据加载到计算 机内存中的数据形式, 对类的进一步分析需要此步骤作为基础。
[0050] 也就是说, 源代码需要编译成字节码, Java虚拟机 (jvm) 才能识别出其中的 类结构, 如果不进行编译, 源代码和普通的文本文件没有区别, jvm就无法获取 到其中的信息。
[0051] S202, 利用 Java类加载器加载所述 Java字节码, 保留符合预设规则的类。
[0052] 其中, Java类加载器 (java Classloader) 是 Java运行时环境 (java Runtime Environment) 的一部分, 负责动态加载 Java类到 Java虚拟机的内存空间中。
[0053] 利用 Java类加载器加载编译后的 Java字节码, 并结合设计好的规则库, 依次扫 描加载进来的类, 同时根据规则库中的规则对被扫描的类进行匹配, 符合预设 规则的类被保留, 不符合预设规则的类被过滤掉, 即符合条件的类进行保留, 不符合条件的类则过滤掉。
[0054] Java类加载器是将 Java类加载至 Java虚拟机, 虚拟机不包括规则库, 规则库是 本工具中单独定义的一个用于做类过滤的模块, 用于在类加载器将 java类加载至 虚拟机后, 在对已加载进 Java虚拟机的类进行扫描时, 按规则库中的规则过滤出 满足预设规则的 Java类。 对于 API, 只需过滤出一些对外开放的接口信息, 并非 要所有的接口信息全部暴露出来, 因此需要一个规则库, 来指定哪些类需要进 行信息的提取, 这样一方面可以保证受限的信息不对外暴漏, 另一方便, 后续 如果有生成规则的变化, 只需更新规则库, 而不需要重新编写代码。
[0055] S203, 确定被保留的类的类别。
[0056] 其中, 被保留的类的类别包括但不限于请求参数类、 响应参数类、 和接口定义 类等。 基于不同的分类规则, 分析被保留的类是属于那种类别,
[0057] 根据上一步的筛选结果, 分析被保留的类是属于那种类别, 由于系统的代码是 基于一定的规范进行开发的, 那么不同的类从命名和继承关系上都有一定的规 则。
[0058] 例如, 前面提到的请求参数类, 类命名一定是以 Request结尾的, 并且所有请求 参数类继承自 Request类, 因此既可以通过类名称进行判断分类, 也可以从继承 关系上进行判断分类。
[0059] 又如, 对于响应参数类, 类命名一定是以 Response结尾的, 并且所有响应参数 类继承自 Response类, 因而通过类名称进行判断分类。
[0060] 接口定义类, 类命名一定是以 Action结尾的, 并且所有接口定义类继承自 Actio n类, 因而通过类名称进行判断分类。
[0061] 其他的类判断分类的原理类似, 不过不同的类可能有不同的规则, 本申请不再 ——歹■]举。
[0062] S204, 基于反射机制提取各个类别用于描述应用程序编程接口的接口信息。
[0063] 其中, 根据类别的划分, 应用不同的提取规则提取不同的接口信息。 例如, 对 请求参数类和响应参数类, 需要提取字段详细信息; 对接口类只需要提取接口 名称信息等。
[0064] 反射机制指在运行状态中, 对于任意一个类, 都能够知道这个类的所有属性和 方法, 对于任意一个对象, 都能调用它的任意一个方法。 Java语言的反射机制为 动态获取信息, 以及动态调用对象方法的功能。
[0065] 本申请实施例中, 通过反射机制提取各个类别用于描述 API的接口信息。 示例 性地, 提取描述 API的完整信息项, 完整信息项包括接口名称、 接口请求参数名 称、 接口请求参数类型、 接口请求参数是否为必传参数、 接口响应参数名称、 接口响应参数类型、 接口响应参数中关联的枚举类型、 接口响应参数中关联的 对象类型、 接口版本等。 [0066] 进一步地, 在本申请其他实施例中, 如图 3所示, 在步骤 204之后, 还包括步骤 205 , 将各个类别用于描述应用程序编程接口的接口信息按简单 Java对象的方式 进行存储, 形成结构化的接口信息。
[0067] 在本申请实施例中, 以 json字符串的形式将描述一个 API的接口信息, 按简单 Ja va对象的方式进行存储, 形成结构化的接口信息。 例如完整信息项包括: 接口名 称、 接口请求参数名称、 接口请求参数类型、 接口请求参数是否为必传参数、 接口响应参数名称、 接口响应参数类型、 接口响应参数中关联的枚举类型、 接 口响应参数中关联的对象类型、 接口版本等, 用 json字符串的方式进行组织和存 储后, 将其反序列化为简单 Java对象非常简便, 形成结构化的接口信息, 示例如 下所示:
[0068] {
[0069] "name": "ListRegions",
[0070] "request": {
[0071] "attributes": [
[0072] {
[0073] "annotations": [],
[0074] "name": "id",
[0075] "required": false,
[0076] "type": "String"
[0077] } ,
[0078] {
[0079] "annotations": [],
[0080] "name": "productCode",
[0081] "required": false,
[0082] "type": "String"
[0083]
Figure imgf000009_0001
[0084]
Figure imgf000009_0002
[0085] enums": [], [0086] "name": "ListRegionsRequest"
[0087] } ,
[0088] "response": {
[0089] "attributes": [
[0090] {
[0091] "name": "regions",
[0092] "type": "RegionBean[]n
[0093] }
[0094] ],
[0095] "beans": [
[0096] {
[0097] "attributes": [
[0098] {
[0099] "name": "id",
[0100] "type": "String"
[0101] } ,
[0102] {
[0103] "name": "code",
[0104] "type": "String"
[0105] } ,
[0106] {
[0107] "name": "name",
[0108] "type": "String"
[0109] } ,
[0110] {
[0111] "name": "displayName",
[0112] "type": "String"
[0113] } , [0114]
Figure imgf000011_0001
[0115] "name": "description",
[0116] "type": "String"
[0117] }
[0118] ],
[0119] "enums": [],
[0120] "name": "RegionBean"
[0121] }
[0122] ],
[0123] "name": "ListRegionsResponse"
[0124]
Figure imgf000011_0002
[]
[0125] S103 , 获取预设编程语言对应的 SDK模板, 所述 SDK模板包括待填充项。
[0126] 在本申请实施例中, 根据不同编程语言的语法特征, 为各个不同的编程语言的 SDK事先编写了文件模板, 也就是说, 为不同编程语言预设了对应的 SDK模板 。 此外, 还可以根据不同的文件用途对这些模板进行继续组织与管理。
[0127] 编程语言为所述软件开发工具包被调用时所采用的编程语言, 该编程语言可以 为 C语言、 C++语言、 Java语言、 go语言、 python语言、 或 nodejs语言等等。 需要 说明的是, 获取何种预设编程语言的 SDK模板, 可由使用本申请的软件开发工 具包的用户, 即由使用本工具的用户提供, 也可为系统默认的编程语言, 也可 以由用户自定义设置的编程语言, 可以为一个, 也可以为多个。 本申请对此不 做具体限定。 当需要生成多个编程语言的 SDK时, 分别获取多个编程语言对应 的 SDK模板, 从而分别生成对应的 SDK。
[0128] 各类编程语言有各自的语法规则, 编写不同的编程语言的文件模板过程中, 只 需按照语法规则, 抽象出 SDK代码可变部分和不可变部分即可, 然后按照具体 的文件模板语法, 撰写模板内容即可, 本申请中使用的模板是 freemarker。 其中 , SDK模板的可变部分即 SDK模板的待填充项, 为需要根据 API的接口信息进行 填充的部分; 不可变部分即 SDK模板的固定内容。 [0129] 例如, 对于 C语言来说, 其 SDK模板采用函数的方式描述, 而 Java语言, 其 SD K模板采用对象类的方式描述。 可以事先生成多个采用不同的编程语言描述的 S DK模板, 在运行过程中根据用户确定的编程语言或者默认的编程语言来调取相 应的 SDK模板。 无论是 C语言采用函数方式描述还是采用 Java采用对象类方式描 述, 均留出待填充项填写接口信息, 该“待填充项”即所述软件开发工具包模板的 可变部分。 例如, 采用函数方式描述时, 则将函数名称、 函数实体及函数参数 作为待填充项, 而其他的用于标识函数的符号 (例如“${ }”等) 或者关键字 (例 如“name”或“module”等) 则预先在 SDK模板中写入, 并在执行后续步骤 104中, 将接口信息所包括的名称填入需要填写部分的函数名称, 将指令填入需要填写 部分的函数实体, 将所述指令参数所包括的参数对外名称填入需要填写部分的 函数参数。 同样, 如果是采用对象类进行描述, 则将对象类名称、 对象类中所 包括的函数实体、 函数参数等作为需要填写部分, 并在执行步骤 104中, 将接口 信息所包括的名称填入需要填写部分的对象类名称, 将指令填入需要填写部分 的对象类中所包括的函数实体, 将指令参数所包括的参数对外名称填入需要填 写部分的对象类中所包括的函数参数。 其他语言的 SDK模板类似, 只是各语言 语法规则不同, 此处不再一一列举。
[0130] S104, 从所述接口信息中获取与所述 SDK模板中每个所述待填充项对应的目标 接口信息, 将所述目标接口信息按照预设编程语言编译后填充至所述 SDK模板 的所述待填充项中, 生成 SDK编程文件。
[0131] 在步骤 102提取了 API的接口信息, 步骤 103获取到 SDK模板, 因此, 在步骤 104 中, 将接口信息按照预设编程语言编译后对应填充至 SDK模板的待填充项中, 生成 SDK编程文件。
[0132] 也就是说, 步骤 104为 SDK编程文件的生成过程, 经过 API内容分析, 可以提取 出生成 SDK所需的接口信息, 经过编写 SDK模板, 已经确定了 SDK的整体结构 与内容, 只需将前面步骤提取到的接口信息, 填充到已经准备好的 SDK模板中
[0133] 可以理解的是, 在提取到类信息时, 根据不同的类, 将提取到的接口信息, 例 如请求参数类和响应参数类等, 映射到 SDK模板的待填充项, 从而填充到 SDK 模板中。
[0134] 可选地, 如图 4所示, 在步骤 104之后还包括步骤 105: 将所述 SDK编程文件在 不同操作系统中进行编译验证以生成针对不同操作系统的 SDK。
[0135] 其中, 在生成 SDK编程文件之后, 将 SDK编程文件加入到各个语言开发的不同 操作系统中, 即不同的开发环境中进行编译验证, 生成针对不同操作系统的 SD
K。
[0136] 可选地, 在本申请其他实施例中, 在步骤 105之后, 还包括: 将 SDK保存在所 述 SDK的预设保存路径, 以供用户设备下载。
[0137] 其中, 还可以预先获取 SDK保存路径, 将编译得到的 SDK保存在所述 SDK保存 路径, SDK保存路径可以是磁盘路径、 网路路径、 或者是存储卡路径等。
[0138] 本申请实施例提出的 SDK生成方法, 其本质就是通过代码生成代码的过程, 本 申请在提取到 API的接口信息后, 将这些接口信填充到 SDK模板形成的新的文件 , 就是新的代码, 由于 SDK模板中的内容定义是严格按照程序的语法规范定义 的, 因而可以提高生成 SDK的效率, 减少了人工成本。
[0139] 对应于上文实施例所述的软件开发工具包的生成方法, 图 5示出了本申请实施 例提供的软件开发工具包的生成装置的结构框图, 为了便于说明, 仅示出了与 本申请实施例相关的部分。
[0140] 参照图 5 , 该软件开发工具包的生成装置包括:
[0141] 源代码获取单元 51, 用于获取应用程序的源代码;
[0142] 提取单元 52, 用于对所述源代码进行解析, 并提取出应用程序编程接口的接口 信息;
[0143] 模板获取单元 53, 用于获取预设编程语言对应的 SDK模板, 所述 SDK模板包括 待填充项;
[0144] 填充单元 54, 用于从所述接口信息中获取与所述 SDK模板中每个所述待填充项 对应的目标接口信息, 将所述目标接口信息按照预设编程语言编译后填充至所 述 SDK模板的所述待填充项中, 生成 SDK编程文件。
[0145] 可选地, 所述提取单元 52具体用于:
[0146] 对所述源代码进行编译, 生成 Java字节码; [0147] 利用 Java类加载器加载所述 Java字节码, 保留符合预设规则的类;
[0148] 确定被保留的类的类别, 基于反射机制提取各个类别用于描述应用程序编程接 口的接口信息。
[0149] 可选地, 所述提取单元 52还用于:
[0150] 将各个类别用于描述应用程序编程接口的接口信息按简单 Java对象的方式进行 存储, 形成结构化的接口信息。
[0151] 可选地, 所述接口信息至少包括: 接口名称、 接口请求参数信息和接口响应参 数信息。
[0152] 可选地, 所述源代码获取单元 51具体用于:
[0153] 通过 Git在预先配置好的应用程序源代码托管地址下载所述应用程序的源代码
[0154] 可选地, 如图 6所示, 所述软件开发工具包的生成装置还包括编译单元 55 , 所 述编译单元 55用于将所述 SDK编程文件在不同操作系统中进行编译验证以生成 针对不同操作系统的 SDK。
[0155] 本申请实施例提出的 SDK生成方法, 其本质就是通过代码生成代码的过程, 本 申请在提取到 API的接口信息后, 将这些接口信填充到 SDK模板形成的新的文件 , 就是新的代码, 由于 SDK模板中的内容定义是严格按照程序的语法规范定义 的, 因而可以提高生成 SDK的效率, 减少了人工成本。
[0156] 图 7是本申请一实施例提供的终端设备的示意图。 如图 7所示, 该实施例的终端 设备 7包括: 处理器 70、 存储器 71以及存储在所述存储器 71中并可在所述处理器 70上运行的计算机可读指令 72, 例如 SDK生成程序。 所述处理器 70执行所述计 算机可读指令 72时实现上述各个软件开发工具包的生成方法实施例中的步骤, 例如图 1所示的步骤 101至 104。 或者, 所述处理器 70执行所述计算机可读指令 72 时实现上述各装置实施例中各模块 /单元的功能, 例如图 5所示单元 51至 54的功能
[0157] 示例性的, 所述计算机可读指令 72可以被分割成一个或多个模块 /单元, 所述 一个或者多个模块 /单元被存储在所述存储器 71中, 并由所述处理器 70执行, 以 完成本申请。 所述一个或多个模块 /单元可以是能够完成特定功能的一系列计算 机可读指令指令段, 该指令段用于描述所述计算机可读指令 72在所述终端设备 7 中的执行过程。
[0158] 所述终端设备 7可以是服务器、 桌上型计算机、 笔记本、 掌上电脑及云端服务 器等计算设备。 所述终端设备可包括, 但不仅限于, 处理器 70、 存储器 71。 本 领域技术人员可以理解, 图 7仅仅是终端设备 7的示例, 并不构成对终端设备 7的 限定, 可以包括比图示更多或更少的部件, 或者组合某些部件, 或者不同的部 件, 例如所述终端设备还可以包括输入输出设备、 网络接入设备、 总线等。
[0159] 所称处理器 70可以是中央处理单元 (Central Processing Unit, CPU) , 还可以是其 他通用处理器、 数字信号处理器 (Digital Signal Processor, DSP)、 专用集成电路 (Application Specific Integrated Circuit, ASIC)、 现成可编程门阵列
(Field-Programmable Gate Array, FPGA)或者其他可编程逻辑器件、 分立门或者 晶体管逻辑器件、 分立硬件组件等。 通用处理器可以是微处理器或者该处理器 也可以是任何常规的处理器等。
[0160] 所述存储器 71可以是所述终端设备 7的内部存储单元, 例如终端设备 7的硬盘或 内存。 所述存储器 71也可以是所述终端设备 7的外部存储设备, 例如所述终端设 备 7上配备的插接式硬盘, 智能存储卡 (Smart Media Card,
SMC) , 安全数字 (Secure Digital, SD) 卡, 闪存卡 (Flash Card) 等。 进一步 地, 所述存储器 71还可以既包括所述终端设备 7的内部存储单元也包括外部存储 设备。 所述存储器 71用于存储所述计算机可读指令以及所述终端设备所需的其 他程序和数据。 所述存储器 71还可以用于暂时地存储已经输出或者将要输出的 数据。
[0161] 本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程, 是可 以通过计算机可读指令来指令相关的硬件来完成, 所述的计算机可读指令可存 储于一非易失性计算机可读取存储介质中, 该计算机可读指令在执行时, 可包 括如上述各方法的实施例的流程。 其中, 本申请所提供的各实施例中所使用的 对存储器、 存储、 数据库或其它介质的任何引用, 均可包括非易失性和 /或易失 性存储器。 非易失性存储器可包括只读存储器 (ROM) 、 可编程 ROM (PROM ) 、 电可编程 ROM (EPROM) 、 电可擦除可编程 ROM (EEPROM) 或闪存。 易失性存储器可包括随机存取存储器 (RAM) 或者外部高速缓冲存储器。 作为 说明而非局限, RAM以多种形式可得, 诸如静态 RAM (SRAM) 、 动态 RAM ( DRAM) 、 同步 DRAM (SDRAM) 、 双数据率 SDRAM (DDRSDRAM) 、 增强 型 SDRAM (ESDRAM) 、 同步链路 (Synchlink) DRAM (SLDRAM) 、 存储 器总线 (Rambus) 直接 RAM (RDRAM) 、 直接存储器总线动态 RAM (DRDR AM) 、 以及存储器总线动态 RAM (RDRAM) 等。
[0162] 所属领域的技术人员可以清楚地了解到, 为了描述的方便和简洁, 仅以上述各 功能单元、 模块的划分进行举例说明, 实际应用中, 可以根据需要而将上述功 能分配由不同的功能单元、 模块完成, 即将所述装置的内部结构划分成不同的 功能单元或模块, 以完成以上描述的全部或者部分功能。 实施例中的各功能单 元、 模块可以集成在一个处理单元中, 也可以是各个单元单独物理存在, 也可 以两个或两个以上单元集成在一个单元中, 上述集成的单元既可以采用硬件的 形式实现, 也可以采用软件功能单元的形式实现。 另外, 各功能单元、 模块的 具体名称也只是为了便于相互区分, 并不用于限制本申请的保护范围。 上述系 统中单元、 模块的具体工作过程, 可以参考前述方法实施例中的对应过程, 在 此不再赘述。
[0163] 在上述实施例中, 对各个实施例的描述都各有侧重, 某个实施例中没有详述或 记载的部分, 可以参见其它实施例的相关描述。
[0164] 所述作为分离部件说明的单元可以是或者也可以不是物理上分开的, 作为单元 显示的部件可以是或者也可以不是物理单元, 即可以位于一个地方, 或者也可 以分布到多个网络单元上。 可以根据实际的需要选择其中的部分或者全部单元 来实现本实施例方案的目的。
[0165] 另外, 在本申请各个实施例中的各功能单元可以集成在一个处理单元中, 也可 以是各个单元单独物理存在, 也可以两个或两个以上单元集成在一个单元中。 上述集成的单元既可以采用硬件的形式实现, 也可以采用软件功能单元的形式 实现。
[0166] 所述集成的模块 /单元如果以软件功能单元的形式实现并作为独立的产品销售 或使用时, 可以存储在一个计算机可读取存储介质中。 基于这样的理解, 本申 请实现上述实施例方法中的全部或部分流程, 也可以通过计算机可读指令来指 令相关的硬件来完成, 所述的计算机可读指令可存储于一计算机可读存储介质 中, 该计算机可读指令在被处理器执行时, 可实现上述各个方法实施例的步骤
[0167] 以上所述实施例仅用以说明本申请的技术方案, 而非对其限制; 尽管参照前述 实施例对本申请进行了详细的说明, 本领域的普通技术人员应当理解: 其依然 可以对前述各实施例所记载的技术方案进行修改, 或者对其中部分技术特征进 行等同替换; 而这些修改或者替换, 并不使相应技术方案的本质脱离本申请各 实施例技术方案的精神和范围, 均应包含在本申请的保护范围之内。

Claims

权利要求书
[权利要求 1] 一种软件开发工具包 SDK的生成方法, 其特征在于, 包括:
获取应用程序的源代码;
对所述源代码进行解析, 并提取出应用程序编程接口的接口信息; 获取预设编程语言对应的 SDK模板, 所述 SDK模板包括待填充项; 从所述接口信息中获取与所述 SDK模板中每个所述待填充项对应的目 标接口信息, 将所述目标接口信息按照预设编程语言编译后填充至所 述 SDK模板的所述待填充项中, 生成 SDK编程文件。
[权利要求 2] 如权利要求 1所述的生成方法, 其特征在于, 所述对所述源代码进行 解析, 并提取出应用程序编程接口的接口信息, 包括:
对所述源代码进行编译, 生成 Java字节码;
利用 Java类加载器加载所述 Java字节码, 保留符合预设规则的类; 确定被保留的类的类别, 基于反射机制提取各个类别用于描述应用程 序编程接口的接口信息。
[权利要求 3] 如权利要求 2所述的生成方法, 其特征在于, 所述基于反射机制提取 各个类别用于描述应用程序编程接口的接口信息之后, 还包括 将各个类别用于描述应用程序编程接口的接口信息按简单 Java对象的 方式进行存储, 形成结构化的接口信息。
[权利要求 4] 如权利要求 2或 3所述的生成方法, 其特征在于, 所述接口信息至少包 括: 接口名称、 接口请求参数信息和接口响应参数信息。
[权利要求 5] 如权利要求 1-3任一项所述的生成方法, 其特征在于, 所述获取应用 程序的源代码, 包括:
通过 Git在预先配置好的应用程序源代码托管地址下载所述应用程序 的源代码。
[权利要求 6] 如权利要求 1-3任一项所述的生成方法, 其特征在于, 所述生成 SDK 编程文件之后, 还包括:
将所述 SDK编程文件在不同操作系统中进行编译验证以生成针对不同 操作系统的 SDK
[权利要求 7] 一种软件开发工具包 SDK的生成装置, 其特征在于, 包括:
源代码获取单元, 用于获取应用程序的源代码; 提取单元, 用于对所述源代码进行解析, 并提取出应用程序编程接口 的接口信息;
模板获取单元, 用于获取预设编程语言对应的 SDK模板, 所述 SDK模 板包括待填充项;
填充单元, 用于从所述接口信息中获取与所述 SDK模板中每个所述待 填充项对应的目标接口信息, 将所述目标接口信息按照预设编程语言 编译后填充至所述 SDK模板的所述待填充项中, 生成 SDK编程文件。
[权利要求 8] 如权利要求 7所述的生成装置, 其特征在于, 所述提取单元具体用于 对所述源代码进行编译, 生成 Java字节码;
利用 Java类加载器加载所述 Java字节码, 保留符合预设规则的类; 确定被保留的类的类别, 基于反射机制提取各个类别用于描述应用程 序编程接口的接口信息。
[权利要求 9] 如权利要求 8所述的生成装置, 其特征在于, 所述提取单元还用于: 将各个类别用于描述应用程序编程接口的接口信息按简单 Java对象的 方式进行存储, 形成结构化的接口信息。
[权利要求 10] 如权利要求 8或 9所述的生成装置, 其特征在于, 所述接口信息至少包 括: 接口名称、 接口请求参数信息和接口响应参数信息。
[权利要求 11] 如权利要求 7-9任一项所述的生成装置, 其特征在于, 所述源代码获 取单元具体用于:
通过 Git在预先配置好的应用程序源代码托管地址下载所述应用程序 的源代码。
[权利要求 12] 如权利要求 7-9任一项所述的生成装置, 其特征在于, 还包括编译单 , 所述编译单元用于将所述 SDK编程文件在不同操作系统中进行编译 验证以生成针对不同操作系统的 SDK。
[权利要求 13] 一种终端设备, 包括存储器以及处理器, 所述存储器中存储有可在所 述处理器上运行的计算机可读指令, 其特征在于, 所述处理器执行所 述计算机可读指令时, 实现如下步骤:
获取应用程序的源代码;
对所述源代码进行解析, 并提取出应用程序编程接口的接口信息; 获取预设编程语言对应的 SDK模板, 所述 SDK模板包括待填充项; 从所述接口信息中获取与所述 SDK模板中每个所述待填充项对应的目 标接口信息, 将所述目标接口信息按照预设编程语言编译后填充至所 述 SDK模板的所述待填充项中, 生成 SDK编程文件。
[权利要求 14] 如权利要求 13所述的终端设备, 其特征在于, 所述对所述源代码进行 解析, 并提取出应用程序编程接口的接口信息, 包括:
对所述源代码进行编译, 生成 Java字节码;
利用 Java类加载器加载所述 Java字节码, 保留符合预设规则的类; 确定被保留的类的类别, 基于反射机制提取各个类别用于描述应用程 序编程接口的接口信息。
[权利要求 15] 如权利要求 14所述的终端设备, 其特征在于, 所述基于反射机制提取 各个类别用于描述应用程序编程接口的接口信息之后, 还包括 将各个类别用于描述应用程序编程接口的接口信息按简单 Java对象的 方式进行存储, 形成结构化的接口信息。
[权利要求 16] 如权利要求 14或 15所述的终端设备, 其特征在于, 所述接口信息至少 包括: 接口名称、 接口请求参数信息和接口响应参数信息。
[权利要求 17] 如权利要求 13-15任一项所述的终端设备, 其特征在于, 所述获取应 用程序的源代码, 包括:
通过 Git在预先配置好的应用程序源代码托管地址下载所述应用程序 的源代码。
[权利要求 18] 如权利要求 13-15任一项所述的终端设备, 其特征在于, 所述生成 SD
K编程文件之后, 还包括:
将所述 SDK编程文件在不同操作系统中进行编译验证以生成针对不同 操作系统的 SDK。
[权利要求 19] 一种计算机可读存储介质, 所述计算机可读存储介质存储有计算机可 读指令, 其特征在于, 所述计算机可读指令被处理器执行时实现如下 步骤:
获取应用程序的源代码;
对所述源代码进行解析, 并提取出应用程序编程接口的接口信息; 获取预设编程语言对应的 SDK模板, 所述 SDK模板包括待填充项; 从所述接口信息中获取与所述 SDK模板中每个所述待填充项对应的目 标接口信息, 将所述目标接口信息按照预设编程语言编译后填充至所 述 SDK模板的所述待填充项中, 生成 SDK编程文件。
[权利要求 20] 如权利要求 19所述的计算机可读存储介质, 其特征在于, 所述对所述 源代码进行解析, 并提取出应用程序编程接口的接口信息, 包括: 对所述源代码进行编译, 生成 Java字节码;
利用 Java类加载器加载所述 Java字节码, 保留符合预设规则的类; 确定被保留的类的类别, 基于反射机制提取各个类别用于描述应用程 序编程接口的接口信息。
PCT/CN2019/117180 2019-02-27 2019-11-11 软件开发工具包的生成方法、装置及终端设备 WO2020173128A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910145901.2 2019-02-27
CN201910145901.2A CN109976761B (zh) 2019-02-27 2019-02-27 软件开发工具包的生成方法、装置及终端设备

Publications (1)

Publication Number Publication Date
WO2020173128A1 true WO2020173128A1 (zh) 2020-09-03

Family

ID=67077465

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/117180 WO2020173128A1 (zh) 2019-02-27 2019-11-11 软件开发工具包的生成方法、装置及终端设备

Country Status (2)

Country Link
CN (1) CN109976761B (zh)
WO (1) WO2020173128A1 (zh)

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112099794A (zh) * 2020-09-28 2020-12-18 中国银行股份有限公司 前端项目构建方法及装置
CN112306498A (zh) * 2020-11-13 2021-02-02 用友网络科技股份有限公司 代码生成方法、erp系统和可读存储介质
CN112835615A (zh) * 2021-02-08 2021-05-25 百度在线网络技术(北京)有限公司 软件开发工具包的插件化处理方法、装置及电子设备
CN112965708A (zh) * 2021-03-29 2021-06-15 武汉悦学帮网络技术有限公司 代码的生成方法及装置
CN113076119A (zh) * 2021-03-25 2021-07-06 北京车和家信息技术有限公司 一种车机程序的更新方法、装置、介质和电子设备
CN113238740A (zh) * 2021-06-11 2021-08-10 腾讯科技(深圳)有限公司 代码生成方法、代码生成装置、存储介质及电子设备
CN113268267A (zh) * 2021-05-21 2021-08-17 深圳Tcl新技术有限公司 一种数据包生成方法、装置、计算机设备及存储介质
CN113535147A (zh) * 2021-07-20 2021-10-22 挂号网(杭州)科技有限公司 一种调用代码的生成方法、装置、电子终端及存储介质
CN113625999A (zh) * 2021-08-10 2021-11-09 未鲲(上海)科技服务有限公司 应用程序的生成方法、装置、设备及存储介质
CN114253520A (zh) * 2020-09-21 2022-03-29 北京字节跳动网络技术有限公司 接口代码生成方法和装置
CN116382703A (zh) * 2023-06-07 2023-07-04 建信金融科技有限责任公司 软件包生成方法、代码开发方法及装置、电子设备和介质
CN116974581A (zh) * 2023-09-25 2023-10-31 中化现代农业有限公司 代码生成方法、装置、电子设备和存储介质
CN117034900A (zh) * 2023-09-27 2023-11-10 厦门星纵数字科技有限公司 一种api代码文件自动生成方法、终端设备及存储介质
CN117435177A (zh) * 2023-12-20 2024-01-23 浙江寰福科技有限公司 应用程序接口构建方法、系统、设备及存储介质
CN117472336A (zh) * 2023-12-28 2024-01-30 芯瞳半导体技术(山东)有限公司 基于程序api的代码生成装置及其方法、设备及介质

Families Citing this family (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109976761B (zh) * 2019-02-27 2022-06-07 平安科技(深圳)有限公司 软件开发工具包的生成方法、装置及终端设备
CN110647317A (zh) * 2019-09-27 2020-01-03 中国航空无线电电子研究所 基于模板的应用框架生成方法
CN110990833B (zh) * 2019-10-31 2022-08-05 重庆小雨点小额贷款有限公司 一种sdk安全检测方法及相关设备
CN110852259A (zh) * 2019-11-08 2020-02-28 深圳前海微众银行股份有限公司 活体识别方法、系统、装置、设备及计算机可读存储介质
CN112748914B (zh) * 2020-03-18 2023-09-19 腾讯科技(深圳)有限公司 一种应用程序开发方法、装置、电子设备和存储介质
CN113495730A (zh) * 2020-03-20 2021-10-12 北京沃东天骏信息技术有限公司 资源包的生成及解析方法和装置
CN111506305B (zh) * 2020-03-26 2023-07-18 拉扎斯网络科技(上海)有限公司 工具包生成方法、装置、计算机设备及可读存储介质
CN111580829B (zh) * 2020-05-09 2023-08-04 广东天波信息技术股份有限公司 一种适用多种红外热成像测温模组的sdk开发装置
CN111638906B (zh) * 2020-05-15 2023-02-03 郑州阿帕斯数云信息科技有限公司 一种软件开发工具包sdk接入方法、装置和系统
CN111736916A (zh) * 2020-06-08 2020-10-02 北京达佳互联信息技术有限公司 基于Java语言的动态扩展方法、装置、电子设备及存储介质
CN111782737B (zh) * 2020-08-12 2024-05-28 中国工商银行股份有限公司 信息处理方法、装置、设备及存储介质
CN112363705B (zh) * 2020-11-10 2023-07-28 中国平安人寿保险股份有限公司 系统包生成方法、装置、计算机设备及存储介质
CN112764756A (zh) * 2021-01-15 2021-05-07 广州华多网络科技有限公司 软件资源编译方法及其相应的装置、设备、介质
CN113064820B (zh) * 2021-03-26 2022-09-16 深圳依时货拉拉科技有限公司 更新a/b实验sdk的方法、设备和计算机可读存储介质
CN112988289A (zh) * 2021-04-09 2021-06-18 北京字节跳动网络技术有限公司 调用接口的方法及系统
CN113220275A (zh) * 2021-05-25 2021-08-06 北京小米移动软件有限公司 软件获取方法和装置
CN113590098A (zh) * 2021-07-30 2021-11-02 中电金信软件有限公司 一种软件开发工具包sdk的生成方法、装置及电子设备
CN114115854A (zh) * 2021-11-29 2022-03-01 北京百度网讯科技有限公司 一种sdk文件生成方法、装置、设备以及存储介质
CN114398102B (zh) * 2022-01-18 2023-08-08 杭州米络星科技(集团)有限公司 一种应用程序包生成方法、装置、编译服务器及计算机可读存储介质
CN116450107B (zh) * 2023-04-04 2023-12-01 北京科乐园网络科技有限公司 低代码平台二次开发软件的方法、装置、电子设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070256055A1 (en) * 2004-11-19 2007-11-01 Adrian Herscu Method for building component-software for execution in a standards-compliant programming environment
CN102750152A (zh) * 2012-06-21 2012-10-24 新浪网技术(中国)有限公司 一种基于描述语言生成多种编程语言的应用的方法及装置
CN108563435A (zh) * 2018-04-19 2018-09-21 北京百度网讯科技有限公司 代码生成的方法及装置
CN108932122A (zh) * 2018-06-19 2018-12-04 上海陆家嘴国际金融资产交易市场股份有限公司 接口文档生成方法、装置、计算机设备和存储介质
CN109976761A (zh) * 2019-02-27 2019-07-05 平安科技(深圳)有限公司 软件开发工具包的生成方法、装置及终端设备

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103677821B (zh) * 2013-12-05 2018-06-12 金蝶软件(中国)有限公司 软件开发工具代码发布的方法和装置
CN103713896B (zh) * 2013-12-17 2017-01-04 北京京东尚科信息技术有限公司 用于访问服务器的软件开发工具包生成方法及装置
US20170102925A1 (en) * 2014-03-26 2017-04-13 Syed Adeel Ali Automatch process and system for software development kit for application programming interface
CN108628635B (zh) * 2018-05-07 2021-12-14 广州视源电子科技股份有限公司 获取参数名和局部变量名的方法、装置、设备及存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070256055A1 (en) * 2004-11-19 2007-11-01 Adrian Herscu Method for building component-software for execution in a standards-compliant programming environment
CN102750152A (zh) * 2012-06-21 2012-10-24 新浪网技术(中国)有限公司 一种基于描述语言生成多种编程语言的应用的方法及装置
CN108563435A (zh) * 2018-04-19 2018-09-21 北京百度网讯科技有限公司 代码生成的方法及装置
CN108932122A (zh) * 2018-06-19 2018-12-04 上海陆家嘴国际金融资产交易市场股份有限公司 接口文档生成方法、装置、计算机设备和存储介质
CN109976761A (zh) * 2019-02-27 2019-07-05 平安科技(深圳)有限公司 软件开发工具包的生成方法、装置及终端设备

Cited By (25)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114253520B (zh) * 2020-09-21 2024-03-12 抖音视界有限公司 接口代码生成方法和装置
CN114253520A (zh) * 2020-09-21 2022-03-29 北京字节跳动网络技术有限公司 接口代码生成方法和装置
CN112099794A (zh) * 2020-09-28 2020-12-18 中国银行股份有限公司 前端项目构建方法及装置
CN112306498A (zh) * 2020-11-13 2021-02-02 用友网络科技股份有限公司 代码生成方法、erp系统和可读存储介质
CN112835615A (zh) * 2021-02-08 2021-05-25 百度在线网络技术(北京)有限公司 软件开发工具包的插件化处理方法、装置及电子设备
CN112835615B (zh) * 2021-02-08 2024-01-30 百度在线网络技术(北京)有限公司 软件开发工具包的插件化处理方法、装置及电子设备
CN113076119A (zh) * 2021-03-25 2021-07-06 北京车和家信息技术有限公司 一种车机程序的更新方法、装置、介质和电子设备
CN113076119B (zh) * 2021-03-25 2023-12-12 北京车和家信息技术有限公司 一种车机程序的更新方法、装置、介质和电子设备
CN112965708A (zh) * 2021-03-29 2021-06-15 武汉悦学帮网络技术有限公司 代码的生成方法及装置
CN113268267A (zh) * 2021-05-21 2021-08-17 深圳Tcl新技术有限公司 一种数据包生成方法、装置、计算机设备及存储介质
CN113238740B (zh) * 2021-06-11 2023-10-27 腾讯科技(深圳)有限公司 代码生成方法、代码生成装置、存储介质及电子设备
CN113238740A (zh) * 2021-06-11 2021-08-10 腾讯科技(深圳)有限公司 代码生成方法、代码生成装置、存储介质及电子设备
CN113535147A (zh) * 2021-07-20 2021-10-22 挂号网(杭州)科技有限公司 一种调用代码的生成方法、装置、电子终端及存储介质
CN113625999B (zh) * 2021-08-10 2024-04-09 北京阅见未来网络科技有限公司 应用程序的生成方法、装置、设备及存储介质
CN113625999A (zh) * 2021-08-10 2021-11-09 未鲲(上海)科技服务有限公司 应用程序的生成方法、装置、设备及存储介质
CN116382703B (zh) * 2023-06-07 2023-08-22 建信金融科技有限责任公司 软件包生成方法、代码开发方法及装置、电子设备和介质
CN116382703A (zh) * 2023-06-07 2023-07-04 建信金融科技有限责任公司 软件包生成方法、代码开发方法及装置、电子设备和介质
CN116974581B (zh) * 2023-09-25 2024-01-23 中化现代农业有限公司 代码生成方法、装置、电子设备和存储介质
CN116974581A (zh) * 2023-09-25 2023-10-31 中化现代农业有限公司 代码生成方法、装置、电子设备和存储介质
CN117034900B (zh) * 2023-09-27 2023-12-26 厦门星纵数字科技有限公司 一种api代码文件自动生成方法、终端设备及存储介质
CN117034900A (zh) * 2023-09-27 2023-11-10 厦门星纵数字科技有限公司 一种api代码文件自动生成方法、终端设备及存储介质
CN117435177A (zh) * 2023-12-20 2024-01-23 浙江寰福科技有限公司 应用程序接口构建方法、系统、设备及存储介质
CN117435177B (zh) * 2023-12-20 2024-03-26 浙江寰福科技有限公司 应用程序接口构建方法、系统、设备及存储介质
CN117472336A (zh) * 2023-12-28 2024-01-30 芯瞳半导体技术(山东)有限公司 基于程序api的代码生成装置及其方法、设备及介质
CN117472336B (zh) * 2023-12-28 2024-04-12 芯瞳半导体技术(山东)有限公司 基于程序api的代码生成装置及其方法、设备及介质

Also Published As

Publication number Publication date
CN109976761A (zh) 2019-07-05
CN109976761B (zh) 2022-06-07

Similar Documents

Publication Publication Date Title
WO2020173128A1 (zh) 软件开发工具包的生成方法、装置及终端设备
CN110162296B (zh) 应用程序编程接口文档的生成方法、装置及终端设备
JP5090169B2 (ja) プラットホーム独立の動的リンキング
US8607208B1 (en) System and methods for object code hot updates
CN109614165B (zh) 一种com组件的多版本并行运行方法和装置
CN107924326B (zh) 对经更新的类型的迁移方法进行覆盖
US9471282B2 (en) System and method for using annotations to automatically generate a framework for a custom javaserver faces (JSF) component
US10048960B2 (en) Identifying source code used to build executable files
US20060031820A1 (en) Method for program transformation and apparatus for COBOL to Java program transformation
US10417024B2 (en) Generating verification metadata and verifying a runtime type based on verification metadata
WO2019090994A1 (zh) 测试脚本自动化执行方法、装置、设备以及存储介质
WO2024045382A1 (zh) 区块链中实现反射机制
US9378013B2 (en) Incremental source code analysis
US10545743B2 (en) Enhanced programming language source code conversion with implicit temporary object emulation
CN111179086A (zh) 一种基于WebAssembly的智能合约虚拟机
CN111880801A (zh) 应用程序动态化方法、装置、电子设备
WO2022141703A1 (zh) 基于区块链平台的智能合约部署和调用方法及相关设备
CN112328241B (zh) 一种应用程序开发中创建Android库模块依赖关系的方法及装置
US9672020B2 (en) Selectively loading precompiled header(s) and/or portion(s) thereof
WO2022194173A1 (zh) 补丁方法及相关设备
WO2022099913A1 (zh) 界面配置方法、装置、设备及介质
WO2021174756A1 (zh) 应用系统部署方法、装置、计算机设备及存储介质
CN109960522B (zh) 一种软件升级方法及装置
CN114579141A (zh) require框架转化为VUE框架的方法及装置
CN112925523A (zh) 对象比较方法、装置、设备及计算机可读介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19916839

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 20.10.2021)

122 Ep: pct application non-entry in european phase

Ref document number: 19916839

Country of ref document: EP

Kind code of ref document: A1