SDK adaptation method, device, electronic equipment and storage medium

文档序号:1952087 发布日期:2021-12-10 浏览:18次 中文

阅读说明:本技术 Sdk适配方法、装置、电子设备及存储介质 (SDK adaptation method, device, electronic equipment and storage medium ) 是由 孙哲 林乐洋 于 2021-08-18 设计创作,主要内容包括:本发明提供了一种SDK适配方法、装置、电子设备及存储介质,涉及软件开发技术领域。所述方法包括:获取目标SDK对应的对外公开元素集合;对公开元素集合进行转换,以得到目标SDK对应的目标适配文件。因此,能够解决相关技术中SDK适配文件的编写工作量大,而导致SDK适配文件编写效率低的问题。(The invention provides an SDK adaptation method, an SDK adaptation device, electronic equipment and a storage medium, and relates to the technical field of software development. The method comprises the following steps: acquiring an external public element set corresponding to the target SDK; and converting the public element set to obtain a target adaptation file corresponding to the target SDK. Therefore, the problem that the writing efficiency of the SDK adaptation file is low due to the fact that the writing workload of the SDK adaptation file is large in the related technology can be solved.)

1. A method of SDK adaptation, the method comprising:

acquiring an external public element set corresponding to the target SDK;

and converting the public element set to obtain a target adaptation file corresponding to the target SDK.

2. The method of claim 1, wherein obtaining the set of externally disclosed elements corresponding to the target SDK comprises:

traversing the target SDK;

generating an abstract syntax tree corresponding to the target SDK;

and acquiring the external public element set according to the abstract syntax tree.

3. The method of claim 1, wherein obtaining the set of exposed elements according to the abstract syntax tree comprises:

acquiring a constructor set of the target SDK disclosed to the outside according to the abstract syntax tree; and the number of the first and second groups,

acquiring a static object set externally disclosed by the target SDK according to the abstract syntax tree; and the number of the first and second groups,

and acquiring a method set of the target SDK externally disclosed according to the abstract syntax tree.

4. The method of claim 3, wherein obtaining the constructor set of the target SDK's external disclosure according to the abstract syntax tree comprises:

acquiring a constructor of the target SDK disclosed to the outside according to the node attribute of the node in the abstract syntax tree;

classifying the constructors to obtain the constructor set, wherein the constructor set comprises an unnamed constructor subset, a common constructor subset and a non-abstract constructor subset.

5. The method of claim 4, wherein obtaining the set of methods of the target SDK disclosure from the abstract syntax tree comprises:

acquiring a method for externally disclosing the target SDK according to the node attribute of the node in the abstract syntax tree;

and eliminating methods which do not meet preset conditions to obtain the method set.

6. The method of claim 1, wherein the set of public elements comprises a set of constructors, a set of static objects, and a set of methods, wherein,

converting the public element set to obtain a target adaptation file corresponding to the target SDK, including:

and performing field-specific language DSL conversion on the constructor set, the static object set and the method set to obtain a JSON file corresponding to the target SDK.

7. The method of claim 6, wherein after converting the set of public elements to obtain a target adaptation file corresponding to the target SDK, the method further comprises:

registering the JSON file to obtain a target JSON file corresponding to the target SDK; and the target JSON file is used for calling the target SDK.

8. The method of claim 7, wherein registering the JSON file to obtain a target JSON file corresponding to the target SDK comprises:

acquiring a Key value corresponding to the JSON file;

determining parameters corresponding to the JSON file according to the Key value;

and executing the preset engine according to the parameters to obtain the target JSON file.

9. The method of claim 1, prior to obtaining the set of exposed elements corresponding to the target SDK, further comprising:

and acquiring a preset instruction, wherein the preset instruction is used for indicating to acquire a target adaptation file corresponding to the target SDK, and the preset instruction comprises a file type, a file path and an output path of the target SDK.

10. An SDK adaptation apparatus, characterized in that the apparatus comprises:

the acquisition unit is used for acquiring an external public element set corresponding to the target SDK;

and the processing unit is used for converting the public element set to obtain a target adaptation file corresponding to the target SDK.

11. An electronic device, comprising: memory, processor and computer program stored on the memory and executable on the processor, which computer program, when executed by the processor, carries out the steps of the SDK adaptation method according to any one of claims 1 to 9.

12. A storage medium, characterized in that the storage medium has stored thereon a computer program which, when being executed by a processor, carries out the steps of the SDK adaptation method according to any one of claims 1 to 9.

Technical Field

The invention relates to the technical field of software development, in particular to an SDK adaptation method, an SDK adaptation device, electronic equipment and a storage medium.

Background

In the process of developing a Flutter application program in the prior art, when the Flutter application program needs to call a third-party SDK (Software Development Kit), an adaptation file corresponding to the third-party SDK to be used needs to be manually written, a relevant calling method for the adaptation file is opened externally, and the adaptation file is packaged into a configurable type, so that the function of dynamically using the third-party SDK can be realized.

In the process of implementing the invention, the applicant finds that the following technical problems exist in the prior art:

1. the workload for generating the adaptation file corresponding to the third-party SDK is large;

2. developers manually write the adaptation files corresponding to the third-party SDK, so that omission and errors are easily caused;

3. each third-party SDK upgrade requires the developer to manually rewrite the corresponding adaptation file.

Aiming at the problems existing in the writing of the SDK adaptation file in the related technology, no effective technical means is provided at present.

Disclosure of Invention

The embodiment of the invention provides an adaptation file generation method, an adaptation file generation device, electronic equipment and a storage medium, and aims to solve at least part of problems in writing of an SDK adaptation file in the related art.

In order to solve the technical problem, the invention is realized as follows:

in a first aspect, an embodiment of the present invention provides an SDK adaptation method, where the method includes: acquiring an external public element set corresponding to the target SDK; and converting the public element set to obtain a target adaptation file corresponding to the target SDK.

Further, acquiring an external public element set corresponding to the target SDK includes: traversing the target SDK; generating an abstract syntax tree corresponding to the target SDK; and acquiring the external public element set according to the abstract syntax tree.

Further, obtaining the set of the external public elements according to the abstract syntax tree includes: acquiring a constructor set of the target SDK disclosed to the outside according to the abstract syntax tree; acquiring a static object set externally disclosed by the target SDK according to the abstract syntax tree; and acquiring a method set of the target SDK disclosed to the outside according to the abstract syntax tree.

Further, acquiring a constructor set of the target SDK exposed to the outside according to the abstract syntax tree, including: acquiring a constructor of the target SDK disclosed to the outside according to the node attribute of the node in the abstract syntax tree; classifying the constructors to obtain the constructor set, wherein the constructor set comprises an unnamed constructor subset, a common constructor subset and a non-abstract constructor subset.

Further, acquiring the externally disclosed method set of the target SDK according to the abstract syntax tree, including: acquiring a method for externally disclosing the target SDK according to the node attribute of the node in the abstract syntax tree; and eliminating methods which do not meet preset conditions to obtain the method set.

Further, the public element set includes a constructor set, a static object set, and a method set, where converting the public element set to obtain a target adaptation file corresponding to the target SDK includes: and performing field-specific language DSL conversion on the constructor set, the static object set and the method set to obtain a JSON file corresponding to the target SDK.

Further, after converting the public element set to obtain a target adaptation file corresponding to the target SDK, the method further includes: registering the JSON file to obtain a target JSON file corresponding to the target SDK; and the target JSON file is used for calling the target SDK.

Further, executing the JSON file through a preset engine to obtain the target adaptation file, including: acquiring a Key value corresponding to the JSON file; determining parameters corresponding to the JSON file according to the Key value; and executing the preset engine according to the parameters to obtain the target JSON file.

Further, before obtaining the external public element set corresponding to the target SDK, the method further includes: and acquiring a preset instruction, wherein the preset instruction is used for indicating to acquire a target adaptation file corresponding to the target SDK, and the preset instruction comprises a file type, a file path and an output path of the target SDK.

In a second aspect, an embodiment of the present invention further provides an SDK adaptation apparatus, where the apparatus includes: the acquisition unit is used for acquiring an external public element set corresponding to the target SDK; and the processing unit is used for converting the public element set to obtain a target adaptation file corresponding to the target SDK.

In a third aspect, an embodiment of the present invention additionally provides an electronic device, including: memory, a processor and a computer program stored on the memory and executable on the processor, which computer program, when executed by the processor, carries out the steps of the SDK adaptation method according to the first aspect.

