Data processing method, device, equipment and medium for cross-compilation

By obtaining the configuration file and replacing the file name of the header file during the cross-compilation process, the problem of case incompatibility in cross-compilation is solved, and the compilation success rate is improved.

CN118838603BActive Publication Date: 2025-03-21ZHEJIANG DAHUA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411312841.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-19
Publication Date
2025-03-21
Estimated Expiration
2044-09-19

AI Technical Summary

Technical Problem

During cross-compilation, the case incompatibility of header files due to platform differences leads to compilation errors, affecting the success rate of cross-compilation.

Method used

By obtaining the configuration file and determining its absolute path for each header file that the source file to be compiled, if it is not searched, the case format is ignored and the file name of the header file in the configuration file is replaced to solve the case incompatibility problem.

Benefits of technology

It effectively solves the problem of case incompatibility during cross-compilation, improves the success rate of cross-compilation, and avoids the problem of case incompatibility of header files caused by platform differences.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118838603B_ABST
    Figure CN118838603B_ABST
Patent Text Reader

Abstract

The present application discloses a data processing method, device, equipment and medium for cross-compilation, which is used to solve the case incompatibility problem existing in the current cross-compilation process and improve the success rate of cross-compilation. The method includes: obtaining a configuration file, which is constructed in a first platform based on the configuration of a second platform; for each header file in the configuration file that the source file to be compiled depends on, performing the following operations respectively to obtain an updated configuration file: determining the absolute path of the header file, if the header file is not searched in the absolute path, ignoring the case format of the characters in the file name of the header file and searching again, and when the target file is searched, using the file name of the target file to replace the file name of the header file in the configuration file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a data processing method, device, equipment and medium for cross-compilation. Background Art

[0002] With the rapid development of the computer industry, various hardware platforms have appeared on computers. Due to limited hardware resources, some hardware platforms cannot compile programs directly, so cross-compilation is required on other platforms.

[0003] Cross-compilation is to compile an executable file or library on one source platform that can run on another source platform. During the cross-compilation process, you need to find the corresponding dependent header file. If the name of the dependent header file and the header file found by the command line are different in capital letters, the compilation will report an error, indicating that the corresponding header file cannot be found. For example, when compiling a library for the Windows environment in a Linux environment, because file names in Linux are case-sensitive, but file names in Windows are not case-sensitive, the above compilation error may occur during the compilation process.

[0004] Therefore, the case compatibility issue that arises during cross-platform cross-compilation is an issue that needs to be solved urgently. Summary of the invention

[0005] The embodiments of the present application provide a data processing method, apparatus, device and medium for cross-compilation, so as to solve the case incompatibility problem existing in the current cross-compilation process and improve the success rate of cross-compilation.

[0006] An embodiment of the present application provides a data processing method for cross-compilation, including:

[0007] Obtaining a configuration file, where the configuration file is constructed in the first platform based on the configuration of the second platform;

[0008] For each header file in the configuration file that the source file to be compiled depends on, the following operations are performed to obtain an updated configuration file: the absolute path of the header file is determined; if the header file is not found in the absolute path, the case of the characters in the header file name is ignored and the search is performed again; when the target file is found, the file name of the target file is used to replace the file name of the header file in the configuration file.

[0009] In an embodiment of the present application, during the cross-compilation process, after obtaining the configuration file, for each header file in the configuration file that the source file to be compiled depends on, first determine the absolute path of the header file, and then search for the header file based on the absolute path of the header file. If the header file is not found in the absolute path, it is determined that there is a case incompatibility problem in this header file. At this time, ignore the case format of the characters in the header file name and search again. When the target file is searched, use the file name of the target file to replace the file name of the header file in the configuration file to obtain an updated configuration file.

[0010] By replacing the file name of the header file in the configuration file with the file name of the target file, all header file names with case incompatibility problems in the configuration file are replaced. Compared with the existing technology, this can solve the case incompatibility problem in the cross-compilation process, avoid the case incompatibility of header files caused by platform differences in the cross-compilation process, and improve the success rate of cross-compilation.

[0011] In some embodiments, obtaining the configuration file includes:

[0012] In the first platform, obtain the project file to be compiled;

[0013] Using a preset command to process the project file to be compiled, and constructing a project file directory based on the configuration of the second platform;

[0014] The configuration file is searched from the project file directory.

[0015] In some embodiments, searching the configuration file from the project file directory includes:

[0016] Searching the project file directory for a file with a first preset name;

[0017] If a file with the first preset name is found and the file content is not empty, the file with the first preset name is determined as the configuration file; or

[0018] If a file named with the first preset name is found and the file content is empty, a file named with the second preset name is searched in the project file directory, and the found file named with the second preset name is determined as the configuration file.

