[go: up one dir, main page]

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

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

Info

Publication number
CN118838603B
CN118838603B CN202411312841.6A CN202411312841A CN118838603B CN 118838603 B CN118838603 B CN 118838603B CN 202411312841 A CN202411312841 A CN 202411312841A CN 118838603 B CN118838603 B CN 118838603B
Authority
CN
China
Prior art keywords
file
name
configuration
header
absolute path
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202411312841.6A
Other languages
Chinese (zh)
Other versions
CN118838603A (en
Inventor
熊宇鹏
王康
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Dahua Technology Co Ltd
Original Assignee
Zhejiang Dahua Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Dahua Technology Co Ltd filed Critical Zhejiang Dahua Technology Co Ltd
Priority to CN202411312841.6A priority Critical patent/CN118838603B/en
Publication of CN118838603A publication Critical patent/CN118838603A/en
Application granted granted Critical
Publication of CN118838603B publication Critical patent/CN118838603B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/14Details of searching files based on file metadata
    • G06F16/148File search processing
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/164File meta data generation
    • G06F16/166File name conversion
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/43Checking; Contextual analysis
    • G06F8/433Dependency analysis; Data or control flow analysis
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • Human Computer Interaction (AREA)
  • Library & Information Science (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Stored Programmes (AREA)

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.

Description

Data processing method, device, equipment and medium applied to cross compiling
Technical Field
The present application relates to the field of computer technologies, and in particular, to a data processing method, apparatus, device, and medium applied to cross compiling.
Background
With the rapid development of the computer industry, various hardware platforms appear on a computer, which are limited by hardware resources, and some hardware platforms cannot directly compile programs, so that cross-compiling on other platforms is needed.
Cross-compilation, i.e., compiling an executable file or library on one source platform that can run on another source platform. In the process of cross compiling, the head files corresponding to the dependent are required to be searched, if the head files of the dependent and the head files searched by the command line are different in the case of names, the compiling will report errors, and the corresponding head files are not found. For example, a library of a Windows environment is compiled in a Linux environment, because file names in Linux are case-specific, but file names in Windows are not case-specific, the problem of the above-mentioned compiling error may occur in the compiling process.
Therefore, the case-case compatibility problem in the cross-platform cross-compiling process is a problem to be solved in the present day.
Disclosure of Invention
The embodiment of the application provides a data processing method, device, equipment and medium applied to cross compiling, which are used for solving the problem of case incompatibility in the current cross compiling process and improving the cross compiling success rate.
The embodiment of the application provides a data processing method applied to cross compiling, which comprises the following steps:
acquiring a configuration file, wherein the configuration file is built in a first platform based on the configuration of a second platform;
And respectively executing the following operations for each header file on which the source file to be compiled depends in the configuration files to obtain updated configuration files, wherein the absolute path of the header file is determined, if the header file is not searched in the absolute path, the case format of characters in the header file name is ignored for re-searching, and when a target file is searched, the file name of the target file is used for replacing the file name of the header file in the configuration files.
In the embodiment of the application, after a configuration file is acquired in a cross compiling process, for each header file on which a source file to be compiled depends in the configuration file, firstly determining an absolute path of the header file, then searching the header file based on the absolute path of the header file, if the header file is not searched in the absolute path, determining that the header file has a problem of incompatibilities in case and case, at the moment, ignoring the case format of characters in the name of the header file, searching again, and when a target file is searched, replacing the name of the header file in the configuration file by the name of the target file, thereby obtaining the updated configuration file.
By replacing the file name of the header file in the configuration file by the file name of the target file, the header file names with the case incompatibility problem in the configuration file are replaced, compared with the prior art, the case incompatibility problem in the cross compiling process can be solved, the case incompatibility of the header file caused by the platform difference in the cross compiling process is avoided, and the cross compiling success rate is improved.
In some embodiments, the acquiring the configuration file includes:
Acquiring an engineering file to be compiled in a first platform;
Processing the engineering file to be compiled by using a preset command, and constructing an engineering file directory based on the configuration of the second platform;
searching the configuration file from the engineering file catalogue.
In some embodiments, the searching the configuration file from the engineering file directory includes:
searching a file with a file name of a first preset name in the engineering file catalogue;
If the file with the file name of the first preset name is searched and the file content is not empty, determining the file with the file name of the first preset name as the configuration file, or
If the file name is searched for the file with the first preset name and the file content is empty, searching the engineering file directory for the file with the second preset name, and determining the searched file with the second preset name as the configuration file.
In some embodiments, when determining the file with the file name of the first preset name as the configuration file, the determining the absolute path of the header file includes:
analyzing the configuration file, and separating the information of each header file from the configuration file;
And determining the absolute path of each header file according to the absolute path of the configuration file and the information of each header file which are acquired in advance.
In some embodiments, the determining the absolute path of each header file according to the absolute path of the configuration file and the information of each header file, which are acquired in advance, includes:
Acquiring the relative path of each header file relative to the folder in which the configuration file is located from the address information of each header file;
and splicing the absolute path of the configuration file and the relative path to obtain the absolute path of the header file.
In some embodiments, when determining the file with the file name of the second preset name as the configuration file, the determining the absolute path of the header file includes:
analyzing the configuration file, and analyzing the relative path of a dependent file from the configuration file, wherein the dependent file comprises header file information of a source file to be compiled;
determining the absolute path of the dependent file according to the absolute path of the configuration file and the relative path of the dependent file which are acquired in advance;
and acquiring the dependent file according to the absolute path of the dependent file, and acquiring the absolute path of each head file from the head file information contained in the dependent file.
In some embodiments, the method further comprises:
compiling based on the updated configuration file to generate an executable file or library.
Accordingly, an embodiment of the present application provides a data processing apparatus applied to cross-compiling, the apparatus including:
The system comprises an acquisition unit, a configuration file generation unit and a configuration unit, wherein the acquisition unit is used for acquiring a configuration file which is built in a first platform based on the configuration of a second platform;
And the processing unit is used for respectively executing the following operations for each header file on which the source file to be compiled depends in the configuration file to obtain an updated configuration file, wherein the absolute path of the header file is determined, if the header file is not searched in the absolute path, the case format of characters in the header file name is ignored for re-searching, and when a target file is searched, the file name of the target file is used for replacing the file name of the header file in the configuration file.
In some embodiments, the acquiring unit is specifically configured to:
Acquiring an engineering file to be compiled in a first platform;
Processing the engineering file to be compiled by using a preset command, and constructing an engineering file directory based on the configuration of the second platform;
searching the configuration file from the engineering file catalogue.
In some embodiments, the acquiring unit is specifically configured to:
searching a file with a file name of a first preset name in the engineering file catalogue;
If the file with the file name of the first preset name is searched and the file content is not empty, determining the file with the file name of the first preset name as the configuration file, or
If the file name is searched for the file with the first preset name and the file content is empty, searching the engineering file directory for the file with the second preset name, and determining the searched file with the second preset name as the configuration file.
In some embodiments, the processing unit is specifically configured to:
when the file with the file name of the first preset name is determined to be the configuration file, analyzing the configuration file, and separating the information of each header file from the configuration file;
And determining the absolute path of each header file according to the absolute path of the configuration file and the information of each header file which are acquired in advance.
In some embodiments, the processing unit is specifically configured to:
Acquiring the relative path of each header file relative to the folder in which the configuration file is located from the address information of each header file;
and splicing the absolute path of the configuration file and the relative path to obtain the absolute path of the header file.
In some embodiments, the processing unit is specifically configured to:
When the file with the file name of the second preset name is determined to be the configuration file, analyzing the configuration file, and analyzing the relative path of a dependent file from the configuration file, wherein the dependent file comprises header file information of a source file to be compiled;
determining the absolute path of the dependent file according to the absolute path of the configuration file and the relative path of the dependent file which are acquired in advance;
and acquiring the dependent file according to the absolute path of the dependent file, and acquiring the absolute path of each head file from the head file information contained in the dependent file.
In some embodiments, the apparatus further comprises:
and the compiling unit is used for compiling based on the updated configuration file to generate an executable file or library.
Another embodiment of the present application provides an electronic device, including a memory for storing program instructions and a processor for calling the program instructions stored in the memory, and executing any one of the methods according to the obtained program.
Another embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions for causing the computer to perform any of the methods described above.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of a data processing method according to an embodiment of the present application;
fig. 2 is a schematic diagram of file content of a dependent. Make file according to an embodiment of the present application;
FIG. 3 is a schematic diagram of file content of a DependInfo. Cmake file according to an embodiment of the present application;
FIG. 4 is a schematic diagram of file content of another dependent. Make file according to an embodiment of the present application;
Fig. 5 is a schematic diagram of header information according to an embodiment of the present application;
fig. 6 is a schematic flow chart of a specific data processing process when a configuration file is a dependent.
FIG. 7 is a schematic diagram of file content of another embodiment of the present application;
FIG. 8 is a schematic diagram of relying on file information according to an embodiment of the present application;
FIG. 9 is a schematic diagram of file content dependent files according to an embodiment of the present application;
FIG. 10 is a flowchart illustrating a specific data processing procedure when a configuration file is a DependInfo. Cmake file according to an embodiment of the present application;
FIG. 11 is a flowchart illustrating a cross-compilation implementation process according to an embodiment of the present application;
FIG. 12 is a schematic diagram of a data processing apparatus according to an embodiment of the present application;
Fig. 13 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments, but not all embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The embodiment of the application provides a data processing method, device, equipment and medium applied to cross compiling, which are used for solving the problem of case incompatibility in the current cross compiling process and improving the cross compiling success rate.
The method, the device, the apparatus, the medium and the medium are based on the same application conception, and because the method, the device, the apparatus and the medium have similar principles for solving the problems, the implementation of the device, the apparatus, the medium and the method can be referred to each other, and the repetition is omitted.
The terms first, second and the like in the description and in the claims of embodiments of the application and in the above-described figures, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments described herein may be implemented in other sequences than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The following examples and embodiments are to be construed as illustrative only. Although the specification may refer to "an", "one", or "some" example or embodiment(s) at several points, this does not mean that each such reference is related to the same example or embodiment, nor that the feature is applicable to only a single example or embodiment. Individual features of different embodiments may also be combined to provide further embodiments. Furthermore, terms such as "comprising" and "including" should be understood not to limit the described embodiments to consist of only those features mentioned, but such examples and embodiments may also include features, structures, units, modules, etc. that are not specifically mentioned.
Various embodiments of the application are described in detail below with reference to the drawings attached to the specification. It should be noted that, the display sequence of the embodiments of the present application only represents the sequence of the embodiments, and does not represent the advantages or disadvantages of the technical solutions provided by the embodiments.
With the rapid development of the computer industry, various hardware platforms appear on a computer, which are limited by hardware resources, and some hardware platforms cannot directly compile programs, so that cross-compiling on other platforms is needed.
Cross-compilation, i.e., compiling an executable file or library on one source platform that can run on another source platform. In the process of cross compiling, the head files corresponding to the dependent are required to be searched, if the head files of the dependent and the head files searched by the command line are different in the case of names, the compiling will report errors, and the corresponding head files are not found. For example, a library of a Windows environment is compiled in a Linux environment, because file names in Linux are case-specific, but file names in Windows are not case-specific, the problem of the above-mentioned compiling error may occur in the compiling process.
Therefore, the case-case compatibility problem in the cross-platform cross-compiling process is a problem to be solved in the present day.
In the embodiment of the application, after a configuration file is acquired in a cross compiling process, for each header file on which a source file to be compiled depends in the configuration file, firstly determining an absolute path of the header file, then searching the header file based on the absolute path of the header file, if the header file is not searched in the absolute path, determining that the header file has a problem of incompatibilities in case and case, at the moment, ignoring the case format of characters in the name of the header file, searching again, and when a target file is searched, replacing the name of the header file in the configuration file by the name of the target file, thereby obtaining the updated configuration file.
By replacing the file name of the header file in the configuration file by the file name of the target file, the header file names with the case incompatibility problem in the configuration file are replaced, compared with the prior art, the case incompatibility problem in the cross compiling process can be solved, the case incompatibility of the header file caused by the platform difference in the cross compiling process is avoided, and the cross compiling success rate is improved.
Before formally describing the embodiment of the present application, it should be noted that, the data processing method applied to cross-compiling provided by the embodiment of the present application may be executed by a terminal device that executes cross-compiling, which is not limited by the embodiment of the present application.
Clang and gcc are two commonly used compiling tools and both support cross-compiling, and the following description of the embodiments of the present application is only given by way of example with clang, and of course, the data processing method provided in the embodiments of the present application is equally applicable to gcc and other cross-compiling tools.
Referring to fig. 1, an implementation flow of a data processing method applied to cross compiling provided in an embodiment of the present application includes the following steps S101 to S102:
s101, acquiring a configuration file, wherein the configuration file is built in the first platform based on the configuration of the second platform.
In the implementation, the engineering files to be compiled are obtained in the first platform, then the engineering files to be compiled are processed by using a preset command, an engineering file catalog is built based on the configuration of the second platform, and the configuration files are searched from the engineering file catalog. The project file to be compiled may be written by a user or uploaded by the user, which is not limited in the embodiment of the present application, and the preset command may be cmake commands.
In practical application, after creating the complete project file directory, the header file corresponding to the source file to be compiled (cpp or c) is already set in the configuration file, and the configuration file is generally dependent.
In view of the fact that the file names of the configuration files are fixed, when the configuration files are specifically searched from the engineering file catalogue, the file with the file name of the first preset name can be searched in the engineering file catalogue, if the file with the file name of the first preset name is searched and the file content is not empty, the file with the file name of the first preset name is determined to be the configuration file, if the file with the file name of the first preset name is searched and the file content is empty, the file with the file name of the second preset name is searched in the engineering file catalogue, and the file with the searched file name of the second preset name is determined to be the configuration file. Wherein the first preset name is dependent. The second preset name is dependendinfo.
In one example, the content format of the dependent. Make file, as shown in fig. 2, in which the part h following the colon is the · cpp or · c dependent header file, and the · included_path/example_inc1. H, as shown in fig. 2, is a · cpp or · c dependent header file. Wherein the signs represent arbitrary characters.
In another example, the content format of the dependendnfo.cmake file, as shown in fig. 3, is in the dependendnfo.cmake file content.
S102, for each header file on which a source file to be compiled depends in the configuration file, respectively executing the following operations to obtain an updated configuration file, wherein the absolute path of the header file is determined, if the header file is not searched in the absolute path, the case format of characters in the header file name is ignored for re-searching, and when a target file is searched, the file name of the target file is used for replacing the file name of the header file in the configuration file.
It should be noted that, since the configuration files are divided into the independent file and the independent file, and the file contents of the independent file and the independent file are different, the following description will be made with reference to the two configuration files to determine the absolute path of the header file and to replace the specific implementation process of the file name of part or all of the header file.
1. The configuration file is a dependent.
In this case, when determining the absolute path of the header files, the configuration files are parsed, the information of each header file is separated from the configuration files, and then the absolute path of each header file is determined according to the absolute path of the configuration files and the information of each header file obtained in advance. Specifically, the relative path of each header file relative to the folder in which the configuration file is located is obtained from the address information of each header file, and the absolute path and the relative path of the configuration file are spliced to obtain the absolute path of the header file.
Specifically, the dependent. Make file is usually divided by empty line, and represents one. Cpp or. C dependent header file, as shown in fig. 4, for example, the source file cpp_file2.C to be compiled depends on three header files, file names are example_inc4.H, example_inc5.H, example_inc6.H, where the./ included_path 2/dirname in front of example_inc6.H represents the relative path with respect to the engineering file directory, the compiled target product is cpp_file2.C.o, and then the target product and the dependent header file information of other source files cpp_file1.C and cpp_file3.C to be compiled are respectively before and after the empty line.
In specific implementation, the read dependent content is stored in a variable cpp_ depend _h_total, information corresponding to each source file to be compiled is analyzed by dividing the variable cpp_ depend _h_str_list, each member of the cpp_ depend _h_str_list is traversed in sequence, the member variable is cpp_ depend _h_per_str, then dependent header file information is divided for cpp_ depend _h_per_str through a line-changing character, and the member formats of the list variables cpp_ depend _h_per_list and cpp_ depend _h_per_list are shown in fig. 5.
Then traversing cpp_ depend _h_per_list elements in turn, and analyzing the o file character string and the h file character string through a colon, wherein the variables var_o_str and var_h_str exist in the file character string respectively, and for example, the character string illustrated in fig. 5 can be analyzed:
var_o_str=complier_result_path/cpp_file2.c.o
var_h_str=../include_path2/dirname23/example_inc6.h
The original file name of the header file is stored in a variable var_h_old, where var_h_old=example_inc6. H, and the absolute path var_h_ abspath of the header file can be obtained by splicing the absolute path of the obtained dependent. Make file and the relative path of the h file (the above mentioned var_h_str variable).
After obtaining the absolute path of the header file, searching the header file based on the absolute path of the header file by using a preset function, for example, judging whether the header file exists under the absolute path of the header file through a function os.path.exists (var_h_ abspath), if so, indicating that the header file name does not have the problem of case incompatibility, continuing to process the next header file without performing a replacement operation, if not, indicating that the header file has the problem of case incompatibility, continuing to search by ignoring the character case format of the file name, and when searching the target file, storing the file name of the target file in a variable var_h_new, and further storing the original file name of the header file with the unmatched file name and the correct file name in a dictionary var_h_direct, wherein var_h_di= { var_h_new }, until one pp_62_per_62_per }, is completed.
The designated substring in the string variable cpp_ depend _h_per_str is replaced, the designated substring is var_h_old, the designated substring is replaced by var_h_new, and the substring is stored in the list variable cpp_ depend _h_str_new_list after the replacement is completed. After traversing all cpp_ depend _h_str_list, obtaining the latest cpp_ depend _h_str_new_list, splicing cpp_ depend _h_str_new_list by using empty lines to obtain a character string variable cpp_ depend _h_total_new, then clearing the content of the dependent. Make file, and writing the cpp_ depend _h_total_new into the dependent. Make file, namely realizing the replacement of the file name of the head file with the incompatible file name, solving the problem of case incompatibility in the cross compiling process, avoiding the head file case incompatibility caused by platform difference in the cross compiling process, and improving the cross compiling success rate.
Next, with reference to fig. 6, a detailed description will be given of an implementation procedure for replacing a file name of a header file whose file name is not matched in case of a configuration file being a dependent.
In step 601, the content of the dependent. Make file is read and stored in a variable cpp_ depend _h_total, and divided by empty line, cpp_ depend _h_total is divided, and the divided block exists in a list variable cpp_ depend _h_str_list.
In step 602, cpp_ depend _h_per_str, which is a member of cpp_ depend _h_str_list, is parsed by a line feed, and the result of the parsing is stored in a list variable cpp_ depend _h_per_list.
In step 603, for each cpp_ depend _h_per_list, the o file string and the h file string are parsed by colon, and the variables var_o_str and var_h_str exist respectively.
Step 604, the absolute path var_h_ abspath of the header file is obtained by splicing the absolute path of the obtained dependent.
Step 605, it is determined whether or not the var_h_ abspath exists as a header file, if so, the next cpp_ depend _h_per_list is processed in step 603, and if not, step 606 is executed.
In step 606, the character case format in the file name of the header file is ignored, the searching is continued, and the searched file name of the target file and the original file name of the header file are stored in the var_h_subject dictionary.
Step 607, it is determined whether the header file in cpp_ depend _h_per_list is processed, if not, step 603 is continued to process the next header file, and if so, step 608 is executed.
After traversing one cpp_ depend _h_per_list, step 608 replaces the file name of the header file with the file name of the cpp_ depend _h_per_str with the unmatched file name, and then step 602 is performed to process the next cpp_ depend _h_str_list.
It should be noted that, when all cpp_ depend _h_str_list processing is completed, and obtaining an updated dependent. Make file, namely an updated configuration file.
2. The configuration file is a dependendnfo.
In this case, when determining the absolute path of the header file, firstly, analyzing the configuration file, analyzing the relative path of the dependent file from the configuration file, wherein the dependent file contains header file information on which the source file to be compiled depends, then, determining the absolute path of the dependent file according to the absolute path of the configuration file and the relative path of the dependent file which are obtained in advance, and finally, obtaining the dependent file according to the absolute path of the dependent file, and obtaining the absolute path of each header file from the header file information contained in the dependent file.
Specifically, the content of the dependendinfo.cmake file is obtained, as shown in fig. 7, by parsing the content after the acquisition set (CMAKE _ DEPENDS _ DEPENDENCY _ FILES, which is present in the string variable dependInfo _str.
Then, the string variable dependInfo _str is divided and spaces are removed through a line feed character, the list variable cpp_ depend _list is obtained through analysis, and the cpp_ depend _list stores the dependency information of all cpp or c in the configuration file, and the element format in the cpp_ depend _list is shown in fig. 8.
Traversing each member (cpp_ depend _per_str) in cpp_ depend _list, obtaining the relative path of cpp_ depend _per_str by space analysis, and determining the absolute path per_obj_d_ abspath of cpp_obj.d by the absolute path of the pre-obtained dependent info.
Then, the per_obj_d_ abspath file is read, and the file content is obtained, as shown in fig. 9, the file content has a string variable per_obj_d_info, the string variable per_obj_d_info is split by a line-feed character and a reverse slash (\), and all elements have a list variable cpp_ depend _inc_list, wherein cpp_ depend _inc_list contains two elements.
Traversing cpp_ depend _inc_list each element cpp_ depend _inc_str, wherein cpp_ depend _inc_str is the absolute path of the h header file, the original file name of the h header file is expressed by using a variable var_h_old, traversing to the cpp and cpp.obj selects to skip without processing, judging whether the header file exists through a function os.path.exist (cpp_ depend _inc_str) when traversing to h, if so, indicating that the file name of the header file does not have the problem of case incompatibility, continuing to process the next header file, if not, indicating that the file name of the header file has the problem of case incompatibility under the absolute path of the header file, continuing to search for characters of the file name, and when searching for the target file, writing the variables var_new_h_old and the variable var_old in the target file into the dictionary format of the header file, and writing the dictionary of the header file in the format of the current direction of the header file in the current direction of the header file.
Finally, the substrings where the var_h_old in the dictionary variable var_h_subject are located are replaced by the corresponding var_h_new, namely the file names of the head files with the unmatched file names in the per_obj_d_info are replaced until the complete cpp_ depend _list is traversed, namely the replacement of the file names of the head files with the unmatched file names in the file names is realized, the problem of the incompatibility of the case and the case in the cross compiling process is solved, the head file incompatibility caused by the platform difference in the cross compiling process is avoided, and the cross compiling success rate is improved.
Next, with reference to fig. 10, a detailed description will be given of an implementation process of replacing a file name of a header file whose file name is not matched in case of a configuration file being a dependendinfo.
In step 1001, the content of the dependinfo.cmake file is obtained, the key string is extracted, and stored in the variable dependInfo _str.
In step 1002, the string variable dependInfo _str is parsed by a line feed, and the parsing result is stored in the list variable cpp_ depend _list.
In step 1003 the process proceeds to step 1003, traversing each member cpp depend per str in cpp depend list, resolving cpp_ depend _per_str gives the absolute path per_obj_d_ abspath of the. Obj.d.
In step 1004, the per_obj_d_ abspath file is read, the file content is obtained, and the file content exists in the string variable per_obj_d_info.
In step 1005, by wrapping the line and the reverse slash segmentation string variable per_obj_d_info, all elements in the list variable cpp_ depend _inc_list, traversing each element cpp_ depend _inc_str in cpp_ depend _inc_list, and obtaining the original file name of the h header file, where the original file name is represented by variable var_h_old.
Step 1006, determining whether cpp_ depend _inc_str exists or not, if so, executing step 1005 to check the next header file, and if not, executing step 1007.
In step 1007, the character case format in the file name of the header file is ignored, the search is continued, and the file name of the searched target file and the original file name of the header file are stored in the var_h_subject dictionary.
Step 1008, it is determined whether the header file in cpp_ depend _inc_list is processed, if not, step 1005 is continued to process the next header file, and if so, step 1009 is performed.
Step 1009, after traversing to complete one cpp_ depend _inc_list, replacing the file name of the header file with the file name of which the case does not match in per_obj_d_info by using the dictionary var_h_direct, and then executing step 1003 to process the next cpp_ depend _per_str.
It should be noted that, after all cpp_ depend _per_str processes are completed, an updated dependendinfo.cmake file, that is, an updated configuration file, may be obtained.
In the implementation, after the updated configuration file is obtained, the embodiment of the application can compile based on the updated configuration file to generate an executable file or library.
The following describes in detail the cross-compiling process of the data processing method according to the embodiment of the present application with reference to fig. 11, and as shown in fig. 11, the specific cross-compiling process includes:
And 1101, processing the engineering file to be compiled by using cmake command to generate an engineering file directory.
Step 1102, search the project file directory for a dependent.
Step 1103, determining whether the file content of the dependent. Make file is empty, if the file content of the dependent. Make file is not empty, executing step 1104, otherwise, executing step 1105.
And 1104, taking the dependent. Make file as a configuration file, and replacing the file name of the header file with the incompatible file name and case in the configuration file to obtain an updated configuration file.
The implementation process of replacing the file name of the header file with the incompatible file name case in the configuration file is shown in fig. 6, and will not be repeated here.
Step 1105, search the project file directory for a dependendnfo.
Step 1106, taking the DependInfo. Cmake file as the configuration file, replacing the file name of the header file with incompatible file name and file case in the configuration file, and obtaining the updated configuration file.
The implementation process of replacing the file name of the header file with the incompatible file name case in the configuration file is shown in fig. 10, and will not be repeated here.
Step 1107, compiling based on the updated configuration file to generate an executable file or library.
Based on the same inventive concept, the embodiment of the application also provides a data processing device applied to cross compiling. As shown in fig. 12, which is a schematic structural diagram of the data processing apparatus 1200, may include:
An obtaining unit 1201, configured to obtain a configuration file, where the configuration file is built in the first platform based on the configuration of the second platform;
The processing unit 1202 is configured to determine an absolute path of a header file, and if the header file is not searched in the absolute path, ignore a case format of characters in a header file name, and re-search the header file, and when a target file is searched, replace the file name of the header file in the configuration file with the file name of the target file.
In some embodiments, the obtaining unit 1201 is specifically configured to:
Acquiring an engineering file to be compiled in a first platform;
processing the engineering file to be compiled by using a preset command, and constructing an engineering file directory based on the configuration of the second platform;
searching configuration files from the engineering file catalogue.
In some embodiments, the obtaining unit 1201 is specifically configured to:
Searching a file with a file name of a first preset name in an engineering file catalog;
If the file with the file name of the first preset name is searched and the file content is not empty, determining the file with the file name of the first preset name as a configuration file, or
If the file with the file name of the first preset name is searched and the file content is empty, searching the engineering file directory for the file with the file name of the second preset name, and determining the searched file with the file name of the second preset name as the configuration file.
In some embodiments, the processing unit 1202 is specifically configured to:
when a file with a file name being a first preset name is determined to be a configuration file, the configuration file is analyzed, and information of each header file is separated from the configuration file;
and determining the absolute path of each header file according to the absolute path of the configuration file and the information of each header file which are acquired in advance.
In some embodiments, the processing unit 1202 is specifically configured to:
Acquiring the relative path of each header file relative to the folder in which the configuration file is located from the address information of each header file;
and splicing the absolute path and the relative path of the configuration file to obtain the absolute path of the header file.
In some embodiments, the processing unit 1202 is specifically configured to:
When the file with the file name being the second preset name is determined to be the configuration file, analyzing the relative path of the dependent file from the configuration file, wherein the dependent file comprises header file information of the source file to be compiled;
Determining the absolute path of the dependent file according to the absolute path of the pre-acquired configuration file and the relative path of the dependent file;
And acquiring the dependent file according to the absolute path of the dependent file, and acquiring the absolute path of each head file from the head file information contained in the dependent file.
In some embodiments, the apparatus further comprises:
and a compiling unit 1203 configured to compile based on the updated configuration file, and generate an executable file or library.
The embodiment of the application also provides electronic equipment based on the same conception as the embodiment of the method. The electronic device may be used to process configuration files generated during cross-compilation. In this embodiment, the electronic device may be configured as shown in fig. 13, including a memory 1301, a communication module 1303, and one or more processors 1302.
Memory 1301 is used for storing a computer program executed by processor 1302. The memory 1301 may mainly include a storage program area that may store an operating system, programs required for running an instant messaging function, and the like, and a storage data area that may store various instant messaging information, an operation instruction set, and the like.
Memory 1301 may be a volatile memory (RAM), such as random-access memory (RAM), or memory 1301 may be a non-volatile memory (non-volatile memory), such as read-only memory (rom), flash memory (flash memory), hard disk (HARD DISK DRIVE, HDD) or solid state disk (solid-state disk) (STATE DRIVE, SSD), or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto. Memory 1301 may be a combination of the above.
The processor 1302 may include one or more central processing units (central processing unit, CPU) or digital processing units, or the like. A processor 1302 for implementing the above-described data processing method applied to cross-compilation when calling the computer program stored in the memory 1301.
The communication module 1303 is used for communicating with the terminal device and other servers.
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. The disclosed embodiment is illustrated in fig. 13 by a memory 1301 and a processor 1302 connected by a bus 13013, where the bus 13013 is illustrated in fig. 13 by a bold line, and the manner in which the other components are connected is illustrated by way of example only and not by way of limitation. Bus 13013 can be divided into address bus, data bus, control bus, and the like. For ease of illustration, only one thick line is shown in fig. 13, but not only one bus or one type of bus.
The memory 1301 stores therein a computer storage medium in which computer executable instructions for implementing the data processing method for cross-compilation according to the embodiment of the present application are stored. The processor 1302 is configured to perform the data processing method described above as being applied to cross-compilation, as shown in fig. 1.
In some possible embodiments, aspects of the data processing method applied to cross-compilation provided by the present application may also be implemented in the form of a program product comprising program code for causing a computer device to carry out the steps of the data processing method applied to cross-compilation according to the various exemplary embodiments of the present application described herein above when the program product is run on a computer device, for example, the computer device may carry out the steps as shown in fig. 1.
The program product may employ 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 can be, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of a readable storage medium include an electrical connection having 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The program product of embodiments of the present application may employ a portable compact disc read only memory (CD-ROM) and include program code and may run on a computing device. However, the program product of the present application is not limited thereto, and in embodiments of the present application, the readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with a command execution system, apparatus, or device.
The readable signal medium may include a data signal propagated in baseband or as part of a carrier wave with readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with a command execution system, apparatus, or device.
Program code embodied on a readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Program code for carrying out operations of the present application may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's equipment, as a stand-alone software package, partly on the user's computing device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of remote computing devices, the remote computing device may be connected to the user computing device through any kind 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., connected via the Internet using an Internet service provider).
In the present embodiment, the term "module" or "unit" refers to a computer program or a part of a computer program having a predetermined function and working together with other relevant parts to achieve a predetermined object, and may be implemented in whole or in part by using software, hardware (such as a processing circuit or a memory), or a combination thereof. Also, a processor (or multiple processors or memories) may be used to implement one or more modules or units. Furthermore, each module or unit may be part of an overall module or unit that incorporates the functionality of the module or unit.
It should be noted that although several units or sub-units of the apparatus are mentioned in the above detailed description, such a division is merely exemplary and not mandatory. Indeed, the features and functions of two or more of the elements described above may be embodied in one element in accordance with embodiments of the present application. Conversely, the features and functions of one unit described above may be further divided into a plurality of units to be embodied.
Furthermore, although the operations of the methods of the present application are depicted in the drawings in a particular order, this is not required or suggested that these operations must be performed in this particular order or that all of the illustrated operations must be performed in order to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step to perform, and/or one step decomposed into multiple steps to perform.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program commands may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the commands executed by the processor of the computer or other programmable data processing apparatus produce means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program commands may also be stored in a computer readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the commands stored in the computer readable memory produce an article of manufacture including command means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the application.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present application without departing from the spirit or scope of the application. Thus, it is intended that the present application also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.

Claims (8)

1. A data processing method for cross-compilation, the method comprising:
acquiring a configuration file, wherein the configuration file is built in a first platform based on the configuration of a second platform;
Determining an absolute path of the header file, if the header file is not searched in the absolute path, ignoring a case format of characters in the header file name for searching again, and replacing the file name of the header file in the configuration file by the file name of the target file when the target file is searched;
The acquiring the configuration file comprises the following steps:
Acquiring an engineering file to be compiled in a first platform;
Processing the engineering file to be compiled by using a preset command, and constructing an engineering file directory based on the configuration of the second platform;
searching a file with a file name of a first preset name in the engineering file catalogue;
if the file with the file name of the first preset name is searched and the file content is not empty, determining the file with the file name of the first preset name as the configuration file;
If the file name is searched for the file with the first preset name and the file content is empty, searching the engineering file directory for the file with the second preset name, and determining the searched file with the second preset name as the configuration file.
2. The method of claim 1, wherein determining the absolute path of the header file when determining the file with the file name of the first preset name as the configuration file comprises:
analyzing the configuration file, and separating the information of each header file from the configuration file;
And determining the absolute path of each header file according to the absolute path of the configuration file and the information of each header file which are acquired in advance.
3. The method of claim 2, wherein determining the absolute path of each header file based on the absolute path of the configuration file and the information of each header file obtained in advance comprises:
Acquiring the relative path of each header file relative to the folder in which the configuration file is located from the address information of each header file;
and splicing the absolute path of the configuration file and the relative path to obtain the absolute path of the header file.
4. The method according to claim 1, wherein determining the absolute path of the header file when determining the file with the file name of the second preset name as the configuration file comprises:
analyzing the configuration file, and analyzing the relative path of a dependent file from the configuration file, wherein the dependent file comprises header file information of a source file to be compiled;
determining the absolute path of the dependent file according to the absolute path of the configuration file and the relative path of the dependent file which are acquired in advance;
and acquiring the dependent file according to the absolute path of the dependent file, and acquiring the absolute path of each head file from the head file information contained in the dependent file.
5. The method according to any one of claims 1-4, further comprising:
compiling based on the updated configuration file to generate an executable file or library.
6. A data processing apparatus for cross-compilation, the apparatus comprising:
The system comprises an acquisition unit, a configuration file generation unit and a configuration unit, wherein the acquisition unit is used for acquiring a configuration file which is built in a first platform based on the configuration of a second platform;
The processing unit is used for respectively executing the following operations aiming at each header file on which a source file to be compiled in the configuration file depends to obtain an updated configuration file, wherein the absolute path of the header file is determined, if the header file is not searched in the absolute path, the case format of characters in the header file name is ignored for re-searching, and when a target file is searched, the file name of the target file is used for replacing the file name of the header file in the configuration file;
The acquisition unit is specifically configured to:
Acquiring an engineering file to be compiled in a first platform;
Processing the engineering file to be compiled by using a preset command, and constructing an engineering file directory based on the configuration of the second platform;
searching a file with a file name of a first preset name in the engineering file catalogue;
if the file with the file name of the first preset name is searched and the file content is not empty, determining the file with the file name of the first preset name as the configuration file;
If the file name is searched for the file with the first preset name and the file content is empty, searching the engineering file directory for the file with the second preset name, and determining the searched file with the second preset name as the configuration file.
7. An electronic device, comprising:
a memory for storing program instructions;
a processor for invoking program instructions stored in said memory to perform the method of any of claims 1-5 in accordance with the obtained program.
8. A computer-readable storage medium storing computer-executable instructions for causing a computer to perform the method of any one of claims 1 to 5.
CN202411312841.6A 2024-09-19 2024-09-19 Data processing method, device, equipment and medium for cross-compilation Active CN118838603B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411312841.6A CN118838603B (en) 2024-09-19 2024-09-19 Data processing method, device, equipment and medium for cross-compilation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411312841.6A CN118838603B (en) 2024-09-19 2024-09-19 Data processing method, device, equipment and medium for cross-compilation

Publications (2)

Publication Number Publication Date
CN118838603A CN118838603A (en) 2024-10-25
CN118838603B true CN118838603B (en) 2025-03-21

Family

ID=93149660

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411312841.6A Active CN118838603B (en) 2024-09-19 2024-09-19 Data processing method, device, equipment and medium for cross-compilation

Country Status (1)

Country Link
CN (1) CN118838603B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119127217B (en) * 2024-11-14 2025-03-04 联通在线信息科技有限公司 MailCore2 component integration configuration file generation method and device

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6941547B2 (en) * 2001-06-25 2005-09-06 International Business Machines Corporation Apparatus and method for porting applications to different platforms
CN100442234C (en) * 2005-06-21 2008-12-10 国际商业机器公司 Software package construction method and system for embedded systems
US10592215B1 (en) * 2017-08-17 2020-03-17 NanoVMs, Inc. Unikernel cross-compilation
CN115390846A (en) * 2022-08-11 2022-11-25 地平线(上海)人工智能技术有限公司 Compilation construction method, device, electronic device and storage medium
CN115437639A (en) * 2022-08-24 2022-12-06 深圳云豹智能有限公司 Automatic generation method and device of compiling configuration file, electronic equipment and storage medium
CN116257250A (en) * 2023-02-20 2023-06-13 重庆长安汽车股份有限公司 Cross-platform compiling method, device, electronic device and storage medium
CN116841635A (en) * 2023-05-24 2023-10-03 上海益世界信息技术集团有限公司 Parameter configuration method, device, equipment and storage medium
CN118444920A (en) * 2024-04-12 2024-08-06 浙江大华技术股份有限公司 Cross-platform compiling method, electronic device and computer readable storage medium

Also Published As

Publication number Publication date
CN118838603A (en) 2024-10-25

Similar Documents

Publication Publication Date Title
CN106547527B (en) JavaScript file construction method and device
CN109766099A (en) Front end source code Compilation Method, device, storage medium and computer equipment
US10248409B1 (en) Limiting the effects of source code patches on corresponding native-code patches
CN109491661B (en) Universal cross-compiling method and device
CN118838603B (en) Data processing method, device, equipment and medium for cross-compilation
CN110990051B (en) Method, apparatus, medium and equipment for maintaining software package dependencies
CN113515303A (en) Project transformation method, device and equipment
CN113495728A (en) Dependency relationship determination method, dependency relationship determination device, electronic equipment and medium
CN113886839A (en) Method and device for identifying risk problems in batch job dependencies
CN112905164B (en) A project code processing method and device
CN115390944A (en) Algorithm service calling method and device, electronic equipment and storage medium
CN118409793B (en) Code migration method, device, equipment and medium for front-end framework upgrade
US20220350797A1 (en) Providing container images
CN113821486B (en) Method and device for determining dependency relationship between pod libraries and electronic equipment
US20240248689A1 (en) Determining dependencies in workspaces
US9817659B2 (en) Artifact normalization
CN115934098B (en) Physical model configuration method, device and computer-readable storage medium
JP2025529139A (en) Automated wrapping tool with guidance from example commands
CN112925573B (en) Methods, devices, equipment and computer-readable media for loading web pages
US10120968B1 (en) System and method for hierarchical library searching
CN118210781B (en) Compatible database generation method and computing device
CN119645531B (en) Method, device, equipment and medium for unifying content of base application and sub-application
CN120030083B (en) Document visualization method and device based on graph database GQL syntax
CN114675867B (en) A data processing method, device, server and storage medium
CN114840217A (en) Compiling method, device, equipment and readable storage medium

Legal Events

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