Automatic deployment method and device for compiled file, terminal equipment and storage medium
By monitoring the compilation events in real time and writing to the firmware automatically based on file information, the inefficiency problem caused by manual burning of compiled files in development projects is solved, and the automatic deployment of compiled files is realized, and the development efficiency is improved.
Patent Information
- Application Number
- CN202411890318.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-11
AI Technical Summary
In the development project, the compiled compiled files need to be manually burned into the firmware for testing and debugging, resulting in a lot of boring and repeated manual interventions, which reduces work efficiency.
Provides an automatic deployment method for compiling files. By listening to the compilation events of the target folder in real time, obtaining the file information of the compiled file, determining the file type based on the file information, and calling the corresponding configuration parameters according to the file type, and automatically writing the compiled file into the firmware.
Reduce the repetitive work of developers, automate the burning process, and improve development efficiency.
Smart Images

Figure CN119806561A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer control technology, and in particular to a method, apparatus, terminal device and storage medium for automatically deploying compiled files. Background Art
[0002] In the development project, in addition to developing the code, developers also need to burn the compiled files into the firmware for testing and debugging. The deployment of each compiled file requires a lot of boring and repetitive manual intervention, which is an unnecessary waste for developers, and the steps are complicated and time-consuming. There is no optimized operation in the existing technology, which greatly reduces work efficiency. Summary of the invention
[0003] In view of this, the embodiments of the present application provide a method, apparatus, terminal device and storage medium for automatically deploying compiled files, which can effectively solve problems such as low work efficiency.
[0004] In a first aspect, an embodiment of the present application provides a method for automatically deploying a compiled file, comprising:
[0005] Monitor the compilation event of the target folder in real time, and when the compilation event is monitored, monitor whether the compilation event is completed;
[0006] When the compilation event is completed, obtaining file information of the compiled file after the target folder is compiled, and determining the file type of the compiled file according to the file information;
[0007] According to the file type, corresponding configuration parameters are called, and according to the configuration parameters, the compiled file is written into the firmware.
[0008] In one embodiment, the file information includes a file suffix and magic information;
[0009] The determining the file type of the compiled file according to the file information includes:
[0010] The determining the file type of the compiled file according to the file information includes:
[0011] When the magic information is preset Linux application information, the file type is determined to be a Linux application;
[0012] When the file suffix is apk and the magic information is preset Android application information, the file type is determined to be an Android application;
[0013] When the file suffix is img, the file type is determined to be a partition image;
[0014] When the file type is not one of the above three, it is determined that the file type is a configuration file.
[0015] In one embodiment, calling corresponding configuration parameters according to the file type includes:
[0016] When the file type is a Linux application, calling the deployment path, related process name and restart parameters of the Linux application;
[0017] When the file type is an Android application, calling the deployment path and package name of the Android application;
[0018] When the file type is a partition image, calling the installation partition of the partition image;
[0019] When the file type is a configuration file, the deployment path, related process name and restart parameters of the configuration file are called.
[0020] In one embodiment, writing the compiled file into the firmware according to the configuration parameters includes:
[0021] When the file type is the partition image, the partition image is burned into the installation partition through a preset installation instruction.
[0022] In one embodiment, writing the compiled file into the firmware according to the configuration parameters includes:
[0023] When the file type is the configuration file, it is deployed according to the deployment path, and it is determined whether the process configuration corresponding to the relevant process name exists. If it exists, the corresponding service is restarted, and if it does not exist, the system is restarted.
[0024] In one embodiment, writing the compiled file into the firmware according to the configuration parameters includes:
[0025] When the file type is the Android application, installing the Android application on the firmware according to the deployment path;
[0026] Restart the corresponding application process according to the package name.
[0027] In one embodiment, writing the compiled file into the firmware according to the configuration parameters includes:
[0028] When the file type is the Linux application, first determine whether it is a priority application according to the restart parameters;
[0029] If it is a priority application, the Linux application is written into the firmware according to the deployment path, and then the system is restarted. If it is not a priority application, the corresponding application process is restarted according to the related process name.
[0030] In a second aspect, the present application also provides a compiled file automatic deployment device, comprising:
[0031] A monitoring module is used to monitor the compilation event of the target folder in real time, and when the compilation event is monitored, monitor whether the compilation event is completed;
[0032] an identification module, configured to obtain file information of a compiled file after the target folder is compiled when the compilation event is completed, and determine a file type of the compiled file according to the file information;
[0033] The burning module is used to call corresponding configuration parameters according to the file type and write the compiled file into the firmware according to the configuration parameters.
[0034] In a third aspect, the present application further provides a terminal device, the terminal device comprising a processor and a memory, the memory storing a computer program, and the processor being used to execute the computer program to implement the automatic deployment method of compiled files.
[0035] In a fourth aspect, the present application further provides a computer-readable storage medium storing a computer program, which, when executed on a processor, implements the method for automatic deployment of compiled files.
[0036] The embodiments of the present application have the following beneficial effects:
[0037] The automatic deployment method of compiled files of the present application triggers work by automatic monitoring, identifies the type of compiled files by obtaining file information, obtains corresponding configuration parameters according to the type of compiled files, and then performs corresponding burning work, automatically writing the compiled files into the firmware, thereby reducing the repetitive work of developers and automating the entire burning process, thereby increasing development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0039] Figure 1 A schematic diagram of a process flow of a method for automatically deploying compiled files according to an embodiment of the present application is shown;
[0040] Figure 2 A schematic diagram of a process flow of another method for automatically deploying compiled files according to an embodiment of the present application is shown;
[0041] Figure 3 A schematic diagram of the structure of an automatic deployment device for compiled files according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0042] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.
[0043] The components of the embodiments of the present application generally described and shown in the drawings herein may be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0044] Hereinafter, the terms "including", "having" and their cognates that can be used in various embodiments of the present application are intended only to indicate specific features, numbers, steps, operations, elements, components or a combination of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or a combination of the foregoing items or increasing the possibility of one or more features, numbers, steps, operations, elements, components or a combination of the foregoing items. In addition, the terms "first", "second", "third" and the like are only used to distinguish descriptions and cannot be understood as indicating or implying relative importance.
[0045] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art in the various embodiments of the present application. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present application.
[0046] The deployment and debugging of each module in the development project requires a lot of boring and repetitive manual intervention, which is an unnecessary consumption for developers. The present application provides a method for automatically deploying compiled files, which monitors the compilation events of the target folder in real time, obtains the compilation instructions when the compilation events are monitored, and obtains the compilation information according to the compilation instructions; determines the type of the compiled file after the compilation is completed according to the compilation information; calls the corresponding configuration parameters according to the type of the compiled file, and writes the compiled file into the firmware according to the configuration parameters. This allows the compiled compiled file to be automatically written into the firmware in an appropriate manner.
[0047] Figure 1 A flow chart of the automatic deployment method of compiled files in an embodiment of the present application is shown. Exemplarily, the automatic deployment method of compiled files includes the following steps:
[0048] Step S100, monitoring the compilation event of the target folder in real time, and when the compilation event is monitored, monitoring whether the compilation event is completed.
[0049] In development projects, developers often develop and compile programs on a work computer or server environment. However, the compiled program needs to be burned into the corresponding firmware before debugging. Therefore, all compiled files generated during development are debugging modules used for debugging.
[0050] Among them, the project file will be stored in a specific folder. The user needs to compile the project file in the folder through the compilation command. After the compilation, the compiled file needs to be burned into the firmware. Therefore, the method of this embodiment will monitor the compilation event of the target folder in real time. As long as a compilation event occurs, the method program of this embodiment will be activated, and the folder will continue to be monitored until the compilation event ends to obtain the compiled file.
[0051] The compilation instructions are generally set through make or build, which start the compilation script for compilation operations. The compilation instructions are generally followed by the name of the project to be compiled and related parameters. These compilation information can indicate information such as the type of file to be compiled.
[0052] The way to monitor the target folder is to directly monitor the folder path. As long as the compilation script in it is called and run, you can start to pay attention to the path of the generated compilation file in it, so as to prepare for obtaining the compilation file next.
[0053] Whether the compilation event is completed can be determined by determining whether the compilation process has died. As long as the compilation process has died, it means that the compilation event has ended, and the latest compilation file will exist in the corresponding path.
[0054] Step S200, when the compilation event is completed, obtaining file information of the compiled file after the target folder is compiled, and determining the file type of the compiled file according to the file information.
[0055] After the file is compiled, you can get the name, suffix, path and magic information of the compiled file at the same time. The magic information is a unique identifier used to confirm the type of the file. These identifiers are pre-set and can be used to determine the type of compiled file.
[0056] Compiled files are generally stored in specified paths according to compilation instructions. Therefore, when there is compilation action in the monitoring folder, you can monitor whether compiled files are generated under these paths. After the compilation program is executed, you can obtain these compiled files and obtain relevant information such as the name, suffix, path, magic information, etc. of the compiled files.
[0057] In one embodiment, the compiled files can be divided into four types, namely Android applications, Linux applications, partition images and configuration files. These four files are compiled files obtained after compiling according to different program contents. For example, the Android application is a file formed after compiling part of the code developed for the Android system in the entire project.
[0058] A partition image is a file obtained by compiling the entire project file. It is the representative of the entire project file and contains all the contents of the entire project. It is the largest file. To determine whether it is a partition image, you can use its suffix img and if it is at the same level as the compiled output path of the target device, then it can be determined to be a partition image.
[0059] Linux application files can be identified by their magic information. For example, if the magic information corresponding to the Linux application is preset to "0x7f, 0x45, 0x4c, 0x46", then when the obtained magic information is "0x7f, 0x45, 0x4c, 0x46", it can be determined that the file is a Linux file.
[0060] The judgment method for Android applications is similar. In addition to setting the magic information to "0x50, 0x4B, 0x03, 0x04", you also need to see whether its suffix is apk. If the magic information corresponds and the suffix is also apk, then it can be determined that the compiled file is an Android application.
[0061] After identification, if the file does not belong to any of the above types, it will be regarded as a configuration file by default.
[0062] It is understandable that the methods and locations of burning the above four compiled files into the firmware are different, so they need to be identified first, and then the corresponding operations are performed according to the differences of each file.
[0063] Step S300, calling corresponding configuration parameters according to the file type, and writing the compiled file into the firmware according to the configuration parameters.
[0064] Different file types have different corresponding configuration parameters. Configuration parameters are used to indicate how to burn these compiled files, what path to burn them to, and what operations need to be performed after burning. The configuration parameters can be called in the form of configuration files, and each file type corresponds to a corresponding configuration file. The name of each configuration file can be the name of the file type, and the calling method can be to traverse each configuration file according to the file type name. After traversing to the corresponding configuration file, the corresponding configuration file is called for the current compiled file, thereby realizing the operation of calling the corresponding configuration parameters.
[0065] For Android applications, the required configuration parameters may be the deployment path and package name, and in one embodiment, may also include the name of the component that is automatically started after deployment, etc. After deployment according to the deployment path, the corresponding application process may be started according to the package name, or the related components may be started according to the name of the automatically started component to implement the application of the new module.
[0066] For example, for a Linux application ELF, the corresponding configuration parameters may be a deployment path, a related process name, and a restart parameter, etc. The restart parameter is used to set whether the system needs to be restarted after the Linux application is re-burned.
[0067] For example, for a compilation file of the configuration file type, the corresponding configuration parameters may be a deployment path, a related process name, and a restart parameter, which are used to indicate the installation location of the compilation file, as well as the corresponding application process and restart mode.
[0068] For example, for a compilation file of a partition image, the required configuration parameter is the installation partition, which is used to indicate the partition to which the partition image is to be installed.
[0069] After determining the configuration parameters corresponding to the compilation file, you can implement the corresponding burning work according to the configuration parameters.
[0070] During installation, the program will automatically use shell commands to perform the corresponding burning operations. These commands are pre-set commands. As long as the name of the compiled file to be burned and related parameters are entered, the burning can be completed.
[0071] In particular, if the current compiled file is an Android application file, you can deploy it through adb according to the preset path, and then use the package name to restart the corresponding application process.
[0072] In addition, if it is an Android application, there is also a situation where there is no preset corresponding configuration parameters. In this case, the corresponding packaging path will be used for deployment, and then a tool (apktool) will be used to automatically extract and parse the package name, and then the application process will be restarted.
[0073] The above tool operations require running adbd as the root user and using corresponding commands to perform corresponding operations. For example, a soft reboot: adb shell svc power reboot userspace or adb reboot userspace. The deployment command can be adb push <source path> <destination path>.
[0074] Stop the process: adb shell kill -9`adb shell ps|grep <process name e>|awk'{print$2}'`.
[0075] Start the application: adb shell am start-n "$(adb shell "cmd package resolve-activity --brief $1 | tail-n 1")".
[0076] Restart the service: adb shell setpropctl.restart <service>. The above command can be used to deploy local files to the firmware and perform the required restart operation.
[0077] For different types of compiled files, the parameters for burning are different, and the corresponding operations are also different. For demonstration purposes, Figure 2 A possible burning process is shown.
[0078] When the compiled file is a configuration file, it is deployed directly according to its deployment path, and it is determined whether the process configuration corresponding to the relevant process name exists. If it exists, the corresponding service is restarted, and if it does not exist, the system is restarted.
[0079] When the compiled file is a partition image, the partition image is burned into the installation partition in the boot program through the preset installation instructions. Specifically, it is necessary to restart the system through a command, and then enter the boot program such as bootloader or fastboot to burn the partition image into the installation partition.
[0080] When the file type is the Linux application, first determine whether it is a priority application according to a restart parameter, where the restart parameter is a pre-set parameter for how to restart the Linux application after the burning is completed.
[0081] If it is a priority application, the Linux application is written into the firmware according to the deployment path, and then the system is restarted. If it is not a priority application, the corresponding application process is restarted according to the related process name. The application process restarted here is an application related to the Linux application, for example, the process will call the Linux application or be used to execute the Linux application, etc. These processes need to be restarted to make the updated content take effect.
[0082] Priority application refers to the application that is more important to the system than other applications. The standard for whether the Linux application is a priority application can be determined based on the layer where the application is located. For example, an application running in the bottom driver can be considered a priority application, while an application running in the network layer or application layer is not considered a priority application. It can also be determined based on the impact on system stability. There are many different judgment methods, which will not be explained here.
[0083] When the file type is the Android application, it is first determined whether the aforementioned configuration parameters are obtained, and if so, the Android application is installed on the firmware according to the deployment path, and then the application process corresponding to the package name is restarted according to the preset package name, where the preset package name is the package name of the file package of the Android application.
[0084] If no configuration parameters are obtained, the above deployment paths are in the default state. At this time, you need to use tools to parse the packaging path and the preset package name, deploy the Android application according to the parsed packaging path, and then restart the application process according to the parsed preset package name.
[0085] Because the default package name contains the name of the Android application, which is consistent with the application process, when you restart the application process, you will start with the package name for parsing.
[0086] The automatic deployment method of compiled files in this embodiment monitors compilation events, and then classifies different types of compiled files according to file information. At the same time, different configuration parameters are set for different types of compiled files, and then the compiled files are automatically written into the firmware according to the configuration parameters. During the whole process, the developer only needs to keep the firmware and the computer connected, and execute the compilation instructions. The remaining burning operations are automatically completed by the program, and the developer does not need to worry about it, which greatly reduces the developer's repetitive work and increases work efficiency.
[0087] Figure 3A schematic diagram of the structure of the automatic deployment device of the compiled file in the embodiment of the present application is shown. Exemplarily, the device includes:
[0088] The monitoring module 10 is used to monitor the compilation event of the target folder in real time, and when the compilation event is monitored, monitor whether the compilation event is completed;
[0089] An identification module 20 is used to obtain file information of the compiled file after the target folder is compiled when the compilation event is completed, and determine the file type of the compiled file according to the file information;
[0090] The burning module 30 is used to call corresponding configuration parameters according to the file type, and write the compiled file into the firmware according to the configuration parameters.
[0091] The present application also provides a terminal device, which includes a processor and a memory, wherein the memory stores a computer program, and the processor is used to execute the computer program to implement the automatic deployment method of compiled files.
[0092] The terminal device can be a computer, a server, or other terminal devices that can be used for development, testing, and debugging.
[0093] The present application also provides a computer-readable storage medium storing a computer program, which implements the automatic deployment method of compiled files when executed on a processor.
[0094] It can be understood that the device of this embodiment corresponds to the method of the above embodiment, and the options in the above embodiment are also applicable to this embodiment, so they will not be described repeatedly here.
[0095] Among them, the processor can be an integrated circuit chip with signal processing capabilities. The processor can be a general-purpose processor, including a central processing unit (CPU), a graphics processing unit (GPU) and a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or at least one of other programmable logic devices, discrete gates or transistor logic devices, and discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc., which can implement or execute the disclosed methods, steps and logic block diagrams in the embodiments of the present application.
[0096] The memory may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc. The memory is used to store a computer program, and the processor may execute the computer program accordingly after receiving an execution instruction.
[0097] The computer-readable storage medium of the present application is used to store the computer program used in the above-mentioned terminal device. For example, the computer-readable storage medium may include, but is not limited to, various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0098] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow diagram, and the combination of boxes in the structure diagram and / or the flow diagram, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0099] In addition, the functional modules or units in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0100] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application.
[0101] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.
Claims
1. A method for automatically deploying compiled files, characterized in that: include: Monitor the compilation event of the target folder in real time, and when the compilation event is monitored, monitor whether the compilation event is completed; When the compilation event is completed, obtaining file information of the compiled file after the target folder is compiled, and determining the file type of the compiled file according to the file information; According to the file type, corresponding configuration parameters are called, and according to the configuration parameters, the compiled file is written into the firmware.
2. The method for automatically deploying compiled files according to claim 1, characterized in that: The file information includes file suffix and magic information; The determining the file type of the compiled file according to the file information includes: When the magic information is preset Linux application information, the file type is determined to be a Linux application; When the file suffix is apk and the magic information is preset Android application information, the file type is determined to be an Android application; When the file suffix is img, the file type is determined to be a partition image; When the file type is not one of the above three, it is determined that the file type is a configuration file.
3. The method for automatically deploying compiled files according to claim 1, characterized in that: The calling of corresponding configuration parameters according to the file type includes: When the file type is a Linux application, calling the deployment path, related process name and restart parameters of the Linux application; When the file type is an Android application, calling the deployment path and package name of the Android application; When the file type is a partition image, calling the installation partition of the partition image; When the file type is a configuration file, the deployment path, related process name and restart parameters of the configuration file are called.
4. The method for automatically deploying compiled files according to claim 3, characterized in that: Writing the compiled file into the firmware according to the configuration parameters includes: When the file type is the partition image, the partition image is burned into the installation partition through a preset installation instruction.
5. The method for automatically deploying compiled files according to claim 3, characterized in that: Writing the compiled file into the firmware according to the configuration parameters includes: When the file type is the configuration file, it is deployed according to the deployment path, and it is determined whether the process configuration corresponding to the relevant process name exists. If so, the corresponding service is restarted; if not, the system is restarted.
6. The method for automatically deploying compiled files according to claim 3, characterized in that: Writing the compiled file into the firmware according to the configuration parameters includes: When the file type is the Android application, installing the Android application on the firmware according to the deployment path; Restart the corresponding application process according to the package name.
7. The method for automatically deploying compiled files according to claim 3, characterized in that: Writing the compiled file into the firmware according to the configuration parameters includes: When the file type is the Linux application, first determine whether it is a priority application according to the restart parameters; If it is a priority application, the Linux application is written into the firmware according to the deployment path, and then the system is restarted. If it is not a priority application, the corresponding application process is restarted according to the related process name.
8. A compiled file automatic deployment device, characterized in that: include: A monitoring module is used to monitor the compilation event of the target folder in real time, and when the compilation event is monitored, monitor whether the compilation event is completed; an identification module, configured to obtain file information of a compiled file after the target folder is compiled when the compilation event is completed, and determine a file type of the compiled file according to the file information; The burning module is used to call corresponding configuration parameters according to the file type and write the compiled file into the firmware according to the configuration parameters.
9. A terminal device, characterized in that: The terminal device comprises a processor and a memory, wherein the memory stores a computer program, and the processor is configured to execute the computer program to implement the method for automatically deploying compiled files according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer program is stored therein, and when the computer program is executed on a processor, the method for automatically deploying compiled files according to any one of claims 1 to 7 is implemented.