Software development kit publishing method, device and electronic device
By marking and modifying the original code of the software development toolkit, the compatibility problem between the application and the SDK during SDK update is solved, and the compatibility guarantee of the SDK is achieved every time the SDK is updated.
Patent Information
- Application Number
- CN202210264675.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-17
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2042-03-17
AI Technical Summary
Existing software development toolkits are prone to introduce compatibility issues when upgrading iteratively, resulting in incompatibility between the application and the SDK.
By marking the original code of the software development toolkit, it is determined whether the code part of the application programming interface meets the compatibility standards, and modify the code that does not meet the compatibility standards into code that meets the compatibility standards, and finally compile and publish the binary file.
Ensure that the SDK meets compatibility standards during each update iteration and avoid incompatibility between the application and the SDK.
Smart Images

Figure CN114860275B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method for publishing a software development toolkit, and also to a publishing device, electronic device and computer storage medium of the software development toolkit. Background Art
[0002] To facilitate the development of applications, the Software Development Kit (SDK) can be called during the development of applications, that is, the SDK is connected to the application through the application programming interface so that the application can directly use some functions in the SDK. In this way, the code development process of code developers can be facilitated during the development of applications, that is, some existing functions in the SDK can be used during the development process, reducing the code development work corresponding to these functions.
[0003] However, since SDK needs to be constantly updated, that is, after its initial version is released, there will be a continuous need for version iterations due to fixes, function iterations, or product optimization. For SDKs developed using the C++ language, some of the language features of C++ make it easier for SDK products developed based on it to introduce potential compatibility issues during iterative upgrades, resulting in incompatibility between the two when the application calls the SDK. Therefore, how to develop a software development kit that meets compatibility standards has become a technical problem that needs to be solved urgently. Summary of the invention
[0004] The present application provides a method for publishing a software development kit to solve the technical problem that the existing software development kit does not meet the compatibility standard. At the same time, the present application also provides a software development kit publishing device, electronic equipment and computer storage medium.
[0005] The present application provides a method for publishing a software development kit, comprising:
[0006] Obtaining marked original code for implementing the functions of the software development kit; the marked original code is original code in which the code portion related to the corresponding application programming interface has been marked, and the application programming interface is an interface between the application and the software development kit that needs to be published externally;
[0007] Based on the marking identifier in the marked original code, determining whether the code portion corresponding to the application programming interface meets the compatibility standard;
[0008] If the code portion of the corresponding application programming interface does not meet the compatibility standard, modifying the code portion of the corresponding application programming interface to a code that meets the compatibility standard, and obtaining the modified code;
[0009] After the code portion corresponding to the application programming interface in the marked original code is processed by the above method, the modified code is compiled and the compiled binary file is released.
[0010] Optionally, before executing the step of determining whether the code portion corresponding to the application programming interface meets the compatibility standard, the following step is executed: marking the code portion in the original code involving the corresponding application programming interface.
[0011] Optionally, the marking of the code portion of the original code related to the corresponding application programming interface includes:
[0012] Determine the attribution result information of the application programming interface corresponding to the code portion of the corresponding application programming interface, that is, determine whether the application programming interface belongs to the following forms: an application programming interface provided by a software development kit to an application, or an application programming interface provided by an application to a software development kit;
[0013] Based on the attribution result information, the code portion in the original code involving the corresponding application programming interface is marked accordingly; if the application programming interface is an application programming interface provided by the software development kit to the application, a first mark is added to the application programming interface; if the application programming interface is an application programming interface provided by the application to the software development kit, a second mark is added to the application programming interface.
[0014] Optionally, based on the attribution result information, correspondingly marking the code portion in the original code involving the corresponding application programming interface includes:
[0015] If the application programming interface is an application programming interface provided by a software development kit to an application program, the following mark is further provided for the application programming interface:
[0016] Adding a third tag to the creation interface instance of the application programming interface;
[0017] A fourth tag is added to the destruction interface instance of the application programming interface.
[0018] Optionally, judging whether the code portion of the corresponding application programming interface meets the compatibility standard based on the marking identifier in the marked original code includes:
[0019] Obtaining the header file in the marked original code;
[0020] Based on the header file in the marked original code, determining an application programming interface included in the program segment including the header file;
[0021] According to the application programming interface provided in the header file, searching for the code of the application programming interface;
[0022] According to the code of the application programming interface, it is determined whether it meets the compatibility standard.
[0023] Optionally, determining whether the code portion of the corresponding application programming interface meets the compatibility standard includes: determining whether the code portion of the definition file of the application programming interface contains a virtual function keyword.
[0024] Optionally, modifying the code portion of the corresponding application programming interface to a code that meets the compatibility standard includes:
[0025] If the application programming interface is an application programming interface provided to an application by a software development kit, a class of non-virtual functions is created corresponding to the class involving virtual functions in the application programming interface; wherein the class of non-virtual functions is a class published to the outside;
[0026] Encapsulating the class of the non-virtual function and the class of the virtual function accordingly to obtain the encapsulated class;
[0027] Execute code generation of the encapsulated class to obtain the code of the encapsulated class;
[0028] The code of the encapsulated class is used to replace the code involving virtual functions in the code portion of the corresponding application programming interface.
[0029] Optionally, modifying the code portion of the corresponding application programming interface to a code that meets the compatibility standard includes:
[0030] If the application programming interface is an application programming interface provided by an application to a software development kit, creating a function pointer for a class involving a virtual function in the application programming interface;
[0031] Providing the function pointer to the application program, and obtaining a calling address for calling the virtual function filled in the function pointer by the application program;
[0032] Execute code generation of the function pointer including the calling address to obtain code of the function pointer including the calling address;
[0033] The code containing the function pointer of the calling address is used to replace the code involving the virtual function in the code part of the corresponding application programming interface.
[0034] Optionally, before publishing the compiled binary, also include:
[0035] Obtaining the header file that needs to be published in the modified code;
[0036] Packaging the header files that need to be published in the modified code with the compiled binary files;
[0037] The publishing of the compiled binary file includes: publishing the packaged file after the packaging process.
[0038] The present application provides a publishing device for a software development kit, comprising:
[0039] a marked code acquisition unit, used to acquire marked original code for realizing the functions of the software development kit; the marked original code is original code in which the code part related to the corresponding application programming interface has been marked, and the application programming interface is an interface between the application and the software development kit that needs to be published externally;
[0040] A judging unit, configured to judge whether the code portion of the corresponding application programming interface meets the compatibility standard based on the marking identifier in the marked original code;
[0041] a modification unit, configured to modify the code portion of the corresponding application programming interface to a code that satisfies the compatibility standard if the code portion of the corresponding application programming interface does not satisfy the compatibility standard, and obtain the modified code;
[0042] The publishing unit is used to compile the modified code after the code part corresponding to the application programming interface in the marked original code is processed by the above method, and publish the compiled binary file.
[0043] The present application provides an electronic device, including:
[0044] processor;
[0045] The memory is used to store a computer program, and the computer program is run by the processor to execute the release method of the software development kit.
[0046] The present application provides a computer storage medium, wherein the computer storage medium stores a computer program, and the computer program is run by a processor to execute the release method of the software development kit.
[0047] Compared with the prior art, the embodiments of the present application have the following advantages:
[0048] The present application provides a method for publishing a software development kit, comprising: obtaining marked original code for implementing the functions of the software development kit; the marked original code is original code on which a code portion involving a corresponding application programming interface in the original code has been marked, and the application programming interface is an interface between an application and a software development kit that needs to be announced to the outside; based on a marking identifier in the marked original code, determining whether the code portion corresponding to the application programming interface meets a compatibility standard; if the code portion corresponding to the application programming interface does not meet the compatibility standard, modifying the code portion corresponding to the application programming interface to a code that meets the compatibility standard, and obtaining the modified code; after the code portion corresponding to the application programming interface in the marked original code is processed by the above method, compiling the modified code and publishing the compiled binary file. Since in this application, the code parts involving the corresponding application programming interface in the original code used to implement the software development kit function are marked, it is convenient to judge whether the application programming interface that needs to be announced to the outside meets the compatibility standards based on the marking identifiers in the marked original code, and modify the code parts that do not meet the compatibility standards, so that the binary files compiled and released based on this as the benchmark meet the compatibility standards, and thus the software development kit can meet the compatibility standards in each subsequent update iteration process. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0050] Figure 1 A first schematic diagram of a scenario of a method for publishing a software development kit provided in the present application;
[0051] Figure 2 A second schematic diagram of a scenario of a method for publishing a software development kit provided by the present application;
[0052] Figure 3 A third schematic diagram of a scenario of a method for publishing a software development kit provided in the present application;
[0053] Figure 4A flowchart of a method for publishing a software development kit provided in the first embodiment of the present application;
[0054] Figure 5 A schematic diagram of a publishing device for a software development kit provided in a second embodiment of the present application;
[0055] Figure 6 A schematic diagram of an electronic device provided in the third embodiment of the present application. DETAILED DESCRIPTION
[0056] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application. Therefore, the present application is not limited to the specific implementation disclosed below.
[0057] The present application provides a method, device, electronic device and computer storage medium for publishing a software development kit. The following describes the method, device, electronic device and computer storage medium for publishing a software development kit through specific embodiments.
[0058] The software development kit publishing method of the present application is mainly used when developing an application program, so that the application program can directly call the software development kit (Software Development Kit, SDK) published using the software development kit publishing method of the present application.
[0059] Specifically, when an application calls an SDK, it is implemented based on an API (Application Programming Interface). When an application calls an SDK, the application and the SDK are connected through the API. In fact, the API can be provided by the application to the SDK, or by the SDK to the application.
[0060] However, no matter which of the above situations is true, that is, whether the API is provided by the application to the SDK or by the SDK to the application, the SDK must meet compatibility (that is, the SDK and the application are compatible) so that the application can successfully call the SDK.
[0061] Taking the SDK developed in C++ as an example, the application mainly calls the SDK based on the virtual function list. The virtual function list mainly stores the address table of the virtual functions of a class. The virtual function list solves the inheritance and coverage problems of the class and ensures that it truly reflects the actual function.
[0062] The above inheritance mainly refers to: the mechanism that subclasses automatically share the parent class data structure and methods, which is a relationship between classes. When defining and implementing a class, you can do it based on an existing class, taking the content defined by the existing class as your own content, and adding some new content. For example, in the class inheritance process, you may add some new functions as new content.
[0063] Specifically, see Figure 1 , which is the first schematic diagram of the scenario of the method for publishing the software development kit provided by this application, and the diagram actually reflects the specific situation of the class in the SDK. Specifically, by Figure 1 It can be seen that the original class contains three virtual functions, namely: Function1, Function2 and Function3. The corresponding addresses of these three virtual functions are Oxc001, Oxc002 and Oxc003 respectively. The application can call the virtual function Funtion2 through the address Oxc002.
[0064] If the SDK needs to be updated, for example Figure 1 As shown, it is necessary to add a new virtual function Function4 to the original class. If the virtual function is added directly to the original class, the virtual function Function4 in the new class of the updated SDK occupies the address of the original virtual function Function2, that is, the address of the virtual function Function4 in the new class is Oxc002, the address of the virtual function Function2 becomes Oxc003, and the address of the virtual function Function3 is Oxc003. Since the application previously used the calling address Oxc002 when calling the virtual function Function2, if the application did not recompile the client code before calling the virtual function, but directly replaced the updated binary library according to the updated SDK, the application will still call the virtual function Funtion2 through the original virtual function list in the subsequent process, that is, it will still call through the address Oxc002. This is mainly because in the calling process, the SDK and the application call the virtual function based on the virtual function list. During the SDK update process, the application did not recompile the client code, so naturally the list of virtual functions it learned was not updated, which would cause errors in subsequent calls.
[0065] But in fact, the virtual function called by address Oxc002 is not virtual function Function2, but virtual function Function4, which will appear Figure 1 This situation indicates that the application is actually incompatible with the updated SDK.
[0066] The software development kit publishing method of the present application solves the above-mentioned situation that the application and the updated SDK are incompatible during the SDK update and iteration process. Specifically, during the release process of the software development kit (ie: SDK), the original code used to implement the software development kit function is marked.
[0067] The original code used to implement the software development kit function is marked, which specifically refers to: marking the code portion of the original code that involves the corresponding application programming interface. The application programming interface (i.e., API) is an interface between the application and the software development kit that needs to be published to the outside world.
[0068] More specifically, the above-mentioned marking process for the code portion in the original code involving the corresponding application programming interface can be carried out in the following manner: first, determine the attribution result information of the application programming interface corresponding to the code portion corresponding to the application programming interface, that is, determine which of the following forms the application programming interface belongs to: an application programming interface provided by a software development kit to an application, or an application programming interface provided by an application to a software development kit; then, based on the attribution result information, perform corresponding marking process on the code portion in the original code involving the corresponding application programming interface; specifically, it can mean: if the application programming interface is an application programming interface provided by a software development kit to an application, then add a first tag to the application programming interface; if the application programming interface is an application programming interface provided by an application to a software development kit, then add a second tag to the application programming interface.
[0069] In addition, if the application programming interface is an application programming interface provided to the application by a software development kit, a third tag can be added to the creation interface instance of the application programming interface, that is, through which interface the interface instance is created; and a fourth tag can be added to the destruction interface instance of the application programming interface, that is, through which interface the interface instance is destroyed.
[0070] The following is an example of adding the first, third, and fourth tags:
[0071]
[0072]
[0073] The above-mentioned situation corresponding to adding the first mark actually means that the API interface is implemented by the SDK, and the application only uses the capabilities corresponding to the API interface.
[0074] An example of adding a second tag is as follows:
[0075]
[0076]
[0077] The above-mentioned situation corresponding to adding the second mark actually means that the API interface is implemented by the application, and the SDK uses the capabilities provided by the application through the API interface, which usually corresponds to the application providing a callback to the SDK.
[0078] After marking the code portion of the original code that is related to the corresponding application programming interface, it can be determined whether the code portion of the corresponding application programming interface meets the compatibility standard based on the marking identifier in the marked original code. In this application, as long as the code portion of the corresponding application programming interface meets the compatibility standard, the application can be compatible with the updated SDK, and then the application and the SDK can call each other's functions normally.
[0079] When judging whether the code portion of the corresponding application programming interface meets the compatibility standard, it is specifically implemented based on the header file in the marked original code. Specifically, judging whether the code portion of the corresponding application programming interface meets the compatibility standard can be implemented based on the following process: first, obtain the header file in the marked original code; then, based on the header file in the marked original code, determine the application programming interface included in the program segment containing the header file; then, according to the application programming interface provided in the header file, find the code of the application programming interface; finally, according to the code of the application programming interface, judge whether it meets the compatibility standard.
[0080] Of course, when specifically judging whether the code portion of the corresponding application programming interface meets the compatibility standard, it can refer to: judging whether the code portion of the definition file of the application programming interface contains virtual function keywords. If the code portion of the definition file of the application programming interface contains virtual function keywords, it can be judged that the code portion of the corresponding application programming interface does not meet the compatibility standard.
[0081] After determining that the code portion of the corresponding application programming interface does not meet the compatibility standard, it is necessary to modify the code portion of the corresponding application programming interface to a code that meets the compatibility standard, and obtain the modified code.
[0082] When modifying the code portion of the corresponding application programming interface to the code that meets the compatibility standard, it is necessary to modify the code portion of the corresponding application programming interface to the code that meets the compatibility standard based on the attribution result information of the application programming interface corresponding to the code portion of the corresponding application programming interface.
[0083] Specifically, if the application programming interface is an application programming interface provided to an application by a software development kit, the code portion corresponding to the application programming interface is modified to a code that meets the compatibility standard, including the following process: first, a class of non-virtual functions is created corresponding to the class involving virtual functions in the application programming interface; wherein the class of non-virtual functions is a class published to the outside; then, the class of non-virtual functions is encapsulated with the class of virtual functions to obtain the encapsulated class; then, code generation for the encapsulated class is performed to obtain the code for the encapsulated class; finally, the code for the encapsulated class is used to replace the code involving virtual functions in the code portion of the corresponding application programming interface.
[0084] To help you understand how to modify the code of the corresponding application programming interface to meet the compatibility standard when the application programming interface is provided by the software development kit to the application program, see Figure 2 , which is the second schematic diagram of the scenario of the software development kit publishing method provided by the present application, and the figure reflects that by encapsulating the classes involving virtual functions in the application programming interface, the purpose of making the SDK and the application compatible before and after the SDK is updated is achieved.
[0085] Before modifying the code portion of the corresponding application programming interface, the classes involving virtual functions in the application programming interface, such as Figure 2 The left side shows the diagram (only the original class corresponds to: before modifying the code part of the corresponding application programming interface, the class involving virtual functions in the application programming interface); after modifying the code part of the corresponding application programming interface, the encapsulated class is as follows Figure 2 The diagram on the right shows that (the class with both non-virtual functions and the original class corresponds to the encapsulated class), that is, the class of virtual functions corresponds to the class of non-virtual functions, and each virtual function in the class of non-virtual functions corresponds to the virtual function in the class of virtual functions. For example, Non-Virtual Function1 corresponds to Virtual Function1.
[0086] After modifying the code part of the corresponding application programming interface, since the class of non-virtual function is a published class, when the application calls the SDK through the API, it only calls the non-virtual function in the class of non-virtual function; only within the SDK, the virtual function is called through the virtual function list through the correspondence between the class of non-virtual function and the class of virtual function, and the virtual function is no longer called through the virtual function list between the SDK and the application, thereby solving the incompatibility problem between the SDK and the application during the SDK update process.
[0087] The above method is actually to shield the application program from the original API (the original API refers to the interface called by the virtual function list) by automatically generating the encapsulation class, so as to achieve the purpose of compatibility in the encapsulated interface.
[0088] Specifically, if the application programming interface is an application programming interface provided by an application to a software development kit, the code portion corresponding to the application programming interface is modified to code that meets the compatibility standard, including the following process: first, a function pointer is created for the class involving virtual functions in the application programming interface; then, the function pointer is provided to the application, and a calling address for calling the virtual function filled in by the application in the function pointer is obtained; then, code generation for the function pointer containing the calling address is performed to obtain the code for the function pointer containing the calling address; finally, the code involving the virtual function in the code portion of the corresponding application programming interface is replaced with the code for the function pointer containing the calling address.
[0089] To help you understand how to modify the code of the corresponding application programming interface to meet the compatibility standard when the application programming interface is provided by the application to the software development kit, see Figure 3 , which is the third schematic diagram of the scenario of the software development kit publishing method provided by this application, and the figure reflects the way of creating function pointers for classes involving virtual functions in the application programming interface to achieve the purpose of making the SDK and the application compatible before and after the SDK is updated.
[0090] Specifically, a function pointer is created for a class involving a virtual function in an application programming interface; thereafter, the function pointer is provided to an application, and a calling address filled in by the application in the function pointer for calling the virtual function is obtained; see Figure 3, the calling address filled in by the application for the virtual function Virtual Function1 for calling Virtual Function1 is function pointer / std::function func1; the calling address filled in by the application for calling Virtual Function2 is function pointer / std::function func2; the calling address filled in by the application for calling Virtual Function3 is function pointer / std::functionfunc3; after the application fills in the calling address, the function pointer containing the calling address is provided to the SDK, and the SDK can execute the code generation of the function pointer containing the calling address to obtain the code of the function pointer containing the calling address; finally, the code involving the virtual function in the code part of the corresponding application programming interface is replaced with the code of the function pointer containing the calling address.
[0091] Before modifying the code portion of the corresponding application programming interface, the classes involving virtual functions in the application programming interface, such as Figure 3 The left side shows the original class (before modifying the code part of the corresponding application programming interface, the class involving virtual functions in the application programming interface); after modifying the code part of the corresponding application programming interface, the pointer structure of the function pointer containing the call address is as follows Figure 3 The right side shows that: the class of the virtual function is converted into a function pointer containing the call address, and each virtual function containing the function pointer of the call address corresponds to the virtual function in the class of the virtual function. For example, the function pointer / std::function func1 corresponds to Virtual Function1.
[0092] After modifying the code part of the corresponding application programming interface, when the SDK calls the function of the application through the API, it only calls back through the calling address in the function pointer; the virtual function is no longer called through the virtual function list between the SDK and the application, thus solving the incompatibility problem between the SDK and the application during the SDK update process.
[0093] After the code portion corresponding to the application programming interface in the marked original code is processed by the above method, the modified code is compiled and the compiled binary file is released. After the compilation and before the release, the header file that needs to be released in the modified code is obtained; the header file that needs to be released in the modified code is packaged with the compiled binary file; finally, the packaged file is released.
[0094] The above-mentioned Figures 1 to 3 That is, it is a diagram of an application scenario of the release method of the software development kit of the present application. The application scenario of the release method of the software development kit is not specifically limited in the embodiments of the present application. The application scenario of the release method of the software development kit is only an embodiment of the application scenario of the release method of the software development kit provided by the present application. The purpose of providing the application scenario embodiment is to facilitate the understanding of the release method of the software development kit provided by the present application, and is not used to limit the release method of the software development kit provided by the present application. Other application scenarios of the release method of the software development kit in the embodiments of the present application are not described one by one.
[0095] First embodiment
[0096] The first embodiment of the present application provides a method for publishing a software development kit, which is as follows: Figure 4 It should be noted that the above scenario embodiments are further examples and detailed descriptions of this embodiment. For some detailed descriptions of this embodiment, please refer to the above scenario embodiments.
[0097] Please refer to Figure 4 , which is a flowchart of the method for publishing a software development kit provided in the first embodiment of the present application.
[0098] The method for publishing a software development kit in an embodiment of the present application comprises the following steps:
[0099] Step S401: Obtain the marked original code for implementing the software development kit function.
[0100] The marked codes for realizing the functions of the software development kit are actually obtained by marking the original codes for realizing the functions of the software development kit.
[0101] Since the SDK may become incompatible with the application during the SDK update and iteration process, the present application can modify the code corresponding to the application programming interface connecting the two, that is, modify the code of the application programming interface to code that meets the compatibility standard, thereby making the SDK and the application compatible during the SDK update and iteration process.
[0102] In this embodiment, the marked original code is the original code that has been marked with the code part involving the corresponding application programming interface. The application programming interface is an interface between the application and the software development kit that needs to be published to the outside world.
[0103] The reason why the marked original code is needed is that the code part involving the corresponding application programming interface is marked in the original code, so that in the subsequent SDK update and iteration process, it is helpful to make the SDK and the application compatible by modifying the code. The code part that needs to be modified is the marked code part. Therefore, it is necessary to mark the code part involving the corresponding application programming interface in the original code.
[0104] As an implementation method of marking the code portion in the original code involving the corresponding application programming interface, it can mean: first, determining the attribution result information of the application programming interface corresponding to the code portion corresponding to the application programming interface, that is, determining which of the following forms the application programming interface belongs to: an application programming interface provided by a software development kit to an application, or an application programming interface provided by an application to a software development kit; then, based on the attribution result information, performing corresponding marking processing on the code portion in the original code involving the corresponding application programming interface; if the application programming interface is an application programming interface provided by the software development kit to the application, adding a first tag to the application programming interface, and if the application programming interface is an application programming interface provided by the application to the software development kit, adding a second tag to the application programming interface.
[0105] Furthermore, based on the attribution result information, the code portion in the original code involving the corresponding application programming interface is marked accordingly, which may also mean: if the application programming interface is an application programming interface provided to the application by a software development kit, the following markings are further provided for the application programming interface: a third marking is added to the creation interface instance of the application programming interface; a fourth marking is added to the destruction interface instance of the application programming interface.
[0106] For a detailed example of how to mark the code portion corresponding to the application programming interface, please refer to the scenario embodiment of the first embodiment, which will not be repeated here.
[0107] Step S402: Based on the marking identifier in the marked original code, determine whether the code portion corresponding to the application programming interface meets the compatibility standard.
[0108] As an implementation method of determining whether the code portion of the corresponding application programming interface meets the compatibility standard based on the marking identifier in the marked original code, it can refer to: first, obtaining the header file in the marked original code; then, based on the header file in the marked original code, determining the application programming interface included in the program segment including the header file; then, according to the application programming interface provided in the header file, searching for the code of the application programming interface; finally, according to the code of the application programming interface, determining whether it meets the compatibility standard.
[0109] Specifically, in order to quickly obtain the header files in the marked original code, a temporary directory for storing the marked original code can be pre-established, and the marked original code can be stored in the temporary directory; the header files can be traversed and retrieved one by one in the temporary directory. In this embodiment, the header files to be traversed and retrieved are header files that need to be published externally, and the application programming interface that needs to be published externally can be found based on the header files that need to be published externally.
[0110] The above-mentioned judgment on whether the code portion corresponding to the application programming interface meets the compatibility standard is actually to judge whether the code portion corresponding to the application programming interface meets the compatibility standard by searching for the application programming interface included in the program segment in the header file. This method helps to find the code portion corresponding to the application programming interface more conveniently.
[0111] As a specific implementation method of determining whether the code portion of the corresponding application programming interface meets the compatibility standard, it may refer to: determining whether the code portion of the definition file of the application programming interface contains a virtual function keyword.
[0112] In this embodiment, as long as there is a virtual function in the definition file of the application programming interface, it may cause the SDK and the application to be incompatible during the SDK update process. Therefore, when judging whether the code part of the corresponding application programming interface meets the compatibility standard, it is only necessary to judge whether the code part of the definition file of the application programming interface contains the virtual function keyword.
[0113] Specifically, when judging whether the code portion corresponding to the application programming interface meets the compatibility standard, the code portion of the corresponding application programming interface definition file and the code portion of the corresponding application programming interface usage method in the marked original code can be determined based on the marking identifier in the marked original code; then, the code portion of the corresponding application programming interface definition file and the code portion of the corresponding application programming interface usage method are judged separately whether they meet the compatibility standard.
[0114] Specifically, since when judging whether the code portion of the corresponding application programming interface definition file meets the compatibility standard, it can refer to judging whether the code portion of the application programming interface definition file contains virtual function keywords; then, judging whether the code portion of the corresponding application programming interface usage method meets the compatibility standard can also refer to judging whether the code portion of the application programming interface usage method contains virtual function keywords.
[0115] For example, if the code in the example of adding the second tag contains: "vritual", it can be determined that the code contains the virtual function keyword.
[0116] Step S403: If the code portion corresponding to the application programming interface does not meet the compatibility standard, the code portion corresponding to the application programming interface is modified to a code that meets the compatibility standard, and the modified code is obtained.
[0117] In step S402, as long as the code portion of the corresponding application programming interface contains virtual function keywords, the code portion of the corresponding application programming interface does not meet the compatibility standard. In order to ensure compatibility between the SDK and the application during the SDK update process, the code portion of the corresponding application programming interface needs to be modified to code that meets the compatibility standard.
[0118] When modifying the code portion of the corresponding application programming interface to the code that meets the compatibility standard, the code portion of the corresponding application programming interface can be modified to the code that meets the compatibility standard according to the attribution result information of the application programming interface corresponding to the code portion of the corresponding application programming interface.
[0119] The first method is to modify the code portion corresponding to the application programming interface to meet the compatibility standard:
[0120] If the application programming interface is an application programming interface provided to the application by a software development kit, firstly, a class of non-virtual functions is created corresponding to the class involving virtual functions in the application programming interface; wherein the class of non-virtual functions is a class published to the outside.
[0121] Afterwards, the class of the non-virtual function and the class of the virtual function are encapsulated correspondingly to obtain the encapsulated class.
[0122] After that, code generation of the encapsulated class is performed to obtain the code of the encapsulated class.
[0123] Finally, the code of the encapsulated class is used to replace the code involving virtual functions in the code portion of the corresponding application programming interface.
[0124] The second method is to modify the code portion corresponding to the application programming interface to meet the compatibility standard:
[0125] If the application programming interface is an application programming interface provided by the application to the software development kit, first, a function pointer is created for the class involving the virtual function in the application programming interface.
[0126] Afterwards, the function pointer is provided to the application, and the calling address for calling the virtual function filled in by the application in the function pointer is obtained.
[0127] Afterwards, code generation of the function pointer including the calling address is performed to obtain the code of the function pointer including the calling address.
[0128] Finally, the code involving the virtual function in the code portion of the corresponding application programming interface is replaced with the code containing the function pointer of the calling address.
[0129] The examples corresponding to the above two methods of modifying the code portion of the corresponding application programming interface to a code that meets the compatibility standard have been introduced in detail in the above scenario embodiments. Please refer to the above scenario embodiments for details and will not be repeated here.
[0130] In fact, the above-mentioned process of modifying the code part corresponding to the application programming interface into the code that meets the compatibility standard and obtaining the modified code can actually be understood as: first, modifying the code part of the corresponding application programming interface definition file into the code of the definition file that meets the compatibility standard; then, based on the code of the definition file that meets the compatibility standard, modifying the code part of the corresponding application programming interface usage method into the code of the usage method that meets the compatibility standard; finally, the code of the definition file that meets the compatibility standard and the code of the usage method that meets the compatibility standard are used together as the code that meets the compatibility standard.
[0131] Step S404: After the code portion corresponding to the application programming interface in the marked original code is processed by the above method, the modified code is compiled and the compiled binary file is released.
[0132] It should be noted that before the compiled binary file is released, it also includes: obtaining the header file that needs to be released to the outside in the modified code, and packaging the header file that needs to be released to the outside in the modified code and the compiled binary file; finally, publishing the packaged file after packaging.
[0133] In this embodiment, a GCC / G++ compiler may be used for compiling.
[0134] Since the above packaged files are composed of the compiled binary library and the header files that need to be published in the modified code, the header files that need to be published can fully meet the compatibility requirements.
[0135] The present application provides a method for publishing a software development kit, comprising: obtaining marked original code for implementing the functions of the software development kit; the marked original code is the original code on which the code portion involving the corresponding application programming interface in the original code has been marked, and the application programming interface is an interface between the application and the software development kit that needs to be announced to the outside; based on the marking identifier in the marked original code, judging whether the code portion corresponding to the application programming interface meets the compatibility standard; if the code portion corresponding to the application programming interface does not meet the compatibility standard, modifying the code portion corresponding to the application programming interface to a code that meets the compatibility standard, and obtaining the modified code; after the code portion corresponding to the application programming interface in the marked original code is processed by the above method, compiling the modified code, and publishing the compiled binary file. Since in this application, the code parts involving the corresponding application programming interface in the original code used to implement the software development kit function are marked, it is convenient to judge whether the application programming interface that needs to be announced to the outside meets the compatibility standards based on the marking identifiers in the marked original code, and modify the code parts that do not meet the compatibility standards, so that the binary files compiled and released based on this as the benchmark meet the compatibility standards, and thus the software development kit can meet the compatibility standards in each subsequent update iteration process.
[0136] Second embodiment
[0137] Corresponding to the method for publishing a software development kit provided in the first embodiment of the present application, the second embodiment of the present application also provides a device for publishing a software development kit. Since the device embodiment is basically similar to the first embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the first embodiment. The device embodiment described below is only illustrative.
[0138] Please refer to Figure 5 , which is a schematic diagram of a publishing device for a software development kit provided in the second embodiment of the present application.
[0139] The release kit of the software development kit includes:
[0140] The marked code acquisition unit 501 is used to acquire the marked original code for realizing the functions of the software development kit; the marked original code is the original code in which the code part related to the corresponding application programming interface has been marked, and the application programming interface is an interface between the application and the software development kit that needs to be published externally;
[0141] A judging unit 502, configured to judge whether the code portion of the corresponding application programming interface meets the compatibility standard based on the marking identifier in the marked original code;
[0142] A modifying unit 503 is used to modify the code portion of the corresponding application programming interface to a code that meets the compatibility standard if the code portion of the corresponding application programming interface does not meet the compatibility standard, and obtain the modified code;
[0143] The publishing unit 504 is used to compile the modified code after the code part corresponding to the application programming interface in the marked original code is processed by the above method, and publish the compiled binary file.
[0144] Optionally, it also includes: a marking processing unit; the marking processing unit is used to perform the following steps before the step of determining whether the code portion of the corresponding application programming interface meets the compatibility standard: marking the code portion in the original code involving the corresponding application programming interface.
[0145] Optionally, the marking processing unit specifically includes:
[0146] Determine the attribution result information of the application programming interface corresponding to the code portion of the corresponding application programming interface, that is, determine whether the application programming interface belongs to the following forms: an application programming interface provided by a software development kit to an application, or an application programming interface provided by an application to a software development kit;
[0147] Based on the attribution result information, the code portion in the original code involving the corresponding application programming interface is marked accordingly; if the application programming interface is an application programming interface provided by the software development kit to the application, a first mark is added to the application programming interface; if the application programming interface is an application programming interface provided by the application to the software development kit, a second mark is added to the application programming interface.
[0148] Optionally, the marking processing unit specifically includes:
[0149] If the application programming interface is an application programming interface provided by a software development kit to an application program, the following mark is further provided for the application programming interface:
[0150] Adding a third tag to the creation interface instance of the application programming interface;
[0151] A fourth tag is added to the destruction interface instance of the application programming interface.
[0152] Optionally, the judging unit is specifically configured to:
[0153] Obtaining the header file in the marked original code;
[0154] Based on the header file in the marked original code, determining an application programming interface included in the program segment including the header file;
[0155] According to the application programming interface provided in the header file, searching for the code of the application programming interface;
[0156] According to the code of the application programming interface, it is determined whether it meets the compatibility standard.
[0157] Optionally, the judging unit is specifically used to judge whether the code portion of the definition file of the application programming interface contains a virtual function keyword.
[0158] Optionally, the modification unit is specifically used to:
[0159] If the application programming interface is an application programming interface provided to an application by a software development kit, a class of non-virtual functions is created corresponding to the class involving virtual functions in the application programming interface; wherein the class of non-virtual functions is a class published to the outside;
[0160] Encapsulating the class of the non-virtual function and the class of the virtual function accordingly to obtain the encapsulated class;
[0161] Execute code generation of the encapsulated class to obtain the code of the encapsulated class;
[0162] The code of the encapsulated class is used to replace the code involving virtual functions in the code portion of the corresponding application programming interface.
[0163] Optionally, the modification unit is specifically used to:
[0164] If the application programming interface is an application programming interface provided by an application to a software development kit, creating a function pointer for a class involving a virtual function in the application programming interface;
[0165] Providing the function pointer to the application program, and obtaining a calling address for calling the virtual function filled in the function pointer by the application program;
[0166] Execute code generation of the function pointer including the calling address to obtain code of the function pointer including the calling address;
[0167] The code containing the function pointer of the calling address is used to replace the code involving the virtual function in the code part of the corresponding application programming interface.
[0168] Optionally, a packaging unit is further included; the packaging unit is specifically used to: before publishing the compiled binary file, obtain the header file that needs to be published in the modified code;
[0169] Packaging the header files that need to be published in the modified code with the compiled binary files;
[0170] The publishing unit is specifically used to publish the packaged file after the packaging process.
[0171] Third embodiment
[0172] Corresponding to the method for publishing a software development kit in the first embodiment of the present application, the third embodiment of the present application further provides an electronic device.
[0173] like Figure 6 As shown, Figure 6 This is a schematic diagram of an electronic device provided in the third embodiment of the present application. The electronic device comprises: a processor 601; a memory 602 for storing a computer program, the computer program is run by the processor to execute the method for publishing the software development kit of the first embodiment.
[0174] Fourth embodiment
[0175] Corresponding to the method for publishing a software development kit in the first embodiment of the present application, the fourth embodiment of the present application further provides a computer storage medium, wherein the computer storage medium stores a computer program, and the computer program is executed by a processor to execute the method for publishing a software development kit in the first embodiment.
[0176] Although the present application is disclosed as above in the form of a preferred embodiment, it is not intended to limit the present application. Any technical personnel in this field may make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.
[0177] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory. The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0178] 1. Computer readable media includes permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined in this article, computer readable media does not include non-transitory computer readable storage media (non-transitorycomputer readable storage media), such as modulated data signals and carrier waves.
[0179] 2. Those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems or computer program products. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
Claims
1. A method for publishing a software development kit, characterized in that: include: Access to the marked-up source code used to implement the SDK functionality; The marked original code is the original code in which the code part related to the corresponding application programming interface has been marked, and the application programming interface is an interface between the application program and the software development kit that needs to be published to the outside world; Based on the marking identifier in the marked original code, determining whether the code portion corresponding to the application programming interface meets the compatibility standard; If the code portion of the corresponding application programming interface does not meet the compatibility standard, modifying the code portion of the corresponding application programming interface to a code that meets the compatibility standard according to a provider of the application programming interface, and obtaining the modified code, the provider including the application or the software development kit; After the code portion corresponding to the application programming interface in the marked original code is processed by the above method, the modified code is compiled and the compiled binary file is released.
2. The method for publishing a software development kit according to claim 1, characterized in that: Before the step of determining whether the code portion corresponding to the application programming interface meets the compatibility standard is performed, the following step is performed: marking the code portion related to the corresponding application programming interface in the original code.
3. The method for publishing a software development kit according to claim 2, characterized in that: The marking process of the code part related to the corresponding application programming interface in the original code includes: Determine the attribution result information of the application programming interface corresponding to the code portion of the corresponding application programming interface, that is, determine whether the application programming interface belongs to the following forms: an application programming interface provided by a software development kit to an application, or an application programming interface provided by an application to a software development kit; Based on the attribution result information, the code portion in the original code involving the corresponding application programming interface is marked accordingly; if the application programming interface is an application programming interface provided by the software development kit to the application, a first mark is added to the application programming interface; if the application programming interface is an application programming interface provided by the application to the software development kit, a second mark is added to the application programming interface.
4. The method for publishing a software development kit according to claim 3, characterized in that: Based on the attribution result information, correspondingly marking the code portion in the original code related to the corresponding application programming interface includes: If the application programming interface is an application programming interface provided by a software development kit to an application program, the following mark is further provided for the application programming interface: Adding a third tag to the creation interface instance of the application programming interface; A fourth tag is added to the destruction interface instance of the application programming interface.
5. The method for publishing a software development kit according to claim 1, characterized in that: The determining, based on the marking identifier in the marked original code, whether the code portion of the corresponding application programming interface meets the compatibility standard includes: Obtaining the header file in the marked original code; Based on the header file in the marked original code, determining an application programming interface included in the program segment including the header file; According to the application programming interface provided in the header file, searching for the code of the application programming interface; According to the code of the application programming interface, it is determined whether it meets the compatibility standard.
6. The method for publishing a software development kit according to claim 1, characterized in that: The determining whether the code portion of the corresponding application programming interface meets the compatibility standard includes: determining whether the code portion of the definition file of the application programming interface contains a virtual function keyword.
7. The method for publishing a software development kit according to claim 3, characterized in that: The step of modifying the code portion of the corresponding application programming interface into a code that meets the compatibility standard includes: If the application programming interface is an application programming interface provided to an application by a software development kit, a class of non-virtual functions is created corresponding to the class involving virtual functions in the application programming interface; wherein the class of non-virtual functions is a class published to the outside; Encapsulating the class of the non-virtual function and the class of the virtual function accordingly to obtain the encapsulated class; Execute code generation of the encapsulated class to obtain the code of the encapsulated class; The code of the encapsulated class is used to replace the code involving virtual functions in the code portion of the corresponding application programming interface.
8. The method for publishing a software development kit according to claim 3, characterized in that: The step of modifying the code portion of the corresponding application programming interface into a code that meets the compatibility standard includes: If the application programming interface is an application programming interface provided by an application to a software development kit, creating a function pointer for a class involving a virtual function in the application programming interface; Providing the function pointer to the application program, and obtaining a calling address for calling the virtual function filled in the function pointer by the application program; Execute code generation of the function pointer including the calling address to obtain code of the function pointer including the calling address; The code containing the function pointer of the calling address is used to replace the code involving the virtual function in the code part of the corresponding application programming interface.
9. The method for publishing a software development kit according to claim 1, characterized in that: Before publishing the compiled binary, also include: Obtaining the header file that needs to be published in the modified code; Packaging the header files that need to be published in the modified code with the compiled binary files; The publishing of the compiled binary file includes: publishing the packaged file after the packaging process.
10. A software development kit publishing device, characterized in that: include: A marked code acquisition unit, used for acquiring marked original codes for implementing functions of the software development kit; The marked original code is the original code in which the code part related to the corresponding application programming interface has been marked, and the application programming interface is an interface between the application program and the software development kit that needs to be published to the outside world; A judging unit, configured to judge whether the code portion of the corresponding application programming interface meets the compatibility standard based on the marking identifier in the marked original code; a modification unit, configured to modify the code portion of the corresponding application programming interface to a code that meets the compatibility standard according to a provider of the application programming interface if the code portion of the corresponding application programming interface does not meet the compatibility standard, and obtain the modified code, the provider including the application or the software development kit; The publishing unit is used to compile the modified code after the code part corresponding to the application programming interface in the marked original code is processed by the above method, and publish the compiled binary file.
11. An electronic device, characterized in that: include: processor; A memory for storing a computer program, wherein the computer program is executed by a processor to perform the method according to any one of claims 1 to 9.
12. A computer storage medium, characterized in that: The computer storage medium stores a computer program, which is executed by a processor to perform the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Detection methods and devices
CN108628728A
Method and equipment for dynamically updating software development kit and storage medium
CN113326078A