CN114020694B - Header file address acquisition method and device, electronic equipment and storage medium - Google Patents

Header file address acquisition method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114020694B
CN114020694B CN202111216764.0A CN202111216764A CN114020694B CN 114020694 B CN114020694 B CN 114020694B CN 202111216764 A CN202111216764 A CN 202111216764A CN 114020694 B CN114020694 B CN 114020694B
Authority
CN
China
Prior art keywords
file
component
header
header file
name
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
CN202111216764.0A
Other languages
Chinese (zh)
Other versions
CN114020694A (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.)
Beijing 58 Information Technology Co Ltd
Original Assignee
Beijing 58 Information 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 Beijing 58 Information Technology Co Ltd filed Critical Beijing 58 Information Technology Co Ltd
Priority to CN202111216764.0A priority Critical patent/CN114020694B/en
Publication of CN114020694A publication Critical patent/CN114020694A/en
Application granted granted Critical
Publication of CN114020694B publication Critical patent/CN114020694B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/73Program documentation

Landscapes

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

Abstract

The invention provides a method and a device for acquiring a header file address, electronic equipment and a storage medium. For any component in the engineering project, a HeaderMap file of the component which the component depends on is obtained, and a ' component name-own-target-heads of the dependent component ' hmap ' file is arranged in the Header Search Path of the component. And under the condition that a first source file in the first assembly needs to call a header file address of a header file of a second source file in a second assembly in the engineering project, acquiring the assembly name of the second assembly and the header file name of the header file of the second source file. According to the component name of the second component, a file of the component name-own-target-heads of the second component is searched in the Header Search Path of the first component. And searching the header file address of the second header file according to the component name of the second component and the header file name of the header file of the second source file. By the method and the device, the header file address of the header file of the second source file in the second assembly can be found as far as possible, so that compiling errors can be avoided.

Description