[0019] In some embodiments, when a file named with the first preset name is determined as the configuration file, determining the absolute path of the header file includes:

[0020] Parsing the configuration file, and separating information of each header file from the configuration file;

[0021] The absolute path of each header file is determined according to the pre-acquired absolute path of the configuration file and the information of each header file.

[0022] In some embodiments, determining the absolute path of each header file based on the pre-acquired absolute path of the configuration file and the information of each header file includes:

[0023] Obtaining, from the address information of each header file, a relative path of each header file relative to the folder where the configuration file is located;

[0024] The absolute path of the configuration file and the relative path are concatenated to obtain the absolute path of the header file.

[0025] In some embodiments, when a file named as the second preset name is determined as the configuration file, determining the absolute path of the header file includes:

[0026] Parsing the configuration file, parsing the relative path of the dependent file from the configuration file, the dependent file containing header file information that the source file to be compiled depends on;

[0027] Determine the absolute path of the dependent file according to the pre-acquired absolute path of the configuration file and the relative path of the dependent file;

[0028] According to the absolute path of the dependent file, the dependent file is obtained, and the absolute path of each header file is obtained from the header file information included in the dependent file.

[0029] In some embodiments, the method further comprises:

[0030] Compile based on the updated configuration file to generate an executable file or a library.

[0031] Accordingly, an embodiment of the present application provides a data processing device for cross-compilation, the device comprising:

[0032] An acquisition unit, configured to acquire a configuration file, wherein the configuration file is constructed in the first platform based on the configuration of the second platform;

[0033] The processing unit is used to perform the following operations for each header file on which the source file to be compiled in the configuration file depends, so as to obtain an updated configuration file: determining the absolute path of the header file, and if the header file is not found in the absolute path, ignoring the case format of the characters in the file name of the header file and searching again, and when the target file is found, replacing the file name of the header file in the configuration file with the file name of the target file.

[0034] In some embodiments, the acquisition unit is specifically used to:

[0035] In the first platform, obtain the project file to be compiled;

[0036] Using a preset command to process the project file to be compiled, and constructing a project file directory based on the configuration of the second platform;

[0037] The configuration file is searched from the project file directory.

[0038] In some embodiments, the acquisition unit is specifically used to:

[0039] Searching the project file directory for a file with a first preset name;

[0040] If a file with the first preset name is found and the file content is not empty, the file with the first preset name is determined as the configuration file; or

[0041] If a file named with the first preset name is found and the file content is empty, a file named with the second preset name is searched in the project file directory, and the found file named with the second preset name is determined as the configuration file.

[0042] In some embodiments, the processing unit is specifically configured to:

[0043] When a file named with the first preset name is determined as the configuration file, the configuration file is parsed to separate information of each header file from the configuration file;

[0044] The absolute path of each header file is determined according to the pre-acquired absolute path of the configuration file and the information of each header file.

[0045] In some embodiments, the processing unit is specifically configured to:

[0046] Obtaining, from the address information of each header file, a relative path of each header file relative to the folder where the configuration file is located;

[0047] The absolute path of the configuration file and the relative path are concatenated to obtain the absolute path of the header file.

[0048] In some embodiments, the processing unit is specifically configured to:

[0049] When a file named with the second preset name is determined as the configuration file, the configuration file is parsed to obtain a relative path of a dependent file from the configuration file, wherein the dependent file includes header file information on which the source file to be compiled depends;

[0050] Determine the absolute path of the dependent file according to the pre-acquired absolute path of the configuration file and the relative path of the dependent file;

[0051] According to the absolute path of the dependent file, the dependent file is obtained, and the absolute path of each header file is obtained from the header file information included in the dependent file.

[0052] In some embodiments, the apparatus further comprises:

[0053] The compiling unit is used to compile based on the updated configuration file to generate an executable file or a library.

[0054] Another embodiment of the present application provides an electronic device, which includes a memory and a processor, wherein the memory is used to store program instructions, and the processor is used to call the program instructions stored in the memory and execute any of the above methods according to the obtained program.

[0055] Another embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable the computer to execute any of the above methods. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0057] Figure 1 A flowchart of a data processing method provided in an embodiment of the present application;

[0058] Figure 2 A schematic diagram of the file content of a depend.make file provided in an embodiment of the present application;

[0059] Figure 3 A schematic diagram of the file contents of a DependInfo.cmake file provided in an embodiment of the present application;

[0060] Figure 4 A schematic diagram of the file contents of another depend.make file provided in an embodiment of the present application;

[0061] Figure 5 A schematic diagram of header file information provided in an embodiment of the present application;

