Code publishing method, device, equipment and storage medium
By obtaining code release instructions, processing to generate SDK integration files and publishing them to the target library, the problem of cumbersome and inefficient code release steps in the existing technology is solved, and efficient code release and reuse is achieved, suitable for iOS and Flutter applications.
Patent Information
- Application Number
- CN202111463271.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-02
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2041-12-02
AI Technical Summary
Existing code publishing methods rely on cocoapods and git libraries, with cumbersome steps, low processing efficiency and low reuse efficiency, resulting in low publishing success rate.
Provide a code publishing method, which can generate SDK integration files based on the release type by obtaining code publishing instructions, including the source code file to be published and the release type processing, and publish them to the target code library, supporting one-click generation of closed source library code , automatically synchronize demo and setup information, and support simultaneous management of open source libraries and closed source libraries.
It improves the processing efficiency and release success rate of code release, simplifies code reuse, reduces maintenance costs, and supports the generation of open source libraries and closed source libraries at the same time, suitable for iOS and Flutter applications.
Smart Images

Figure CN114115982B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a code publishing method, device, equipment and storage medium. Background Art
[0002] With the rapid development of computer technology and the rapid iteration of products, in order to adapt to new business needs and implement new functions, R&D personnel will develop new codes and generate some third-party application toolkits or dependency libraries for internal or external personnel to use. Therefore, after R&D personnel develop new codes, how to release them is the key.
[0003] In the prior art, the code publishing process mainly relies on cocoapods and git libraries. Specifically, git libraries are libraries for storing codes, and cocoapods is a tool for managing third-party dependency libraries. Cocoapods can be used to resolve the dependencies between different git libraries, and use the source code in the git library to build a software development kit (SDK) and then publish it.
[0004] However, when using cocoapod to create and use SDK projects, the steps are cumbersome and require inputting a large number of commands. If the code is released incorrectly, it needs to be manually checked and cleaned up, resulting in low processing efficiency. The git library needs to be manually created and associated, which limits the output speed of the SDK project. In addition, using git to manage code in the same project makes code reuse inconvenient and results in low reuse efficiency. That is, the existing code release method has the problems of low processing efficiency and low release success rate. Summary of the invention
[0005] The present application provides a code publishing method, apparatus, device and storage medium to overcome the problems of low processing efficiency and low publishing success rate in the existing code publishing process.
[0006] In a first aspect, the present application provides a code publishing method, comprising:
[0007] Obtaining a code release instruction, the code release instruction including: a source code file to be released and a release type, the release type being used to indicate release to an open source library or to a closed source library;
[0008] Based on the release type, the source code file is processed to generate a software development kit SDK integration file;
[0009] Publish the SDK integration file to the target code library corresponding to the release type.
[0010] In a possible design of the first aspect, the publishing type is used to indicate publishing to an open source library;
[0011] Accordingly, based on the release type, the source code file is processed to generate a software development kit SDK integration file, including:
[0012] Generate an SDK project based on the release type and a preset project creation template, wherein the SDK project has an sdk project file directory, and the sdk project file directory includes: a demo version project folder, an sdk code folder, and an sdk resource folder;
[0013] Based on the source code file, obtaining a system dependency library and a compile command for the source code file;
[0014] According to the system dependency library and the compile command, the sdk code in the SDK project is edited to generate the SDK integration file.
[0015] In another possible design of the first aspect, the publishing type is used to indicate publishing to a closed source library, and the source code file is an open source library code;
[0016] Correspondingly, based on the release type, the source code file is processed to generate a software development kit SDK integration file, including:
[0017] Generate an SDK project based on the release type and a preset project creation template, wherein the SDK project has an sdk project file directory, and the sdk project file directory includes: a demo version project folder, an sdk code folder, and an sdk resource folder;
[0018] Packaging the open source library code into a closed source framework;
[0019] Obtain a demo project file corresponding to the open source library code from the open source library;
[0020] The SDK integration file is generated according to the dependent library configuration of the open source library code, the closed source framework and the demo version project file.
[0021] Optionally, before publishing the SDK integration file to the target code library corresponding to the publishing type, the method further includes:
[0022] Check the code integrity of the SDK integration file;
[0023] When the code of the SDK integration file is incomplete, an error prompt is output, and the error prompt includes: error location and / or error type;
[0024] When the code of the SDK integration file is complete, storing the code of the SDK integration file in the git repository;
[0025] According to the preset project configuration file, a tag is added to the SDK integration file.
[0026] Optionally, the method further includes:
[0027] When the SDK integration file fails to be published, cache information corresponding to the SDK integration file is cleared.
[0028] In another possible design of the first aspect, before processing the source code file based on the release type to generate a software development kit SDK integration file, the method further includes:
[0029] Decoupling the source code files to obtain at least two types of source code;
[0030] Storing the at least two types of source code in at least two git repositories respectively;
[0031] Determine a repository reference relationship between the at least two git repositories.
[0032] In yet another possible design of the first aspect, before obtaining the code release indication, the method further includes:
[0033] Capture code usage events for multiple code resources;
[0034] Determining a resource path of each code resource based on the code usage event and a library type corresponding to each code resource;
[0035] The source code file generated based on the multiple code resources is obtained, and the source code file carries a resource path of each code resource.
[0036] In a second aspect, the present application provides a code publishing device, comprising:
[0037] An acquisition module, used to acquire a code release instruction, wherein the code release instruction includes: a source code file to be released and a release type, wherein the release type is used to indicate release to an open source library or to a closed source library;
[0038] A processing module, used to process the source code file based on the release type to generate a software development kit SDK integration file;
[0039] The publishing module is used to publish the SDK integration file to the target code library corresponding to the publishing type.
[0040] In a possible design of the second aspect, the publishing type is used to indicate publishing to an open source library;
[0041] Accordingly, the processing module is specifically used for:
[0042] Generate an SDK project based on the release type and a preset project creation template, wherein the SDK project has an sdk project file directory, and the sdk project file directory includes: a demo version project folder, an sdk code folder, and an sdk resource folder;
[0043] Based on the source code file, obtaining a system dependency library and a compile command for the source code file;
[0044] According to the system dependency library and the compile command, the sdk code in the SDK project is edited to generate the SDK integration file.
[0045] In another possible design of the second aspect, the publishing type is used to indicate publishing to a closed source library, and the source code file is an open source library code;
[0046] Accordingly, the processing module is specifically used for:
[0047] Generate an SDK project based on the release type and a preset project creation template, wherein the SDK project has an sdk project file directory, and the sdk project file directory includes: a demo version project folder, an sdk code folder, and an sdk resource folder;
[0048] Packaging the open source library code into a closed source framework;
[0049] Obtain a demo project file corresponding to the open source library code from the open source library;
[0050] The SDK integration file is generated according to the dependent library configuration of the open source library code, the closed source framework and the demo version project file.
[0051] Optionally, the processing module is further used to:
[0052] Check the code integrity of the SDK integration file;
[0053] When the code of the SDK integration file is incomplete, an error prompt is output, and the error prompt includes: error location and / or error type;
[0054] When the code of the SDK integration file is complete, storing the code of the SDK integration file in the git repository;
[0055] According to the preset project configuration file, a tag is added to the SDK integration file.
[0056] Optionally, the processing module is further used to clear cache information corresponding to the SDK integration file when the SDK integration file fails to be published.
[0057] In yet another possible design of the second aspect, the processing module is further configured to:
[0058] Decoupling the source code files to obtain at least two types of source code;
[0059] Storing the at least two types of source code in at least two git repositories respectively;
[0060] Determine a repository reference relationship between the at least two git repositories.
[0061] In another possible design of the second aspect, the processing module is further used to capture code usage events of multiple code resources, and determine a resource path of each code resource based on the code usage events and a library type corresponding to each code resource;
[0062] The acquisition module is further used to acquire the source code file generated based on the multiple code resources, and the source code file carries the resource path of each code resource.
[0063] In a third aspect, the present application provides an electronic device comprising: a processor, a memory, and computer program instructions stored in the memory and executable on the processor, wherein when the processor executes the computer program instructions, it implements the method described in the first aspect and various possible designs of the first aspect.
[0064] Optionally, the processor may be a chip.
[0065] In a fourth aspect, the present application provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed by a processor, they are used to implement the method described in the first aspect and various possible designs of the first aspect.
[0066] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the method described in the first aspect and various possible designs of the first aspect.
[0067] The code publishing method, apparatus, device and storage medium provided in the embodiment of the present application obtain a code publishing instruction, which includes: the source code file to be published and the publishing type, the publishing type is used to indicate publishing to an open source library or to a closed source library, based on the above publishing type, the source code file is processed to generate an SDK integration file, and the SDK integration file is published to the target code library corresponding to the above publishing type. In this technical solution, the user does not need to add a runtime library and fill in the configuration, the code is integrated with one click, and the closed source library is packaged in one click. All SDKs exist in the form of frameworks, and the source code files can be accurately published to open source libraries or closed source libraries, which improves the processing efficiency and the publishing success rate, and solves the problems of low processing efficiency and low publishing success rate in the existing code publishing process. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] Figure 1 It is a schematic diagram of an application scenario to which the code publishing method provided by an embodiment of the present invention is applicable;
[0069] Figure 2 A flowchart of the first embodiment of the code publishing method provided by this application;
[0070] Figure 3 A schematic diagram of the process of building the basic environment applicable to the code publishing method provided in this application;
[0071] Figure 4 A schematic diagram of the process of publishing to an open source library in the code publishing method provided in this application;
[0072] Figure 5 This is a diagram of the SDK project directory created during the open source library release process;
[0073] Figure 6 A schematic diagram of the process of publishing to a closed source library in the code publishing method provided in this application;
[0074] Figure 7 A flowchart of the second embodiment of the code publishing method provided by this application;
[0075] Figure 8 A schematic diagram of the structure of the first embodiment of the code issuing device provided by the present application;
[0076] Fig. 9 A schematic diagram of the structure of an electronic device embodiment provided in this application. DETAILED DESCRIPTION
[0077] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0078] Before introducing the application scenarios and technical solutions of the present application, the nouns and terms involved in the embodiments of the present application are first explained:
[0079] APP: abbreviation of application software;
[0080] Mac: Apple computer, using macos system;
[0081] Sdk: Software Development Kit;
[0082] Framework: specifically refers to the static library of iOS;
[0083] Flutter - for creating high-performance, cross-platform mobile apps.
[0084] iOS: the operating system for iPhones;
[0085] Open source: code source files are visible;
[0086] Closed source: code source files are hidden;
[0087] Cocoapod: is a third-party library management tool, widely used for iOS code management;
[0088] Git is an open source distributed version control system used to handle any small or large project in an agile and efficient manner. The Git repository is an open source version control software that can store generated code files.
[0089] With the rapid development of network technology and communication technology, mobile terminals have gradually become popular, and the applications of mobile terminals are becoming more and more abundant. They have gradually become Internet terminals. In order to adapt to the new business needs of Internet terminals and realize new functions, R&D personnel will develop new codes and generate some third-party application toolkits or dependency libraries for internal or external personnel to use. Therefore, after R&D personnel develop new codes, how to publish them is the key.
[0090] Exemplarily, the scenario for code release may be the financial industry, and the technical solution of the present application may be applied to the management of the mobile iOS application code base in the financial industry.
[0091] In the prior art, the code publishing process mainly relies on cocoapods and git libraries. However, there are problems such as low processing efficiency and inconvenient code reuse. In view of the problems existing in the prior art, this application provides a specific implementation plan. The following briefly explains the problems of the prior art and the solutions of this application, as follows:
[0092] 1. When using the cocoapod method to create an SDK project and use it, you need to enter a large number of commands, the steps are cumbersome, and when the code is released, it cannot be processed quickly. You need to manually check and clean the mixed storage, and the storage processing efficiency is low. In addition, the git library needs to be manually created and associated, which is not suitable for the rapid output of a large number of SDK projects. The code publishing method provided in this application can generate a project and a git library with one click, which is fast and convenient.
[0093] 2. The existing technology mainly packages the open source library, which is not suitable for confidential release. In addition, the existing method cannot generate closed source code packages with one click, and cannot synchronize the demos of open source and closed source. The technical solution of this application can generate closed source library code with one click, and automatically synchronize demo, settings and other information.
[0094] 3. Due to the differences in file reference paths between open source libraries and closed source libraries, it is difficult to generate open source libraries and closed source libraries with the same set of code in existing methods, which is inconvenient to maintain. This application provides a file resource reference processor, which can generate open source libraries and closed source libraries with only one set of code, and has low maintenance costs.
[0095] 4. The existing technology requires manual search and increase of SDK's dependency on system libraries, which is very troublesome and easy to miss. This application can automatically query and fill in the dependency library. Developers only need to focus on writing code without worrying about configuration issues.
[0096] 5. Pod has two reference modes: use_frameworks! and use_modular_headers!. Generally, SDK libraries only support one reference mode. Supporting both requires code modification. The technical solution of this application achieves the purpose of supporting both reference modes by modifying the configuration file.
[0097] In response to the above technical problems and the purpose to be achieved by the present application, the present application provides a code publishing method, which obtains a code publishing indication, which includes: a source code file to be published and a publishing type, and the publishing type includes any one of the following: publishing to an open source library, publishing to a closed source library, and based on the publishing type, processing the source code file to generate an SDK integration file, and then publishing the SDK integration file to the target code library corresponding to the publishing type.
[0098] Specifically, the technical solution of the present application is implemented in a Mac environment, based on cocoapod, and some configuration information is added to make the management of the SDK more convenient. Moreover, unlike traditional code management solutions, users do not need to add runtime libraries and fill in configurations. The code can be integrated with one click and a closed source library can be packaged. All SDKs exist in the form of a framework, and the packaged packages can be used for iOS and flutter applications.
[0099] The technical solution of this application decouples the code, separates the basic code library, UI layer library, etc. by function, and can rely on its own library to implement other libraries. Each library code library is created in the form of an SDK for easy output, based on cocopod and git management. Each SDK is divided into two again, one is an open source library for internal development and use, and the other is a closed source library for external use to protect its own code. The closed source library can be generated with one click, solving the traditional complex problems. Moreover, the technical solution includes version management, which is very convenient for updating and rolling back during use.
[0100] For example, Figure 1 Schematic diagram of an application scenario to which the code publishing method provided in an embodiment of the present invention is applicable. Figure 1 As shown, the application scenario diagram may include: multiple terminal devices used by developers (exemplarily, terminal device 111 and terminal device 112), and electronic devices 12 connected to each terminal device.
[0101] In actual applications, R&D personnel can develop codes on terminal devices and generate source code files. Specifically, R&D personnel can write codes on terminal devices, or obtain part of the codes in closed source libraries or open source libraries from other devices, such as electronic devices, and improve them to generate source code files.
[0102] It is understandable that the embodiments of the present application do not limit the generation method or generation process of the source code file.
[0103] Optionally, in an embodiment of the present application, the electronic device can execute the technical solution of the present application, that is, the electronic device is in a Mac environment and has a cocoapod tool installed thereon, and the cocoapod tool can be used to manage the code on the electronic device.
[0104] Optionally, in an embodiment of the present application, the application scenario diagram may also include a terminal device used by the user, exemplarily including: terminal device 113 and terminal device 114. The terminal device 113 and the terminal device 114 may obtain published code information from an open source library or a closed source library of the electronic device 12 to implement certain business functions.
[0105] Understandably, Figure 1 The scene diagram shown is only an exemplary description. In practical applications, the scene diagram may also include other devices, such as storage devices, etc., which may be adjusted according to actual needs, and the embodiments of the present application do not limit them.
[0106] In the above Figure 1 In the scenario diagram shown, the embodiments of the present application do not limit the specific forms of expression of each device. For example, the electronic device 21 may be a computer device or a server, and the terminal device may be a mobile phone, a tablet computer, a PC terminal, etc., and examples will not be given one by one here.
[0107] It is understandable that, in actual applications, the terminal device can also execute the technical solution of the present application and achieve the purpose of code publishing, and the embodiments of the present application do not limit it.
[0108] Next, combined with the above Figure 1 The scene schematic diagram shown in the figure describes the technical solution of the present invention in detail through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.
[0109] Figure 2 This is a flow chart of the first embodiment of the code publishing method provided by this application. Figure 2 As shown, the code publishing method may include the following steps:
[0110] S201. Obtain a code publishing instruction, where the code publishing instruction includes: a source code file to be published and a publishing type, where the publishing type is used to indicate publishing to an open source library or publishing to a closed source library.
[0111] In an embodiment of the present application, when R&D personnel develop new code based on the functions they want to implement and need to release it, they can issue a code release instruction so that the electronic device can obtain the indicated source code files to be released and the target source library to be released.
[0112] Optionally, the target source library can be an open source library or a closed source library. That is, the source code files developed by the R&D personnel can be published to the closed source library for internal use, or they can be published to the open source library for use by other third parties. It is understandable that the source code files usually need to be published to the open source library first, and then the source code files in the open source library are instructed to be published to the closed source library. The embodiments of the present application do not limit the release type of the source code files, and will not be elaborated here.
[0113] Optionally, in the embodiment of the present application, the implementation premise of code release is that the source code file is in a set basic environment. Therefore, before the electronic device releases the code for the first time, it is necessary to build the basic environment first.
[0114] For example, Figure 3 This is a schematic diagram of the process of building the basic environment applicable to the code publishing method provided in this application. Figure 3 As shown, when building the basic environment, first install the cocoapod tool, and then create a git library. Specifically, on the one hand, create a group (group) of open source libraries and a repo of open source libraries on the git library, and on the other hand, create a group (group) of closed source libraries and a repo of closed source libraries on the git library.
[0115] Specifically, the cocoapod tool can be downloaded and installed according to the instructions on the official website.
[0116] Git library creation: Since code management is based on git, you can first add an open source library group on git to store open source code, add a closed source library group on git to store closed source code, and then create a repo for the open source library to manage the version release of the open source code, and create a repo for the closed source library to manage the version release of the closed source code. Among them, repo is a part of cocoapod management and is used to record versions.
[0117] Furthermore, when building the basic environment, you can also create a custom template, which is the configuration template used by Cocoapod when building the project. Optionally, in the custom template, you can specify the system version supported by the SDK, specify that a demo project can be automatically created when building, use Objective-C as the default language, etc.
[0118] S202: Based on the above release type, the source code file is processed to generate an SDK integration file.
[0119] Optionally, in an embodiment of the present application, the above-mentioned publishing type can be used to indicate publishing to an open source library, and can also be used to indicate publishing to a closed source library. When the meanings of the publishing type indications are different, the above-mentioned S202 can be implemented in different ways.
[0120] As an example, when the publishing type is used to indicate publishing to an open source library, correspondingly, the above S202 can be implemented by the following steps:
[0121] A1. Generate an SDK project based on the release type and the preset project creation template. The SDK project has an sdk project file directory, which includes: a demo project folder, an sdk code folder, and an sdk resource folder.
[0122] A2. Based on the above source code files, obtain the system dependent libraries and compilation commands of the source code files.
[0123] A3. According to the above system dependency libraries and compilation commands, edit the SDK code in the SDK project to generate the SDK integration file.
[0124] For example, Figure 4 This is a schematic diagram of the process of publishing to an open source library in the code publishing method provided in this application. Figure 4 As shown, for the establishment and release of the open source library, first create an SDK project, edit the SDK code, then write a demo test, and then scan the dependent libraries and commands, edit the SDK integration file, and finally check and release it to the established open source library repo.
[0125] Specifically, create an SDK project: Use the SDK creator to create an SDK project with one click, and use a custom template to automatically modify the git address in the SDK project to the specified address, which is the group name + project name in git. In actual applications, you only need to enter the project name into the SDK creator, and the SDK creator will automatically create a git project and initialize the SDK document. The integration method in the SDK document has been automatically written, but the usage method needs to be filled in later.
[0126] The custom template will specify the system version supported by the SDK project, the demo name, the test library, and the naming header of the source code file. For example, all source code files are JCxxx and start with JC.
[0127] Optionally, the created SDK project file directory contains: demo project folder, SDK code folder, SDK resource folder, .spec integration configuration file, .git file, .gitignore file, .travis.yml file, etc.
[0128] Optionally, after the SDK project is successfully created, two folders will be automatically generated, one for storing the SDK code files and the other for storing the SDK resource files. Moreover, after the SDK project is created, the demo project has been automatically created and associated with the SDK code and resources. Then, you can write the SDK code and demo test.
[0129] For example, Figure 5 This is a schematic diagram of the SDK project directory created during the open source library release process. Figure 5As shown, in the SDK project directory, the example is used to store the demo program, the JC framework (JCFoundation) is used to store the source code and resource files, the JC framework (JCFoundation) is the name of this SDK project, the JC framework.library version file (JCFoundation.podspec) is used to store the SDK configuration file; the software license (LICENSE) indicates the proof of permission to access the software, and the read file tag (README.MD) is the introduction document of the project.
[0130] Optionally, during the release of the open source library, the electronic device has an automatic importer (function) for SDK dependency files, that is, it can automatically scan the SDK project to obtain some system dependency libraries and some compilation commands in the source code, and automatically fill them into the integration description file after obtaining them to generate an SDK integration file.
[0131] The compilation command contains some compilation architectures and special compilation instructions that need to be removed. The compilation instructions will be automatically filled in if there is C++ code or extension class found by scanning. It can be understood that the SDK dependency file automatic importer is developed based on the Python language. It scans the project configuration file, matches the corresponding system library name and fills it in.
[0132] As another example, the publishing type is used to indicate publishing to a closed source library, and accordingly, the source code file is an open source library code. Accordingly, the above S202 can be implemented by the following steps:
[0133] B1. Create a template based on the release type and preset project to generate an SDK project.
[0134] The SDK project has an sdk project file directory, which includes: a demo project folder, an sdk code folder, and an sdk resource folder.
[0135] B2. Package the open source library code into a closed source framework;
[0136] B3. Obtain the demo project file corresponding to the open source library code from the open source library;
[0137] B4. Generate SDK integration files based on the dependency library configuration of the open source library code, the closed source framework, and the demo project files.
[0138] For example, Figure 6 This is a flow chart of publishing to a closed source library in the code publishing method provided by this application. Figure 6As shown, for the establishment and release of a closed-source library, first create an SDK project, package the open-source library code, copy the demo version (demo), and then generate and edit the SDK integration file through the integrated file editor. Finally, after inspection and release, it is released to the established closed-source library repo.
[0139] Specifically, in the embodiment of the present application, to create an SDK project: use the SDK creator to create an SDK project with one click, and use a custom template to automatically modify the git address in the SDK project to the specified address, which is the group name + project name in git. In actual application, you only need to enter the project name into the SDK creator, and the SDK creator will automatically create a git project and initialize the SDK document. The integration method in the SDK document has been automatically written, but the usage method needs to be filled in later.
[0140] The custom template will specify the system version supported by the SDK project, the demo name, the test library, and the naming header of the source code file. For example, all source code files are JCxxx and start with JC.
[0141] Optionally, the created SDK project file directory contains: demo project folder, SDK code folder, SDK resource folder, .spec integration configuration file, .git file, .gitignore file, .travis.yml file, etc.
[0142] Optionally, after the SDK project is successfully created, two folders will be automatically generated, one for storing SDK code files and the other for storing SDK resource files.
[0143] Code packager: Automatically packages the code of the open source library into a closed source framework, exposing only the header file but not the specific implementation of the code, so as to facilitate external use. When packaging the open source library code, the arm64 simulator architecture will be automatically removed to reduce errors in packaging and subsequent integration. The mangle optional parameter is provided, which can be selected according to different scenarios. The data source of the packager is the private git source and github source (used to reference third-party code). The packager automatically excludes third-party library files and adopts the subsequent dependency method to facilitate the upgrade of third-party libraries and reduce conflicts with the use of local libraries.
[0144] Smart demo synchronizer: synchronizes demo implementations in open source libraries.
[0145] Integrated file editor: First, synchronize the dependency library configuration in the open source file, automatically edit the resource file address and resource file type based on the analysis of the closed source framework, add integrated support for use_frameworks! and use_modular_headers!, add support for flutter, and generate SDK integration files.
[0146] S203: Publish the SDK integration file to the target code library corresponding to the publishing type.
[0147] Optionally, in an embodiment of the present application, for source code files to be released, after the SDK integration file is generated, it can be released according to the release type. Exemplarily, when the release type is used to indicate release to an open source library, the SDK integration file is released to the established open source library repo; when the release type is used to indicate release to a closed source library, the SDK integration file is released to the established closed source library repo.
[0148] The code publishing method provided in the embodiment of the present application obtains a code publishing instruction, which includes: the source code file to be published and the publishing type, the publishing type is used to indicate publishing to an open source library or to a closed source library, based on the above publishing type, the source code file is processed to generate an SDK integration file, and the SDK integration file is published to the target code library corresponding to the above publishing type. In this technical solution, users do not need to add runtime libraries and fill in configurations, the code is integrated with one click, and the closed source library is packaged in one click. All SDKs exist in the form of frameworks, and the source code files can be accurately published to open source libraries or closed source libraries, which improves processing efficiency and publishing success rate.
[0149] Based on the above embodiment, after the SDK integration file is generated, in order to avoid the problem of being unusable after release, the SDK integration file can be verified before release. Figure 7 The embodiment shown.
[0150] Figure 7 This is a flow chart of the second embodiment of the code publishing method provided by this application. Figure 7 As shown, before the above S203, the method may further include the following steps:
[0151] S701, check the code integrity of the SDK integration file;
[0152] S702: When the code of the SDK integration file is incomplete, an error prompt is output, and the error prompt includes: an error location and / or an error type;
[0153] S703. When the code of the SDK integration file is complete, the code of the SDK integration file is stored in the git repository, and a tag is added to the SDK integration file according to a preset project configuration file.
[0154] Specifically, check whether the code of the SDK integration file is executable. When the code is executable, first publish the code of the SDK integration file to the git repository, and automatically add tags to the SDK integration file according to the preset project configuration file, and then execute the following S704 step.
[0155] S704, publish the SDK integration file with the tag added to the corresponding repo.
[0156] For example, for source code files published to an open source library, they are published to the repo of the open source library; for source code files published to a closed source library, they are published to the repo of the closed source library.
[0157] Accordingly, in the embodiment of the present application, after the above S704, the method may further include the following steps:
[0158] When the SDK integration file is published successfully, it ends;
[0159] S705. When the SDK integration file fails to be released, clear the cache information corresponding to the SDK integration file.
[0160] In an embodiment of the present application, after the SDK integration file is released, the electronic device can detect whether the SDK integration file is released successfully. If successful, the process ends; if failed, on the one hand, an error prompt can be issued, that is, an error report, indicating a release error; on the other hand, the label of the SDK integration file with the label is removed, and the file is rolled back to the last available version, that is, the cache information corresponding to the SDK integration file is cleared to facilitate re-release after modification.
[0161] The code publishing method provided in the embodiment of the present application first checks the code integrity of the SDK integration file before publishing the generated SDK integration file to the target code library corresponding to the publishing type. When the code of the SDK integration file is incomplete, an error prompt is output, and the error prompt includes: error location and / or error type. When the code of the SDK integration file is complete, the code of the SDK integration file is stored in the git library, and a label is added to the SDK integration file according to the preset project configuration file. After publishing the generated SDK integration file to the target code library corresponding to the publishing type, if the SDK integration file fails to be published, the cache information corresponding to the SDK integration file is cleared. In this technical solution, the code integrity of the SDK integration file can be automatically detected, and whether a rollback is required is determined based on whether the publishing is successful, which improves the convenience of updating and rolling back during use.
[0162] Furthermore, in an embodiment of the present application, before the above S202, the code publishing method may further include the following steps:
[0163] Decouple the source code files to obtain at least two types of source code;
[0164] Store at least two types of source code in at least two git repositories respectively;
[0165] Determine the library reference relationship between at least two git repositories.
[0166] For example, after obtaining the source code file, the electronic device first decouples the source code file, separates the basic common code, UI layer code, etc. into independent libraries, separate functions into separate libraries, and references each other between libraries. The codes are independent, so that they can be used alone or in combination to form more complete functions. It is convenient to output SDK integration files as required.
[0167] Optionally, in another possible design of the embodiment of the present application, before the above S201 (obtaining a code release indication), the code release method may further include the following steps:
[0168] Capture code usage events for multiple code resources;
[0169] Based on the above code usage events and the library type corresponding to each code resource, determine the resource path of each code resource;
[0170] The source code file generated based on multiple code resources is obtained, and the source code file carries the resource path of each code resource.
[0171] Specifically, in the embodiments of the present application, since there will be differences in the file reference paths of the open source library and the closed source library, there will also be differences in the codes for file references between the open source library and the closed source library. In the technical solution of the present application, a file resource reference processor is loaded in the electronic device. The file resource reference processor can automatically identify whether the code used by the R&D personnel when developing the source code file comes from the open source library or the closed source library, and obtain the resource path of each code resource in the source code file based on the correct method, so that the generated source code file carries the resource path of each code resource.
[0172] Optionally, the file resource reference processor is used to identify the source of code resources during the SDK development process. The technical solution of the present application can generate open source libraries and closed source libraries with only one set of coding by providing a file resource reference processor, thereby reducing maintenance costs.
[0173] Furthermore, in the embodiments of the present application, when the published source code files are used subsequently, it is necessary to rely on the Mac environment, that is, you only need to install cocoapod and obtain the code permissions of the corresponding closed source library or open source library, use the repo of the corresponding closed source library or open source library as the resource (source) of cocoapod, and then write the code library and version needed, and finally use the installation command provided by cocoapod to install the functions corresponding to the source code file with one click.
[0174] The following are device embodiments of the present application, which can be used to execute the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
[0175] Figure 8 This is a schematic diagram of the structure of the first embodiment of the code publishing device provided by this application. Figure 8 As shown, the code issuing device may include:
[0176] An acquisition module 801 is used to acquire a code release instruction, wherein the code release instruction includes: a source code file to be released and a release type, wherein the release type is used to indicate whether to release to an open source library or to a closed source library;
[0177] A processing module 802 is used to process the source code file based on the release type to generate a software development kit SDK integration file;
[0178] The publishing module 803 is used to publish the SDK integration file to the target code library corresponding to the publishing type.
[0179] In a possible design of an embodiment of the present application, the publishing type is used to indicate publishing to an open source library;
[0180] Accordingly, the processing module 802 is specifically configured to:
[0181] Generate an SDK project based on the release type and a preset project creation template, wherein the SDK project has an sdk project file directory, and the sdk project file directory includes: a demo version project folder, an sdk code folder, and an sdk resource folder;
[0182] Based on the source code file, obtaining a system dependency library and a compile command for the source code file;
[0183] According to the system dependency library and the compile command, the sdk code in the SDK project is edited to generate the SDK integration file.
[0184] In another possible design of the embodiment of the present application, the publishing type is used to indicate publishing to a closed source library, and the source code file is an open source library code;
[0185] Accordingly, the processing module 802 is specifically configured to:
[0186] Generate an SDK project based on the release type and a preset project creation template, wherein the SDK project has an sdk project file directory, and the sdk project file directory includes: a demo version project folder, an sdk code folder, and an sdk resource folder;
[0187] Packaging the open source library code into a closed source framework;
[0188] Obtain a demo project file corresponding to the open source library code from the open source library;
[0189] The SDK integration file is generated according to the dependent library configuration of the open source library code, the closed source framework and the demo version project file.
[0190] Optionally, the processing module 802 is further configured to:
[0191] Check the code integrity of the SDK integration file;
[0192] When the code of the SDK integration file is incomplete, an error prompt is output, and the error prompt includes: error location and / or error type;
[0193] When the code of the SDK integration file is complete, storing the code of the SDK integration file in the git repository;
[0194] According to the preset project configuration file, a tag is added to the SDK integration file.
[0195] Optionally, the processing module 802 is further configured to clear cache information corresponding to the SDK integration file when the SDK integration file fails to be published.
[0196] In another possible design of the embodiment of the present application, the processing module 802 is further configured to:
[0197] Decoupling the source code files to obtain at least two types of source code;
[0198] Storing the at least two types of source code in at least two git repositories respectively;
[0199] Determine a repository reference relationship between the at least two git repositories.
[0200] In another possible design of the embodiment of the present application, the processing module 802 is further used to capture code usage events of multiple code resources, and determine the resource path of each code resource based on the code usage events and the library type corresponding to each code resource;
[0201] The acquisition module 801 is further used to acquire the source code file generated based on the multiple code resources, and the source code file carries the resource path of each code resource.
[0202] The device provided in the embodiment of the present application can be used to execute the technical solution of the above-mentioned method embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0203] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. For example, the processing module can be a separately established processing element, or it can be integrated in a chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a processing element of the above device. The function of the above-mentioned module is determined. The implementation of other modules is similar. In addition, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
[0204] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more microprocessors (digital signal processors, DSP), or one or more field programmable gate arrays (FPGA), etc. For another example, when a module above is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0205] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.
[0206] Fig. 9 This is a schematic diagram of the structure of an electronic device embodiment provided by this application. Fig. 9 As shown, the electronic device may include: a processor 901, a memory 902, a communication interface 903 and a system bus 904. The memory 902 and the communication interface 903 are connected to the processor 901 through the system bus 904 and communicate with each other. The memory 902 is used to store computer program instructions, and the communication interface 903 is used to communicate with other devices. When the processor 901 executes the above computer program instructions, the technical solution of the above method embodiment is implemented.
[0207] Should Fig. 9The system bus mentioned in the specification may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The system bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface is used to realize the communication between the database access device and other devices (such as a client, a read-write library, and a read-only library). The memory may include a random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage.
[0208] The above-mentioned processor can be a general-purpose processor, including a central processing unit CPU, a network processor (NP), etc.; it can also be a digital signal processor DSP, an application-specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0209] Optionally, an embodiment of the present application further provides a computer-readable storage medium, in which computer instructions are stored, and when the computer-readable storage medium is run on a computer, the computer executes the technical solution of the above-mentioned method embodiment.
[0210] Optionally, an embodiment of the present application further provides a chip for running instructions, wherein the chip is used to execute the technical solution of the above method embodiment.
[0211] An embodiment of the present application also provides a computer program product, including a computer program, wherein the computer program is stored in a computer-readable storage medium, and at least one processor can read the computer program from the computer-readable storage medium. When the at least one processor executes the computer program, the technical solution of the above-mentioned method embodiment can be implemented.
[0212] In the present application, "at least one" means one or more, and "plurality" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: the existence of A alone, the existence of A and B at the same time, and the existence of B alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship; in a formula, the character " / " indicates that the previous and next associated objects are in a "division" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single items or plural items.
[0213] It is to be understood that the various numerical numbers involved in the embodiments of the present application are only for the convenience of description and are not intended to limit the scope of the embodiments of the present application. In the embodiments of the present application, the size of the sequence number of each process does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0214] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A code publishing method, characterized in that: include: Obtaining a code release instruction, the code release instruction including: a source code file to be released and a release type, the release type being used to indicate release to an open source library or to a closed source library; Based on the release type, the source code file is processed to generate a software development kit SDK integration file; Publishing the SDK integration file to the target code library corresponding to the publishing type; When the release type is used to indicate release to an open source repository; Correspondingly, based on the release type, the source code file is processed to generate a software development kit SDK integration file, including: Generate an SDK project based on the release type and a preset project creation template, wherein the SDK project has an sdk project file directory, and the sdk project file directory includes: a demo version project folder, an sdk code folder, and an sdk resource folder; Based on the source code file, obtaining a system dependency library and a compile command for the source code file; According to the system dependency library and the compile command, the sdk code in the SDK project is edited to generate the SDK integration file.
2. The method according to claim 1, characterized in that When the publishing type is used to indicate publishing to a closed source library, the source code file is an open source library code; Correspondingly, based on the release type, the source code file is processed to generate a software development kit SDK integration file, including: Generate an SDK project based on the release type and a preset project creation template, wherein the SDK project has an sdk project file directory, and the sdk project file directory includes: a demo version project folder, an sdk code folder, and an sdk resource folder; Packaging the open source library code into a closed source framework; Obtain a demo project file corresponding to the open source library code from the open source library; The SDK integration file is generated according to the dependent library configuration of the open source library code, the closed source framework and the demo version project file.
3. The method according to claim 1 or 2, characterized in that: Before publishing the SDK integration file to the target code library corresponding to the publishing type, the method further includes: Check the code integrity of the SDK integration file; When the code of the SDK integration file is incomplete, an error prompt is output, and the error prompt includes: error location and / or error type; When the code of the SDK integration file is complete, storing the code of the SDK integration file in the git repository; According to the preset project configuration file, a tag is added to the SDK integration file.
4. The method according to claim 1 or 2, characterized in that: The method further comprises: When the SDK integration file fails to be published, cache information corresponding to the SDK integration file is cleared.
5. The method according to claim 1 or 2, characterized in that: Before the source code file is processed based on the release type to generate a software development kit SDK integration file, the method further includes: Decoupling the source code files to obtain at least two types of source code; Storing the at least two types of source code in at least two git repositories respectively; Determine a repository reference relationship between the at least two git repositories.
6. The method according to claim 1 or 2, characterized in that: Before obtaining the code release indication, the method further includes: Capture code usage events for multiple code resources; Determining a resource path of each code resource based on the code usage event and a library type corresponding to each code resource; The source code file generated based on the multiple code resources is obtained, and the source code file carries a resource path of each code resource.
7. A code issuing device, characterized in that: include: An acquisition module, used to acquire a code release instruction, wherein the code release instruction includes: a source code file to be released and a release type, wherein the release type is used to indicate release to an open source library or to a closed source library; A processing module, used to process the source code file based on the release type to generate a software development kit SDK integration file; A publishing module, used for publishing the SDK integration file to the target code library corresponding to the publishing type; When the release type is used to indicate release to an open source repository; Accordingly, the processing module is specifically used for: Generate an SDK project based on the release type and a preset project creation template, wherein the SDK project has an sdk project file directory, and the sdk project file directory includes: a demo version project folder, an sdk code folder, and an sdk resource folder; Based on the source code file, obtaining a system dependency library and a compile command for the source code file; According to the system dependency library and the compile command, the sdk code in the SDK project is edited to generate the SDK integration file.
8. The device according to claim 7, characterized in that When the publishing type is used to indicate publishing to a closed source library, the source code file is an open source library code; Accordingly, the processing module is specifically used for: Generate an SDK project based on the release type and a preset project creation template, wherein the SDK project has an sdk project file directory, and the sdk project file directory includes: a demo version project folder, an sdk code folder, and an sdk resource folder; Packaging the open source library code into a closed source framework; Obtain a demo project file corresponding to the open source library code from the open source library; The SDK integration file is generated according to the dependent library configuration of the open source library code, the closed source framework and the demo version project file.
9. The device according to claim 7 or 8, characterized in that The processing module is further used for: Check the code integrity of the SDK integration file; When the code of the SDK integration file is incomplete, an error prompt is output, and the error prompt includes: error location and / or error type; When the code of the SDK integration file is complete, storing the code of the SDK integration file in the git repository; According to the preset project configuration file, a tag is added to the SDK integration file.
10. The device according to claim 7 or 8, characterized in that The processing module is further configured to clear cache information corresponding to the SDK integration file when the SDK integration file fails to be published.
11. The device according to claim 7 or 8, characterized in that The processing module is further used for: Decoupling the source code files to obtain at least two types of source code; Storing the at least two types of source code in at least two git repositories respectively; Determine a repository reference relationship between the at least two git repositories.
12. The device according to claim 7 or 8, characterized in that The processing module is further used to capture code usage events of multiple code resources, and determine the resource path of each code resource based on the code usage events and the library type corresponding to each code resource; The acquisition module is further used to acquire the source code file generated based on the multiple code resources, and the source code file carries the resource path of each code resource.
13. An electronic device, characterized in that: include: A processor, a memory, and computer program instructions stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 6 when executing the computer program instructions.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, which are used to implement the method according to any one of claims 1 to 6 when executed by a processor.
15. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 6 when being executed by a processor.