In a fourth aspect, the present invention provides a storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of the SDK adaptation method according to the first aspect.

In the embodiment of the invention, an external public element set corresponding to a target SDK is obtained; and converting the public element set to obtain a target adaptation file corresponding to the target SDK. The externally-disclosed element set which is externally disclosed by the target SDK and is required to be called by the target Flutter application program is obtained, the externally-disclosed element set is converted, the target adaptation file corresponding to the target SDK is automatically obtained, manual writing of the target SDK adaptation file is avoided, the manual workload of developers is reduced, file leaks and errors are reduced, and the purpose of improving the writing efficiency of the target SDK adaptation file is achieved. The problem of low efficiency of writing the SDK adaptation file due to large workload of writing the SDK adaptation file in the related technology is solved.

The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.

Drawings

In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained based on these drawings without inventive labor.

Fig. 1 is a schematic view of an application scenario of an SDK adaptation method in an embodiment of the present invention;

fig. 2 is a flow chart of an SDK adaptation method in an embodiment of the present invention;

fig. 3 is a flow chart illustrating another SDK adaptation method in an embodiment of the invention;

fig. 4 is a schematic diagram of a framework of an SDK adaptation apparatus in an embodiment of the present invention.

Detailed Description

The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

Example one

Before the technical solution of the present invention is introduced, the following terms are explained first:

and (3) SDK: software Development Kit a Software Development Kit is generally a collection of Development tools used by some Software engineers to build application Software for a particular Software, Software framework, hardware platform, operating system, etc. Software development tools include a collection of related documents, paradigms, and tools that broadly refer to assisting in the development of a certain class of software.

And (6) Dart: google developed computer programming language.

JSON: JSON (JavaScript Object Notation) is a lightweight data exchange format.

Before introducing the technical solution of the present invention, an application environment of the following embodiments of the present invention is described first:

the embodiment of the invention provides an SDK adaptation method, which applies an SDK adaptation file processing framework with a scene shown in figure 1, wherein the framework comprises an input module 10, a processing module 20 and a registration module 30.

Specifically, the input module 10 is located at the frontmost end of the whole SDK adaptation file processing system, and is configured to input a target SDK that a target Flutter application (for example, a Flutter application in a development process) needs to call, and the processing module 20 obtains an external public element set that is externally disclosed/exposed by the target SDK, and converts the public element set in the registration module 30 to obtain a target adaptation file corresponding to the target SDK.

According to the embodiment, the externally-disclosed element set which is externally disclosed by the target SDK and is required to be called by the target Flutter application program is obtained, the externally-disclosed element set is converted, the target adaptation file corresponding to the target SDK is obtained, manual writing of the target SDK adaptation file is avoided, the manual workload of developers is reduced, file bugs and errors are reduced, and the purpose of improving the writing efficiency of the target SDK adaptation file is achieved. The problem of low efficiency of writing the SDK adaptation file due to large workload of writing the SDK adaptation file in the related technology is solved.

In an embodiment of the present invention, an SDK adaptation method is provided, as shown in fig. 2, the method may specifically include the following steps:

s202, acquiring an external public element set corresponding to the target SDK;

in a specific application scenario, the target Flutter application needs to call a third-party SDK corresponding to the third-party application, that is, the target SDK. The target SDK may be a third party SDK other than the SDK corresponding to the target Flutter application.

Specifically, not all elements in the target SDK support external calls, the elements that support external calls are open elements exposed to the outside/exposed to the outside, and the elements that do not support external calls are non-open elements. In this embodiment, the adaptation file corresponding to the disclosure element is mainly obtained from the target SDK, and therefore, the disclosure element exposed to the outside/the outside of the target SDK is obtained, where the disclosure element includes, but is not limited to, a method, a constructor, a static object, and the like.

Optionally, in this embodiment, the obtaining of the external public element set corresponding to the target SDK includes: traversing the target SDK; generating an abstract syntax tree corresponding to the target SDK; and acquiring the external public element set according to the abstract syntax tree.

Specifically, a Dart file provided by a target SDK externally is analyzed by obtaining a file path corresponding to the SDK file, a file entry corresponding to the target SDK file is determined according to the Dart file, a plurality of files corresponding to the target SDK are obtained according to the file entry, the plurality of files in the target SDK are traversed, an abstract syntax tree corresponding to the target SDK is generated according to file names, attributes and the like, whether corresponding constructors, static objects and methods can be exposed externally is determined according to attributes of different nodes in the abstract syntax tree, and corresponding externally-exposed constructors, static objects and methods are generated. It should be noted that the attribute of a node in the abstract syntax tree is used to identify whether an element corresponding to the node is abstract or not and whether the node is exposed to the outside.

Further optionally, the set of external disclosure elements is obtained according to an abstract syntax tree, including but not limited to: acquiring a constructor set externally disclosed by the target SDK according to the abstract syntax tree; acquiring a static object set externally disclosed by the target SDK according to the abstract syntax tree; and acquiring a method set of the target SDK disclosed to the outside according to the abstract syntax tree.

In one example, a corresponding abstract syntax tree is generated by traversing the target SDK file, and each node includes a node attribute corresponding to the node according to different nodes in the abstract syntax tree, and is used to identify whether the element is abstract and whether the element of the node is exposed to the outside. In this embodiment, the elements of the nodes in the abstract syntax tree include, but are not limited to, constructors, static correspondences, and methods, and a constructor set, a static object set, and a method set, which are disclosed to the outside by the target SDK, are obtained according to the node attributes.

Optionally, in this embodiment, obtaining the externally disclosed constructor set of the target SDK according to the abstract syntax tree includes: acquiring a constructor of the external disclosure of the target SDK according to the node attribute of the node in the abstract syntax tree; and classifying the constructors to obtain a constructor set, wherein the constructor set comprises an unnamed constructor subset, a common constructor subset and a non-abstract constructor subset.

Specifically, in this embodiment, the constructors of the classes in the target SDK include three classes, which are: unnamed constructors, common constructors, and non-abstract constructors. Through traversal of the target SDK file, the target SDK file comprises a plurality of classes, the externally-disclosed structural functions in each class of the target SDK file are obtained, classification is carried out according to the attributes of the structural functions, three groups of structural function sub-sets obtained by classifying and summarizing the classes in the target SDK file are obtained, namely, the structural function set corresponding to the target SDK comprises three structural function sub-sets which are respectively an unnamed structural function sub-set, a common structural function sub-set and a non-abstract structural function sub-set. The constructors in each subset of constructors all belong to the same type of constructor.

Through the embodiment, the externally-disclosed constructors of the target SDK are classified, so that the difficulty and complexity of converting the constructors are reduced subsequently, and the processing efficiency of the target SDK is improved.

On the other hand, the static object set exposed to the outside of the target SDK is obtained according to the abstract syntax tree, including but not limited to, obtaining the static object set of each of the plurality of classes of the target SDK according to the node attributes of the nodes in the abstract syntax tree, wherein the static object set includes static objects exposed to the outside (exposed to the outside).

Optionally, in this embodiment, the method set for obtaining the external disclosure of the target SDK according to the abstract syntax tree includes, but is not limited to: according to the node attributes of the nodes in the abstract syntax tree and the node attributes of the nodes in the abstract syntax tree, acquiring a method for externally disclosing the target SDK; and eliminating methods which do not meet preset conditions to obtain a method set.

In a specific application scene, a method for externally disclosing (externally exposing) a class in a target SDK is obtained according to node attributes of nodes in an abstract syntax tree, whether the method in the class meets a preset condition or not is judged according to the attributes, field elements and the like of the method in the class, static abstract methods, non-public methods, abandoned methods and methods for introducing tests which do not meet the preset condition are removed, the methods which meet the preset condition are reserved, and an externally disclosed method set in the target SDK is obtained.

Through the embodiment, the three sets of externally disclosed public element sets in the target SDK file are obtained, and classification and collection of the externally disclosed elements in the target SDK are achieved.

And S204, converting the public element set to obtain a target adaptation file corresponding to the target SDK.

Specifically, after classifying and screening the external public elements in the target SDK, three public element sets are obtained. In this embodiment, the open elements in the three sets of open element sets are respectively converted to obtain an SDK adaptation file corresponding to the target SDK, so as to call the target SDK.