Header file address acquisition method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for acquiring a header file address, an electronic device, and a storage medium.
Background
As a project is iterated and increased, the data of the source code is increased to an unimaginable volume with the passage of time, and the waiting time for compiling into an executable program in daily development is increased. This results in a long latency for development of debug work and packaging tests. It is a pressing matter to reduce the compilation time.
The header mapping HeaderMap technology mainly scans real addresses of header files of source files in components, then generates key-value format files, and when a preprocessor encounters an instruction for introducing the header files, original IO (Input/Output ) disk lookup is converted into memory lookup, so that the compiling efficiency can be remarkably improved.
However, in actual development, due to the multiplexing and huge problems of the engineering project, the engineering project is usually split into individual components, and the components are used as dimensions to generate the HeaderMap. In an engineering project comprising a plurality of components, a HeaderMap is generated for each component. If other assemblies call the source files of the assembly, the HeaderMap of the assembly is not hit during compiling, and further the disk IO searching flow is hit. The search process at this stage is time consuming and therefore the official HeaderMap technique is not applicable in engineering projects involving multiple components.
In another approach, engineering projects may be managed based on coco-codes. Under the management of the coco tools, the content of the HeaderMap generated by the code when the component is used as a dimension is different. The header maps of different components only include header addresses of header files of source files included in each component, and when a component needs to obtain header addresses of header files of source files of other components on which the component depends, the header addresses of source files of other components on which the component depends often cannot be found from the header map of the component, so that compiling errors can be caused.
Disclosure of Invention
The application discloses a method and a device for acquiring a header file address, electronic equipment and a storage medium.
In a first aspect, the present application shows a method for acquiring a header file address, where the method includes:
in the process of compiling an engineering project comprising a plurality of components, for any one component in the engineering project, acquiring a header map file of the component which the any one component depends on, wherein the header map file of the dependent component comprises a ' dependent component name-own-target-headers ' hmap ' file, and the ' dependent component name-own-target-headers ' file comprises a corresponding relation between a header file identifier of a header file of a source file in the dependent component and a header file address of the header file of the source file in the dependent component; the header file identifier of the header file comprises a component name of a component where the header file is located, a header file name of the header file and the like;
setting a file of a component name-own-target-headers of a dependent component in a Header Search Path of any one component;
under the condition that a first source file in a first assembly in the engineering project needs to call a header file address of a header file of a second source file in a second assembly in the engineering project, acquiring a component name of the second assembly and the header file name of the header file;
according to the component name of the second component, searching a file of 'component name-own-target-heads.hmap' of the second component in the Header Search Path of the first component;
and searching a header file address of the second header file in a corresponding relation between a header file identifier of the header file of the source file in the second component and a header file address of the header file of the source file in the second component in a component name-own-target-headers.
In an optional implementation, the method further includes:
under the condition that a new source file and a header file of the new source file are added in a target assembly in a plurality of assemblies in the engineering project, acquiring a component name of the target assembly, a header file name of the header file of the new source file and a header file address of the header file of the new source file;
searching a file of ' component name of a target component-own-target-headers ' hmap ' in the Header Search Path of each component in the engineering project;
in a corresponding relation between a header file identifier of a header file of a source file in the target assembly and a header file address of a header file of a source file in the target assembly in the searched assembly name-own-target-headers.hmap file, storing the header file identifier of the header file of the new source file and the header file address of the header file of the new source file, wherein the header file identifier of the header file of the new source file comprises the assembly name of the target assembly and the header file name of the header file of the new source file.
In an optional implementation, the method further comprises:
under the condition that a new component is added in the engineering project and a new source file and a header file of the new source file are added in the new component, acquiring a component name of the new component, a header file name of the header file of the new source file and a header file address of the header file of the new source file;
generating a new component HeaderMap file, wherein the new component HeaderMap file comprises a file of 'new component name-own-target-heads.hmap' and a file of 'new component name-own-target-heads.hmap' comprising: the corresponding relation between the header file identification of the header file of the source file in the new assembly and the header file address of the header file of the source file in the new assembly; the header file identification of the header file of the new source file comprises the component name of the new component and the header file name of the header file of the new source file;
the "new component's component name-own-target-headers. Hmap" file is set in the loader Search Path of the new component dependent component in the engineering project.
In an optional implementation manner, at least paths of a plurality of components in the engineering project in a disk are recorded in a Header Search Path of any one of the components; the content of the record in the Header Search Path of any one component has a searching sequence;
the setting a "dependent component name-own-target-headers" file of the dependent component in the Header Search Path of any one of the components includes:
in the Header Search Path of any one component, setting a "dependent component name-own-target-headers.hmap" file at a position before the position of the Path of the components in the disk in the engineering project, so that the precedence Search order of the "dependent component name-own-target-headers.hmap" file is located before the precedence Search order of the Path of the components in the disk in the engineering project.
In an optional implementation manner, at least a Path of a plurality of components in the engineering project in a disk is recorded in the loader Search Path of any one of the components;
the setting a "dependent component name-own-target-headers" file of the dependent component in the Header Search Path of any one of the components includes:
in the Header Search Path of any one component, replacing paths of a plurality of components in the engineering project in the disk by using a "dependent component name-own-target-headers" file.
In a second aspect, the present application shows an apparatus for obtaining a header file address, the apparatus comprising:
a first generating module, configured to, in a process of compiling an engineering project including multiple components, obtain, for any one component in the engineering project, a HeaderMap file of a component on which the any one component depends, where the HeaderMap file of the dependent component includes a "component name-own-target-heads.hmap" file of the dependent component, and the "component name-own-target-heads.hmap" file of the dependent component includes a correspondence between a header file identifier of a header file of a source file in the dependent component and a header file address of a header file of a source file in the dependent component; the header file identifier of the header file comprises a component name of a component where the header file is located, a header file name of the header file and the like;
a first setting module, configured to set a "down-target-headers of a dependent component" file in a Header Search Path of the arbitrary component;
a first obtaining module, configured to obtain a component name of a second component and a header file name of a second source file in a second component in the engineering project when a first source file in a first component in the engineering project needs to call a header file address of the header file;
a first searching module, configured to Search, according to the component name of the second component, a "component name-own-target-headers" file of the second component in a Header Search Path of the first component;
a second searching module, configured to search, according to the component name of the second component and the header file name of the header file of the second source file, a header file address of the second header file in a correspondence relationship between a header file identifier of the header file of the source file in the second component and the header file address of the header file of the source file in the second component in a component name-own-target-headers.
In an optional implementation, the apparatus further comprises:
a second obtaining module, configured to, when a new source file and a header file of the new source file are added to a target component among multiple components in the engineering project, obtain a component name of the target component, a header file name of the header file of the new source file, and a header file address of the header file of the new source file;
a third searching module, configured to Search a "component name-own-target-heads" file of a target component in a Header Search Path of each component in the engineering project;
a storage module, configured to store, in a correspondence relationship between a header file identifier of a header file of a source file in a target assembly and a header file address of a header file of a source file in the target assembly in a found "component name of the target assembly-own-target-headers" file, a header file identifier of a header file of a new source file and a header file address of a header file of a new source file, where the header file identifier of the header file of the new source file includes the component name of the target assembly and the header file name of the header file of the new source file.
In an optional implementation, the apparatus further comprises:
a third obtaining module, configured to, when a new component is added to the engineering project and a new source file and a header file of the new source file are added to the new component, obtain a component name of the new component, a header file name of the header file of the new source file, and a header file address of the header file of the new source file;
a second generating module, configured to generate a header map file of the new component, where the header map file of the new component includes a "new component name-own-target-headers. The corresponding relation between the header file identification of the header file of the source file in the new assembly and the header file address of the header file of the source file in the new assembly; the header file identification of the header file of the new source file comprises the component name of the new component and the header file name of the header file of the new source file;
a second setting module, configured to set a "new component name-own-target-headers" file in a Header Search Path of a component that depends on the new component in the engineering project.
In an optional implementation manner, at least paths of a plurality of components in the engineering project in a disk are recorded in a Header Search Path of any one of the components; the content of the record in the Header Search Path of any one component has a searching sequence;
the first setting module includes:
a setting unit, configured to set, in the Header Search Path of any one of the components, a "dependent component name-own-target-headers.hmap" file at a position before positions of paths of the multiple components in the engineering project in the disk, so that a precedence Search order of the "dependent component name-own-target-headers.hmap" file is located before a precedence Search order of paths of the multiple components in the engineering project in the disk.
In an optional implementation manner, at least a Path of a plurality of components in the engineering project in a disk is recorded in the loader Search Path of any one of the components;
the setting module includes:
and a replacing unit, configured to replace, in the Header Search Path of any one of the components, paths of multiple components in the engineering project in the disk by using a "dependent-component name-own-target-headers" file.
In a third aspect, the present application shows an electronic device comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to execute the method for acquiring the header file address according to the first aspect.
In a fourth aspect, the present application shows a non-transitory computer-readable storage medium, wherein instructions of the storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the method for obtaining a header address according to the first aspect.
In a fifth aspect, the present application shows a computer program product, in which instructions, when executed by a processor of an electronic device, enable the electronic device to execute the header address obtaining method according to the first aspect.
The technical scheme provided by the application can comprise the following beneficial effects:
in the present application, in the process of compiling an engineering project including a plurality of components, for any one component in the engineering project, a header map file of the component that the any one component depends on is obtained, the header map file of the dependent component includes a "dependent component name-own-target-headers" file, and the "dependent component name-own-target-headers" file includes a correspondence between a header file identifier of a header file of a source file in the dependent component and a header file address of the header file of the source file in the dependent component; the header file identifier of the header file includes a component name of a component in which the header file is located, a header file name of the header file, and the like. The "dependent component's component name-own-target-headers. Hmap" file is set in the Header Search Path of the arbitrary component. Under the condition that a first source file in a first assembly in an engineering project needs to call a header file address of a header file of a second source file in a second assembly in the engineering project, acquiring a component name of the second assembly and the header file name of the header file of the second source file. According to the component name of the second component, a file of the component name-own-target-headers of the second component is searched in the Header Search Path of the first component. And according to the component name of the second component and the header file name of the header file of the second source file, searching the header file address of the second header file in the corresponding relation between the header file identifier of the header file of the source file in the second component and the header file address of the header file of the source file in the second component in the component name-own-target-headers.
By the method and the device, under the condition that the first source file in the first assembly in the engineering project needs to call the header file address of the header file of the second source file in the second assembly in the engineering project, the header file address of the header file of the second source file in the second assembly can be found as far as possible, and therefore compiling errors can be avoided.
Drawings
Fig. 1 is a flowchart illustrating steps of a header address obtaining method according to the present application.
Fig. 2 is a block diagram of a header address obtaining apparatus according to the present application.
Fig. 3 is a block diagram of an electronic device shown in the present application.
Fig. 4 is a block diagram of an electronic device shown in the present application.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without inventive step based on the embodiments of the present invention, are within the scope of protection of the present invention.
Referring to fig. 1, the present application shows a flow chart of steps of a method for acquiring a header address. The method specifically comprises the following steps:
in step S101, in the process of compiling an engineering project including multiple components, for any one component in the engineering project, obtaining a headmap file of the component that the any one component depends on, where the headmap file of the dependent component includes a "component name-own-target-heads of the dependent component" file, and the "component name-own-target-heads of the dependent component" file includes a correspondence between a header file identifier of a header file of a source file in the dependent component and a header file address of a header file of a source file in the dependent component; the header file identifier of the header file includes a component name of a component in which the header file is located, a header file name of the header file, and the like.
The same is true for every other component in the engineering project.
In the application, the engineering project comprises a plurality of components, each component comprises at least one source file, each source file is provided with a header file, each header file is provided with a respective header file address, header file addresses of different header files are different, and developers can control a compiler to compile the engineering project.
The method includes the steps that a developer can respectively start a user Header Map for each component in an engineering project, then a compiling instruction for compiling the engineering project is input into a compiler, and under the condition that the compiler receives the compiling instruction for compiling the engineering project input by the developer, a Header Map file of each component in the engineering project can be generated respectively.
For example, for any one component in the engineering project, the compiler may first generate a HeaderMap file for the component, and in one possible case, the compiler may generate at least 6 HeaderMap files for the component, including, for example: hmap file, "hmap file of the component," all-non-frame-target-headers "file of the component," all-target-headers "file of the component," hmap file of the component, "own-target-headers" file of the component, and "project-headers" file of the component, etc.
The inventor researches and discovers that the 'component name-generated-files-hmap' file, the 'component name-all-non-frame-target-heads-hmap' file and the 'component name-all-target-heads-hmap' file are always empty.
And the "component name of the component-own-target-headers" file includes: the corresponding relation between the header file name of the header file of the source file in the assembly and the header file address of the header file of the source file in the assembly, and, further comprising: the corresponding relation between the header file identification of the header file of the source file in the component and the header file address of the header file of the source file in the component does not include the corresponding relation between the header file identification of the header file of the source file in the other components except the component in the engineering project and the header file address of the header file of the source file in the other components. Wherein, the header file identification of the header file of the source file in the component comprises: the component name of the component and the header file name of the header file of the source file in the component.
And "the component name of the component-all-target-headers. Hmap" includes: the corresponding relation between the header file identification of the header file of the source file in the component and the header file address of the header file of the source file in the component does not include the corresponding relation between the header file identification of the header file of the source file in the other components except the component in the engineering project and the header file address of the header file of the source file in the other components. Wherein, the header file identification of the header file of the source file in the assembly comprises: the component name of the component and the header file name of the header file of the source file in the component.
The same is true for every other component in the engineering project.
In this application, a compiler is a program that translates "one language (typically a high-level language)" into "another language (typically a low-level language)". The main work flow of the compiler is as follows: source code → preprocessor → compiler ompiler → object code → linker → executable program exclusibles.
The compiler includes LLVM (Low Level Virtual Machine), etc., and may be a front-end compiler based on C language/C + + language of LLVM/object-oriented programming language object-C of augmented C, e.g., front-end Clang, etc.
The front-end Clang is a front-end compiler of an object-oriented programming language Objective-C based on a C language/C + + language of LLVM (Low Level Virtual Machine, chinese full name: low Level Virtual Machine) and C extension.
The compiler may also include Xcode, etc. The Xcode is an Integrated Development tool (IDE) running on the operating system Mac OS X, and is developed by Apple Inc. Xcode is the fastest way to develop macOS and iOS applications. The Xcode has a uniform user interface design, and the encoding, the testing and the debugging are completed in a simple window.
HeaderMap: the method is a scheme for increasing the searching speed of the header file by the apple. During compilation, the head file Search is converted from IO Path Search of the Header Search Path to Key-Value Search of the memory in the form of HashMap.
In step S102, a file of "dependent component name-own-target-headers" of the dependent component is set in the Header Search Path of the arbitrary one component.
For the search principle of the compiler, in the process of compiling the engineering project, for any one component in the engineering project, in one case, if the header file of the source file in the other components except for the component in the engineering project is introduced in the component in the form of # import "header name.h", the header file address of the header file of the source file can be searched in the "component name of the component-headers" file in the header map file of the component according to the header file name of the source file. Wherein, "header name.h" is the header file name of the header file of the source file.
Or, in another case, if the header file of the source file in the other component in the engineering project is introduced in the component in the form of "# import < component name/header name.h >" of the other component, the header file address of the header file of the source file may be looked up in the "component name-own-target-headers" file of the component in the header map file of the component according to the header file identifier of the header file of the source file. Where "header name.h" is the header filename of the header file. The header file identifier of the header file includes a component name of a component in which the header file is located, a header file name of the header file, and the like.
However, since only the header filename (and/or header identification) of the header file of the source file in the component and the header file address of the header file of the source file in the component exist in the "component name-project-headers.hmap" file of the component and the "component name-own-target-headers.hmap" file of the component, the header filename (and/or header identification) of the header file of the source file in the component and the header file address of the header file of the source file in the other component in the project item other than the component do not exist. And because the components in the engineering project are independent from each other, for the component, when compiling the component, the compiler will only find the header address of the header file in the "component name of the component-own-target-headers.hmap" file and the "component name of the component-project-headers.hmap" file included in the header map file of the component, and will not find the header address of the header file in the "component name of other components-own-target-headers.hmap" file and the "component name of other components-project-headers.hmap" file included in the header map files of the components other than the component, that is, the header address of the header file in the "component name of other components-own-target-headers" file and the "component name of other components-header-headers" file included in the header file of other components are not aware of the component.
Therefore, in the above two cases, in the case that the component depends on other components in the engineering project, the header file address of the header file of the source file of the other component that the component depends on cannot be found for the component.
Therefore, in order to solve the above problem, a file of "down-target-headers, the component name of the component on which the arbitrary one component depends" may be set in the Header Search Path of the arbitrary one component.
In step S103, in a case that a first source file in a first component in the project item needs to call a header file address of a header file of a second source file in a second component in the project item, a component name of the second component and a header file name of the header file of the second source file are acquired.
In this application, for any one component in an engineering project, in a case where the component needs to be compiled, a source file in the component may need to call a header address of a header file of another source file in another component other than the component in an engineering project on which the component depends, and in a case where the header address of the header file of another source file in another component needs to be called, a compiler may obtain the header address of the header file of the source file in the component and the header address of the header file of the source file in another component on which the component depends, and then use the header address of the header file of the source file in the component and the header address of the header file of the source file in another component on which the component depends in a process of compiling the component. The same is true for every other component in the engineering project.
For example, for a first component of a plurality of components in an engineering project, the first component may have its own header file of a source file, and the first component may also depend on the source file of a second component, in this case, for the first source file of the first component, it is necessary to obtain a header file address of the header file of the source file of the first component itself and a header file address of the header file of the source file of the second component that the first component depends on, and then the header file address of the header file of the source file of the first component itself and the header file address of the header file of the source file of the second component that the first component depends on may be used later in the process of compiling the first component.
The first component is one of the components in the engineering project, and the second component is the other component except the first component in the engineering project. The first source file is one of the first component source files, and the second source file is one of the second component source files.
In this way, in the case that the first source file in the first component in the engineering project needs to retrieve the header address of the header file of the second source file in the second component in the engineering project, the component name of the second component and the header name of the header file of the second source file may be acquired, and then step S104 is executed.
In step S104, according to the component name of the second component, the file "component name-own-target-headers of the second component" is searched in the Header Search Path of the first component.
In this application, a "component name-own-target-headers.hmap" file of the first component and a "component name-own-target-headers.hmap" file of the second component that the first component depends on are set in the Header Search Path in the first component, so that the "component name-own-target-headers.hmap" file of the second component that the first component depends on can be searched in the Header Search Path in the first component according to the component name of the second component, and then step S105 is executed.
In step S105, according to the component name of the second component and the header file name of the header file of the second source file, in the correspondence between the header file identifier of the header file of the source file in the second component and the header file address of the header file of the source file in the second component in the "component name-own-target-headers.
In the present application, in the file of "component name-own-target-headers of second component" in the Header Search Path in the first component, the following are included: and the corresponding relation between the header file identification of the header file of the source file in the second assembly and the header file address of the header file of the source file in the second assembly. The header file identifier of the header file includes a component name of a component in which the header file is located and a header file name of the header file.
Therefore, the header file identifier of the second header file may be generated according to the component name of the second component and the header file name of the header file of the second source file, and then, in the correspondence relationship between the header file identifier of the header file of the source file in the second component and the header file address of the header file of the source file in the second component in the "component name of the second component-own-target-headers.
In the present application, in the process of compiling an engineering project including a plurality of components, for any one component in the engineering project, a header map file of the component that the any one component depends on is obtained, the header map file of the dependent component includes a "dependent component name-own-target-headers" file, and the "dependent component name-own-target-headers" file includes a correspondence between a header file identifier of a header file of a source file in the dependent component and a header file address of the header file of the source file in the dependent component; the header file identifier of the header file includes a component name of a component in which the header file is located, a header file name of the header file, and the like. The "dependent component's component name-own-target-headers. Hmap" file is set in the Header Search Path of the arbitrary component. Under the condition that a first source file in a first assembly in an engineering project needs to call a header file address of a header file of a second source file in a second assembly in the engineering project, acquiring a component name of the second assembly and a header file name of the header file of the second source file. According to the component name of the second component, a file of the component name-own-target-headers of the second component is searched in the Header Search Path of the first component. And according to the component name of the second component and the header file name of the header file of the second source file, searching the header file address of the second header file in the corresponding relation between the header file identifier of the header file of the source file in the second component and the header file address of the header file of the source file in the second component in the component name-own-target-headers.
By the method and the device, under the condition that the first source file in the first assembly in the engineering project needs to call the header file address of the header file of the second source file in the second assembly in the engineering project, the header file address of the header file of the second source file in the second assembly can be found as far as possible, and therefore compiling errors can be avoided.
In the present application, after the header map files of the components in the engineering project are generated respectively, sometimes a developer may add a new source file in the engineering project (for example, a new source file may be added to an existing component in the engineering project, or a new component may be created in the engineering project and a new source file may be added to a new component), so that the header file address of the header file of the new source file does not exist in the header map file of any generated component, and thus, a compilation for "involving the new source file" may be in error.
In order to avoid the above situation, the header map file of each component in the engineering project may be regenerated, so that the header file address of the header file of the new source file exists in the header map file of the component related to the header file of the new source file, but the process of regenerating the header map file of each component in the engineering project wastes time, and thus the compiling efficiency is reduced.
Therefore, in order to improve the compiling efficiency, in another embodiment of the present application, after the header map files of the respective components in the engineering project are respectively generated, in the case where a new source file and a header file of the new source file are added to a target component among a plurality of components in the engineering project, a component name of the target component, a header file name of the header file of the new source file, and a header file address of the header file of the new source file may be acquired.
Thereafter, a "component name of target component-own-target-headers" file may be looked up in the loader Search Path of each component in the engineering project.
Then, in the found correspondence relationship between the header file identifier of the header file of the source file in the target component and the header file address of the header file of the source file in the target component in the "component name-own-target-headers.hmap" file of the target component, the header file identifier of the header file of the new source file and the header file address of the header file of the new source file may be stored, and the header file identifier of the header file of the new source file includes the component name of the target component and the header file name of the header file of the new source file.
Therefore, under the condition that a new source file and a Header file of the new source file are added in a target assembly in a plurality of assemblies in the engineering project after the Header map files of the assemblies in the engineering project are respectively generated, the Header file identification of the Header file of the new source file and the Header file address of the Header file of the new source file can be updated in a Header Search Path of the assembly (such as the assembly depending on the target assembly) related to the new source file in real time, and the Header map files of the assemblies in the engineering project are prevented from being re-generated, so that the time can be saved, and the compiling efficiency can be improved.
Alternatively, in order to improve the compiling efficiency, in another embodiment of the present application, after the header map files of the components in the engineering project are generated, new components are added to the engineering project, and a new source file and a header file of the new source file are added to the new components, the component name of the new components, the header file name of the header file of the new source file, and the header file address of the header file of the new source file may be acquired.
A new component header map file may be generated, where the new component header map file includes a "new component name-own-target-headers.hmap" file, and the "new component name-own-target-headers.hmap" file includes: the corresponding relation between the header file identification of the header file of the source file in the new assembly and the header file address of the header file of the source file in the new assembly; the header file identification of the header file of the new source file includes the component name of the new component and the header file name of the header file of the new source file.
Hmap files may then be placed in the Header Search Path of the new component dependent components in the engineering project.
Therefore, after the header map files of the components in the engineering project are respectively generated, new components are added in the engineering project, and new source files and header files of the new source files are added in the new components, the header file identification of the header files of the new source files and the header file addresses of the header files of the new source files can be updated in the components (such as the components depending on the new components) related to the new source files in real time, and the header map files of the components in the engineering project are prevented from being re-generated, so that the time can be saved, and the compiling efficiency can be improved.
In this application, if the Header file address of the Header file of the source file of the other component that the first component depends on cannot be found for the first component, the compiler may often obtain the Path in the disk of the multiple components in the engineering project set in the Header Search Path in the first component, and then find the Header file address of the Header file of the source file of the other component that the component depends on in the Path in the disk of the multiple components in the engineering project in the disk.
As can be seen, for the header file address of the header file of the source file of the other component on which the first component depends, the last search pocket of the compiler is: the Path in the disk of the plurality of components in the engineering project set in the loader Search Path in the first component.
In an embodiment of the present application, for any one component in an engineering project, at least paths of multiple components in the engineering project in a disk are recorded in a Header Search Path of the component, and if a Header file address of a Header file of a source file in the component is searched in the disk according to the Path first, since a rate of accessing data in the disk is slow, a process of searching for the Header file address of the Header file of the source file in the component in the disk takes a long time, thereby resulting in low compilation efficiency.
Therefore, in order to improve the compiling efficiency, in an embodiment of the present application, the contents of the records in the Header Search Path of the component have a sequential searching order, for example, the content with the position in the Header Search Path of the component being more forward is searched in the forward order, and the content with the position in the Header Search Path of the component being more backward is searched in the backward order.
Therefore, in order to find the Header file address of the Header file of the source file in the component in the Header Search Path of the first component, the Header file address of the Header file of the source file in the component is found in the "component name-own-target-headers" file in the Header map file in the first component, instead of finding the Header file address of the Header file of the source file in the component in the disk, when the "dependent component name-own-target-headers" file is set in the Header Search Path of any one component, the "dependent component name-own-target-headers" file is set in the location before the location of the Path of the components in the disk in the project item, so that the "dependent component name-own-target-headers" file is located in the order of the multiple components in the Header Search Path of the project item.
Thus, when the header file address of the header file of the source file in the component is searched in the first component, the header file address of the header file of the source file in the component is searched in the "component name-own-target-headers" file in the header map file in the first component, and the header file address of the header file of the source file in the component is often found in the "component name-own-target-headers" file in the header map file in the component, once the header file address of the header file of the source file in the component is found, the header file address of the header file of the source file in the component is not searched in the disk any more, the operation of searching the header file address of the header file of the source file in the component in the header file in the first component belongs to the search in the memory form, the access rate of the head file of the source file in the component is higher than the access rate of the head file in the first component, and therefore the application time length of the header file of the head file in the component can be increased.
In an embodiment of the present application, for any one component in an engineering project, at least paths of multiple components in the engineering project in a disk are recorded in a Header Search Path of the component, and if a Header address of a Header file of a source file in the component is searched in the disk according to the Path first, since a rate of accessing data in the disk is slow, a process of searching for the Header address of the Header file of the source file in the component in the disk consumes a long time, and thus compiling efficiency is low.
Therefore, in order to improve the compiling efficiency, in an embodiment of the present application, it is necessary to search for the header file address of the header file of the source file in the component in the "component name-own-target-headers" file in the header map file in the component, instead of searching for the header file address of the header file of the source file in the component in the disk.
In order to find the Header file address of the Header file of the source file in the component in the "component name-own-target-headers" file in the Header map file in the component instead of finding the Header file address of the Header file of the source file in the component in the disk, when the "component name-own-target-headers" file of the dependent component is set in the Header Search Path of any one component, the Path of the plurality of components in the project item in the disk is replaced with the "component name-own-target-headers" file of the dependent component in the Header Search Path of any one component.
In this way, paths of multiple components in the engineering project in the disk do not exist in the Path set in the Header Search Path in any component, and a "component name-own-target-headers" file in the Header map file of the component involved in the component exists.
Therefore, when the header file address of the header file of the source file in the component is searched in the first component, the header file address of the header file of the source file in the component is searched in the "component name-own-target-headers" file in the header map file in the first component, but the header file address of the header file of the source file in the component is not searched in the disk any more, the operation of searching the header file address of the header file of the source file in the component in the "component name-own-target-headers" file in the header map file in the first component belongs to the search in a memory form, and the rate of accessing the data in the memory is higher than the rate of accessing the data in the disk, so that the time consumed in the process of searching the header file address of the header file can be reduced, and the compiling efficiency can be improved.
It is noted that, for simplicity of explanation, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will appreciate that the present application is not limited by the order of acts, as some steps may, in accordance with the present application, occur in other orders and concurrently. Further, those skilled in the art will also appreciate that the embodiments described in the specification are exemplary and that no action is necessarily required in this application.
Referring to fig. 2, a block diagram of a structure of an apparatus for acquiring a header file address according to the present application is shown, where the apparatus may specifically include the following modules:
a first generating module 11, configured to, in a process of compiling an engineering project including multiple components, obtain, for any one component in the engineering project, a HeaderMap file of the component that the any one component depends on, where the HeaderMap file of the dependent component includes a "component name-own-target-heads-hmap" file of the dependent component, and the "component name-own-target-heads-hmap" file of the dependent component includes a correspondence between a header identifier of a header file of a source file in the dependent component and a header address of a header file of a source file in the dependent component; the header file identifier of the header file comprises a component name of a component where the header file is located, a header file name of the header file and the like;
a first setting module 12, configured to set a "component name-own-target-headers of a dependent component" file in a Header Search Path of the arbitrary component;
a first obtaining module 13, configured to obtain, when a first source file in a first component in the engineering project needs to invoke a header file address of a header file of a second source file in a second component in the engineering project, a component name of the second component and a header file name of the header file;
a first searching module 14, configured to Search, according to the component name of the second component, a "component name-own-target-headers" file of the second component in a Header Search Path of the first component;
a second searching module 15, configured to search, according to the component name of the second component and the header file name of the header file of the second source file, a header file address of the second header file in a correspondence relationship between a header file identifier of the header file of the source file in the second component and a header file address of the header file of the source file in the second component in the component name-own-target-headers.
In an optional implementation, the apparatus further comprises:
a second obtaining module, configured to, when a new source file and a header file of the new source file are added to a target component among multiple components in the engineering project, obtain a component name of the target component, a header file name of the header file of the new source file, and a header file address of the header file of the new source file;
a third searching module, configured to Search a "component name-own-target-heads" file of a target component in a Header Search Path of each component in the engineering project;
a storage module, configured to store, in a correspondence relationship between a header file identifier of a header file of a source file in a target assembly and a header file address of a header file of a source file in the target assembly in a found "component name of the target assembly-own-target-headers" file, a header file identifier of a header file of a new source file and a header file address of a header file of a new source file, where the header file identifier of the header file of the new source file includes the component name of the target assembly and the header file name of the header file of the new source file.
In an optional implementation manner, the apparatus further includes:
a third obtaining module, configured to obtain a component name of a new component, a header file name of a header file of the new source file, and a header file address of the header file of the new source file when a new component is added to the engineering project and a new source file and a header file of the new source file are added to the new component;
a second generating module, configured to generate a new component header map file, where the new component header map file includes a "new component name-own-target-headers.hmap" file, and the "new component name-own-target-headers.hmap" file includes: the corresponding relation between the header file identification of the header file of the source file in the new assembly and the header file address of the header file of the source file in the new assembly; the header file identification of the header file of the new source file comprises the component name of the new component and the header file name of the header file of the new source file;
a second setting module, configured to set a "new component name-own-target-headers" file in a Header Search Path of a component that depends on the new component in the engineering project.
In an optional implementation manner, at least paths of a plurality of components in the engineering project in a disk are recorded in a Header Search Path of any one of the components; the content of the record in the Header Search Path of any one component has a searching sequence;
the first setting module includes:
a setting unit, configured to set, in the Header Search Path of any one of the components, a "dependent component name-own-target-headers.hmap" file at a position before positions of paths of multiple components in the engineering project in the disk, so that a precedence Search order of the "dependent component name-own-target-headers.hmap" file is located before a precedence Search order of paths of the multiple components in the engineering project in the disk.
In an optional implementation manner, at least a Path of a plurality of components in the engineering project in a disk is recorded in the loader Search Path of any one of the components;
the setting module includes:
and a replacing unit, configured to replace, in the Header Search Path of any one of the components, paths of multiple components in the engineering project in the disk by using a "dependent-component name-own-target-headers" file.
In the present application, in the process of compiling an engineering project including multiple components, for any one component in the engineering project, a header map file of the component on which the any one component depends is obtained, where the header map file of the dependent component includes a "component name-own-target-headers.hmap" file of the dependent component, and the "component name-own-target-headers.hmap" file of the dependent component includes a correspondence between a header file identifier of a header file of a source file in the dependent component and a header file address of a header file of a source file in the dependent component; the header file identifier of the header file includes a component name of a component in which the header file is located, a header file name of the header file, and the like. The "dependent component's component name-own-target-headers. Under the condition that a first source file in a first assembly in an engineering project needs to call a header file address of a header file of a second source file in a second assembly in the engineering project, acquiring a component name of the second assembly and the header file name of the header file of the second source file. According to the component name of the second component, a file of the component name-own-target-headers of the second component is searched in the Header Search Path of the first component. And according to the component name of the second component and the header file name of the header file of the second source file, searching the header file address of the second header file in the corresponding relation between the header file identifier of the header file of the source file in the second component and the header file address of the header file of the source file in the second component in the component name-own-target-headers.
By the method and the device, under the condition that the first source file in the first assembly in the engineering project needs to call the header file address of the header file of the second source file in the second assembly in the engineering project, the header file address of the header file of the second source file in the second assembly can be found as far as possible, and therefore compiling errors can be avoided.
For the apparatus embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and reference may be made to the partial description of the method embodiment for relevant points.
Optionally, an embodiment of the present invention further provides an electronic device, including: the processor, the memory, and the computer program stored in and executable on the memory, where the computer program when executed by the processor implements each process of the above-mentioned header file address obtaining method embodiment, and can achieve the same technical effect, and are not described herein again to avoid repetition.
The embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when being executed by a processor, the computer program implements each process of the above-mentioned method for acquiring a header file address, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here. The computer-readable storage medium may be a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk.
Fig. 3 is a block diagram of an electronic device 800 shown in the present application. For example, the electronic device 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 3, electronic device 800 may include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input/output (I/O) interface 812, a sensor component 814, and a communication component 816.
The processing component 802 generally controls overall operation of the electronic device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing components 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operation at the device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phonebook data, messages, images, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or non-volatile memory devices, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
The power supply component 806 provides power to the various components of the electronic device 800. The power components 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device 800.
The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the device 800 is in an operational mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the electronic device 800 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
Sensor assembly 814 includes one or more sensors for providing various aspects of state assessment for electronic device 800. For example, the sensor assembly 814 may detect an open/closed state of the device 800, the relative positioning of components, such as a display and keypad of the electronic device 800, the sensor assembly 814 may also detect a change in the position of the electronic device 800 or a component of the electronic device 800, the presence or absence of user contact with the electronic device 800, orientation or acceleration/deceleration of the electronic device 800, and a change in the temperature of the electronic device 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object in the absence of any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 may access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G, or 5G), or a combination thereof. In an exemplary embodiment, the communication component 816 receives broadcast signals or broadcast operation information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the electronic device 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), digital Signal Processors (DSPs), digital Signal Processing Devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 804 comprising instructions, executable by the processor 820 of the electronic device 800 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
Fig. 4 is a block diagram of an electronic device 1900 shown in the present application. For example, the electronic device 1900 may be provided as a server.
Referring to fig. 4, electronic device 1900 includes a processing component 1922 further including one or more processors and memory resources, represented by memory 1932, for storing instructions, e.g., applications, executable by processing component 1922. The application programs stored in memory 1932 may include one or more modules that each correspond to a set of instructions. Further, the processing component 1922 is configured to execute instructions to perform the above-described method.
The electronic device 1900 may also include a power component 1926 configured to perform power management of the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input/output (I/O) interface 1958. The electronic device 1900 may operate based on an operating system stored in memory 1932, such as Windows Server, mac OS XTM, unixTM, linuxTM, freeBSDTM, or the like.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one of 8230, and" comprising 8230does not exclude the presence of additional like elements in a process, method, article, or apparatus comprising the element.
Through the description of the foregoing embodiments, it is clear to those skilled in the art that the method of the foregoing embodiments may be implemented by software plus a necessary general hardware platform, and certainly may also be implemented by hardware, but in many cases, the former is a better implementation. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
While the present invention has been described with reference to the particular illustrative embodiments, it is to be understood that the invention is not limited to the disclosed embodiments, but is intended to cover various modifications, equivalent arrangements, and equivalents thereof, which may be made by those skilled in the art without departing from the spirit and scope of the invention as defined by the appended claims.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the technical solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
It can be clearly understood by those skilled in the art that, for convenience and simplicity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one type of logical functional division, and other divisions may be realized in practice, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention or a part thereof which substantially contributes to the prior art may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U disk, a removable hard disk, a ROM, a RAM, a magnetic disk or an optical disk, and various media capable of storing program codes.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. A method for acquiring a header file address is characterized by comprising the following steps:
in the process of compiling an engineering project comprising a plurality of components, acquiring a HeaderMap file of any component dependent on the any component for the any component in the engineering project, wherein the HeaderMap file of the dependent component comprises a 'dependent component name-own-target-heads.hmap' file, and the 'dependent component name-own-target-heads.hmap' file comprises a corresponding relation between a header file identifier of a header file of a source file in the dependent component and a header file address of the header file of the source file in the dependent component; the header file identification of the header file comprises the component name of the component where the header file is located and the header file name of the header file;
setting a "dependent component name-own-target-headers.hmap" file in a Header Search Path of the any one component, where at least paths of multiple components in the engineering project in a disk are recorded in the Header Search Path of the any one component, and setting the "dependent component name-own-target-headers.hmap" file in the Header Search Path of the any one component includes: replacing paths of a plurality of components in the engineering project in a disk by using a ' dependent component name-own-target-heads ' hmap ' file in the Header Search Path of any one component;
under the condition that a first source file in a first assembly in the engineering project needs to call a header file address of a header file of a second source file in a second assembly in the engineering project, acquiring a component name of the second assembly and the header file name of the header file;
according to the component name of the second component, searching a file of ' component name-own-target-heads of the second component ' hmap ' in the Header Search Path of the first component;
and according to the component name of the second component and the header file name of the header file of the second source file, searching for the header file address of the header file of the source file in the second component in the corresponding relationship between the header file identifier of the header file of the source file in the second component and the header file address of the header file of the source file in the second component in the component name-own-target-headers.
2. The method of claim 1, further comprising:
under the condition that a new source file and a header file of the new source file are added in a target component in a plurality of components in the engineering project, acquiring a component name of the target component, a header file name of the header file of the new source file and a header file address of the header file of the new source file;
searching a file of 'component name-own-target-headers, hmap' of a target component in the loader Search Path of each component in the engineering project;
in a correspondence relationship between a header file identifier of a header file of a source file in the target assembly and a header file address of a header file of a source file in the target assembly in the found "component name of the target assembly-own-target-headers" file, storing the header file identifier of the header file of the new source file and the header file address of the header file of the new source file, wherein the header file identifier of the header file of the new source file comprises the component name of the target assembly and the header file name of the header file of the new source file.
3. The method of claim 1, further comprising:
under the condition that a new component is added in the engineering project and a new source file and a header file of the new source file are added in the new component, acquiring a component name of the new component, a header file name of the header file of the new source file and a header file address of the header file of the new source file;
generating a new component HeaderMap file, wherein the new component HeaderMap file comprises a file of 'new component name-own-target-heads.hmap' and a file of 'new component name-own-target-heads.hmap' comprising: the corresponding relation between the header file identification of the header file of the source file in the new assembly and the header file address of the header file of the source file in the new assembly; the header file identification of the header file of the new source file comprises the component name of the new component and the header file name of the header file of the new source file;
the "new component's component name-own-target-headers. Hmap" file is set in the loader Search Path of the new component dependent component in the engineering project.
4. The method according to claim 1, wherein the content of the record in the Header Search Path of any one component has a look-ahead order;
the setting a "component name-own-target-headers of a dependent component" file in the Header Search Path of any one component further includes:
in the Header Search Path of any one component, setting a "dependent component name-own-target-headers.hmap" file at a position before positions of paths of multiple components in the engineering project in the disk, so that a precedence Search order of the "dependent component name-own-target-headers.hmap" file is located before a precedence Search order of paths of the multiple components in the engineering project in the disk.
5. An apparatus for acquiring a header file address, the apparatus comprising:
a first generating module, configured to, in a process of compiling an engineering project including multiple components, obtain, for any one component in the engineering project, a header map file of the component that the any one component depends on, where the header map file of the dependent component includes a "component name-own-target-headers" file of the dependent component, and the "component name-own-target-headers" file of the dependent component includes a correspondence between a header file identifier of a header file of a source file in the dependent component and a header file address of a header file of a source file in the dependent component; the header file identification of the header file comprises the component name of the component where the header file is located and the header file name of the header file;
a first setting module, configured to set a "component name of a dependent component-own-target-headers, hmap" file in a Header Search Path of any one of the components, where at least paths of multiple components in the engineering project in a disk are recorded in the Header Search Path of any one of the components, where the first setting module includes: a replacing unit, configured to replace, in the loader Search Path of any one of the components, paths of multiple components in the engineering project in a disk by using a "dependent component name-own-target-headers.hmap" file;
a first obtaining module, configured to obtain a component name of a second component and a header file name of a second source file in a second component in the engineering project when a first source file in a first component in the engineering project needs to call a header file address of the header file;
a first searching module, configured to Search, according to the component name of the second component, a "component name-own-target-headers" file of the second component in a Header Search Path of the first component;
a second searching module, configured to search, according to the component name of the second component and the header file name of the header file of the second source file, a header file address of the header file of the source file in the second component in a correspondence relationship between a header file identifier of the header file of the source file in the second component and a header file address of the header file of the source file in the second component in a component name-own-target-headers.
6. The apparatus of claim 5, further comprising:
a second obtaining module, configured to, when a new source file and a header file of the new source file are added to a target component among multiple components in the engineering project, obtain a component name of the target component, a header file name of the header file of the new source file, and a header file address of the header file of the new source file;
a third searching module, configured to Search a "component name-own-target-heads" file of a target component in a Header Search Path of each component in the engineering project;
a storage module, configured to store, in a correspondence relationship between a header file identifier of a header file of a source file in a target assembly and a header file address of a header file of a source file in the target assembly in a found "component name of the target assembly-own-target-headers" file, a header file identifier of a header file of a new source file and a header file address of a header file of a new source file, where the header file identifier of the header file of the new source file includes the component name of the target assembly and the header file name of the header file of the new source file.
7. The apparatus of claim 5, further comprising:
a third obtaining module, configured to obtain a component name of a new component, a header file name of a header file of the new source file, and a header file address of the header file of the new source file when a new component is added to the engineering project and a new source file and a header file of the new source file are added to the new component;
a second generating module, configured to generate a header map file of the new component, where the header map file of the new component includes a "new component name-own-target-headers. The corresponding relation between the header file identification of the header file of the source file in the new assembly and the header file address of the header file of the source file in the new assembly; the header file identification of the header file of the new source file comprises the component name of the new component and the header file name of the header file of the new source file;
a second setting module, configured to set a "new component name-own-target-headers" file in a Header Search Path of a component that depends on the new component in the engineering project.
8. The apparatus according to claim 5, wherein the content of the record in the Header Search Path of any one component has a look-ahead order;
the first setting module includes:
a setting unit, configured to set, in the Header Search Path of any one of the components, a "dependent component name-own-target-headers.hmap" file at a position before positions of paths of multiple components in the engineering project in the disk, so that a precedence Search order of the "dependent component name-own-target-headers.hmap" file is located before a precedence Search order of paths of the multiple components in the engineering project in the disk.
9. An electronic device, comprising: processor, memory and computer program stored on said memory and executable on said processor, said computer program when executed by said processor implementing the steps of the header address retrieval method according to any one of claims 1 to 4.
10. A computer-readable storage medium, characterized in that a computer program is stored thereon, which, when being executed by a processor, implements the steps of the header address acquisition method according to any one of claims 1 to 4.
CN202111216764.0A 2021-10-19 2021-10-19 Header file address acquisition method and device, electronic equipment and storage medium Active CN114020694B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111216764.0A CN114020694B (en) 2021-10-19 2021-10-19 Header file address acquisition method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111216764.0A CN114020694B (en) 2021-10-19 2021-10-19 Header file address acquisition method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN114020694A CN114020694A (en) 2022-02-08
CN114020694B true CN114020694B (en) 2022-10-28