[0062] Figure 6 A flowchart of a specific data processing process when a configuration file provided in an embodiment of the present application is a depend.make file;

[0063] Figure 7 A schematic diagram of the file contents of another DependInfo.cmake file provided in an embodiment of the present application;

[0064] Figure 8 A schematic diagram of dependent file information provided in an embodiment of the present application;

[0065] Fig. 9 A schematic diagram of the file content of a dependent file provided in an embodiment of the present application;

[0066] Fig.10 A flowchart of a specific data processing process when a configuration file provided in an embodiment of the present application is a DependInfo.cmake file;

[0067] Fig.11 A flowchart of a specific implementation process of cross-compilation provided in an embodiment of the present application;

[0068] Fig.12 A schematic diagram of the structure of a data processing device provided in an embodiment of the present application;

[0069] Fig.13 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0070] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0071] The embodiments of the present application provide a data processing method, apparatus, device and medium for cross-compilation, so as to solve the case incompatibility problem existing in the current cross-compilation process and improve the success rate of cross-compilation.

[0072] Among them, the method and the device, equipment, and medium are based on the same application concept. Since the principles of solving problems by the method and the device, equipment, and medium are similar, the implementation of the device, equipment, medium, and method can refer to each other, and the repeated parts will not be repeated.

[0073] The terms "first", "second", etc. (if any) in the specification and claims of the embodiments of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0074] The following examples and embodiments are to be understood as illustrative examples only. Although this specification may refer to "one", "an" or "some" examples or embodiments in several places, this does not mean that each such reference relates to the same example or embodiment, nor does it mean that the feature applies only to a single example or embodiment. Individual features of different embodiments may also be combined to provide other embodiments. In addition, terms such as "including" and "comprising" should be understood as not limiting the described embodiments to consist only of those features that have been mentioned; such examples and embodiments may also include features, structures, units, modules, etc. that are not specifically mentioned.

[0075] The following is a detailed description of each embodiment of the present application in conjunction with the accompanying drawings. It should be noted that the display order of the embodiments of the present application only represents the order of the embodiments, and does not represent the advantages and disadvantages of the technical solutions provided by the embodiments.

[0076] With the rapid development of the computer industry, various hardware platforms have appeared on computers. Due to limited hardware resources, some hardware platforms cannot compile programs directly, so cross-compilation is required on other platforms.

[0077] Cross-compilation is to compile an executable file or library on one source platform that can run on another source platform. During the cross-compilation process, you need to find the corresponding dependent header file. If the name of the dependent header file and the header file found by the command line are different in capital letters, the compilation will report an error, indicating that the corresponding header file cannot be found. For example, when compiling a library for the Windows environment in a Linux environment, because file names in Linux are case-sensitive, but file names in Windows are not case-sensitive, the above compilation error may occur during the compilation process.

[0078] Therefore, the case compatibility issue that arises during cross-platform cross-compilation is an issue that needs to be solved urgently.

[0079] In an embodiment of the present application, during the cross-compilation process, after obtaining the configuration file, for each header file in the configuration file that the source file to be compiled depends on, first determine the absolute path of the header file, and then search for the header file based on the absolute path of the header file. If the header file is not found in the absolute path, it is determined that there is a case incompatibility problem in this header file. At this time, ignore the case format of the characters in the header file name and search again. When the target file is searched, use the file name of the target file to replace the file name of the header file in the configuration file to obtain an updated configuration file.

[0080] By replacing the file name of the header file in the configuration file with the file name of the target file, all header file names with case incompatibility problems in the configuration file are replaced. Compared with the existing technology, this can solve the case incompatibility problem in the cross-compilation process, avoid the case incompatibility of header files caused by platform differences in the cross-compilation process, and improve the success rate of cross-compilation.

[0081] Before formally introducing the embodiments of the present application, it should be noted that the data processing method for cross-compilation provided in the embodiments of the present application can be executed by a terminal device that performs cross-compilation, and the embodiments of the present application do not limit this.

[0082] clang and gcc are two commonly used compilation tools, and both support cross-compilation. In the following description of the embodiments of the present application, only clang is used as an example. Of course, the data processing method provided in the embodiments of the present application is also applicable to cross-compilation tools such as gcc.

[0083] See also Figure 1 The implementation process of the data processing method for cross-compilation provided in the embodiment of the present application includes the following steps S101-S102:

[0084] S101, obtaining a configuration file, where the configuration file is constructed in the first platform based on the configuration of the second platform.