Optionally, in this embodiment, the public element set includes a constructor set, a static object set, and a method set, where public elements in the public element set are converted to obtain a target adaptation file corresponding to the target SDK, including but not limited to: performing Domain Specific Language (DSL) (domain Specific language) conversion on the constructor set, the static object set and the method set to obtain a JSON file corresponding to the target SDK;

through the step S202, a public element set corresponding to the target SDK to be written or converted is obtained, and the public element set includes a constructor set, a static object set, and a method set. The public element set in this embodiment is a file of a Dart structure, the Dart file provides an access entry for accessing the public element set, elements exposed to the outside/the outside in the public element set can be read through the Dart file, and the JSON file corresponding to the target SDK is obtained by performing DSL conversion on the public elements in the constructor set, the static object set, and the method set in the file.

In this embodiment, after the target adaptation file JSON file is obtained, the public element is registered in the preset engine to call the third party SDK. The manual writing of the target SDK is avoided, and the dynamic conversion of the adaptive file of the target SDK is realized.

In one example, assume that the target SDK file is "context _ bottom _ bar _ SDK" whose public element set is "fair _ context _ bottom _ bar _ sdk.dart". The JSON file "context _ bottom _ bar _ component" is obtained by performing DSL conversion on the public element set "face _ context _ bottom _ bar _ sdk.dart".

Optionally, in this embodiment, after converting the public element set to obtain a target adaptation file corresponding to the target SDK, the method further includes: and registering the JSON file to obtain a target JSON file corresponding to the target SDK, wherein the target JSON file is used for calling the target SDK.

In a specific application scene, in the application page rendering process of the target Flutter application program, if the application is required to be applied to the service or function corresponding to the third-party application program, acquiring a JSON file corresponding to the target SDK of the third-party application program in a Flutter library, registering the JSON file through a preset engine FariAPP to obtain a target JSON file, and executing the target JSON file to call the target SDK of the third-party application program.

Further optionally, executing the JSON file by using a preset engine to obtain a target adaptation file, including: acquiring a Key value corresponding to the JSON file; determining parameters corresponding to the JSON file according to the Key value; and executing a preset engine according to the parameters to obtain the target JSON file.

In a specific application scenario, a JSON file obtained by converting an external public element set of a target SDK includes multiple public elements, such as a method, a constructor or a static object, each public element corresponds to one Key, each Key has a corresponding Key value, a parameter value corresponding to each Key is obtained, and a preset engine is executed according to multiple parameter value values corresponding to multiple keys, so that the public elements of the target SDK are registered in the preset engine, and a registered target JSON file corresponding to the target SDK is obtained.

In a specific application scenario, a parameter of a method in a public element is a parameter value of a method call function, and a parameter of a constructor in the public element is an available parameter name for identifying the constructor. The parameters of the static object in the public element are the calling mode of the static object.

It should be noted that, in this embodiment, the preset engine is a preset SDK, and is configured to register a public element of the target SDK, so as to enable the target Flutter application to call the target SDK of the third-party application.

For example, DSL conversion is performed on the public element set "fair _ volume _ bottom _ bar _ sdk.dart" to obtain a JSON file "constant _ bottom _ bar _ component", the "constant _ bottom _ bar _ component" is input into a default engine FairAPP engine, a key of the "constant _ bottom _ bar _ component" is obtained, a corresponding parameter value is determined according to the key, and the FairAPP engine is operated according to the parameter value. The registration is completed by adding "context _ bottom _ bar _ component" to the global generamemodule.

And then, determining the version of the target adaptation file by determining the version of the target SDK to be loaded, and realizing the calling of the target SDK after registering in a preset engine. Or directly calling the registered target SDK corresponding to the third-party application in the application page rendering process of the target Flutter application program in a mode of issuing the target JSON file corresponding to the third-party application in the preset server corresponding to the target Flutter application program.

In one example, a third-party JSON file is generated by a preset engine FairAPP, a target SDK is called by the third-party JSON file, contents such as ConverxAppBar and tabletm which need to be used can call the target SDK in an application page of a Flutter application program, and a service function or a service supported by the target SDK is displayed.

