CN110737429A - modular compiling method and device utilizing Makefile self-dependent relationship - Google Patents
modular compiling method and device utilizing Makefile self-dependent relationship Download PDFInfo
- Publication number
- CN110737429A CN110737429A CN201910227999.6A CN201910227999A CN110737429A CN 110737429 A CN110737429 A CN 110737429A CN 201910227999 A CN201910227999 A CN 201910227999A CN 110737429 A CN110737429 A CN 110737429A
- Authority
- CN
- China
- Prior art keywords
- compiling
- file
- module
- makefile
- dependent
- 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.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/31—Programming languages or programming paradigms
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Stored Programmes (AREA)
Abstract
The invention provides modular compiling method and device by utilizing the dependency relationship of Makefile, wherein the method comprises the steps of searching a file and/or a module depended on by current compiling from a dependency relationship total set when the Makefile executes target engineering compiling, determining whether the file and/or the module depended on exist, if the file and/or the module depended on do not exist, compiling preferentially to obtain the file and/or the module depended on, and triggering to compile when determining that the file and the module depended on exist.
Description
Technical Field
The invention relates to the technical field of computers, in particular to modular compiling methods and devices utilizing the dependency relationship of Makefile.
Background
In order to achieve the correct and orderly compilation of code, the generally requires Makefile organization compilation, wherein Makefile defines series of rules to specify which files need to be compiled first, which files need to be compiled later, which files need to be recompiled, or other more complex operations.
These two dependencies are explained below:
1) dependence on running:
for example, the A module is compiled to generate an a program, the B module is compiled to generate a B program, and the compiling processes of the A module and the B module are not dependent on each other, but the a program runs by requiring the B program to create certain environments in advance, and if the B program does not create the environments in advance, the a program can be mistaken or cannot be executed in the running process.
2) Dependencies in compilation:
this dependency condition mostly occurs in the dependency between the running program and the library, and two modules A, B are still taken as an example: some functions in the module a are implemented in the module B, that is, the module a needs to link the target file compiled by the module B when compiling and linking, so as to find the implementation of all functions.
However, in the actual implementation, because some projects are huge and often use libraries or programs of third parties, the programs of the third parties often have dependency relationship of , in order to solve the dependency problem in the compilation, two sets of systems are often needed to be used simultaneously, the dependency problem between modules is solved through a system similar to menuconfig, and the problem of the compilation is solved through Makefile.
Aiming at the problem that two sets of systems are needed, an effective solution is not provided at present.
Disclosure of Invention
The embodiment of the invention provides modular compiling methods using the dependency relationship of Makefile, so that sets of Makefile systems can be used for simultaneously solving the compiling dependency and compiling problems among modules, and the method comprises the following steps:
when the Makefile executes the target engineering compilation, searching a file and/or a module which are depended by the current compilation from the total set of the dependency relationship;
determining whether the dependent file and/or the dependent module exist;
if not, the file and/or the module which are depended on are compiled preferentially;
and triggering to compile under the condition that the dependent file and the dependent module exist.
In embodiments, the preferential compilation results in dependent files, including:
and compiling to obtain the dependent file according to a preset generation rule corresponding to the dependent file.
In embodiments, the dependency rules among the modules in the total dependency relationship set are arranged according to Makefile compiling rules.
In embodiments, the aggregate set of dependencies includes modules and files that are relied upon by compiling the respective modules.
The embodiment of the invention also provides modular compiling devices utilizing the dependency relationship of the Makefile, which are positioned in the Makefile, so that sets of Makefile systems can be utilized to solve the compiling dependency and compiling problems among the modules at the same time, and the device comprises:
the searching module is used for searching a file and/or a module which are depended on by the current compiling from the total set of the dependency relationships when the target engineering compiling is executed;
a determining module for determining whether the dependent file and/or the dependent module exists;
the compiling module is used for compiling preferentially to obtain the dependent file and/or compiling preferentially the dependent module under the condition of determining that the file does not exist;
and the triggering module is used for triggering the compiling under the condition that the depended files and the depended modules exist.
In embodiments, the compiling module is specifically configured to compile the dependent file according to a preset generation rule corresponding to the dependent file.
In embodiments, the dependency rules among the modules in the total dependency relationship set are arranged according to Makefile compiling rules.
In embodiments, the aggregate set of dependencies includes modules and files that are relied upon by compiling the respective modules.
According to the embodiment of the invention, when the Makefile system executes the target engineering compilation, the file and/or the module depending on the current compilation is searched from the dependency relationship total set, and the file and/or the module depending on the current compilation is preferentially compiled to obtain the file and/or the module depending on the prior compilation under the condition that the file and the module depending on the prior compilation are determined not to exist.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and constitute a part of this application and not limiting of the invention, are illustrated in the accompanying drawings, in which:
FIG. 1 is a method flow diagram of a modular compilation method that utilizes Makefile's own dependencies, according to an embodiment of the invention;
fig. 2 is a block diagram illustrating a modular compilation apparatus using Makefile's own dependency relationship according to an embodiment of the present invention.
Detailed Description
To make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in further with reference to the following embodiments and accompanying drawings.
Aiming at the dependency problem in the existing compiling process, the method can be realized by the following steps:
1) dependence on running:
for this case, describes the dependency relationship in Kconfig to ensure that when Makefile is used to compile and generate a program, B program will be generated.
The method comprises the steps that a Kconfig file is a configuration interface presented by Menuconfig, and is presented by reading the Kconfig file, the Kconfig can describe and express the dependency relationship among modules through syntax description, so that the Menuconfig presents the dependency relationship among the modules when the interface is presented, the Menuconfig is menu type configuration, and when a plurality of modules exist in projects, the Menuconfig can select which files are compiled and which files are not compiled in cooperation with Makefile configuration.
2) Dependencies in compilation:
in order to solve the dependency relationship, a config.in (similar to Kconfig in function) is introduced into the buildrop, and the dependency relationship is clarified in the interface description, so that the dependent module is compiled preferentially in the compiling process, that is, the B module in the above example is compiled preferentially, and when the a module is compiled, the content of the dependent B module is completely ready and can be compiled normally.
Therefore, in order to solve the dependency problem in the compiling, two sets of systems need to be used at the same time, that is, the dependency problem between the modules needs to be solved through a system similar to menuconfig, and the compiling problem needs to be solved through Makefile.
For this reason, in this example, modular compilation methods that utilize Makefile's own dependencies are provided.
Where the context permits, reference to element or component or step(s), etc. should not be construed as limited to only of the elements, components, or steps, but may be or more of the elements, components, or steps, etc.
Although the flow described below includes a number of operations that occur in a particular order, it should be appreciated that these processes may include more or fewer operations, which may be performed sequentially or in parallel (e.g., using a parallel processor or a multi-threaded environment). As shown in FIG. 1, the method includes:
step 101: when the Makefile executes the target engineering compilation, searching a file and/or a module which are depended by the current compilation from the total set of the dependency relationship;
step 102: determining whether the dependent file and/or the dependent module exist;
step 103: if not, the file and/or the module which are depended on are compiled preferentially;
step 104: and triggering to compile under the condition that the dependent file and the dependent module exist.
Before the step 101, a total set of dependencies may be generated as follows:
s1: acquiring development files of all modules in a target project, wherein the development files carry compiling dependency information of the modules;
s2: extracting modules and files which are depended on by compiling of each module from development files of the modules;
and S3, generating total sets of the modules depended on by the modules and the files depended on by the compilation, and combining the total sets into a compilation dependency relationship set of the target project.
In the above example, when the Makefile system executes the target engineering compilation, the file and/or the module depending on the current compilation is searched from the dependency relationship total set, and the file and/or the module depending on the current compilation is preferentially compiled to obtain the file and/or the module depending on the prior compilation under the condition that the file and the module depending on the prior compilation are determined not to exist.
For example, when Makefile executes compilation of the global object, it may first find a dependent file, that is, an object file compiled by all modules, and if the total object-dependent file does not exist or some files do not exist, Makefile may automatically generate the missing file according to a generation rule (command) of previously collecting the missing file, in this way, all modules may be efficiently compiled.
The compiling dependency information of the modules carried in the development file may include, but is not limited to: a file generated after compilation, a method of generating a file, a file on which compilation depends, and a module on which compilation depends. The development file may exist in a file format of.
In step 103, the preferentially compiling to obtain the dependent file may include: and compiling to obtain the dependent file according to a preset generation rule corresponding to the dependent file. The dependency rules among the modules in the dependency relationship collection can be arranged according to the compiling rule of Makefile.
In the embodiments, the method can be applied to embedded Linux development.
The above method is described below with reference to specific examples, however, it should be noted that the specific examples are only for better describing the present application and should not be construed as limiting the present application.
In this example, ways are provided, and the compiling dependency and compiling problem between modules can be solved at the same time only by sets of Makefile systems.
Specifically, the Makefile compiling rule is described as follows:
Target......:prerequisites......
command
wherein, Target represents the Target file, prerequisites represents the Target or file on which the Target needs to be generated, and Command represents the Command to be executed to generate the Target.
The code indicates the dependency relationship of files or modules, that is, or more target files of target depend on files in prequiries, the generation rule is defined in command, Makefile judges whether prequiries exist before compiling target, if no target exists in prequiries, the generation rule of the target which does not exist in prequiries is preferably searched for so as to generate the target which depends on the target first, moreover, if more than files in prequiries are newer than the target file, the command defined by command is executed, which is the rule of Makefile and is the core content of Makefile.
In this example, it is considered that the rule of Makefile itself can be used to perform systematic and ordered processing on a plurality of modules, and all modules are compiled one by using the dependency rule of Makefile.
However, there are two problems to be solved by the above solution: 1) relationships between all modules; 2) the problem of coupling among a plurality of modules is specifically:
1) the relationship between all modules is mainly divided into two directions: and (3) the collection of module information, how to promote the compiling of all modules.
For this purpose, files with mk as a suffix name can be defined in each module in the project as a development file of Makefile, so as to be subsequently defined as a build.mk file by . information of a name for only identification, a target file generated after compiling, a method of compiling and the like is defined in the file.
In this way, when Makefile executes compilation of the total target, it may first find a dependent file, that is, a target file compiled by all modules, and if the file on which the total target depends does not exist, or some files do not exist, Makefile may automatically generate the deleted file according to a generation rule (command) previously collected for the deleted file, and according to this way, all modules may be effectively compiled.
2) There is a problem of coupling between the plurality of modules.
That is, if modules depend on other modules or a plurality of modules in the compiling process, the dependency needs to be declared in the build.mk of the modules, so that the dependency between the modules can be analyzed in the information collection stage of all the modules.
In this example, the dependency and compilation problem between modules in the engineering can be completed only by using the Makefile method for processing the dependency relationship, so that the method is very convenient when a third-party module is assembled in engineering use.
Based on the same inventive concept, modular compiling apparatuses using Makefile's own dependency relationship are also provided in the embodiments of the present invention, as described in the following embodiments, since the principle of solving the problem of the modular compiling apparatuses using Makefile's own dependency relationship is similar to the modular compiling method using Makefile's own dependency relationship, so the implementation of the modular compiling apparatuses using Makefile's own dependency relationship can refer to the implementation of the modular compiling method using Makefile's own dependency relationship, and the repetition is not repeated.
The searching module 201 is configured to search a file and/or a module that is depended on by the current compilation from the total set of dependency relationships when the target engineering compilation is executed;
a determining module 202 for determining whether the dependent file and/or the dependent module exist;
the compiling module 203 is used for preferentially compiling the dependent files and/or modules which are preferentially compiled under the condition that the files do not exist;
a triggering module 204, configured to trigger compiling when it is determined that both the dependent file and the dependent module exist.
In embodiments, the compiling module 203 may be specifically configured to compile the dependent file according to a preset generation rule corresponding to the dependent file.
In embodiments, the dependency rules among the modules in the dependency relationship aggregate can be arranged according to the compilation rule of Makefile.
In embodiments, the total set of dependencies may include, but is not limited to, modules and files that are relied upon to compile the respective modules.
In embodiments, the compilation dependency information for a module may include, but is not limited to, a file generated after compilation, a method of generating a file, a file on which compilation depends, and a module on which compilation depends.
In embodiments, the development file may exist in a.mk file format.
In embodiments, the device can be applied to embedded Linux development.
In another embodiments, software is provided, which is used to implement the technical solutions described in the above embodiments and preferred embodiments.
In another embodiments, storage media are provided, which store the above software, including but not limited to optical disks, floppy disks, hard disks, removable memory, and the like.
From the above description, it can be seen that the embodiment of the present invention achieves the technical effects that when the Makefile system executes the target engineering compilation, the Makefile system searches the file and/or the module depending on the current compilation from the dependency relationship total set, and when it is determined that the file or the module depending on the current compilation does not exist, the Makefile system preferentially compiles the file and/or the module depending on the prior compilation.
It will be apparent to those skilled in the art that the modules or steps of the embodiments of the invention described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of multiple computing devices, and alternatively, they may be implemented by program code executable by a computing device, such that they may be stored in a storage device and executed by a computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into individual integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, embodiments of the invention are not limited to any specific combination of hardware and software.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes may be made to the embodiment of the present invention by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (8)
1, modular compilation method using Makefile's own dependency, comprising:
when the Makefile executes the target engineering compilation, searching a file and/or a module which are depended by the current compilation from the total set of the dependency relationship;
determining whether the dependent file and/or the dependent module exist;
if not, the file and/or the module which are depended on are compiled preferentially;
and triggering to compile under the condition that the dependent file and the dependent module exist.
2. The method of claim 1, wherein preferentially compiling the dependent file comprises:
and compiling to obtain the dependent file according to a preset generation rule corresponding to the dependent file.
3. The method according to claim 1, wherein the dependency rules among the modules in the total set of dependency relationships are arranged according to Makefile compiling rules.
4. The method of , wherein the collection of dependencies comprises modules on which the compilation of modules depends and files on which the compilation of modules depends.
5, modular compiling device using Makefile's own dependency relationship, wherein the modular compiling device located in Makefile includes:
the searching module is used for searching a file and/or a module which are depended on by the current compiling from the total set of the dependency relationships when the target engineering compiling is executed;
a determining module for determining whether the dependent file and/or the dependent module exists;
the compiling module is used for compiling preferentially to obtain the dependent file and/or compiling preferentially the dependent module under the condition of determining that the file does not exist;
and the triggering module is used for triggering the compiling under the condition that the depended files and the depended modules exist.
6. The apparatus according to claim 5, wherein the compiling module is specifically configured to compile the dependent file according to a preset generation rule corresponding to the dependent file.
7. The apparatus of claim 5, wherein the dependency rules among the modules in the total dependency set are arranged according to Makefile's compiling rule.
8. The apparatus according to of any of claims 5-7, wherein the collection of dependency relationships comprises modules and files that are dependent upon compiling the respective modules.
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201810803183 | 2018-07-20 | ||
| CN2018108031839 | 2018-07-20 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN110737429A true CN110737429A (en) | 2020-01-31 |
Family
ID=69236635
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201910227999.6A Pending CN110737429A (en) | 2018-07-20 | 2019-03-25 | modular compiling method and device utilizing Makefile self-dependent relationship |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN110737429A (en) |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2021258692A1 (en) * | 2020-06-24 | 2021-12-30 | 苏州大学 | Multi-chip compatible compiling method and device |
| CN114490422A (en) * | 2022-02-23 | 2022-05-13 | 上海御渡半导体科技有限公司 | A method of using Makefile to monitor files in industrial software |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20040139425A1 (en) * | 2003-01-09 | 2004-07-15 | International Business Machines Corporation | Method and apparatus for deriving multiple test source files from one source file |
| CN101697125A (en) * | 2009-11-04 | 2010-04-21 | 中兴通讯股份有限公司 | Method and device for development environment conversion |
| CN103645888A (en) * | 2013-10-25 | 2014-03-19 | 普华基础软件股份有限公司 | System and method for automatically building operation system |
| CN103870310A (en) * | 2014-02-18 | 2014-06-18 | 小米科技有限责任公司 | Program compilation method and relevant device |
| CN104866369A (en) * | 2015-05-22 | 2015-08-26 | 广州华多网络科技有限公司 | Data processing method and apparatus |
| CN108304185A (en) * | 2016-08-09 | 2018-07-20 | 上海思立微电子科技有限公司 | A kind of method and apparatus of collector |
-
2019
- 2019-03-25 CN CN201910227999.6A patent/CN110737429A/en active Pending
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20040139425A1 (en) * | 2003-01-09 | 2004-07-15 | International Business Machines Corporation | Method and apparatus for deriving multiple test source files from one source file |
| CN101697125A (en) * | 2009-11-04 | 2010-04-21 | 中兴通讯股份有限公司 | Method and device for development environment conversion |
| CN103645888A (en) * | 2013-10-25 | 2014-03-19 | 普华基础软件股份有限公司 | System and method for automatically building operation system |
| CN103870310A (en) * | 2014-02-18 | 2014-06-18 | 小米科技有限责任公司 | Program compilation method and relevant device |
| CN104866369A (en) * | 2015-05-22 | 2015-08-26 | 广州华多网络科技有限公司 | Data processing method and apparatus |
| CN108304185A (en) * | 2016-08-09 | 2018-07-20 | 上海思立微电子科技有限公司 | A kind of method and apparatus of collector |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2021258692A1 (en) * | 2020-06-24 | 2021-12-30 | 苏州大学 | Multi-chip compatible compiling method and device |
| US11579856B2 (en) | 2020-06-24 | 2023-02-14 | Soochow University | Multi-chip compatible compiling method and device |
| CN114490422A (en) * | 2022-02-23 | 2022-05-13 | 上海御渡半导体科技有限公司 | A method of using Makefile to monitor files in industrial software |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| KR101687213B1 (en) | Dynamically loading graph-based computations | |
| US11481200B1 (en) | Checking source code validity at time of code update | |
| CN110737437A (en) | compiling method and device based on code integration | |
| US20050278318A1 (en) | Iterative development with prioritized build | |
| CN111144839B (en) | Project construction method, continuous integration system and terminal equipment | |
| US10013242B2 (en) | Distributed compilation of statically typed languages | |
| CN109032631B (en) | Application program patch package obtaining method and device, computer equipment and storage medium | |
| CN111124872A (en) | Branch detection method and device based on difference code analysis and storage medium | |
| CN114138281B (en) | Compilation methods, devices, equipment and media for software engineering | |
| Fazzini et al. | Apimigrator: an api-usage migration tool for android apps | |
| CN113342323A (en) | Method and device for software online development | |
| CN110737438A (en) | data processing method and device | |
| US9396239B2 (en) | Compiling method, storage medium and compiling apparatus | |
| CN118779247A (en) | Application program testing method, device, storage medium and program product | |
| CN110737429A (en) | modular compiling method and device utilizing Makefile self-dependent relationship | |
| US9116714B2 (en) | Methods and systems for file processing | |
| WO2015003452A1 (en) | Methods and systems for file processing | |
| CN108304184B (en) | Compiling method and device | |
| CN111459535A (en) | Branch merging method, device, equipment and computer storage medium | |
| US11947966B2 (en) | Identifying computer instructions enclosed by macros and conflicting macros at build time | |
| CN111240987A (en) | Migration program detection method and device, electronic equipment and computer readable storage medium | |
| CN112052035A (en) | Version packaging method and device based on bank back-line system | |
| US12093686B2 (en) | Code maintenance system | |
| CN116578282A (en) | Code generation method, device, electronic equipment and medium | |
| CN113821486B (en) | Method and device for determining dependency relationship between pod libraries and electronic equipment |
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 | ||
| RJ01 | Rejection of invention patent application after publication | ||
| RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200131 |