[0085] In the specific implementation, in the first platform, the project file to be compiled is obtained, and then the preset command is used to process the project file to be compiled, a project file directory is constructed based on the configuration of the second platform, and the configuration file is searched from the project file directory. Among them, the project file to be compiled can be written or uploaded by the user, and the embodiment of the present application does not limit this. The preset command can be a cmake command.

[0086] In actual applications, after creating the project file directory, the header file that the source file to be compiled (.cpp or .c) depends on has been set in the configuration file. The configuration file is generally depend.make or DependInfo.cmake. The file name is fixed, so you only need to find the files with these two file names to get the configuration file, and then you can get the header file that the corresponding .cpp depends on.

[0087] Since the file name of the configuration file is fixed, when searching for the configuration file in the project file directory, you can first search for a file with the first preset name in the project file directory. If a file with the first preset name is found and the file content is not empty, the file with the first preset name is determined as the configuration file; if a file with the first preset name is found and the file content is empty, search for a file with the second preset name in the project file directory, and determine the searched file with the second preset name as the configuration file. The first preset name is depend.make, and the second preset name is DependInfo.cmake.

[0088] In an example, the content of the depend.make file is in the format of Figure 2 As shown in the depend.make file, the *.h part after the colon is the header file that .cpp or .c depends on. Figure 2 The .. / include_path / example_inc1.h shown in the figure is a header file that .cpp or .c depends on. The * represents any character.

[0089] In another example, the content format of the DependInfo.cmake file is as follows Figure 3 As shown in the DependInfo.cmake file, *.cpp.obj.d is a file name, and the header file information that the .cpp depends on is in *.cpp.obj.d.

[0090] S102, for each header file that the source file to be compiled in the configuration file depends on, perform the following operations to obtain an updated configuration file: determine the absolute path of the header file, if the header file is not found in the absolute path, ignore the case format of the characters in the header file name and search again, when the target file is found, use the file name of the target file to replace the file name of the header file in the configuration file.

[0091] It should be noted that since the configuration files are divided into depend.make file and DependInfo.cmake file, the contents of the two files are different. Therefore, the specific implementation process of determining the absolute path of the header file and replacing the file name of part or all of the header files is explained below in combination with the two configuration files.

[0092] 1. The configuration file is depend.make file.

[0093] In this case, when determining the absolute path of the header file, the configuration file is parsed, the information of each header file is separated from the configuration file, and then the absolute path of each header file is determined based on the absolute path of the configuration file obtained in advance and the information of each header file. Specifically, from the address information of each header file, the relative path of each header file relative to the folder where the configuration file is located is obtained, and the absolute path and relative path of the configuration file are concatenated to obtain the absolute path of the header file.

[0094] Specifically, the depend.make file is usually separated by empty lines, indicating a .cpp or .c header file that is dependent on, such as Figure 4 As shown in the figure, for example, the source file cpp_file2.c to be compiled depends on three header files, whose names are example_inc4.h, example_inc5.h, and example_inc6.h. The .. / include_path2 / dirname23 in front of example_inc6.h indicates the relative path to the project file directory. The target product of the compilation is cpp_file2.co. The target products and dependent header file information of other source files cpp_file1.c and cpp_file3.c to be compiled are before and after the blank line.

[0095] In the specific implementation, read the depend.make content and save it in the variable cpp_depend_h_total, split it with empty lines, parse out the information corresponding to each source file to be compiled, and store it in the list variable cpp_depend_h_str_list, traverse each member of cpp_depend_h_str_list in turn, the member variable is cpp_depend_h_per_str, and then split the cpp_depend_h_per_str by newline characters to get the dependent header file information, and store it in the list variable cpp_depend_h_per_list. The format of the cpp_depend_h_per_list member is as follows: Figure 5 shown.

[0096] Then traverse the cpp_depend_h_per_list elements one by one, parse the .o file string and .h file string through the colon, and store them in the variables var_o_str and var_h_str respectively, for example Figure 5 The string in the example can be parsed as follows:

[0097] var_o_str=complier_result_path / cpp_file2.co

[0098] var_h_str=.. / include_path2 / dirname23 / example_inc6.h

[0099] The original file name of the header file is stored in the variable var_h_old, where var_h_old = example_inc6.h. By concatenating the absolute path of the depend.make file obtained in advance and the relative path of the .h file (the var_h_str variable mentioned above), the absolute path of the header file var_h_abspath can be obtained.

[0100] After obtaining the absolute path of the header file, use the preset function to search for the header file based on the absolute path of the header file. For example, through the function os.path.exist (var_h_abspath), determine whether the header file exists in the absolute path of the header file. If it exists, it means that the file name of this header file is not case-incompatible, and no replacement operation is required. Continue to process the next header file. If the header file does not exist in the absolute path of the header file, it means that the file name of this header file is case-incompatible. At this time, ignore the character case format of the file name and continue to search. When the target file is searched, the file name of the target file is stored in the variable var_h_new, and then the original file name and the correct file name of the header file whose file name does not match the case can be stored in the dictionary var_h_dict, var_h_dict={var_h_old:var_h_new}, until a cpp_depend_h_per_str is traversed.