Optionally, in this embodiment, before obtaining the external public element set corresponding to the target SDK, the method further includes, but is not limited to: and acquiring a preset instruction, wherein the preset instruction is used for indicating to acquire a target adaptation file corresponding to the target SDK, and the preset instruction comprises a file type, a file path and a target path of the target SDK.

In a specific application scene, a software development system is instructed to automatically acquire a target adaptation file corresponding to a target SDK in a specified application through a preset instruction. The preset instruction comprises a file path of an SDK file of the target SDK, an output path of the target adaptation file, a file type of the target SDK and the like. Under the condition that the SDK versions of the third-party application are overlapped, the target adaptation file corresponding to the target SDK can be automatically acquired by acquiring the preset instruction, and the dynamic conversion of the target SDK is realized, namely, a research and development worker only needs to send the preset instruction to dynamically generate the target adaptation file corresponding to the target SDK.

In one example, the default instruction is "Dart fault. Dart-k SDK-f/Users/sz/. pub-cache/host/pub. flutter-io. cn/context _ bottom _ bar-2.7.1+2/lib/con _ vex _ bottom _ bar. Dart", where "Dart" is a programming language type, "-k" is a file type, and "-f" is a file path where the SDK file is located.

In another example, the default instruction is "Dart fault.

Through the embodiment, the external public element set corresponding to the target SDK is obtained; and converting the public element set to obtain a target adaptation file corresponding to the target SDK. The target adaptation file corresponding to the target SDK is obtained by obtaining the externally-disclosed element set which is externally disclosed by the target SDK and is required to be called by the target Flutter application program and converting the externally-disclosed element set, so that the manual writing of the target SDK adaptation file is avoided, the manual workload of developers is reduced, the file loopholes and errors are reduced, and the purpose of improving the writing efficiency of the target SDK adaptation file is achieved. The problem of low efficiency of writing the SDK adaptation file due to large workload of writing the SDK adaptation file in the related technology is solved.

Example two

This embodiment describes in detail a specific SDK adaptation method provided by the embodiment of the present invention, which may specifically include the following steps:

s302, acquiring a file path corresponding to the SDK file from a preset instruction;

s304, inputting the SDK file into a preset assembly Fairc;

specifically, the preset component Fairc can acquire a constructor, a common method and field elements of the SDK file exposed to the outside or the outside, so as to obtain an externally exposed element set.

S306, generating an SDK adaptation file;

specifically, an external public element set corresponding to the SDK file is obtained through a preset component Fairc, and DSL conversion is performed on the external public element set to obtain an SDK adaptation file, that is, a Dart file.

S308, registering an external public element set in FairAPP;

specifically, when the third-party SDK needs to be called when the rendering application page exists, the file version corresponding to the third-party SDK is determined, and a public element set Dart file corresponding to the file version corresponding to the third-party SDK needing to be called is registered in the preset engine FairAPP, so that the target JSON file is obtained.

S310, sending down the target adaptation file through the network.

Specifically, the registered third-party SDK is directly called in the application page of the Flutter application program in a mode of loading the target JSON file corresponding to the specified version of the target Flutter application program or issuing the target JSON file in a preset server.

The target adaptation file corresponding to the target SDK is obtained by obtaining the externally-disclosed element set externally disclosed by the target SDK of the target Flutter application program and converting the externally-disclosed element set, so that the manual writing of the target SDK adaptation file is avoided, the manual workload of developers is reduced, the file loopholes and errors are reduced, and the purpose of improving the writing efficiency of the target SDK adaptation file is achieved. The problem of low efficiency of writing the SDK adaptation file due to large workload of writing the SDK adaptation file in the related technology is solved.

EXAMPLE III

The embodiment of the invention provides an SDK adaptation device.

Referring to fig. 4, a schematic structural diagram of an SDK adaptation apparatus in an embodiment of the present invention is shown.

The SDK adaptation device of the embodiment of the invention comprises: an acquisition unit 40 and a processing unit 42.

The functions of the modules and the interaction relationship between the modules are described in detail below.

An obtaining unit 40, configured to obtain an external public element set corresponding to the target SDK;

and the processing unit 42 is configured to convert the public element set to obtain a target adaptation file corresponding to the target SDK.

