CN112558975B - Method and device for switching codes of components, electronic equipment and readable storage medium - Google Patents

Method and device for switching codes of components, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN112558975B
CN112558975B CN202011497972.8A CN202011497972A CN112558975B CN 112558975 B CN112558975 B CN 112558975B CN 202011497972 A CN202011497972 A CN 202011497972A CN 112558975 B CN112558975 B CN 112558975B
Authority
CN
China
Prior art keywords
component
switchable
version
switching
source code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011497972.8A
Other languages
Chinese (zh)
Other versions
CN112558975A (en
Inventor
谭志坚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN202011497972.8A priority Critical patent/CN112558975B/en
Publication of CN112558975A publication Critical patent/CN112558975A/en
Application granted granted Critical
Publication of CN112558975B publication Critical patent/CN112558975B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a code switching method and device of a component, electronic equipment and a readable storage medium, and belongs to the technical field of code processing. In the method, whether the description file corresponding to the system contains all preset source code switching identifications or not is judged, and the binary codes of all the switchable components are switched to source codes or the source codes of all the switchable components are switched to binary codes based on whether the description file contains all the source code switching identifications and the types of codes currently displayed in the system. In this way, by defining all source code switching identifications for the system layer, correspondingly, one-key switching of a plurality of switchable components in the system can be realized only by judging whether all source code switching identifications exist. Compared with the mode of detecting the component libraries corresponding to the switchable components one by one, the time consumption can be reduced, and the switching efficiency can be improved.

Description

Method and device for switching codes of components, electronic equipment and readable storage medium
Technical Field
The present invention relates to the field of code processing technologies, and in particular, to a method and an apparatus for switching a code of a component, an electronic device, and a readable storage medium.
Background
Under the condition that more and more services exist, building components are needed to achieve the capability of building a middle platform and speed up code building. For debugging convenience, binary code and source code of the switchable component are often correspondingly arranged. Accordingly, the binary code and the source code of the switchable component can be switched accordingly in case the source code or the binary code is required.
When the existing mode is switched, whether a class file is cited in a component library of the switchable component is often detected, and switching between binary codes and source codes is performed according to whether the class file is cited in the component library. In this way, when all the switchable components need to be switched, the detection needs to be performed once in the component library of each switchable component, which results in more time-consuming and lower efficiency.
Disclosure of Invention
The invention provides a code switching method and device of a component, electronic equipment and a readable storage medium, so as to solve the problems of serious switching time consumption and low efficiency.
According to a first aspect of the present invention there is provided a method of code switching of a component for use in a system comprising at least two switchable components, the method comprising:
Judging whether the description file corresponding to the system contains all preset source code switching identifiers or not;
if all source code switching identifications are included and the codes currently displayed in the system are binary codes corresponding to all switchable components in the system, reading the source codes corresponding to all the switchable components in the system, and switching the displayed binary codes of all the switchable components into the source codes corresponding to all the switchable components;
if all source code switching identifications are not included and the currently displayed codes in the system are source codes corresponding to all the switchable components, reading binary codes corresponding to all the switchable components, and switching the displayed source codes of all the switchable components into the binary codes corresponding to all the switchable components;
the binary code is obtained by converting the source code.
According to a second aspect of the present invention there is provided a code switching device for a component for use in a system comprising at least two switchable components, the device comprising:
the first judging module is used for judging whether the description file corresponding to the system contains all preset source code switching identifiers or not;
The first switching module is used for reading the source codes corresponding to all the switchable components in the system and switching the displayed binary codes of all the switchable components into the source codes corresponding to all the switchable components if all the source code switching identifications are contained and the codes currently displayed in the system are the binary codes corresponding to all the switchable components in the system;
the second switching module is used for reading the binary codes corresponding to the switchable components if all the source code switching identifications are not contained and the codes currently displayed in the system are the source codes corresponding to the switchable components, and switching the source codes of the switchable components to the binary codes corresponding to the switchable components;
the binary code is obtained by converting the source code.
In yet another aspect of the present invention, there is also provided a computer readable storage medium having instructions stored therein, which when run on a computer, cause the computer to perform the method of code switching of any of the above-described components.
In yet another aspect of the invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the method of code switching of any of the above-described components.
Aiming at the prior art, the invention has the following advantages:
and judging whether the description file corresponding to the system contains all preset source code switching identifications, if the description file contains all source code switching identifications and the code currently displayed in the system is the binary code corresponding to each switchable component in the system, reading the source code corresponding to each switchable component in the system, switching the displayed binary code of each switchable component into the source code corresponding to each switchable component, and if the description file does not contain all source code switching identifications and the code currently displayed in the system is the source code corresponding to each switchable component, reading the binary code corresponding to each switchable component, and switching the displayed binary code of each switchable component into the binary code corresponding to each switchable component. In this way, by defining all source code switching identifications for the system layer, correspondingly, one-key switching of a plurality of switchable components in the system can be realized only by judging whether all source code switching identifications exist. Compared with the mode of detecting the switchable component libraries corresponding to the switchable components one by one, the time consumption can be reduced, and the switching efficiency can be improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
FIG. 1-1 is a flow chart of steps of a method for switching codes of a component according to an embodiment of the present invention;
FIGS. 1-2 are a flow chart of steps of a process for all source code switching identification provided by an embodiment of the present invention;
FIGS. 1-3 are flowcharts of steps of a version number setting process provided by an embodiment of the present invention;
FIG. 2 is a schematic diagram of a system process according to an embodiment of the present invention;
FIG. 3 is a block diagram of a code switching apparatus of a component provided by an embodiment of the present invention;
FIG. 4 is a block diagram of a code switching apparatus of another component provided by an embodiment of the present invention;
FIG. 5 is a block diagram of a code switching apparatus of yet another component provided by an embodiment of the present invention;
FIG. 6 is a block diagram of a code switching apparatus of yet another component provided by an embodiment of the present invention;
fig. 7 is a block diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described below with reference to the accompanying drawings in the embodiments of the present invention.
Fig. 1-1 is a flowchart of steps of a method for switching codes of components, which is applied to a system including at least two switchable components and is provided in an embodiment of the present invention, and as shown in fig. 1-1, the method may include:
and step 101, judging whether the description file corresponding to the system contains all preset source code switching identifiers.
In the embodiment of the invention, the system can be a system constructed by components for realizing specific functions. The components in the system can be divided into a basic component, a basic service component, a business component and an event component. The basic service components can depend on the basic components, and the business components can depend on the basic service components while depending on the basic components. Click events between business components may be uniformly scheduled by the event component. Therefore, by dividing the components, the components which are modified can be recompiled, and other components which are not modified can not be recompiled after the components are modified, so that the compiling speed and the developing efficiency can be improved to a certain extent.
Further, the system may be a middle platform system, specific functions may be set according to actual requirements, and the specific functions implemented by the systems constructed by different components may be different.
The description file corresponding to the system can be a version description file (podfile) preset in preset management software, all source code switching identifiers can be one description in the version description file, and the number of all source code switching identifiers can be 1, so that the processing efficiency can be improved to the greatest extent.
The preset management software may be software that manages installation packages for components in the system. By way of example, the preset management software may be Cocoaps software written in an object-oriented programming scripting language (ruby language) for managing apple operating system (Iphone Operation System, IOS) packages.
The all source code switching identification may be an identification used to characterize whether source code switching is required for all switchable components in the system. The source code switching refers to switching binary codes of components displayed in the system to source codes. The specific content of all source code switching identifications can be set according to actual requirements, and by way of example, all source code switching identifications can be expressed as' all_source-! ".
Further, the switchable component in the embodiment of the present invention may be all components included in the system, or may be a component added with a preset identifier in the system. The preset identifier may be set according to actual requirements, and by way of example, the preset identifier may be "QR", and accordingly, the component may be marked as a switchable component by adding the "QR" identifier to the component name of the component. Accordingly, after the "QR" identifier may be added to the component names of the components, a preset field "/source" may also be added to the component names of the components, for example, the component name "QRLogLib" may be modified to the component name "QRLogLib/source". Therefore, when the component is switched by using the preset command, the switching needs to be realized by combining the preset field "/source" in the name of the component, so that the switching of the component can be realized according to the preset command when the subsequent switching is performed by further adding the preset field "/source" in the embodiment of the invention.
Further, in this step, the operation of determining whether the description file corresponding to the system includes all preset source code switching identifiers may be periodically performed according to a preset period. Or after receiving the specific instruction, the operation of judging whether the description file corresponding to the system contains all preset source code switching identifiers or not may be executed. Or, after detecting the specific operation, an operation of determining whether the description file corresponding to the system includes all preset source code switching identifiers is performed, which is not limited in the embodiment of the present invention.
And 102, if all the source code switching identifications are included and the currently displayed codes in the system are binary codes corresponding to all the switchable components in the system, reading the source codes corresponding to all the switchable components in the system, and switching the displayed binary codes of all the switchable components into the source codes corresponding to all the switchable components.
In the embodiment of the invention, the component with the preset mark in the system can be acquired first, and the component with the preset mark can be used as the switchable component. Further, if it is detected that the description file corresponding to the system contains all preset source code switching identifications and the currently displayed codes in the system are binary codes corresponding to all switchable components in the system, the mode that all the switchable components of the system are required to be switched to source codes is indicated to be displayed currently. Accordingly, the source code corresponding to each switchable component in the system can be read, and the source code corresponding to each switchable component can be displayed. Where source code refers to code that is directly generated using a programming language when developing a switchable component.
And 103, if all the source code switching identifications are not included and the currently displayed codes in the system are source codes corresponding to the switchable components, reading the binary codes corresponding to the switchable components, and switching the displayed source codes of the switchable components into the binary codes corresponding to the switchable components.
In the embodiment of the invention, if the description file corresponding to the system does not contain all preset source code switching identifications and the currently displayed codes in the system are the source codes corresponding to the switchable components, the mode that all the switchable components of the system are required to be switched to binary codes is indicated to be displayed currently. Accordingly, the binary codes corresponding to the switchable components in the system can be read, and the binary codes corresponding to the switchable components can be displayed. Wherein binary code refers to code obtained by converting source code of a switchable component into binary form. For example, the source code of the switchable component may be compiled by a preset compiling command, so as to obtain a binary code. The binary code may include a binary file and a header file in a format. By way of example, the preset compilation command may be an "XBUILD" command. The parameters of the command may include an engineering type "workspace" of an engineering to which the source code belongs, an engineering name "PROJECT" of an engineering to which the source code belongs, a TARGET location "scheme $TARGET" of the engineering to which the source code belongs, a device model "sdk" to which the compiled binary file needs to be adapted, a configuration "to which the compiled binary file needs to be adapted, and a directory name of a storage directory to which the compiled binary file corresponds. For example, the directory name may be "configuration_b uild_dir= $process_root/BUILD/$arch-iphone os clean BUILD".
In summary, in the method for switching the codes of the switchable components provided in the embodiment of the present invention, it is determined whether the description file corresponding to the system includes all preset source code switching identifiers, if all source code switching identifiers are included and the code currently displayed in the system is the binary code corresponding to each switchable component in the system, the source code corresponding to each switchable component in the system is read, and the binary code of each displayed switchable component is switched to the source code corresponding to each switchable component, and if all source code switching identifiers are not included and the code currently displayed in the system is the source code corresponding to each switchable component, the binary code corresponding to each switchable component is read, and the source code of each displayed switchable component is switched to the binary code corresponding to each switchable component. In this way, by defining all source code switching identifications for the system layer, correspondingly, one-key switching of a plurality of switchable components in the system can be realized only by judging whether all source code switching identifications exist. Compared with the mode of detecting the switchable component libraries corresponding to the switchable components one by one, the time consumption can be reduced, and the switching efficiency can be improved.
Alternatively, in an alternative embodiment of the present invention, the following steps shown in FIGS. 1-2 may also be performed prior to step 101:
step 201, executing a first operation on the description file under the condition that source codes of all switchable components need to be displayed, so as to add all source code switching identifications in the description file.
In this step, the first operation may specifically be an operation of adding all source code switching identifiers in the description file. For example, the source codes of all switchable components may be confirmed to be displayed when the first instruction sent by the user is received, and accordingly, all source code switching identifiers may be written in the designated location of the description file. The first instruction may be sent by means of voice triggering, virtual key triggering, or the like, and the designated position may be set according to actual requirements, and by way of example, the designated position may be the last position of the description file, the beginning of the description file, or the like.
And 202, executing a second operation on the description file under the condition that all source code switching identifications are added in the description file and binary codes of all switchable components need to be displayed, so as to clear all source code switching identifications in the description file.
In this step, the second operation may specifically be an operation of clearing all source code switching identifiers in the description file. For example, the binary codes of all switchable components may be confirmed to be displayed when the second instruction sent by the user is received, and accordingly, all source code switching identifications of the specified positions of the description file may be deleted. The second instruction may be sent by voice triggering, virtual key triggering, or the like. The manner in which the flag is reset is compared to setting a special flag for an operation of displaying binary codes of all switchable components. In the embodiment of the invention, under the condition that the binary codes of all the switchable components are required to be displayed, all the source code switching identifications are directly cleared, and then under the condition that all the source code switching identifications do not exist, the binary codes corresponding to all the switchable components are directly and correspondingly displayed. Thus, the binary switching of all the switchable components can be controlled by clearing, and the efficiency of the binary switching is improved to a certain extent. It should be noted that, in one implementation, the descriptive language of each line of the description file may be converted into a command through DSL voice characteristics, so that the descriptive language of the description file may be loaded into the memory data, so as to modify the description file from the program level. Accordingly, the first operation and the second operation may be implemented through a preset program command. In this way, compared with the manual modification of the descriptive language, the modification is realized through the preset program command, so that the modification efficiency can be improved to a certain extent.
Correspondingly, the operation of judging whether the description file corresponding to the system contains all preset source code switching identifiers or not can be realized through the following substeps:
substep (1): and after the first operation or the second operation is detected to be executed on the description file, invoking all source code switching identification detection methods in a preset script, and traversing the description file to determine whether all source code switching identifications are contained in the description file.
In this step, the preset script may be a script in which all the source code switching identification detection methods are assembled, and may be assembled with other methods, for example, a platform method, a project method, a source method, a Target method, a pod method, and the like in the cooapods software. The platform method may be used to store platform information and platform version of the system, the project method may be used to store project names corresponding to the system, the source method may be used to store remote private source addresses of switchable components, and the Target method may be used to store Target names corresponding to the system, e.g., "qyoreaderapp". In the case that all source code switching identifications are included and the currently displayed code in the system is the binary code corresponding to each switchable component, the pod method can be used for reading the binary code of the switchable component and switching the currently displayed source code into the binary code for any switchable component. Or, in the case that all source code switching identifications are not included and the currently displayed code in the system is the source code corresponding to each switchable component, for any switchable component, the pod method may be used to implement reading the source code of the switchable component and switching the currently displayed binary code to the source code. Specifically, the characteristics of the Cocoaps support plug-in can be utilized to assemble the method into a script, and the preset script is obtained. Further, the full source code switch identity detection method may be expressed as "all_source-! The method comprises the following steps of. The method for detecting all source code switching identifiers can be used for detecting each description in the description file to determine whether the description is a description representing all source code switching identifiers or not, and further determine whether all source code switching identifiers exist in the description file or not.
In the embodiment of the invention, the first operation or the second operation is firstly executed on the description file according to the actual display requirement, and the operation of judging whether all source code switching identifications exist is executed once after the first operation or the second operation is detected to be executed. In this way, unnecessary operations can be avoided from being performed without requiring one-touch switching. Meanwhile, corresponding switching display can be ensured to be carried out in time according to actual requirements.
Optionally, in an optional embodiment of the present invention, the operation of reading the source code corresponding to each switchable component in the system may include: and for any switchable component, acquiring the source code of the version indicated by the first component version corresponding to the switchable component. The operation of reading the binary code corresponding to each switchable component in the system may include: and for any switchable component, reading the binary code of the version indicated by the first component version corresponding to the switchable component. The first switchable component version is a version appointed in a switchable component version file corresponding to the system.
In particular, the component version file may be a file for indicating a code version of a switchable component required when switching the code of the switchable component. The component version file may include a version specification file of the switchable component or a version management file of the switchable component. Since the code version may iterate, the version required in the switching process can be indicated by setting the component version file, so that the acquisition operation can be conveniently performed. Further, the binary code of the version indicated by the first component version corresponding to the switchable component can be read from a preset code library, wherein the preset code library can be pre-stored with the binary code and the source code of each version of each switchable component, and the binary code and the source code of each version can be correspondingly stored in different storage catalogues of the preset code.
In the embodiment of the invention, when the source code or the binary code is acquired, the version to be acquired can be conveniently determined according to the component version file, so that the processing efficiency is improved to a certain extent. Meanwhile, through the set component version file, codes of corresponding versions can be conveniently controlled to be acquired when the display is switched, and further control efficiency is improved to a certain extent.
Further, the first component version may include a version number of the switchable component defined in the component version file and a version number of a component relied on in the switchable component. When the first component version is acquired, the version number of the switchable component can be searched in the component version file through the component information of the switchable component. And hooking (hook) the first preset method through a preset hook function to acquire the component information of all the components depending on the switchable component from the first preset method. Next, the version numbers of the respective switchable components of the dependency can be found in the component version file by the component information of all the components of the dependency. The component information may be a component name, a component number, and the like. The first preset method may be a sort_dependencies method.
Since the cocoaps software often calls a preset sort_dependencies method after arbitrating the dependency of the component. Therefore, compared with a manual searching mode, the method for acquiring the version number of the dependent component according to the first preset method can be used for quickly and conveniently determining the version number of the dependent component to a certain extent. In the embodiment of the invention, the version management file of the switchable component can be obtained through a second preset method of a preset hook function hook. Accordingly, the version numbers of all the components that are dependent on in the switchable component may be determined directly from the version management file. The second preset method may be a version resolution entry method, for example, a resolve method. Therefore, the acquisition is realized through the second preset method, so that the problem that the acquisition cannot be normally performed under certain conditions due to the limitation of the acquisition mode can be avoided. For example, the first preset method is effective only for scenes switched using the pod update command, and is ineffective for scenes switched using the pod install command.
Further, in one implementation, the source code of all switchable components may be stored in a first folder and the binary code of all switchable components may be stored in a second folder. The first folder and the second folder may be two subfiles (subspecs) under the podspec file in the cooapeds software. The podspec file may be created by a "pod create spec [ component name ]" command. The podspec file may be located in the Resource directory, i.e., stored in the Resource directory. The podspec file may carry version number information of the switchable component to facilitate viewing the version. Other resources may also exist in the Resource directory, for example, the QRAssists directory under the Resource directory may store picture resources to support the direct retrieval of Asset pictures supported by the system native from the Xcode compiler.
Further, the two subspecies may be a source branch and a lib branch, respectively, the source branch may be used to store source code and the lib branch may be used to store binary code. Further, the respective required materials can be configured under the two subspecies. The picture resource path can be configured through the resource_bundles to avoid errors like picture names among components. The storage address of the binary, header and source compressed package can be set through the s.source directory. Accordingly, obtaining the source code of the version indicated by the first component version corresponding to the switchable component may include: and acquiring source codes of versions indicated by the first component versions corresponding to the switchable components from the first folder.
Further, obtaining the binary code of the version indicated by the first component version corresponding to the switchable component may include: and acquiring the binary code of the version indicated by the first component version corresponding to the switchable component from the second folder. For example, the preset command pod 'QRBaseUIKitLib', '3.3.0.10' may be executed to achieve the acquisition of the binary code. Then executing the pod update or pod install command of the Cocoapod to realize the display of the directory where the binary code is located. Further, pod 'QRBaseUIKitLib/source', '3.3.0.10' may be performed to achieve the acquisition of source code. Then, a pod update or pod install command of the Cocoapod can be executed to realize displaying the directory where the source code is located. Therefore, the control of the subspecies can be directly switched according to the preset command without setting the environment variable for control, and the switching can be realized, so that the operation of removing the environment variable can be omitted, and the operation efficiency is improved.
Optionally, in an alternative embodiment of the present invention, a main engineering may be further included in the system, and each switchable component may be subjected to and invoked by the main engineering. Specifically, the main engineering may be a method function, where each switchable component may be called in the method function, and each switchable component may be a component engineering in the system. There may be a dependency between switchable components, for example, switchable component B and switchable component C may be invoked in switchable component a, i.e. switchable component a depends on switchable component B and switchable component C.
Accordingly, in the embodiment of the present invention, the following steps shown in fig. 1 to 3 may also be performed before the binary code is acquired according to the first component version, and before the source code is acquired according to the first component version:
step 301, for any switchable component, determining whether a second component version exists; the second component version includes a version number of the switchable component defined in a version specification file of the main project and a version number of a component dependent in the switchable component.
In the embodiment of the invention, the version specification file of the main project can be a file for characterizing the code version of the switchable component required to be called when the main project calls the switchable component. If this second component version exists, it is stated that the switchable component of the specified code version must now be used in order to ensure that the main project is running successfully. Further, the version number may be an identification for indicating a code version of the code, and version numbers corresponding to different code versions of different switchable components may be different. By way of example, the version numbers may be '2.12.5.11', '2.12.5.7', '2.12.5.6', '3.2.0.2', and so on.
Step 302, if the second component version exists, setting the version number in the first component version as the corresponding version number in the second component version.
In the embodiment of the invention, the value of the version number corresponding to the switchable component in the second component version can be assigned to the version number of the switchable component in the first component version, and the value of the version number corresponding to each component dependent on the switchable component in the second component version can be assigned to the version number of each component dependent on the switchable component in the first component version, so as to ensure that the first component version is consistent with the second component version.
In the embodiment of the invention, the obtained code version of the switchable component is set to be consistent with the code version of the switchable component used in the main engineering. Thus, the problem of main engineering operation errors caused by inconsistent versions after the subsequent code switching of the switchable component can be avoided. It should be noted that in the practical application scenario, there are two dependency modes between the switchable components, one is display dependency, and the second is implicit indirect dependency. In the second case, if the one-key switching of the switchable component code is directly performed, the problem that the main engineering dependent switchable component version and the switchable component dependent component version are inconsistent tends to occur more easily. Thus, in an embodiment of the present invention, the above step 301 and step 302 may be performed with indirect dependencies between switchable components.
Optionally, in an alternative embodiment of the present invention, the following steps may also be performed after step 301:
step 303, if the second component version does not exist, setting the version number in the first component version as the latest version number; and the main engineering calls the switchable component according to the latest version number.
For example, the latest version number may be obtained from the component version management file, and then the value of the latest version number may be assigned to the version number in the first component version. In the actual application scene, if the second component version does not exist, the current main engineering default calling of the switchable component of the latest version is described. Accordingly, the version number in the first component version can be set to be the latest version number, so that the consistency of the subsequently called version of the main project and the switched version is ensured, and the problem of main project operation errors caused by inconsistent versions after the subsequent code switching of the switchable component is avoided. Meanwhile, by setting the latest version number, the problem of poor processing effect caused by using codes of historical versions can be avoided.
Optionally, in an optional embodiment of the present invention, a soft link file may be generated according to the version specification file, and the soft link file may be stored in a preset position; the preset position is located outside the main project. In specific implementation, the soft link file can be generated according to a preset soft link generation algorithm and the path name of the version specification file. Accordingly, the soft link file may contain the pathname of the version specification file. Specific preset positions can be set according to actual requirements, and the embodiment of the invention is not limited to this. Further, the soft link file can also soft link the version specification file of the main project to the outside of the switchable component, so that synchronization is conveniently performed every time the version specification file of the main project is updated. In the embodiment of the invention, the corresponding relation between the storage position of the main project and the storage position of the switchable component can be established in the switchable component, so that the storage position of the main project can be conveniently and quickly obtained in the switchable component, and correspondingly, the packaging operation is often required to be carried out by combining the main project when the switchable component is packaged later, so that a foundation can be provided for subsequent automatic packaging, and the packaging efficiency is improved.
Accordingly, the operation of determining whether the second component version exists may be implemented by the sub-steps of:
substep (2): and reading the soft link file from the preset position.
In this step, the preset location may be accessed to read the soft link file.
Substep (3): if the reading is successful, searching a version corresponding to the component information according to the component information of the switchable component, the component information of the dependent component and the soft link file.
Specifically, the version specification file of the main project can be obtained according to the path name recorded in the soft link file. And then searching a version corresponding to the component information from the version specification file of the main project according to the component information. The component information may be a component name, a component number, and the like.
Further, if the reading fails, reminding information can be displayed; the reminding information is used for reminding a user that the soft link file cannot be read normally. Specifically, the reminding information may be voice type information, text type information, video type information, and the like. The specific content of the reminding information can be set according to actual requirements, and the embodiment of the invention is not limited to the specific content. In the embodiment of the invention, the user is reminded by returning the reminding information, so that the user can check the faults as soon as possible, and further, the follow-up smooth reading of the soft link file is ensured.
Substep (4): and if the version corresponding to the component information is found, determining that the second component version exists.
Specifically, if each component information corresponds to a version, then it can be considered that a second component version exists.
Substep (5): and if the version corresponding to the component information is not found, determining that the second component version does not exist.
Specifically, if there is component information that does not correspond to a version, it can be considered that there is no second component version. In the embodiment of the invention, the version designated file can be conveniently obtained by generating the soft link file and searching the corresponding version according to the soft link file and the component information, so that the processing efficiency can be improved to a certain extent.
Fig. 2 is a schematic diagram of a system processing provided in an embodiment of the present invention, as shown in fig. 2, for a base component, a base service component, a service component, and an event processing component that have a dependency relationship, step 401 may be performed first: and judging whether the mode is a source code mode. That is, it is determined whether the component needs to be switched to source code, step 402: if the mode is the source code mode, judging whether the mode is the all-switching mode. That is, a determination is made as to whether or not it is necessary to support switching of all switchable components to source code. Further, step 403 may be executed without switching the component to source code, i.e., without determining whether the first determination is in the source code mode or not: pod 'component name'. If all the modes are switched, step 404 is executed: the Podfile file is parsed specifically using DSL. Step 405: the component name is modified according to whether the component has a QR identifier or not, so that the component is marked as a switchable component. Specifically, after the component name is modified, a store_pod method preset by a hook is adopted to realize that the modified data is retransmitted into a method which needs to be executed by a specific command. The specific commands may include a pod install command and a pod update command. Accordingly, the source code switching can be performed on all the switchable components in the subsequent case that all the source code switching identifications are detected.
Further, step 406 may be performed without supporting all switchable components to be switched to source code and without switching the components to source code: pod 'component name/source', step 407: material is obtained from a source. Step 408 is then performed to again check whether it is in source mode to ensure accuracy. If so, step 409 may be performed: and obtaining a Class directory file. Wherein the Class directory file may store the source code of the component. If not, step 410 may be performed: and acquiring the file under the Release directory and the header file under the include directory. The binary code of the component can be stored in the file under the Release directory and the header file under the include directory.
In the embodiment of the invention, the switching operation for part of the components is separated from the switching operation for all the switchable components by setting all the switching modes, so that the single components can be flexibly switched according to actual requirements. Meanwhile, all components can be efficiently and conveniently switched by one key, and the switching efficiency is further improved.
Fig. 3 is a block diagram of a code switching apparatus for a component according to an embodiment of the present invention, which may be applied to a system including at least two switchable components, and as shown in fig. 3, the apparatus 50 may include:
A first determining module 501, configured to determine whether a description file corresponding to the system includes all preset source code switching identifiers.
And the first switching module 502 is configured to, if the all source code switching identifiers are included and the currently displayed code in the system is a binary code corresponding to each switchable component in the system, read the source code corresponding to each switchable component in the system, and switch the displayed binary code of each switchable component to the source code corresponding to each switchable component.
A second switching module 503, configured to, if the all source code switching identifiers are not included and a currently displayed code in the system is a source code corresponding to each switchable component, read a binary code corresponding to each switchable component, and switch the displayed source code of each switchable component to a binary code corresponding to each switchable component;
the binary code is obtained by converting the source code.
In summary, the code switching device for a component provided in the embodiment of the present invention may determine whether the description file corresponding to the system includes all preset source code switching identifiers, if all source code switching identifiers are included and the code currently displayed in the system is a binary code corresponding to each switchable component in the system, then the source code corresponding to each switchable component in the system is read, and the binary code of each displayed switchable component is switched to the source code corresponding to each switchable component, and if all source code switching identifiers are not included and the code currently displayed in the system is the source code corresponding to each switchable component, then the binary code corresponding to each switchable component is read, and the source code of each displayed switchable component is switched to the binary code corresponding to each switchable component. In this way, by defining all source code switching identifications for the system layer, correspondingly, one-key switching of a plurality of switchable components in the system can be realized only by judging whether all source code switching identifications exist. Compared with the mode of detecting the switchable component libraries corresponding to the switchable components one by one, the time consumption can be reduced, and the switching efficiency can be improved
Optionally, fig. 4 is a block diagram of a code switching apparatus of another component provided in an embodiment of the present invention, as shown in fig. 4, where the apparatus 50 further includes:
a first execution module 504, configured to execute a first operation on the description file to add the all source code switching identifiers in the description file, where source codes of all switchable components need to be displayed;
a second execution module 505, configured to execute a second operation on the description file to clear all the source code switching identifiers in the description file when all the source code switching identifiers are added to the description file and binary codes of all the switchable components need to be displayed;
accordingly, the first determining module 501 is specifically configured to:
and after the first operation or the second operation is detected to be executed on the description file, invoking all source code switching identification detection methods in a preset script, and traversing the description file to determine whether all source code switching identifications are contained in the description file.
Optionally, the first switching module 502 is specifically configured to: for any switchable component, reading source codes of a first component version corresponding to the switchable component;
The second switching module 503 is specifically configured to: for any switchable component, reading a binary code of a first component version corresponding to the switchable component;
the first component version is a version appointed in a component version file corresponding to the system.
Optionally, the system further comprises a main project, and each switchable component is called by the main project; the first component version comprises the version number of the switchable component defined in the component version file and the version number of the component dependent in the switchable component; fig. 5 is a block diagram of a code switching apparatus of another component provided in an embodiment of the present invention, as shown in fig. 5, the apparatus 50 further includes:
a second determining module 506, configured to determine, for any of the switchable components, whether a second component version exists; the second component version comprises the version number of the switchable component defined in the version specification file of the main project and the version number of the component dependent on the switchable component;
the first setting module 507 is configured to set, if the second component version exists, a version number in the first component version as a version number corresponding to the second component version.
Optionally, the apparatus 50 further includes:
a second setting module 508, configured to set a version number in the first component version as a latest version number if the second component version does not exist; and the main engineering calls the switchable component according to the latest version number.
Optionally, the apparatus 50 further includes:
a generating module 509, configured to generate a soft link file according to the version specification file; storing the soft link file to a preset position; the preset position is located outside the main project;
accordingly, the second determining module 506 is specifically configured to:
reading the soft link file from the preset position;
if the reading is successful, searching a version corresponding to the component information according to the component information of the switchable component, the component information of the dependent component and the soft link file;
if the version corresponding to the component information is found, determining that the second component version exists;
and if the version corresponding to the component information is not found, determining that the second component version does not exist.
Optionally, the second determining module 506 is further specifically configured to:
If the soft link file is not read, displaying reminding information; the reminding information is used for reminding a user that the soft link file cannot be read normally.
Optionally, fig. 6 is a block diagram of a code switching apparatus of another component provided in an embodiment of the present invention, as shown in fig. 6, where the apparatus 50 further includes: and the obtaining module 510 is configured to obtain a component with a preset identifier in the system, and take the component with the preset identifier as the switchable component.
For the above-described device embodiments, the description is relatively simple, as it is substantially similar to the method embodiments, with reference to the description of the method embodiments in part.
The embodiment of the invention also provides an electronic device, as shown in fig. 7, which comprises a processor 901, a communication interface 902, a memory 903 and a communication bus 904, wherein the processor 901, the communication interface 902 and the memory 903 are in communication with each other through the communication bus 904.
A memory 903 for storing a computer program;
the processor 901 is configured to determine whether a description file corresponding to the system includes all preset source code switching identifiers when executing a program stored in the memory 903;
If all source code switching identifications are included and the codes currently displayed in the system are binary codes corresponding to all switchable components in the system, reading the source codes corresponding to all the switchable components in the system, and switching the displayed binary codes of all the switchable components into the source codes corresponding to all the switchable components;
if all source code switching identifications are not included and the currently displayed codes in the system are source codes corresponding to all the switchable components, reading binary codes corresponding to all the switchable components, and switching the displayed source codes of all the switchable components into the binary codes corresponding to all the switchable components;
the binary code is obtained by converting the source code.
The communication bus mentioned by the above terminal may be a peripheral component interconnect standard (Peripheral Component Interconnect, abbreviated as PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, abbreviated as EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the terminal and other devices.
The memory may include random access memory (Random Access Memory, RAM) or non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP for short), etc.; but also digital signal processors (Digital Signal Processing, DSP for short), application specific integrated circuits (Application Specific Integrated Circuit, ASIC for short), field-programmable gate arrays (Field-Programmable Gate Array, FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In yet another embodiment of the present invention, a computer readable storage medium is provided, in which instructions are stored, which when run on a computer, cause the computer to perform the method of switching codes of the components described in any of the above embodiments.
In yet another embodiment of the present invention, there is also provided a computer program product containing instructions that, when run on a computer, cause the computer to perform the method of code switching of a component as described in any of the above embodiments.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may 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 loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present invention, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), etc.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, 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 one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims (8)

1. A method of code switching of a component, for application to a system comprising at least two switchable components, the method comprising:
judging whether the description file corresponding to the system contains all preset source code switching identifiers or not;
if all source code switching identifications are included and the codes currently displayed in the system are binary codes corresponding to all switchable components in the system, for any switchable component, reading the source codes of a first component version corresponding to the switchable component, and switching the displayed binary codes of all the switchable components into the source codes corresponding to all the switchable components; the first component version is a version appointed in a component version file corresponding to the system;
if all source code switching identifications are not included and the currently displayed codes in the system are source codes corresponding to all the switchable components, for any switchable component, reading binary codes of a first component version corresponding to the switchable component, and switching the displayed source codes of all the switchable components into binary codes corresponding to all the switchable components;
Wherein the binary code is obtained by converting according to the source code;
the system also comprises a main project, and each switchable component is called by the main project; the first component version comprises the version number of the switchable component defined in the component version file and the version number of the component dependent in the switchable component; the method further comprises the steps of: judging whether a second component version exists for any switchable component; the second component version comprises the version number of the switchable component defined in the version specification file of the main project and the version number of the component dependent on the switchable component;
if the second component version exists, setting the version number in the first component version as the corresponding version number in the second component version;
if the second component version does not exist, setting the version number in the first component version as the latest version number; and the main engineering calls the switchable component according to the latest version number.
2. The method of claim 1, wherein before determining whether the description file corresponding to the system includes all preset source code switching identifiers, the method further includes:
Under the condition that source codes of all switchable components need to be displayed, executing first operation on the description file so as to add all source code switching identifications in the description file;
under the condition that all source code switching identifications are added in the description file and binary codes of all switchable components need to be displayed, executing second operation on the description file so as to clear all source code switching identifications in the description file;
correspondingly, the judging whether the description file corresponding to the system contains all preset source code switching identifiers comprises the following steps:
and after the first operation or the second operation is detected to be executed on the description file, invoking all source code switching identification detection methods in a preset script, and traversing the description file to determine whether all source code switching identifications are contained in the description file.
3. The method of claim 1, wherein prior to said determining whether the second component version exists, the method further comprises:
generating a soft link file according to the version specification file; storing the soft link file to a preset position; the preset position is located outside the main project;
Accordingly, the determining whether the second component version exists includes:
reading the soft link file from the preset position;
if the reading is successful, searching a version corresponding to the component information according to the component information of the switchable component, the component information of the dependent component and the soft link file;
if the version corresponding to the component information is found, determining that the second component version exists;
and if the version corresponding to the component information is not found, determining that the second component version does not exist.
4. A method according to claim 3, characterized in that the method further comprises:
if the soft link file is not read, displaying reminding information; the reminding information is used for reminding a user that the soft link file cannot be read normally.
5. The method of claim 1, wherein prior to reading the source code of the first component version corresponding to the switchable component, the method further comprises:
and acquiring a component with a preset identifier in the system, and taking the component with the preset identifier as the switchable component.
6. A code switching device for a component, for application to a system comprising at least two switchable components, the device comprising:
The first judging module is used for judging whether the description file corresponding to the system contains all preset source code switching identifiers or not;
the first switching module is used for reading the source codes corresponding to all the switchable components in the system and switching the displayed binary codes of all the switchable components into the source codes corresponding to all the switchable components if all the source code switching identifications are contained and the codes currently displayed in the system are the binary codes corresponding to all the switchable components in the system;
the second switching module is used for reading the binary codes corresponding to the switchable components if all the source code switching identifications are not contained and the codes currently displayed in the system are the source codes corresponding to the switchable components, and switching the source codes of the switchable components to the binary codes corresponding to the switchable components;
wherein the binary code is obtained by converting according to the source code;
the first switching module is specifically configured to: for any switchable component, reading source codes of a first component version corresponding to the switchable component;
The second switching module is specifically configured to: for any switchable component, reading a binary code of a first component version corresponding to the switchable component;
the first component version is a version appointed in a component version file corresponding to the system;
the system also comprises a main project, and each switchable component is called by the main project; the first component version comprises the version number of the switchable component defined in the component version file and the version number of the component dependent in the switchable component; the apparatus further comprises:
the second judging module is used for judging whether a second component version exists for any switchable component; the second component version comprises the version number of the switchable component defined in the version specification file of the main project and the version number of the component dependent on the switchable component;
the first setting module is used for setting the version number in the first component version as the corresponding version number in the second component version if the second component version exists;
optionally, the apparatus further includes:
the second setting module is used for setting the version number in the first component version as the latest version number if the second component version does not exist; and the main engineering calls the switchable component according to the latest version number.
7. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for carrying out the method steps of any one of claims 1-5 when executing a program stored on a memory.
8. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-5.
CN202011497972.8A 2020-12-17 2020-12-17 Method and device for switching codes of components, electronic equipment and readable storage medium Active CN112558975B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011497972.8A CN112558975B (en) 2020-12-17 2020-12-17 Method and device for switching codes of components, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011497972.8A CN112558975B (en) 2020-12-17 2020-12-17 Method and device for switching codes of components, electronic equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN112558975A CN112558975A (en) 2021-03-26
CN112558975B true CN112558975B (en) 2023-09-01

Family

ID=75063053

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011497972.8A Active CN112558975B (en) 2020-12-17 2020-12-17 Method and device for switching codes of components, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN112558975B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1399737A (en) * 1999-09-24 2003-02-26 凤凰技术有限公司 Software development system for facilitating selection of components
JP2009211491A (en) * 2008-03-05 2009-09-17 Oki Semiconductor Co Ltd Program preparation method and device therefor
CN104063258A (en) * 2013-03-21 2014-09-24 国际商业机器公司 Code dynamic switching method and system for debugging process
CN110377523A (en) * 2019-07-24 2019-10-25 网易(杭州)网络有限公司 Program debugging method and device, electronic equipment and storage medium
CN110750310A (en) * 2019-09-28 2020-02-04 同程网络科技股份有限公司 Binary and source code switching method based on IOS system componentization development

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6820255B2 (en) * 1999-02-17 2004-11-16 Elbrus International Method for fast execution of translated binary code utilizing database cache for low-level code correspondence
US20060020930A1 (en) * 2004-07-23 2006-01-26 Press - Sense Ltd. System and method of identifying source code associated with a displayed component
US8645934B2 (en) * 2010-05-06 2014-02-04 International Business Machines Corporation Simultaneous compiler binary optimizations

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1399737A (en) * 1999-09-24 2003-02-26 凤凰技术有限公司 Software development system for facilitating selection of components
JP2009211491A (en) * 2008-03-05 2009-09-17 Oki Semiconductor Co Ltd Program preparation method and device therefor
CN104063258A (en) * 2013-03-21 2014-09-24 国际商业机器公司 Code dynamic switching method and system for debugging process
CN110377523A (en) * 2019-07-24 2019-10-25 网易(杭州)网络有限公司 Program debugging method and device, electronic equipment and storage medium
CN110750310A (en) * 2019-09-28 2020-02-04 同程网络科技股份有限公司 Binary and source code switching method based on IOS system componentization development

Also Published As

Publication number Publication date
CN112558975A (en) 2021-03-26

Similar Documents

Publication Publication Date Title
CN111124906B (en) Tracking method, compiling method and device based on dynamic embedded points and electronic equipment
CN108399132B (en) Scheduling test method, device and storage medium
CN106844136B (en) Method and system for collecting program crash information
CN110287696B (en) Detection method, device and equipment for rebound shell process
CN111427596B (en) Software upgrading method and device and terminal equipment
CN110365724B (en) Task processing method and device and electronic equipment
CN111666091A (en) System updating method, device, electronic equipment and computer readable storage medium
CN113835713B (en) Source code packet downloading method, device, computer equipment and storage medium
CN113050984A (en) Resource calling method and device, electronic equipment and storage medium
CN112099800A (en) Code data processing method and device and server
US11422917B2 (en) Deriving software application dependency trees for white-box testing
CN111045941A (en) Positioning method and device of user interface control and storage medium
CN113821226A (en) ONIE system installation method, apparatus, device and medium
CN113448650A (en) Live broadcast function plug-in loading method, device, equipment and storage medium
US11210110B2 (en) Application library analytics tool
CN111443920B (en) Frame migration method and device
CN112558975B (en) Method and device for switching codes of components, electronic equipment and readable storage medium
KR20180098584A (en) Method and apparatus for executing APP program
CN109375946B (en) Method and system for managing component package of node package manager
CN111338655A (en) Installation package distribution method and system
CN108037914B (en) Method and device for developing android native system by combining js
CN106778270B (en) Malicious application detection method and system
CN112965697B (en) Code file generation method and device and electronic equipment
CN114791884A (en) Test environment construction method and device, storage medium and electronic equipment
CN111367796B (en) Application program debugging method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant