File conversion method and system, terminal and computer readable storage medium
By parsing the Ninja file generated by GN, extracting compiled construction information and generating CMake instructions, the cumbersome problem of converting from BUILD.gn to CMake file is solved, and automated conversion is realized, development efficiency is improved and error risk is reduced. It is suitable for cross-platform software project.
Patent Information
- Application Number
- CN202411005095.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-25
- Publication Date
- 2024-11-22
AI Technical Summary
The existing technology lacks tools for converting from BUILD.gn file to CMake file, which makes manual conversion cumbersome and error-prone in projects that use CMake as a compilation and construction tool, causing inconvenience.
Provide a file conversion method, including parsing the Ninja file generated by GN, extracting the compiled construction information, generating intermediate data files, and mapping them into CMake instructions, and finally generating and saving the CMake file. The entire process is packaged into a tool and integrated into GN. , realize automated and efficient conversion.
Improves development efficiency, reduces the error risk caused by manual operations, and provides a convenient file conversion solution from GN to CMake, suitable for cross-platform conversion of software projects.
Smart Images

Figure CN119002920A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of file processing technology, and in particular to a file conversion method, system, terminal and computer-readable storage medium. Background Art
[0002] In the software development process, compilation and build tools play a vital role in managing and automating the compilation process. Different projects and teams may choose different compilation and build tools, including GN (Generate Ninja) and CMake. GN is a compilation and build tool used to generate Ninja files. The advantages of GN are its simplicity and efficiency, and it is widely used in large projects such as OpenHarmony. By writing BUILD.gn files, you can manage source code, dependencies, and compilation options. CMake is a more general compilation and build tool that is widely used in C++ projects. It has cross-platform support and extensive tool chain integration capabilities. The advantages of CMake are its flexibility and scalability, and it is suitable for projects of all sizes.
[0003] However, for developers who are accustomed to using GN, manually converting the Ninja files generated by GN into CMake files is time-consuming and error-prone. Especially when the development team needs to migrate the project to an environment using CMake, the manual conversion becomes extremely cumbersome and error-prone due to the lack of effective conversion tools, which brings inconvenience to projects that use CMake as a compilation and build tool.
[0004] Therefore, the prior art still needs to be improved and developed. Summary of the invention
[0005] The main purpose of the present invention is to provide a file conversion method, system, terminal and computer-readable storage medium, aiming to solve the technical problem that the prior art currently lacks a tool for converting BUILD.gn into CMake files, which brings inconvenience to projects using CMake as a compilation and construction tool.
[0006] To achieve the above object, the present invention provides a file conversion method, which comprises the following steps:
[0007] Parse the Ninja file generated by GN and extract the compilation and construction information from the Ninja file;
[0008] Generate an intermediate data file according to the compilation and construction information, and map the intermediate data file to a CMake instruction;
[0009] Generate a CMake file according to the CMake instructions, and save the CMake file to a specified directory.
[0010] Optionally, the file conversion method, wherein the parsing of the Ninja file generated by GN and extracting the compilation and construction information from the Ninja file, specifically includes:
[0011] Obtain a Ninja file generated by GN, parse the Ninja file, and read text content in the Ninja file;
[0012] The compilation and construction information is extracted from the text content based on a syntax matching rule, wherein the compilation and construction information includes a compilation target, source code file information, dependent library information, compilation options and macro definitions.
[0013] Optionally, in the file conversion method, the step of extracting the compilation information from the text content based on a grammar matching rule specifically includes:
[0014] Match the build keyword line from the text content using a regular expression;
[0015] The compilation target and source code file information are extracted according to the build keyword line, and the dependent library information and compilation options are determined according to the description items of the compilation target.
[0016] Optionally, the file conversion method, wherein generating an intermediate data file according to the compilation and construction information and mapping the intermediate data file to a CMake instruction, specifically includes:
[0017] Create and initialize an intermediate data storage file, verify the compilation and construction information, and write it into the intermediate data storage file to generate an intermediate data file;
[0018] Mapping is performed according to the compilation target to generate CMake instructions for defining output file types and corresponding source code files;
[0019] Mapping is performed according to the source code file information to generate a CMake instruction for specifying the location and name of the source code file;
[0020] Mapping is performed according to the dependency library information to generate CMake instructions for calling the required library files;
[0021] Generates CMake instructions for adding compiler flags and preprocessor defines based on the compilation options described.
[0022] Optionally, in the file conversion method, generating a CMake file according to the CMake instruction specifically includes:
[0023] Initialize the CMake instructions;
[0024] The CMake project name and version information are defined in the CMake instruction, and a CMake file is generated according to the CMake instruction.
[0025] Optionally, in the file conversion method, the step of saving the CMake file to a specified directory further comprises:
[0026] Defining a save directory of the CMake file in the CMake instruction, and verifying the save directory;
[0027] The access permissions of the CMake file are defined in the CMake directive.
[0028] Optionally, the file conversion method, wherein the CMake file is generated according to the CMake instruction, and the CMake file is saved in a specified directory, further comprising:
[0029] Packaging the CMake instructions to generate a conversion tool;
[0030] The conversion tool is embedded in GN. When GN generates a Ninja file, the conversion tool is automatically called to convert the Ninja file into a CMake file.
[0031] In addition, to achieve the above object, the present invention further provides a file conversion system, wherein the file conversion system comprises:
[0032] A parsing module, used to parse the Ninja file generated by GN and extract the compilation and construction information from the Ninja file;
[0033] A mapping module, used to generate an intermediate data file according to the compilation and construction information, and map the intermediate data file to a CMake instruction;
[0034] The storage module is used to generate a CMake file according to the CMake instruction and save the CMake file to a specified directory.
[0035] In addition, to achieve the above-mentioned purpose, the present invention also provides a terminal, wherein the terminal includes: a memory, a processor, and a file conversion program stored in the memory and executable on the processor, and when the file conversion program is executed by the processor, the steps of the file conversion method described above are implemented.
[0036] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a file conversion program, and when the file conversion program is executed by a processor, the steps of the file conversion method described above are implemented.
[0037] In the present invention, the Ninja file generated by GN is parsed, and the compilation and construction information is extracted from the Ninja file; an intermediate data file is generated according to the compilation and construction information, and the intermediate data file is mapped to a CMake instruction; a CMake file is generated according to the CMake instruction, and the CMake file is saved in a specified directory. The present invention packages the entire conversion process into a tool and integrates it into GN, thereby realizing the automatic and efficient conversion of files from the GN compilation architecture to the CMake compilation architecture, improving development efficiency, reducing the risk of errors caused by manual operations, and is suitable for various software projects that need to be converted between GN and CMake, providing developers with a convenient and reliable solution. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 It is a flow chart of a preferred embodiment of a file conversion method of the present invention;
[0039] Figure 2 It is a schematic diagram of the principle of a preferred embodiment of a file conversion system of the present invention;
[0040] Figure 3 Schematic diagram of the operating environment of a preferred embodiment of the terminal of the present invention. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solution and advantages of the present invention clearer and more specific, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0042] A file conversion method according to a preferred embodiment of the present invention is as follows: Figure 1 As shown, the file conversion method comprises the following steps:
[0043] Step S10: Parse the Ninja file generated by GN, and extract compilation and construction information from the Ninja file.
[0044] Specifically, GN (Generate Ninja) is a build generation tool for generating Ninja build files, which is mainly used to manage the compilation and construction of large code bases. Ninja files are plain text files that record all the compilation, linking and dependency information in the build process in detail. By parsing Ninja files, the compile and build information required for the build can be extracted, and this information will be used to generate CMake files, thereby realizing the conversion from GN to CMake. Parsing the Ninja files generated by GN is the first step of the method of the present invention, and its purpose is to extract the compile and build information from the Ninja files so that the subsequent steps can generate intermediate data files and map them to CMake instructions.
[0045] Furthermore, the parsing of the Ninja file generated by GN and extracting the compilation and construction information from the Ninja file specifically includes:
[0046] Obtain a Ninja file generated by GN, parse the Ninja file, and read text content in the Ninja file.
[0047] The compilation and construction information is extracted from the text content based on a syntax matching rule, wherein the compilation and construction information includes a compilation target, source code file information, dependent library information, compilation options and macro definitions.
[0048] Specifically, get the Ninja file generated by GN from the specified build directory. Ninja files usually contain detailed information about all compilation targets, source code files, dependent libraries, compilation options, and macro definitions, and are the core files of the entire build process. Parse the obtained Ninja file and read its text content line by line. The Ninja file is a plain text file, and each line usually represents a specific build instruction or dependency. By parsing line by line, you can get detailed information about each build step.
[0049] Define and apply a set of syntax matching rules to identify and extract key build information in Ninja files. The extracted build information includes build targets, source code file information, dependency library information, build options, and macro definitions. Specifically, build targets represent output files generated during the build process, such as executable files or target files; source code file information contains the path and name of the source code file used to generate the build target; dependency library information includes library files that need to be linked during the build process; build options include compiler flags and preprocessor definitions, which are used to control the behavior of the compiler; macro definitions are a mechanism for conditional compilation, mainly used to control the compilation path of the code during the compilation process.
[0050] Furthermore, extracting the compilation information from the text content based on the grammar matching rule specifically includes:
[0051] Match build keyword lines from the text content using regular expressions.
[0052] The compilation target and source code file information are extracted according to the build keyword line, and the dependent library information and compilation options are determined according to the description items of the compilation target.
[0053] Specifically, a predefined regular expression is used to match the lines starting with the build keyword in the Ninja file. These lines usually define the compilation target and its corresponding source code file. The information of the compilation target and the source code file is extracted from the matched build keyword line. The compilation target is the output file generated during the build process, such as the target file or executable file, and the source code file is the input file used to generate these targets. According to the description items of the compilation target, the related dependent library information and compilation options are further extracted. The dependent library information includes the library files that need to be linked during the build process, and the compilation options are the flags and preprocessor definitions used to control the behavior of the compiler. Therefore, the necessary compilation and construction information can be extracted from the Ninja file through an automated method, which provides the necessary basic data for subsequent file conversion and generation of CMake files.
[0054] Step S20: Generate an intermediate data file according to the compilation and construction information, and map the intermediate data file to a CMake instruction.
[0055] Specifically, the main task of this step is to convert the compilation and construction information extracted from the Ninja file into an intermediate data file, and then generate the corresponding CMake instructions based on these intermediate data, so as to generate the CMake file later. First, it is necessary to generate an intermediate data file based on the extracted compilation and construction information. The intermediate data file is a structured file for storing and organizing the compilation targets, source code file information, dependency library information, compilation options, macro definitions and other data extracted from the Ninja file, and mapping them to generate corresponding CMake instructions.
[0056] Further, generating an intermediate data file according to the compile and build information, and mapping the intermediate data file to a CMake instruction, specifically includes:
[0057] An intermediate data storage file is newly created and initialized, and the compilation construction information is verified and written into the intermediate data storage file to generate an intermediate data file.
[0058] Mapping is performed according to the compilation target to generate CMake instructions for defining output file types and corresponding source code files.
[0059] Mapping is performed according to the source code file information to generate a CMake instruction for specifying the location and name of the source code file.
[0060] Mapping is performed according to the dependent library information to generate CMake instructions for calling the required library files.
[0061] Generates CMake instructions for adding compiler flags and preprocessor defines based on the compilation options described.
[0062] Specifically, a new intermediate data storage file is created to store the compilation and construction information, and the intermediate data storage file is initialized. To ensure that its structure is correct, the extracted compilation and construction information is verified to ensure its integrity and accuracy, and the verified compilation and construction information is written into the intermediate data storage file to generate an intermediate data file.
[0063] Generate CMake instructions according to the compilation target information. For example, such CMake instructions may include add_executable and add_library, etc., which are used to define the type of output file and its corresponding source code file.
[0064] Generate CMake instructions based on the source code file information to specify the location and name of the source code file. For example, such instructions may include set and target_sources.
[0065] Generate CMake instructions based on the dependency library information. For example, such instructions may include target_link_libraries, etc., for calling the required library files.
[0066] Generates CMake instructions based on the compile options. For example, such instructions may include target_compile_options and target_compile_definitions to add compiler flags and preprocessor definitions.
[0067] Through the above method, the compilation and construction information extracted from the Ninja file can be automatically mapped to CMake instructions and the corresponding CMake file can be generated. In addition, by generating intermediate data files, the consistency and traceability of the compilation and construction information can be ensured, providing reliable protection for the continuous integration and build management of the project.
[0068] Step S30: Generate a CMake file according to the CMake instruction, and save the CMake file to a specified directory.
[0069] Specifically, the mapped CMake instructions are organized in a certain order to generate the final CMake file content, including instructions for adding targets, source files, dependent libraries, and compile options. The save directory of the CMake file is defined in the CMake instructions, and the save directory is verified to ensure that the directory exists and has write permission. Finally, the generated CMake file content is written to the file under the specified directory to achieve file conversion.
[0070] Furthermore, generating a CMake file according to the CMake instruction specifically includes:
[0071] Initialize the CMake directive.
[0072] The CMake project name and version information are defined in the CMake instruction, and a CMake file is generated according to the CMake instruction.
[0073] Specifically, the process of initializing CMake instructions is to ensure that the generated CMake file has the correct basic configuration, including defining the minimum version requirements of CMake and initializing the basic configuration of the project. This process is usually completed through basic CMake instructions, such as cmake_minimum_required and project instructions.
[0074] The project name and version information are the basic information of the CMake project. By defining this information, CMake can correctly identify and manage the project. This process can be completed by adding the project directive in the CMake file, which includes the project name and version information. After completing the initialization and defining the project name and version information, all CMake instructions are organized to generate the complete CMake file content. This process includes adding all the previously extracted and mapped compilation targets, source files, dependent libraries, and compilation option instructions to the CMake file in sequence.
[0075] Furthermore, the step of saving the CMake file to a specified directory also includes:
[0076] A storage directory for the CMake file is defined in the CMake instruction, and the storage directory is verified.
[0077] The access permissions of the CMake file are defined in the CMake directive.
[0078] Specifically, defining the save directory of the CMake file is a key step to ensure that the generated CMake file can be correctly saved to the specified path. For example, the save directory in the CMake instruction can be defined by defining a variable to represent the save directory through the CMake set instruction. In order to ensure the correctness of the file path, path verification is required to ensure that the path exists and is writable. This step includes adding instructions to define the save directory in the CMake instruction and performing path verification before generating the CMake file, such as verification through a script or CMake's file instruction.
[0079] Setting access permissions is a key step to ensure that CMake files can be read and written correctly. By setting file access permissions, you can control the file's read, write, and execute permissions. This step includes adding instructions to set file permissions in CMake instructions to ensure that the generated CMake files have correct access permissions in different environments. Therefore, by defining and verifying the save directory in the CMake instructions, you can ensure that the generated CMake files can be correctly saved to the specified path to avoid file save failures caused by path errors.
[0080] Further, generating a CMake file according to the CMake instruction and saving the CMake file to a specified directory further includes:
[0081] The CMake instructions are packaged to generate a conversion tool.
[0082] The conversion tool is embedded in GN. When GN generates a Ninja file, the conversion tool is automatically called to convert the Ninja file into a CMake file.
[0083] Specifically, this step involves packaging the CMake instructions and logic in the conversion process into an independent tool. The tool can be a script or an executable file that contains all the conversion steps and logic. During the packaging process, it is necessary to ensure that the tool contains all necessary dependencies and configurations so that it can run in different environments. As an example, Python or other suitable programming languages can be selected to write the tool so that it can read Ninja files, parse the compilation and build information therein, and generate CMake files based on this information, encapsulating the conversion logic in an independent module or library to ensure that the tool can run independently. The packaging process needs to ensure that all necessary dependencies (such as parsing libraries, string processing libraries, etc.) are included so that the tool can work properly in different development environments.
[0084] Integrate the generated conversion tool into GN's build process so that GN can automatically call the tool after generating the Ninja file. For example, this can be achieved by adding instructions (such as action instructions) to call the conversion tool in the GN configuration file (such as BUILD.gn). Set GN's build process to automatically call the conversion tool after generating the Ninja file, and pass the generated Ninja file path as a parameter. After ensuring that GN completes the generation of the Ninja file, it can automatically trigger the conversion tool to perform file conversion and generate the latest CMake file.
[0085] Furthermore, if Figure 2 As shown, based on the above-mentioned file conversion method, the present invention also provides a file conversion system accordingly, wherein the file conversion system includes:
[0086] A parsing module 51, used to parse the Ninja file generated by GN and extract the compilation and construction information from the Ninja file;
[0087] A mapping module 52, used to generate an intermediate data file according to the compilation and construction information, and map the intermediate data file to a CMake instruction;
[0088] The storage module 53 is used to generate a CMake file according to the CMake instruction and save the CMake file to a specified directory.
[0089] Furthermore, if Figure 3 As shown, based on the above-mentioned file conversion method and system, the present invention also provides a terminal accordingly, and the terminal includes a processor 10, a memory 20 and a display 30. Figure 3 Only some components of the terminal are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0090] The memory 20 may be an internal storage unit of the terminal in some embodiments, such as a hard disk or memory of the terminal. The memory 20 may also be an external storage device of the terminal in other embodiments, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the terminal. Further, the memory 20 may also include both an internal storage unit of the terminal and an external storage device. The memory 20 is used to store application software and various types of data installed in the terminal, such as the program code of the installation terminal, etc. The memory 20 may also be used to temporarily store data that has been output or is to be output. In one embodiment, a file conversion program 40 is stored on the memory 20, and the file conversion program 40 can be executed by the processor 10, thereby realizing the file conversion method in the present application.
[0091] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run the program code or process data stored in the memory 20, such as executing the file conversion method.
[0092] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 30 is used to display information on the terminal and to display a visual user interface. The components 10-30 of the terminal communicate with each other via a system bus.
[0093] In one embodiment, when the processor 10 executes a file conversion program 40 in the memory 20, the following steps are implemented:
[0094] Parse the Ninja file generated by GN and extract the compilation and construction information from the Ninja file;
[0095] Generate an intermediate data file according to the compilation and construction information, and map the intermediate data file to a CMake instruction;
[0096] Generate a CMake file according to the CMake instructions, and save the CMake file to a specified directory.
[0097] The parsing of the Ninja file generated by GN and extracting the compilation information from the Ninja file specifically includes:
[0098] Obtain a Ninja file generated by GN, parse the Ninja file, and read text content in the Ninja file;
[0099] The compilation and construction information is extracted from the text content based on a syntax matching rule, wherein the compilation and construction information includes a compilation target, source code file information, dependent library information, compilation options and macro definitions.
[0100] The extracting of the compilation information from the text content based on the grammar matching rule specifically includes:
[0101] Match the build keyword line from the text content using a regular expression;
[0102] The compilation target and source code file information are extracted according to the build keyword line, and the dependent library information and compilation options are determined according to the description items of the compilation target.
[0103] The step of generating an intermediate data file according to the compile and build information and mapping the intermediate data file to a CMake instruction specifically includes:
[0104] Create and initialize an intermediate data storage file, verify the compilation and construction information, and write it into the intermediate data storage file to generate an intermediate data file;
[0105] Mapping is performed according to the compilation target to generate CMake instructions for defining output file types and corresponding source code files;
[0106] Mapping is performed according to the source code file information to generate a CMake instruction for specifying the location and name of the source code file;
[0107] Mapping is performed according to the dependency library information to generate CMake instructions for calling the required library files;
[0108] Generates CMake instructions for adding compiler flags and preprocessor defines based on the compilation options described.
[0109] The step of generating a CMake file according to the CMake instruction specifically includes:
[0110] Initialize the CMake instructions;
[0111] The CMake project name and version information are defined in the CMake instruction, and a CMake file is generated according to the CMake instruction.
[0112] The step of saving the CMake file to a specified directory also includes:
[0113] Defining a save directory of the CMake file in the CMake instruction, and verifying the save directory;
[0114] The access permissions of the CMake file are defined in the CMake directive.
[0115] The step of generating a CMake file according to the CMake instruction and saving the CMake file to a specified directory further includes:
[0116] Packaging the CMake instructions to generate a conversion tool;
[0117] The conversion tool is embedded in GN. When GN generates a Ninja file, the conversion tool is automatically called to convert the Ninja file into a CMake file.
[0118] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a file conversion program, and when the file conversion program is executed by a processor, the steps of the file conversion method described above are implemented.
[0119] In summary, the present invention provides a file conversion method, system, terminal and computer-readable storage medium, the method comprising: parsing a Ninja file generated by GN, and extracting compilation and construction information from the Ninja file; generating an intermediate data file according to the compilation and construction information, and mapping the intermediate data file to a CMake instruction; generating a CMake file according to the CMake instruction, and saving the CMake file to a specified directory. The present invention packages the entire conversion process into a tool and integrates it into GN, thereby realizing the automatic and efficient conversion of files from the GN compilation architecture to the CMake compilation architecture, improving development efficiency, and reducing the risk of errors caused by manual operations. It is suitable for various software projects that need to be converted between GN and CMake, and provides developers with a convenient and reliable solution.
[0120] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or terminal including the element.
[0121] Of course, those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware (such as a processor, a controller, etc.) through a computer program, and the program can be stored in a computer-readable storage medium that can be read by a computer, and the program can include the processes of the above-mentioned method embodiments when executed. The computer-readable storage medium can be a memory, a disk, an optical disk, etc.
[0122] It should be understood that the application of the present invention is not limited to the above examples. For ordinary technicians in this field, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A file conversion method, characterized in that: The file conversion method comprises: Parse the Ninja file generated by GN and extract the compilation and construction information from the Ninja file; Generate an intermediate data file according to the compilation and construction information, and map the intermediate data file to a CMake instruction; Generate a CMake file according to the CMake instructions, and save the CMake file to a specified directory.
2. The file conversion method according to claim 1, characterized in that: The parsing of the Ninja file generated by GN and extracting the compilation and construction information from the Ninja file specifically includes: Obtain a Ninja file generated by GN, parse the Ninja file, and read text content in the Ninja file; The compilation and construction information is extracted from the text content based on a syntax matching rule, wherein the compilation and construction information includes a compilation target, source code file information, dependent library information, compilation options and macro definitions.
3. The file conversion method according to claim 2, characterized in that: The extracting the compilation construction information from the text content based on the grammar matching rule specifically includes: Match the build keyword line from the text content using a regular expression; The compilation target and source code file information are extracted according to the build keyword line, and the dependent library information and compilation options are determined according to the description items of the compilation target.
4. The file conversion method according to claim 2, characterized in that: The generating of the intermediate data file according to the compile and build information and mapping the intermediate data file to a CMake instruction specifically includes: Create and initialize an intermediate data storage file, verify the compilation and construction information, and write it into the intermediate data storage file to generate an intermediate data file; Mapping is performed according to the compilation target to generate CMake instructions for defining output file types and corresponding source code files; Mapping is performed according to the source code file information to generate a CMake instruction for specifying the location and name of the source code file; Mapping is performed according to the dependency library information to generate CMake instructions for calling the required library files; Generates CMake instructions for adding compiler flags and preprocessor defines based on the compilation options described.
5. The file conversion method according to claim 1, characterized in that: Generating a CMake file according to the CMake instruction specifically includes: Initialize the CMake instructions; The CMake project name and version information are defined in the CMake instruction, and a CMake file is generated according to the CMake instruction.
6. The file conversion method according to claim 1, characterized in that: The CMake file is saved in a specified directory, and the following is also included before: Defining a save directory of the CMake file in the CMake instruction, and verifying the save directory; The access permissions of the CMake file are defined in the CMake directive.
7. The file conversion method according to claim 1, characterized in that: The step of generating a CMake file according to the CMake instruction and saving the CMake file to a specified directory further includes: Packaging the CMake instructions to generate a conversion tool; The conversion tool is embedded in GN. When GN generates a Ninja file, the conversion tool is automatically called to convert the Ninja file into a CMake file.
8. A file conversion system, characterized in that: The file conversion system comprises: A parsing module, used to parse the Ninja file generated by GN and extract the compilation and construction information from the Ninja file; A mapping module, used to generate an intermediate data file according to the compilation and construction information, and map the intermediate data file to a CMake instruction; The storage module is used to generate a CMake file according to the CMake instruction and save the CMake file to a specified directory.
9. A terminal, characterized in that: The terminal comprises: a memory, a processor, and a file conversion program stored in the memory and executable on the processor, wherein the file conversion program implements the steps of the file conversion method according to any one of claims 1 to 7 when executed by the processor.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a file conversion program, and when the file conversion program is executed by a processor, the steps of the file conversion method according to any one of claims 1 to 7 are implemented.
