File compiling method, file compiling system and electronic equipment

By encapsulating the object code into a module and selecting the corresponding platform architecture compilation parameters, the problem of inefficient compilation of multi-architecture and multi-products is solved, and efficient cross-platform construction is achieved.

CN120371304APending Publication Date: 2025-07-25SHANGHAI LONGSYS DIGITAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410097362.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-23
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

The existing technology has low compilation efficiency and high switching costs during multi-architecture and multi-product compilation, making it difficult to support multi-product construction and maintenance under different architectures on different platforms.

Method used

Provide a file compilation method, encapsulate the target code into module code configuration files, strip away product parameters to generate product parameter configuration files, and select corresponding platform architecture compilation parameters for module code configuration files, supporting the construction and compilation of multiple products and multiple platform architectures.

Benefits of technology

It improves the file compilation efficiency of multiple products, multiple platforms and multiple architectures, simplifies the development process, reduces the switching cost of the compilation system, and supports cross-platform construction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371304A_ABST
    Figure CN120371304A_ABST
Patent Text Reader

Abstract

The invention discloses a file compiling method, a file compiling system and electronic equipment. The method comprises the following steps: acquiring a construction command; determining at least one product configuration parameter file and at least one module code configuration file based on the construction command, wherein each module code configuration file corresponds to a platform architecture compiling parameter; and performing file compiling according to the platform architecture compiling parameters, the at least one product configuration parameter file and the at least one module code configuration file to obtain at least one target file. Through the mode, the technical problem that the compiling efficiency is low when multi-framework multi-product compiling is carried out is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software development, and particularly to a file compilation method, a file compilation system, and an electronic device. Background Art

[0002] In the field of software development, the construction of product code usually requires multiple compilation builds. It mainly relies on developers, that is, users, to compile files by themselves, and at the same time, users also need to perform subsequent maintenance on the written files, which requires users to be familiar with the writing of scripts in this environment. With the development and progress of technology, there are various product development environments. In the prior art, the compilation system is usually for the compilation of a specific product under a certain platform architecture. When facing a variety of development environments, if a user wants to obtain products under different platforms and different architectures, it not only does not support the simultaneous construction of multiple products under different platforms and different architectures, the compilation efficiency is low, but also the cost of switching the compilation system is relatively high, which is not convenient for users to maintain. Summary of the Invention

[0003] The main purpose of this application is to provide a file encoding method, a file compilation system, and an electronic device, which can solve the technical problem of low compilation efficiency when performing multi-architecture and multi-product compilation.

[0004] To solve the above technical problem, the first technical solution adopted by this application is: to provide a file compilation method. The method includes obtaining a build command; determining at least one product configuration parameter file and at least one module code configuration file based on the build command, and each module code configuration file corresponds to a platform architecture compilation parameter; performing file compilation according to the platform architecture compilation parameter, at least one product configuration parameter file, and at least one module code configuration file to obtain at least one target file.

[0005] To solve the above technical problem, the second technical solution adopted by this application is: to provide a file compilation system. The system includes a product parameter configuration unit for configuring a product parameter configuration file; a module code configuration unit for configuring a module code configuration file; a platform architecture compilation configuration unit for configuring a platform architecture compilation parameter; and a compilation unit connected to the product parameter configuration unit, the module code configuration unit, and the platform architecture configuration unit to implement the file compilation method described in the first technical solution.

[0006] To solve the above technical problem, the third technical solution adopted by this application is: to provide an electronic device. The electronic device includes a memory and a processor, and the memory is used to store program data, and the program data can be executed by the processor to implement the file compilation method described in the first technical solution.

[0007] The beneficial effects of the present application are as follows: The target code is encapsulated into a module as a module code configuration file, and then the parameters of the product are stripped to generate a product parameter configuration file, enabling it to support the construction and compilation of multiple products. The corresponding product parameters are selected for the module code configuration file, and the platform architecture compilation parameters are stripped, enabling it to support the construction and compilation of multiple platforms and multiple architectures. The corresponding platform architecture compilation configuration is selected for the module code configuration file. By the above method, when developing a product, the corresponding product parameters and platform architecture compilation parameters are set for the module code configuration file corresponding to each target code file, so as to improve the compilation efficiency when compiling files of multiple products, multiple platforms, and multiple architectures. Brief Description of the Drawings

[0008] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings required for the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention, and those of ordinary skill in the art can obtain other drawings based on these drawings without creative efforts.

[0009] Figure 1 It is a flowchart of the first embodiment of the compilation method of the present application file;