Family

ID=80056546

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111216764.0A Active CN114020694B (en) 2021-10-19 2021-10-19 Header file address acquisition method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114020694B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108153529A (en) * 2017-12-22 2018-06-12 杭州迪普科技股份有限公司 A kind of method and device of file compiling
CN111338689A (en) * 2020-03-05 2020-06-26 网易(杭州)网络有限公司 File calling method, device and equipment

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7516442B2 (en) * 2003-10-23 2009-04-07 Microsoft Corporation Resource manifest
CN103870310B (en) * 2014-02-18 2017-07-14 小米科技有限责任公司 Program compiling method and relevant apparatus
CN109189729A (en) * 2018-09-03 2019-01-11 五八有限公司 Lookup method, device, equipment and the storage medium of each inter-module dependence
CN113495728B (en) * 2020-03-18 2024-06-28 腾讯科技(深圳)有限公司 Dependency relationship determination method, dependency relationship determination device, electronic equipment and medium
CN112650498B (en) * 2020-12-21 2022-05-17 北京五八信息技术有限公司 Static library integration method and device, electronic equipment and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108153529A (en) * 2017-12-22 2018-06-12 杭州迪普科技股份有限公司 A kind of method and device of file compiling
CN111338689A (en) * 2020-03-05 2020-06-26 网易(杭州)网络有限公司 File calling method, device and equipment

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
Linux和Unix编译链接配置文件分析;王敬生等;《皖西学院学报》;20091015(第05期);第30-33页 *
Research on Dynamic Detection of Java Dependency Conflict;Kefeng Pan et al.;《2020 IEEE International Conference on Advances in Electrical Engineering and Computer Applications (AEECA)》;20201109;第711-14页 *
一个Linux下makefile文件的分析;杜小平等;《现代电子技术》;20040701(第07期);第61-63页 *