[0101] Replace the specified substring in the string variable cpp_depend_h_per_str. The specified substring is var_h_old, which is replaced with var_h_new. After the replacement is completed, it is stored in the list variable cpp_depend_h_str_new_list. After traversing all cpp_depend_h_str_list, the latest cpp_depend_h_str_new_list is obtained. The cpp_depend_h_str_new_list is concatenated with blank lines to obtain the string variable cpp_depend_h_total_new. Then the depend.make file content is cleared, and cpp_depend_h_total_new is written into the depend.make file. This means that the file name of each header file whose file name does not match the case is replaced, which solves the case incompatibility problem in the cross-compilation process, avoids the case incompatibility of header files caused by platform differences during the cross-compilation process, and improves the success rate of cross-compilation.

[0102] Combine the following Figure 6 , the implementation process of replacing the file name of the header file whose file name does not match the case when the configuration file is the depend.make file in the embodiment of the present application is described in detail, such as Figure 6 As shown, the specific replacement process includes:

[0103] Step 601, read the contents of the depend.make file, save it in the variable cpp_depend_h_total, split it with empty lines, split cpp_depend_h_total, and store the resulting blocks in the list variable cpp_depend_h_str_list.

[0104] Step 602, parse each member cpp_depend_h_per_str of cpp_depend_h_str_list by line break, and store the parsing result in the list variable cpp_depend_h_per_list.

[0105] Step 603: for each cpp_depend_h_per_list, parse the .o file string and the .h file string through the colon, and store them in variables var_o_str and var_h_str respectively.

[0106] Step 604, the absolute path var_h_abspath of the header file is obtained by concatenating the absolute path of the depend.make file obtained in advance and the relative path of the header file recorded in var_h_str.

[0107] Step 605, determine whether there is a header file in var_h_abspath, if so, continue to execute step 603 to process the next cpp_depend_h_per_list, if not, execute step 606.

[0108] Step 606, continue searching by ignoring the case format of characters in the file name of the header file, and store the searched file name of the target file and the original file name of the header file in the var_h_dict dictionary.

[0109] Step 607, determine whether the header files in cpp_depend_h_per_list have been processed. If not, continue to execute step 603 to process the next header file. If it has been processed, execute step 608.

[0110] Step 608, after traversing one cpp_depend_h_per_list, use the dictionary var_h_dict to replace the file names of the header files whose file names in cpp_depend_h_per_str do not match the case, and then execute step 602 to process the next cpp_depend_h_str_list.

[0111] It should be noted that after all cpp_depend_h_str_list processing is completed, the updated depend.make file, that is, the updated configuration file, can be obtained.

[0112] 2. The configuration file is DependInfo.cmake file.

[0113] In this case, when determining the absolute path of the header file, first parse the configuration file, and parse the relative path of the dependent file from the configuration file. The dependent file contains the header file information that the source file to be compiled depends on; then, based on the absolute path of the configuration file obtained in advance and the relative path of the dependent file, determine the absolute path of the dependent file; finally, based on the absolute path of the dependent file, obtain the dependent file, and obtain the absolute path of each header file from the header file information contained in the dependent file.

[0114] Specifically, get the contents of the DependInfo.cmake file, such as Figure 7 As shown, the content after set(CMAKE_DEPENDS_DEPENDENCY_FILES is obtained by parsing and stored in the string variable dependInfo_str.

[0115] Then the string variable dependInfo_str is split by line breaks and spaces are removed to parse the list variable cpp_depend_list. cpp_depend_list stores the dependency information of all .cpp or .c in the configuration file. The element format of cpp_depend_list is as follows: Figure 8 shown.

[0116] Traverse each member (cpp_depend_per_str) in cpp_depend_list, and obtain the relative path of *.obj.d (i.e., the dependent file mentioned in the embodiment of the present application) by parsing cpp_depend_per_str through spaces. The absolute path of the DependInfo.cmake file obtained in advance can be used to determine the absolute path per_obj_d_abspath of *.obj.d.

[0117] Then, read the per_obj_d_abspath file and get the file content, such as Fig. 9As shown, the file content exists in the string variable per_obj_d_info. The string variable per_obj_d_info is split by newline characters and backslashes (\). All elements exist in the list variable cpp_depend_inc_list. cpp_depend_inc_list contains two elements, *.cpp and *.cpp.obj.

[0118] Traverse each element cpp_depend_inc_str of cpp_depend_inc_list, cpp_depend_inc_str is the absolute path of the *.h header file, the original file name of the *.h header file is represented by the variable var_h_old, and *.cpp and *.cpp.obj are skipped without processing. When traversing to .h, the function os.path.exist (cpp_depend_inc_str) is used to determine whether the header file exists. If it exists, it indicates that the file name of this header file does not exist. For the problem of lowercase incompatibility, no replacement operation is required, and the next header file can be processed. If the header file does not exist under the absolute path of the header file, it indicates that the file name of this header file is case incompatible. At this time, the character case format of the file name is ignored and the search is continued. When the target file is found, the file name of the target file is stored in the variable var_h_new, and then the original file name and the correct file name of the header file with case mismatch can be stored in the dictionary var_h_dict, var_h_dict={var_h_old:var_h_new}.

[0119] Finally, replace all substrings of var_h_old in the dictionary variable var_h_dict with the corresponding var_h_new, that is, replace the file names of header files whose file names do not match the case in per_obj_d_info, until the entire cpp_depend_list is traversed, thus achieving the replacement of the file names of each header file whose file names do not match the case, solving the case incompatibility problem in the cross-compilation process, avoiding the case incompatibility of header files caused by platform differences in the cross-compilation process, and improving the success rate of cross-compilation.

[0120] Combine the following Fig.10 , the implementation process of replacing the file name of the header file whose file name does not match the case when the configuration file is the DependInfo.cmake file in the embodiment of the present application is described in detail, such as Fig.10 As shown, the specific replacement process includes:

[0121] Step 1001, obtain the content of the DependInfo.cmake file, extract the key string, and save it in the variable dependInfo_str.

[0122] Step 1002, parse the string variable dependInfo_str through the line break, and save the parsing result in the list variable cpp_depend_list.

[0123] Step 1003, traverse each member cpp_depend_per_str in cpp_depend_list, parse cpp_depend_per_str to obtain the absolute path per_obj_d_abspath of *.obj.d.

[0124] Step 1004, read the per_obj_d_abspath file, obtain the file content, and store the file content in the string variable per_obj_d_info.

[0125] Step 1005, split the string variable per_obj_d_info by line breaks and backslashes, store all elements in the list variable cpp_depend_inc_list, traverse each element cpp_depend_inc_str in cpp_depend_inc_list, obtain the original file name of the *.h header file and use the variable var_h_old to represent it.

[0126] Step 1006, determine whether there is a header file for cpp_depend_inc_str, if so, execute step 1005, check the next header file, if not, execute step 1007.

[0127] Step 1007, continue searching by ignoring the case of characters in the file name of the header file, and store the searched file name of the target file and the original file name of the header file in the var_h_dict dictionary.

[0128] Step 1008, determine whether the header files in cpp_depend_inc_list have been processed. If not, continue to execute step 1005 to process the next header file. If it has been processed, execute step 1009.

[0129] Step 1009, after traversing a cpp_depend_inc_list, use the dictionary var_h_dict to replace the file names of the header files whose file names do not match the case in per_obj_d_info, and then execute step 1003 to process the next cpp_depend_per_str.

[0130] It should be noted that after all cpp_depend_per_str processing is completed, the updated DependInfo.cmake file, that is, the updated configuration file, can be obtained.

[0131] During specific implementation, after obtaining the updated configuration file, the embodiment of the present application can be compiled based on the updated configuration file to generate an executable file or library.

[0132] Combine the following Fig.11 , the cross-compilation process of the data processing method provided by the embodiment of the present application is described in detail, such as Fig.11 As shown in the figure, the specific cross-compilation process includes:

[0133] Step 1101, use the cmake command to process the project files to be compiled and generate a project file directory.

[0134] Step 1102, search for the depend.make file in the project file directory.

[0135] Step 1103, determine whether the file content of the depend.make file is empty. If the file content of the depend.make file is not empty, execute step 1104, otherwise, execute step 1105.

[0136] Step 1104 , using the depend.make file as a configuration file, replacing the file names of header files whose file names are case incompatible in the configuration file, and obtaining an updated configuration file.

[0137] The specific implementation process of replacing the file name of the header file whose file name is case incompatible in the configuration file is as follows: Figure 6 As shown, no further description is given here.

[0138] Step 1105, search for the DependInfo.cmake file in the project file directory.

[0139] Step 1106, using the DependInfo.cmake file as a configuration file, replacing the file names of header files whose file names are case incompatible in the configuration file, and obtaining an updated configuration file.

[0140] The specific implementation process of replacing the file name of the header file whose file name is case incompatible in the configuration file is as follows: Fig.10 As shown, no further description is given here.

[0141] Step 1107, compile based on the updated configuration file to generate an executable file or library.

[0142] Based on the same inventive concept, the present application also provides a data processing device for cross-compilation. Fig.12 As shown, it is a schematic diagram of the structure of the data processing device 1200, which may include:

[0143] An acquiring unit 1201 is used to acquire a configuration file, where the configuration file is constructed in the first platform based on the configuration of the second platform;

[0144] Processing unit 1202 is used to perform the following operations for each header file that the source file to be compiled in the configuration file depends on, to obtain an updated configuration file: determine the absolute path of the header file, if the header file is not found in the absolute path, ignore the case format of the characters in the header file name and search again, when the target file is found, use the file name of the target file to replace the file name of the header file in the configuration file.

[0145] In some embodiments, the acquisition unit 1201 is specifically configured to:

[0146] In the first platform, obtain the project file to be compiled;

[0147] Use preset commands to process the project files to be compiled, and build a project file directory based on the configuration of the second platform;

[0148] Search for the configuration file in the project file directory.

[0149] In some embodiments, the acquisition unit 1201 is specifically configured to:

[0150] Search for the file named as the first preset name in the project file directory;

[0151] If a file with the first preset name is found and the file content is not empty, the file with the first preset name is determined as the configuration file; or

[0152] If a file with the first preset name is found and the file content is empty, a file with the second preset name is searched in the project file directory, and the found file with the second preset name is determined as the configuration file.

[0153] In some embodiments, the processing unit 1202 is specifically configured to:

[0154] When a file named with the first preset name is determined as a configuration file, the configuration file is parsed to separate information of each header file from the configuration file;

[0155] The absolute path of each header file is determined according to the absolute path of the configuration file obtained in advance and the information of each header file.

[0156] In some embodiments, the processing unit 1202 is specifically configured to:

[0157] From the address information of each header file, obtain the relative path of each header file relative to the folder where the configuration file is located;

[0158] Concatenate the absolute path and relative path of the configuration file to get the absolute path of the header file.

[0159] In some embodiments, the processing unit 1202 is specifically configured to:

[0160] When a file named with the second preset name is determined as a configuration file, the configuration file is parsed, and a relative path of a dependent file is parsed from the configuration file, where the dependent file includes header file information that the source file to be compiled depends on;

[0161] Determine the absolute path of the dependent file based on the absolute path of the configuration file obtained in advance and the relative path of the dependent file;

[0162] Get the dependent file according to the absolute path of the dependent file, and get the absolute path of each header file from the header file information contained in the dependent file.

[0163] In some embodiments, the apparatus further comprises:

[0164] The compiling unit 1203 is used to compile based on the updated configuration file to generate an executable file or a library.

[0165] Based on the same inventive concept as the above method embodiment, an electronic device is also provided in the embodiment of the present application. The electronic device can be used to process the configuration file generated during the cross-compilation process. In this embodiment, the structure of the electronic device can be as follows Fig.13 As shown, it includes a memory 1301 , a communication module 1303 and one or more processors 1302 .

[0166] The memory 1301 is used to store computer programs executed by the processor 1302. The memory 1301 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and programs required for running the instant messaging function, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.

[0167] The memory 1301 may be a volatile memory, such as a random-access memory (RAM); the memory 1301 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); or the memory 1301 may be any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 1301 may be a combination of the above memories.