[0010] Figure 2 It is a flowchart of the second embodiment of the compilation method of the present application file;

[0011] Figure 3 It is a flowchart of the third embodiment of the compilation method of the present application file;

[0012] Figure 4 It is a flowchart of the fourth embodiment of the compilation method of the present application file;

[0013] Figure 5 It is a schematic structural diagram of an embodiment of the compilation system of the present application file;

[0014] Figure 6 It is a schematic structural diagram of an embodiment of the electronic device of the present application. Detailed Embodiments

[0015] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts belong to the scope of protection of the present application.

[0016] The terms "first", "second", etc. in this application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally further include steps or units not listed, or may optionally further include other steps or units inherent to these processes, methods, products or devices.

[0017] Referring to "embodiments" herein means that the specific features, structures or characteristics described in connection with the embodiments can be included in at least one embodiment of this application. The phrase appearing at various positions in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art will explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.

[0018] Referring to Figure 1 , Figure 1 is a schematic flowchart of the first embodiment of the compilation method for the application file of this application. It includes the following steps:

[0019] S11: Obtain a build command.

[0020] S12: Determine at least one product configuration parameter file and at least one module code configuration file based on the build command, and each module code configuration file corresponds to a platform architecture compilation parameter.

[0021] The build command is used to indicate which module code configuration files need to be compiled and built, and which product configuration parameter files and platform architecture compilation parameters these module code configuration files correspond to.

[0022] The module code file includes information such as the target code file to be compiled and path parameters. The product configuration parameter file includes the configuration parameters of the product applicable to the compiled file. For example, in the storage field, for a storage product, its product configuration parameter file may include configuration parameters such as capacity, storage medium type, storage medium speed, and main control type. The platform architecture compilation parameter includes configuration parameters such as the platform, architecture, and compiler applicable to the compiled file. Each module code configuration file has its corresponding platform architecture compilation parameter for participating in the compilation of the module configuration file when being compiled.

[0023] According to the build command, at least one product configuration parameter file and at least one module code configuration file for compiling the target file can be determined.

[0024] Specifically, in one embodiment, at least one compilation project can be determined according to the build command. Each compilation project includes a product configuration parameter file and at least one module code configuration file. Each module code configuration file corresponds to a platform architecture compilation parameter. Each compilation project is used to compile a target file.

[0025] S13: Compile files based on the platform architecture compilation parameter, at least one product configuration parameter file, and at least one module code configuration file to obtain at least one target file.

[0026] After determining the platform architecture compilation parameter, at least one product configuration parameter file, and at least one module code configuration file, compile the target code file in the module code configuration file based on the platform architecture compilation parameter and the product configuration parameter file to obtain the target file.

[0027] Specifically, after determining at least one compilation project, when executing a certain compilation project, determine the product configuration parameter file in this compilation project and at least one module code configuration file. On the basis of determining the product configuration parameters, compile each module code configuration file according to the platform architecture compilation parameter corresponding to each module code configuration file, so as to obtain the target file. Multiple compilation projects can be compiled simultaneously to improve the compilation efficiency of the target file.

[0028] In this embodiment, encapsulate the target code into a module as the module code configuration file, and then strip out the product parameters to generate the product parameter configuration file, so that it can support the construction and compilation of multiple products. Select the corresponding product parameter configuration for the module code configuration file, and strip out the platform architecture compilation parameter, so that it can support the construction and compilation of multiple platforms and multiple architectures. Select the corresponding platform architecture compilation configuration for the module code configuration file. Through the above method, when developing a product, corresponding product parameters and platform architecture compilation parameters can be set for the module code configuration file corresponding to a target code file, so that when compiling files of multiple products, multiple platforms, and multiple architectures, the compilation efficiency can be improved.

[0029] Refer to Figure 2 , Figure 2 which is a schematic flowchart of the second embodiment of the file compilation method of this application. This method is a further extension of the above embodiment and includes the following steps:

[0030] S21: Determine a parameter acquisition script based on the build command.

[0031] Before constructing a command to determine at least one product configuration parameter file and at least one module code configuration file, with each module code configuration file corresponding to a platform architecture compilation parameter, a parameter acquisition script is determined according to the construction command. The parameter acquisition script is used to obtain relevant information of the current compilation environment.

[0032] S22: Execute the parameter acquisition script to obtain the platform information, architecture information, and compiler information of the current platform.