Optionally, in this embodiment, the obtaining unit 40 includes: the traversing module is used for traversing the target SDK; the processing module is used for generating an abstract syntax tree corresponding to the target SDK; a first obtaining module, configured to obtain the external public element set according to the abstract syntax tree.

Optionally, in this embodiment, the first obtaining module includes: the first obtaining submodule is used for obtaining a constructor set which is externally disclosed by the target SDK according to the abstract syntax tree; the second obtaining submodule is used for obtaining a static object set externally disclosed by the target SDK according to the abstract syntax tree; and the third obtaining submodule is used for obtaining the externally disclosed method set of the target SDK according to the abstract syntax tree.

Optionally, in this embodiment, the first obtaining sub-module is configured to: acquiring a constructor of the target SDK disclosed to the outside according to the node attribute of the node in the abstract syntax tree; classifying the constructors to obtain the constructor set, wherein the constructor set comprises an unnamed constructor subset, a common constructor subset and a non-abstract constructor subset.

Optionally, in this embodiment, the third obtaining sub-module is configured to: acquiring a method for externally disclosing the target SDK according to the node attribute of the node in the abstract syntax tree; and eliminating methods which do not meet preset conditions to obtain the method set.

Optionally, in this embodiment, the public element set includes a constructor set, a static object set, and a method set, where the processing unit 42 includes: and the conversion module is used for carrying out field specific language DSL conversion on the constructor set, the static object set and the method set so as to obtain the JSON file corresponding to the target SDK.

Optionally, in this embodiment, the method further includes: and the registration module is used for registering the JSON file to obtain a target JSON file corresponding to the target SDK after the public element set is converted to obtain a target adaptation file corresponding to the target SDK, wherein the target JSON file is used for calling the target SDK.

Optionally, in this embodiment, the registration module includes: the fourth obtaining submodule is used for obtaining a Key value corresponding to the JSON file; the determining submodule is used for determining a parameter corresponding to the JSON file according to the Key value; and the processing submodule is used for executing the preset engine according to the parameters to obtain the target JSON file.

Optionally, in this embodiment, the method further includes: the device comprises a receiving unit, a processing unit and a processing unit, wherein the receiving unit is used for acquiring a preset instruction before acquiring an external public element set corresponding to a target SDK, the preset instruction is used for indicating to acquire a target adaptation file corresponding to the target SDK, and the preset instruction comprises a file type, a file path and an output path of the target SDK.

The SDK adaptation device implements each process of the above SDK adaptation method embodiment, and can achieve the same technical effect, and is not described here again to avoid repetition.

Moreover, according to the embodiment, the externally-disclosed element set which is externally disclosed by the target SDK and is required to be called by the target Flutter application program is obtained, and the externally-disclosed element set is converted to obtain the target adaptation file corresponding to the target SDK, so that the target SDK adaptation file is prevented from being manually written, the manual workload of developers is reduced, further, file bugs and errors are reduced, and the purpose of improving the writing efficiency of the target SDK adaptation file is achieved. The problem of low efficiency of writing the SDK adaptation file due to large workload of writing the SDK adaptation file in the related technology is solved.

Example four

Preferably, an embodiment of the present invention further provides an electronic device, including: a memory, a processor and a computer program stored on the memory and executable on the processor, the computer program, when executed by the processor, implementing the steps of the SDK adaptation method as described in embodiment one.

When being executed by a processor, the computer program realizes the processes of the embodiment of the SDK adaptation method, can achieve the same technical effect, and is not repeated herein for avoiding repetition.

EXAMPLE five

The embodiment of the present invention further provides a storage medium, where the storage medium includes but is not limited to a computer-readable storage medium, and a computer program is stored on the storage medium, and when being executed by a processor, the computer program implements the processes of the above embodiment of the SDK adaptation method, and can achieve the same technical effects, and in order to avoid repetition, the details are not repeated here. The storage medium may be a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk.

It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.

Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.

While the present invention has been described with reference to the embodiments shown in the drawings, the present invention is not limited to the embodiments, which are illustrative and not restrictive, and it will be apparent to those skilled in the art that various changes and modifications can be made therein without departing from the spirit and scope of the invention as defined in the appended claims.

Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.

It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.

In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.

The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.

In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.

The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a U disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk.

The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

14页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:基于一种软件开发平台的软件自动集成控制方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!