[0168] The processor 1302 may include one or more central processing units (CPU) or a digital processing unit, etc. The processor 1302 is used to implement the above-mentioned data processing method for cross-compilation when calling the computer program stored in the memory 1301 .

[0169] The communication module 1303 is used to communicate with terminal devices and other servers.

[0170] The specific connection medium between the memory 1301, the communication module 1303 and the processor 1302 is not limited in the embodiment of the present application. Fig.13 In the embodiment, the memory 1301 and the processor 1302 are connected via a bus 13013. The bus 13013 is connected to the processor 1302 via a bus 13013. Fig.13 The connections between other components are shown in bold lines, which are only for illustration and are not intended to be limiting. Bus 13013 can be divided into address bus, data bus, control bus, etc. For ease of representation, Fig.13 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0171] The memory 1301 stores a computer storage medium, and the computer storage medium stores computer executable instructions, and the computer executable instructions are used to implement the data processing method for cross-compilation in the embodiment of the present application. The processor 1302 is used to execute the above-mentioned data processing method for cross-compilation, such as Figure 1 shown.

[0172] In some possible implementations, various aspects of the data processing method for cross-compilation provided by the present application may also be implemented in the form of a program product, which includes program code. When the program product is run on a computer device, the program code is used to enable the computer device to execute the steps of the data processing method for cross-compilation according to various exemplary embodiments of the present application described above in this specification. For example, the computer device may execute the following steps: Figure 1 Follow the steps shown in .