[0033] The information that can be obtained by running the parameter acquisition script includes the platform information, architecture information, and compiler information of the current platform, etc. The platform information can include information such as windows, Linux, Mac systems, etc., the architecture information can include architecture information such as ARM, RISCV, ARC, and X86, etc., and the compiler information includes compiler information such as GCC, ARM-GCC, RISCV-GCC, ARMCC, ARMCLANG, and ARC.

[0034] S23: Use the platform information, architecture information, and compiler information as the platform architecture compilation parameters corresponding to at least one module code configuration file.

[0035] Use the obtained platform information, architecture information, and compiler information as the platform architecture compilation parameters to compile the module code configuration file, then the subsequent target file can be adapted to the current platform.

[0036] When building the same file in different environments is required, the construction command can be sent to different platforms, the parameter acquisition script can be run to obtain the platform architecture compilation parameters of the platform, and then the file can be compiled according to the platform architecture compilation parameters to obtain target files applicable to each platform, each architecture, and each compiler. Different platform architecture compilation parameters can also be directly set to obtain target files in different environments.

[0037] Refer to Figure 3 , Figure 3 This is a flowchart of the third embodiment of the file compilation method of this application. This method is a further extension of the above embodiment and includes the following steps:

[0038] S31: Perform preprocessing based on the platform architecture compilation parameters, at least one product configuration parameter file, and at least one module code configuration file to obtain at least one preprocessing result.

[0039] Before compiling files according to the platform architecture compilation parameters, at least one product configuration parameter file, and at least one module code configuration file to obtain at least one target file, preprocessing is performed based on the construction command.

[0040] The preprocessing may include parameter checking, parameter configuration, directory deletion, file version generation, serial number generation, etc. before file compilation.

[0041] S32: Use the preprocessing result as the identification information of at least one target file.

[0042] Each preprocessing result corresponds to a compilation project, that is, corresponds to a target file. During the execution of a compilation project, the preprocessing result obtained by preprocessing can be used as the unique identifier of the compilation project, or as the identification information of the target file obtained by compiling the project.

[0043] The preprocessing result can also be used as a prerequisite for subsequent processing flows. When the preprocessing result is obtained, the subsequent compilation process is executed. When the preprocessing is not completed and the preprocessing result is not obtained, the compilation process of the product configuration parameter file and the module code configuration file based on the platform structure parameters corresponding to the preprocessing process is aborted.

[0044] Refer to Figure 4 , Figure 4 is a schematic flowchart of the fourth embodiment of the file compilation method of this application. This method is a further extension of the above embodiment, and it includes the following steps:

[0045] S41: Perform post-processing on at least one target file to obtain a code sub-file and a data sub-file corresponding to each target file.

[0046] S42: After separately packing the code sub-file and the data sub-file, splice them to obtain at least one file package corresponding to at least one target file.

[0047] After file compilation is performed according to the platform architecture compilation parameters, at least one product configuration parameter file, and at least one module code configuration file to obtain at least one target file, post-processing is performed on the target file.

[0048] The post-processing may include separately packing and packaging the executable code and data of the target file. Separate the executable code and data of the target file to obtain a code sub-file and a data sub-file respectively, pack them separately, and then splice them into a file package.

[0049] In one embodiment, the build command further includes an interface document generation command to generate an interface document corresponding to the target file.

[0050] Interface document generation can be achieved by using the Doxygen tool. For interface document generation from the comments in code files, the code comment rules of Doxygen are utilized. The comments in each code file are written according to its rules, and finally, interface document generation can be performed when traversing each piece of code. Of course, other tools can also be used for interface document generation, not limited to this tool. Interface document generation can be automated through continuous integration.

[0051] In one embodiment, the build command further includes a static scanning command to scan and verify the target file.

[0052] Static scanning is to perform static analysis on the code to discover unreasonable and potentially risky code, facilitating early warning. At the same time, it can also scan the usage frequency of certain code. If the usage is high, a warning is issued. These scanning operations can all be automated through continuous integration to achieve such functions. The static scanning command can be used to scan a certain file to obtain its scanning information, or a static scanning tool can be used to scan each file to generate overall scanning information.

[0053] In one embodiment, the build command further includes a code coverage statistics command. The code coverage statistics command performs instrumentation compilation on the build command, then runs the generated executable file, and finally generates code coverage data after the run. Based on the code coverage data, code coverage statistics and the generation of a code coverage report can be performed. Code coverage statistics can include code coverage, function coverage, vulnerability rate, assertion coverage, etc.