Also Published As

Publication number Publication date
CN114020694A (en) 2022-02-08

Similar Documents

Publication Publication Date Title
CN109426504B (en) Program processing method, program processing device, electronic device and storage medium
CN113377370A (en) File processing method and device, electronic equipment and storage medium
CN111913756B (en) Application program optimizing method, device and system, electronic equipment and storage medium
CN111580824B (en) Program optimization method, device and storage medium
CN113076108A (en) Code execution method and device for code execution
CN112114814A (en) Compiled file determining method and device and application program generating method and device
CN106293683B (en) Project compiling method and device
CN114020694B (en) Header file address acquisition method and device, electronic equipment and storage medium
CN110874259A (en) Program execution method, device, equipment and storage medium
CN113590091A (en) Data processing method and device, electronic equipment and storage medium
CN114020693B (en) Header file address acquisition method and device, electronic equipment and storage medium
CN112631695A (en) Data verification method and device, electronic equipment and storage medium
CN113536180A (en) Item processing method, item processing device, electronic equipment, storage medium and program product
CN109933357B (en) Application program upgrading method and device
CN112445484A (en) Register processing method and device, electronic equipment and storage medium
CN113934452B (en) Data processing method and device, electronic equipment and storage medium
CN110659081B (en) File processing method and device for program object and electronic equipment
CN113590128A (en) Method and device for acquiring intermediate file, electronic equipment and storage medium
CN110673850A (en) Method and device for obtaining size of static library
CN113946346B (en) Data processing method and device, electronic equipment and storage medium
CN111596949B (en) Method and device for developing application program
CN114020504B (en) Data processing method and device, electronic equipment and storage medium
CN116400925A (en) Data processing method and device, electronic equipment and storage medium
CN114020505B (en) Data processing method and device, electronic equipment and storage medium
CN109726118B (en) Application program development method and device, electronic equipment and 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