[0173] The program product may adopt any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0174] The program product of the embodiment of the present application may adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a computing device. However, the program product of the present application is not limited thereto. In the embodiment of the present application, the readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with a command execution system, device or device.

[0175] The readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, wherein the readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with a command execution system, apparatus, or device.

[0176] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.

[0177] Program code for performing the operations of the present application may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device via any type of network including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., using an Internet service provider to connect via the Internet).

[0178] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories), or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0179] It should be noted that, although several units or subunits of the device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided into multiple units to be embodied.

[0180] In addition, although the operations of the method of the present application are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.

[0181] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0182] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program commands. These computer program commands can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the commands executed by the processor of the computer or other programmable data processing device generate commands for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0183] These computer program commands may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the commands stored in the computer readable memory produce an article of manufacture comprising a command device, the command device implementing the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0184] These computer program commands can also be loaded onto a computer or other programmable data processing device so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the commands executed on the computer or other programmable device provide the instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0185] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0186] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A data processing method for cross-compilation, characterized in that: The method comprises: Obtaining a configuration file, where the configuration file is constructed in the first platform based on the configuration of the second platform; For each header file in the configuration file that the source file to be compiled depends on, the following operations are performed to obtain an updated configuration file: determining the absolute path of the header file, and if the header file is not found in the absolute path, ignoring the case format of the characters in the file name of the header file and searching again, and when the target file is found, replacing the file name of the header file in the configuration file with the file name of the target file; The obtaining of the configuration file comprises: In the first platform, obtain the project file to be compiled; Using a preset command to process the project file to be compiled, and constructing a project file directory based on the configuration of the second platform; Searching the project file directory for a file with a first preset name; If a file with the first preset name is found and the file content is not empty, the file with the first preset name is determined as the configuration file; If a file named with the first preset name is found and the file content is empty, a file named with the second preset name is searched in the project file directory, and the found file named with the second preset name is determined as the configuration file.

2. The method according to claim 1, characterized in that When a file whose name is the first preset name is determined as the configuration file, determining the absolute path of the header file includes: Parsing the configuration file, and separating information of each header file from the configuration file; The absolute path of each header file is determined according to the pre-acquired absolute path of the configuration file and the information of each header file.

3. The method according to claim 2, characterized in that The step of determining the absolute path of each header file based on the pre-acquired absolute path of the configuration file and the information of each header file includes: Obtaining, from the address information of each header file, a relative path of each header file relative to the folder where the configuration file is located; The absolute path of the configuration file and the relative path are concatenated to obtain the absolute path of the header file.

4. The method according to claim 1, characterized in that: When a file named as the second preset name is determined as the configuration file, determining the absolute path of the header file includes: Parsing the configuration file, parsing the relative path of the dependent file from the configuration file, the dependent file containing header file information that the source file to be compiled depends on; Determine the absolute path of the dependent file according to the pre-acquired absolute path of the configuration file and the relative path of the dependent file; According to the absolute path of the dependent file, the dependent file is obtained, and the absolute path of each header file is obtained from the header file information included in the dependent file.

5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: Compile based on the updated configuration file to generate an executable file or a library.

6. A data processing device for cross-compilation, characterized in that: The device comprises: An acquisition unit, configured to acquire a configuration file, wherein the configuration file is constructed in the first platform based on the configuration of the second platform; The processing unit is used to perform the following operations respectively for each header file in the configuration file that the source file to be compiled depends on, so as to obtain an updated configuration file: determining the absolute path of the header file, and if the header file is not found in the absolute path, ignoring the case format of the characters in the file name of the header file and searching again, and when the target file is found, replacing the file name of the header file in the configuration file with the file name of the target file; The acquisition unit is specifically used for: In the first platform, obtain the project file to be compiled; Using a preset command to process the project file to be compiled, and constructing a project file directory based on the configuration of the second platform; Searching the project file directory for a file with a first preset name; If a file with the first preset name is found and the file content is not empty, the file with the first preset name is determined as the configuration file; If a file named with the first preset name is found and the file content is empty, a file named with the second preset name is searched in the project file directory, and the found file named with the second preset name is determined as the configuration file.

7. An electronic device, characterized in that: include: A memory for storing program instructions; A processor, configured to call the program instructions stored in the memory, and execute the method according to any one of claims 1 to 5 according to the obtained program.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable the computer to execute the method according to any one of claims 1 to 5.