[0054] In one embodiment, the build command further includes a debugging command to perform debugging and record debugging logs when a compilation error occurs. During the file compilation process, if a compilation error occurs, debugging can be performed to generate and record rich debugging logs for users to view. The debugging command can also include pre-compilation debugging.

[0055] Except for the compilation command for files, the above various commands are extensible commands. The build command of this application supports extensibility. In the build command, different parameters can be set to distinguish each extended command. For example, the corresponding extended command can be run through fields such as Doxygen or scan.

[0056] A unified compilation parsing command is provided in the compilation process to facilitate the access of continuous integration for compiled files.

[0057] Specific embodiments are given below to illustrate the file compilation method of this application in more detail.

[0058] After running the compilation and build command, a parameter acquisition script will be executed first to obtain the compilation parameters of the current platform's architecture, including platform information, architecture information, compiler information, and so on. This parameter acquisition script is a script that supports running on all platforms. If Python is used to write this parameter acquisition script, it can support running in all platform environments. Then, select the compilation parameters of this platform architecture for file compilation. By sending the build command to each platform in this way, the build command can remain unchanged, and multiple target files applicable to multiple platforms can be obtained.

[0059] When performing compilation, the configuration of the product configuration parameter file will be carried out first. Then, the configuration of the module code configuration file will be carried out to specify the target code files that need to be compiled. Next, the build command will be obtained. The build command can determine at least one compilation project. Each compilation project includes a product configuration parameter file and at least one module code configuration file. Each module code configuration file corresponds to a compilation parameter of the platform architecture. The compilation parameters of the platform architecture can be user-configured or obtained by the script. Each compilation project is used to compile a target file. Based on the build command, a preprocessing step can also be executed. The preprocessing can include parameter checking, parameter configuration, directory deletion, file version generation, and serial number generation, etc., before file compilation. The preprocessing results generated by the preprocessing can participate in the compilation process together and be used as the unique identification information of the corresponding project or the corresponding target file. After the preprocessing is completed, file compilation will start, generating intermediate files, and then generating target files. The debug command included in the build command can be used for debugging when a compilation error occurs, generating and recording rich debug logs for users to view. Finally, the generated target file often needs to be post-processed. The target file can be an image file. The post-processing can be, for example, splitting the executable code and data of the image file, then packing each part, and then piecing them together into a complete file package, and using this file package for burning. Each project can be carried out simultaneously until all compilation projects are compiled, and then the build command is executed.

[0060] The file compilation method provided by this application supports cross-platform, multi-instruction architecture, and multi-compiler compilation. For example, when building target files of the ARM architecture, the system of the present invention can support normal compilation on both Windows and Linux systems without modifying the compilation rules. It mainly automatically selects the corresponding compiler and compilation environment by running the script, that is, equivalent to building an intermediate layer in the compilation framework, thereby shielding the underlying differences and facilitating cross-platform support.

[0061] For the constructed target files, they can be compiled with different architectures or compilers. For example, one compilation project uses the ARM architecture, and another compilation project uses the ARC architecture. This application can support building the target files of multiple compilation projects simultaneously. It mainly adjusts parameters such as compilers and architectures through platform architecture compilation parameters, thereby realizing the project construction of multiple architectures and multiple compilers.

[0062] According to the build command, static scanning of the firmware code can also be performed before compilation to scan out some basic errors. Interface documentation for the target files can also be generated, and coverage executable files can also be generated, etc. After the target file compilation is completed, post-processing can also be performed on it.

[0063] The file compilation method of this application supports multi-platform and multi-architecture compilation. When the project under development needs to switch platforms, it can be directly built, which is simple and convenient. And it can support multiple build configurations for a single piece of code, without the need for multiple compilations, improving the compilation efficiency. The build command of this application has excellent scalability. Different fields are used to add, distinguish, and run extended commands, greatly facilitating the transplantation operations between different projects.

[0064] As Figure 5 shown, Figure 5 is a schematic structural diagram of an embodiment of the file compilation system of this application.

[0065] The file compilation system includes a product parameter configuration unit 110, a module code configuration unit 120, a platform architecture compilation configuration unit 130, and a compilation unit 140.

[0066] The product parameter configuration unit 110 is used to configure the product parameter configuration file, the module code configuration unit 120 is used to configure the module code configuration file, the platform architecture compilation configuration unit 130 is used to configure the platform architecture compilation parameters, and the compilation unit 140 is connected to the product parameter configuration unit 110, the module code configuration unit 120, and the platform architecture configuration unit 130 to implement the file compilation method provided by any one and possible combinations of the above file compilation methods of this application.

[0067] As Figure 6 shown, Figure 6 is a schematic structural diagram of an embodiment of the electronic device of this application.

[0068] The electronic device includes a processor 210 and a memory 220.

[0069] The processor 210 controls the operation of the electronic device. The processor 210 may also be referred to as a CPU (Central Processing Unit). The processor 210 may be an integrated circuit chip with the ability to process signal sequences. The processor 210 may also be a general-purpose processor, a digital signal sequence processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0070] The memory 220 stores the instructions and program data required for the operation of the processor 210.

[0071] The processor 210 is used to execute instructions to implement the methods provided by any one of the foregoing embodiments of the file compilation method of the present application and possible combinations.

[0072] In summary, the present application encapsulates the target code into a module as a module code configuration file, and then strips out the parameters of the product to generate a product parameter configuration file, enabling it to support the construction and compilation of multiple products. Select the corresponding product parameters for the module code configuration file, and strip out the platform architecture compilation parameters, enabling it to support the construction and compilation of multiple platforms and multiple architectures. Select the corresponding platform architecture compilation configuration for the module code configuration file. By the above method, when developing a product, set the corresponding product parameters and platform architecture compilation parameters for the module code configuration file corresponding to each target code file, so that when compiling files of multiple products, multiple platforms, and multiple architectures, the compilation efficiency can be improved.

[0073] In several embodiments provided by the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0074] The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they may be located in one place, or they may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0075] In addition, in each embodiment of the present application, each functional unit may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of a software functional unit.

[0076] If the integrated unit in the above-mentioned other embodiments is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, may be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs.

[0077] The above are only the embodiments of the present application, and do not limit the patent scope of the present application. Any equivalent structural or equivalent process transformation made by using the content of the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present application.

Claims

1. A file compilation method, characterized in that, The method includes: Obtaining a build command; Determining at least one product configuration parameter file and at least one module code configuration file based on the build command, each of the module code configuration files corresponding to a platform architecture compilation parameter; Performing file compilation according to the platform architecture compilation parameter, the at least one product configuration parameter file, and the at least one module code configuration file to obtain at least one target file.

2. The method according to claim 1, characterized in that Before the step of determining at least one product configuration parameter file and at least one module code configuration file based on the build command, each of the module code configuration files corresponding to a platform architecture compilation parameter, it includes: Determining a parameter acquisition script based on the build command; Executing the parameter acquisition script to obtain platform information, architecture information, and compiler information of the current platform; Using the platform information, the architecture information, and the compiler information as the platform architecture compilation parameter corresponding to the at least one module code configuration file.

3. The method according to claim 1, characterized in that Before the step of performing file compilation according to the platform architecture compilation parameter, the at least one product configuration parameter file, and the at least one module code configuration file to obtain at least one target file, it includes: Performing preprocessing based on the platform architecture compilation parameter, the at least one product configuration parameter file, and the at least one module code configuration file to obtain at least one preprocessing result; Using the preprocessing result as the identification information of the at least one target file.

4. The method according to claim 1, wherein After the step of performing file compilation according to the platform architecture compilation parameter, the at least one product configuration parameter file, and the at least one module code configuration file to obtain at least one target file, it includes: Performing post-processing on the at least one target file to obtain a code sub-file and a data sub-file corresponding to each of the target files; Packaging the code sub-file and the data sub-file respectively and then splicing them to obtain at least one file package corresponding to the at least one target file.

5. The method according to claim 1, characterized in that, The build command further includes an interface document generation command for generating an interface document corresponding to the target file.

6. The method according to claim 1, wherein The build command further includes a static scanning command for scanning and checking the target file.

7. The method according to claim 1, wherein The build command further includes a coverage rate statistics command.

8. The method according to claim 1, characterized in that, The build command further includes a debugging command for performing debugging and recording a debugging log when a compilation error occurs.

9. A file compilation system, characterized in that, It includes: A product parameter configuration unit for configuring a product parameter configuration file; A module code configuration unit for configuring a module code configuration file; A platform architecture compilation configuration unit for configuring a platform architecture compilation parameter; A compilation unit connected to the product parameter configuration unit, the module code configuration unit, and the platform architecture configuration unit to implement the file compilation method as described in any one of claims 1-8.

10. An electronic device, characterized in that, It includes a memory and a processor, the memory being used to store program data, and the program data being executable by the processor to implement the method as described in any one of claims 1-8.