CN108304184A - Compilation Method and device - Google Patents

Compilation Method and device Download PDF

Info

Publication number
CN108304184A
CN108304184A CN201610646882.8A CN201610646882A CN108304184A CN 108304184 A CN108304184 A CN 108304184A CN 201610646882 A CN201610646882 A CN 201610646882A CN 108304184 A CN108304184 A CN 108304184A
Authority
CN
China
Prior art keywords
compiling
node
configuration
compilation
script
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.)
Granted
Application number
CN201610646882.8A
Other languages
Chinese (zh)
Other versions
CN108304184B (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.)
Silead Inc
Original Assignee
Silead Inc
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 Silead Inc filed Critical Silead Inc
Priority to CN201610646882.8A priority Critical patent/CN108304184B/en
Publication of CN108304184A publication Critical patent/CN108304184A/en
Application granted granted Critical
Publication of CN108304184B publication Critical patent/CN108304184B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/447Target code generation

Abstract

A kind of Compilation Method and device, the Compilation Method include:Default configuration file is read, the default configuration file is suitable for recording the environment configurations that compilation process utilizes and input configures, and the input configuration is corresponding with the compiling node of directory tree, and the node of the compiling directory tree includes common node and compiling node;At least part in the input configuration of the environment configurations and the common node in the default configuration file that reads is override, the input configuration of the compiling node and the input configuration record after overriding have the compiling demand information of the compiling node;It is configured according to the corresponding input of the compiling node, the environment configurations after overriding and the input configuration are compiled the source program of all compiling nodes.Technical solution of the present invention can promote compiling efficiency.

Description

Compilation Method and device
Technical field
The present invention relates to field of computer technology more particularly to a kind of Compilation Method and devices.
Background technology
The process of compiling is by the process of source program to target program.One engineering may include several source files, especially Be in heavy construction, source file it is more;When in a large scale system including multiple engineerings, the quantity of source file is more It is huge.
In the prior art, all compilings configuration input text set is closed in the same compiling rule file of root, Cause the entire compilation process time long, it is complicated for operation.Each collector does not have compilation script, only compiling configuration input text This, cannot be by going to execute compiling in current directory make orders;Android must remove root by special command, such as mm The lower compiling for executing present node (module or catalogue).And it cannot be gone to compile with the standard target script of convention in each catalogue It translates, it is necessary to the target script for going combining characters string of the root input with module name to name, it is less efficient.Simultaneously as institute Some compiling configuration input texts close in a compilation script, so the name for the file destination that the compiling of a module obtains Being must be different, identical to fail, and must be introduced into extremely complex naming rule in this way, resulting variable is very It is more, it is very difficult to read and understand, lack inheritance maintainability.One module of compiling must call the son compiling foot of a clear variable every time This.And the variable of this sub- compilation script is very more, one newly into guardian not exclusively understand whole script, it is difficult to which which is known A little variables need clearly, and slightly mistake can then cause compiling to fail.And compiling dependence processing in the prior art, only in root It works under catalogue smooth, can not find the compiling rule of Depending module in other catalogues, compiling is less efficient.
Invention content
Present invention solves the technical problem that being how to improve compiling efficiency.
In order to solve the above technical problems, the embodiment of the present invention provides a kind of Compilation Method, the Compilation Method includes:It reads Default configuration file, the default configuration file is suitable for recording the environment configurations that compilation process utilizes and input configures, described defeated It is corresponding with the node of directory tree is compiled to enter configuration, the node for compiling directory tree includes common node and compiling node;It is right In the input configuration of the environment configurations and the common node in the default configuration file read at least A part is override, and the input configuration of the compiling node and the input configuration record after overriding have the compiling node Compiling demand information;According to the environment configurations and described after the corresponding input configuration of the compiling node, overriding Input configuration is compiled the source program of all compiling nodes.
Optionally, it is described according to it is described compiling node it is corresponding it is described input configuration, overriding after the environment configurations and It is described input configuration to it is all compiling nodes source programs be compiled including:It is called not according to the environment configurations after overriding Same environment script, or adjust back different translation and compiling environments;The defeated of the compiling node is configured according to the input after overriding Enter configuration and call corresponding compilation script, the compiling rule file of node is compiled described in dynamic formation, with to the compiling node Source program be compiled.
Optionally, the environment script fits compilation process according to the environmental variance in the environment configurations after overriding It is assigned to compiling host and running environment.
Optionally, the compilation script executes compiling according to the compiling rule file to the source program of the compiling node Action exports file destination.
Optionally, executing compiling action to the source program of the compiling node includes:Obtain the corresponding quilt of the source program Depending module inventory, the depended module inventory record the depended module that the compiling node relies on;Jump to the quilt The depended module is compiled under the path of Depending module.
Optionally, the compiling node is located at the leaf node of the compiling directory tree, each section of the compiling directory tree Storage has the compilation script that the compilation process needs in point.
Optionally, the compilation script includes the root script for the root node for being located at the compiling directory tree, position Subdirectory script in the subdirectory node of the compiling directory tree and the compiling node script positioned at the compiling node.
Optionally, the input of the common node, which configures, includes:Baseline code configuration, each project configuration and output Bibliographic structure configures.
Optionally, the environment configurations in the described pair of default configuration file read and the common node At least part in the input configuration carries out overriding and includes:By public configuration script to the baseline code configuration and The configuration script of each project configuration executes callback operation to be override.
In order to solve the above technical problems, the embodiment of the invention also discloses a kind of compilation device, the compilation device includes: Default configuration file reading unit, is suitable for reading default configuration file, and the default configuration file is suitable for record compilation process profit Environment configurations and input configure, and the input configuration is corresponding with the compiling node of directory tree, the compiling directory tree Node includes common node and compiling node;Unit is override, suitable for the ring in the default configuration file to reading At least part that border configures in the input configuration with the common node is override, and the input of the compiling node is matched Input configuration record after setting and overriding has the compiling demand information of the compiling node;Compilation unit is suitable for according to institute The environment configurations and the input after the corresponding input configuration of compiling node, overriding are stated to configure to all compiling nodes Source program be compiled.
Optionally, the compilation unit includes:Environment configurations subelement is suitable for according to the environment configurations tune after overriding With different environment scripts, or translation and compiling environment that readjustment is different;Subelement is compiled, suitable for matching according to the input after overriding It sets and calls corresponding compilation script with the input configuration of the compiling node, the compiling rule text of node is compiled described in dynamic formation Part is compiled with the source program to the compiling node.
Optionally, the environment script fits compilation process according to the environmental variance in the environment configurations after overriding It is assigned to compiling host and running environment.
Optionally, the compilation script executes compiling according to the compiling rule file to the source program of the compiling node Action exports file destination.
Optionally, the compiling subelement includes:Depending module inventory obtains subelement, is suitable for obtaining the source program pair The depended module inventory answered, the depended module inventory record the depended module that the compiling node relies on;Redirect volume Subelement is translated, the depended module is compiled under the path suitable for jumping to the depended module.
Optionally, the compiling node is located at the leaf node of the compiling directory tree, each section of the compiling directory tree Storage has the compilation script that the compilation process needs in point.
Optionally, the compilation script includes the root script for the root node for being located at the compiling directory tree, position Subdirectory script in the subdirectory node of the compiling directory tree and the compiling node script positioned at the compiling node.
Optionally, the input of the common node, which configures, includes:Baseline code configuration, each project configuration and output Bibliographic structure configures.
Optionally, the overriding unit passes through public configuration script to the baseline code configuration and each project The configuration script of configuration executes callback operation to be override.
Compared with prior art, the technical solution of the embodiment of the present invention has the advantages that:
The embodiment of the present invention is suitable for record compilation process and utilizes by reading default configuration file, the default configuration file Environment configurations and input configure, input configuration is corresponding with the node of directory tree is compiled;To the acquiescence read At least part in the input configuration of the environment configurations and the common node in configuration file is override, institute Stating the input configuration of compiling node and the input configuration record after overriding has the compiling demand information of the compiling node;Root According to the corresponding input of the compiling node configures, the environment configurations after overriding and the input are configured to all compilings The source program of node is compiled.It, can by at least part of overwriting operations in the input configuration to common node To avoid in each compiling, the content repeated in compilation process is write repeatedly, promotes compiling efficiency;Meanwhile passing through To the overwriting operations of default configuration file, the differentiated demand of different compiling nodes can also be met so that the embodiment of the present invention In Compilation Method can it is more flexible be suitable for various scenes.At the same time it can also make more hardware platforms, 64/32 System, entry system, the compiling for sharing multimode software baseline packet and maintenance become easy, and then promote compiling efficiency
Further, the corresponding depended module inventory of the source program is obtained, described in the depended module inventory record Compile the depended module that node relies on;It jumps under the path of the depended module and compiles the depended module.To Realization can obtain the path of depended module when compiling this module under the catalogue of operational blocks which partition system with auto-associating depended module And compile depended module under depended module catalogue automatically, due to engineer no longer need accurately to remember intermodule according to The relationship of relying is not easy to malfunction, improves the efficiency of compiling, while also allowing for the attended operation of engineer even if stopping compiling.
Description of the drawings
Fig. 1 is a kind of flow chart of Compilation Method of the embodiment of the present invention;
Fig. 2 is a kind of method flow diagram of overriding in the embodiment of the present invention;
Fig. 3 is a kind of structural schematic diagram of compiling directory tree in the embodiment of the present invention;
Fig. 4 is a kind of flow chart of the reading of file in the embodiment of the present invention;
Fig. 5 is a kind of flow chart being compiled to a compiling node in the embodiment of the present invention;
Fig. 6 is a kind of structural schematic diagram of compilation device in the embodiment of the present invention;
Fig. 7 is a kind of structural schematic diagram of compiling subelement in the embodiment of the present invention.
Specific implementation mode
As described in the background art, it in the prior art when source file quantity is more, such as compiles to large scale system When translating, source file is thousands of, and the process compiled is complex.The compiling rule file of system is integrated into the prior art In one catalogue, cause compilation time long, it is complicated for operation, entire Compilation Method inefficiency is caused, and be easy in compilation process In there are various problems, the file destination for compiling generation is also susceptible to problem at runtime.
To make the above purposes, features and advantages of the invention more obvious and understandable, below in conjunction with the accompanying drawings to the present invention Specific embodiment be described in detail.
Fig. 1 is a kind of flow chart of Compilation Method of the embodiment of the present invention.With reference to Fig. 1 to the specific of the Compilation Method Step is described in detail.
Step S101:Read default configuration file.
In specific implementation, the default configuration file is suitable for recording the environment configurations that compilation process utilizes and input configures, The input configuration is corresponding with the compiling node of directory tree, and the node of the compiling directory tree includes that common node and compiling save Point.Specifically, the common node of compiling directory tree may include that the public node of entire compiling system and each project are common Node.
Specifically, the process for reading default configuration file can read the process of multiple default configuration files.Specifically Ground can be the corresponding input configuration of node of environment configurations and multiple compiling directory trees that compilation process utilizes.
In specific implementation, input configuration and central processing unit (Central Processing Unit, CPU) framework, hardware Ability, bus bit wide, OS Type, the definition of output directory structure, collector inventory etc. are related.
In an embodiment of the present invention, from inherit and call relation on for, compiling directory tree (can also claim compiling set) The bibliographic structure of corresponding software system may include root node, subdirectory node and compiling node.Wherein, root section The top-level director (namely root) of point corresponding software system;Subdirectory node corresponds to subdirectory, and subdirectory indicates multiple softwares Multiple software modules are constituted a subsystem by the parent directory of module directory;Compile the catalogue of node respective software module, compiling Node can be the leaf node of compiling directory tree, and the software code for indicating specific specific function is stored in the catalogue of software module, A target (target) can be generated after compiling.
In specific implementation, the configuration input file of the corresponding root node of input configuration of root node (for example, Currdir.mk), can to specify its under submodule or subdirectory.Such as it can be expressed as:SUBMODULES:= Childdirpath childdirpath childdirpath, are also denoted as SUBMODULES:= module1module2.The corresponding subdirectory configuration input file (for example, currdir.mk) of input configuration of subdirectory node, can With to specify its under submodule or subdirectory.Such as it can be expressed as:SUBMODULES:=fpsvc fpsvcd Fpcal fpsvcrx callib slfpauth, are also denoted as SUBMODULES:=module1module2.Compiling section The input of point configure corresponding file include configuration input file (for example, currdir.cfg) and control input file (for example, Currdir.mk), configuration input file (for example, currdir.cfg) can be indicating compiling target, output format etc.;Control Input file (for example, currdir.mk) processed can to indicate compiling node source file or precompile file, output mesh Mark the format of code, the library etc. of dependence.For example, the configuration input file of compiling node can be expressed as:
#GLV_BUILD_GOAL:=HOST
#GLV_HOST_OVERWRITED_OUT_EXEDIR:=default
#GLV_BUILD_INSTR_WIDTH_COMBO:=both | primary | secondary | 64 | 32 | 16
Wherein, GLV_BUILD_GOAL selections compiling target is that the object code after compiling operates on host or directly Generate target (target);GLV_BUILD_INSTR_WIDTH_COMBO selection compiling output be 32,64 or 32 and 64.
The control input file (for example, currdir.mk) of compiling node can be expressed as:
DEP_LIBS:=
DEP_LIBS_32:=
DEP_LIBS_64:=
DEP_LIBS_arm:=
DEP_LIBS_arm64:=
DEP_PREBUILT_TARGET:=#autotest_prebuilt
TARGET_SUFFIX:=.so.
In one embodiment of the invention, environment configurations correspond to environment script, may include environment script type, and environment script type is matched Setting environmental variance makes compiled system that correct environment script type be called to go to be fitted to running environment, mainly so that compilation process The framework of central processing unit (Central Processing Unit, CPU) when can be fitted to operation so that the target of generation Code can operate in configured operational objective, such as can be CPU and hardware (for example, BOARD) environment.
In specific implementation, reading default configuration file may include:Call the input of configuration script and all compiling nodes Configuration file.
Step S102:To the institute of the environment configurations and the common node in the default configuration file that reads At least part stated in input configuration is override.
In specific implementation, the input configuration of the compiling node and the input configuration record after overriding have the compiling The compiling demand information of node.
In one embodiment of the invention, compiling node input configuration cannot override, and overriding is the default configuration of baseline code The default configuration with each project.Specifically, the configuration input file and subdirectory to root node configure input file. That is, the configuration input file by root node overrides submodule or subdirectory under root node;Pass through Subdirectory configures the submodule or subdirectory under input file overriding subdirectory node.
In specific implementation, configuration file corresponds to configuration script, and configuration script may include configuration script class, and overwriting operations can To be the overriding to configuration script class.Being override to configuration script class can be by reading the configuration script class reality built in difference It is existing.For example, the script type of various target environment/hosted environments;The engineer of secondary development postpone matching for project, then compiling The system of translating can automatically select and adjust back corresponding environment script type and built-in configuration script class, to be override.
Due to the process of reading can be inherit or call process, be similar to face-objected programming method in succession or Calling process, therefore modify the original description having no effect in default configuration file to the default configuration file read, only It is to meet the modification for carrying out adaptability the needs of different compiling nodes so that the Compilation Method applicability in the embodiment of the present invention It is stronger, and default configuration file can be repeatedly multiplexed so that more hardware platforms, 64/32 systems, entry systems System, the compiling for sharing multimode software baseline packet and maintenance become easy, and then promote compiling efficiency.
Step S103:The environment configurations after configuring, override according to the corresponding input of the compiling node and institute Input configuration is stated to be compiled the source program of all compiling nodes.
In specific implementation, environment script fits compilation process according to the environmental variance in the environment configurations after overriding It is assigned to compiling host and running environment., can be with processing environment variable specifically, environment script corresponds to environment script type, it can be with Environment when compilation process being fitted to various compiling hosts and is fitted to various operations according to the input information of configuration script class.
In specific implementation, corresponding compile is called in the input configuration that the compiling node is configured according to the input after overriding Script is translated, the compiling rule file of node is compiled described in dynamic formation, is compiled with the source program to the compiling node.It compiles It translates script and compiling action is executed to the source program for compiling node according to compiling rule file, export file destination.Specifically, compiling Translating rule file can save according to baseline code default configuration, the configuration of detailed programs, the configuration of output directory structure and compiling The input of point configures dynamic formation.More specifically, compiling rule file can be according to configuration input file, the son of root node Catalogue configure input file, compile node configuration input file (for example, currdir.cfg) and control input file (for example, Currdir.mk) dynamic formation.
By the way that compiling action is recorded in compilation script, data recordation in default configuration file, may be implemented data and Action separates, and reduces the coupling between data and action, makes compiled system frame structure in order, promote the efficiency of Compilation Method.
In specific implementation, the compilation script being stored in each node of compiling directory tree can be inherited in corresponding node Built-in script.
It should be noted that the built-in preset script of script represenation alleged by the embodiment of the present invention, deposits in compiling body in advance In system.
In specific implementation, compilation script may include the root foot for the root node for being located at the compiling directory tree Originally, the subdirectory script positioned at the subdirectory node of the compiling directory tree and the compiling node foot positioned at the compiling node This, inherits respectively in built-in root script, built-in subdirectory script and built-in compiling node script.It compiles as a result, Script can be located at the root in compiled system frame structure, can also be located at subdirectory, and extension name can be .malefile.Has inheritance between the compilation script of different directories, the process of the succession can be similar to object-oriented and compile The process inherited in Cheng Fangfa.
It is understood that when having multilayer bibliographic structure, compilation script to deposit in relationship between superior and subordinate in compiled system Multiple catalogues in when, can be according to the position of node to be compiled, according to the sequence of bibliographic structure from top to bottom, inheriting successively should All compilation scripts in bibliographic structure branch line where node to be compiled.It in specific implementation, can be according to demand to storage There is the compilation script of different content to be named and store, such as:
basenode.makefile:It is stored in the compilation script class of basic compiling node, source code can be compiled by being stored with The data that the object code suitable for 64 or 32 systems is relied on are translated into, to above-mentioned data with can be matched by overriding Set file setting.One engineering can be a basic compiling node, lower to have several source programs.Basic compiling node can To be located at root node, subdirectory node can also be located at;
basetarget.makefile:It is stored in the compilation script class of basic compiling node, can be integrated in Basenode.makefile, being stored with by source code while can be compiled into suitable for 64 and 32 or one 64 independent The data that position or 32 object codes are relied on;
basesubdirs.makefile:The compilation script class of base directory node, base directory node can be basic The corresponding directory node of node is compiled, the succession that lower child node can be parallel is in the compiling foot of basetarget.makefile The compiling node of this class control;
baserootdir.makefile:The compilation script class of root node, lower child node can be The compiling child node of basetarget.makefile controls can also be the catalogue section of basesubdirs.makefile controls Point;
basedist.makefile:The root compilation script class of software publication, the process of control software publication;
basedist_rel.makefile:It inherits in basedist.makefile, the hair of control software object code packet The code that cloth, wherein application layer are increased income can be with secondary development;
basedist_sdk.makefile:It inherits in basedist.makefile, the publication of control software SDK packets, Middle middle layer Open Source Code can be with secondary development.
Wherein basenode.makefile script types can be made of multiple submodule, their each responsible sub-fractions are compiled Script type function is translated, such advantage is that a big module splits into several small modules, convenient for safeguarding.Above-mentioned multiple sons Module may include:
basenodeprebuilt.mk:The installation module of the good object code of precompile;
basenodelink.mk:The link module of object code;
basenodeinfermetas.mk:Anonymous collector;
basenodedirgen.mk:The standard directories generation module of one basic compiling node;
basenodedirectives.mk:The processing module of built-in pragma control variable (directive);
basenodedirdef.mk:The standard directories definition module of one basic compiling node;
basenodedepends.mk:Compiling relies on the module of (dependency) processing;
cfg/codelineversion.cfg:The configuration of Version Control, for generating version information.
In another embodiment of the present invention, for root node, each subdirectory node and compiling node, it can also be arranged Standard target script (targets).Standard target script (targets) can be used for calling the rule of some standards in compiling (RULES) result of standard is generated.
For example, standard targets may include:
default:It quickly generates object library or target executes file, need not thoroughly recompilate and (not regenerate Dependent file need not regenerate the obj files of other source files);
all:Thoroughly recompilate and generate object library or target and execute file, rely on (dependency) file with After obj files all complete deletions, recompilate;
clean:Remove obj files;
clean_depends:Remove dependency files;
clean_all:Remove obj files and dependency files;
depends:Generate dependency files;
Dependency filenames:Generate the dependency files;
dirs:Standard subdirectory generates;
Subdirectory name:The subdirectory generates;
Obj filenames:Generate the obj files;
Current library name or executable file name:It generates current goal library or target executes file;
pre:Pretreatment;Including precompile library, executable file can perform the installation of script;
basenodeprebuilt_clean:Precompile library is removed, executable file can perform the installation of script;
Library, executable file, executable script name are installed in precompile:Install the precompile installation library, executable file, can Perform script.
Wherein, for 64 and 32 systems, all_both, default_both, clean_both, clean_all_ Both etc. can not only compile 64 but also compile 32 systems, and all, default, clean, clean_all etc. are just for 32 System, all_2, default_2, clean_2, clean_all_2 etc. are compiled to 64 systems.
In an embodiment of the present invention, to the succession of compilation script class, to described in the environment configurations and corresponding node The process that at least part in input configuration is override may refer to Fig. 2.Fig. 2 is a kind of overriding in the embodiment of the present invention Method flow diagram.
In step s 201, configuration default in generic configuration file common.cfg is read, project configuration is returned Adjust registration process.
Wherein, common.cfg is default configuration file, and default configuration therein is default configuration;Callback registration processing It is the process for the interface that overriding configuration is left in default configuration file.Callback registration processing can use include sentences to override Variant content in default configuration;Callback registration processing can also be to be adjusted back automatically according to the configuration of configuration script.
In step S202, general environment configuration file common.env is read, the related script of environment is adjusted back Registration process.
Wherein, common.env is default configuration file, and default configuration therein is default configuration;Callback registration processing It is the process for the interface that overriding configuration file is left in default configuration file.Callback registration processing can use include sentences; Callback registration processing can also be to be adjusted back automatically according to the configuration of configuration script.
In step S203, at least part in the default configuration file that reads is override.
Specifically, secondary development engineer can use common.cfg file configurations to adjust back, each project pair is realized The overriding of common.cfg default configurations, the common.cfg after overriding can be used for configuring each project.Such as can be, cfg/$(SL_PROJECT_NAME).cfg.Common.env can make the distinctive environment of item setup.Such as can be, cfg/$(SL_PROJECT_NAME).env。
The object override can be related with the framework of OS, CPU or related with detailed programs, by being override, It is capable of providing various compiling option controls.
It is host environmental correclation, such as system environment variable PATH etc. to carry out overriding object, can be that basis is matched at this time The configuration for setting script is adjusted back automatically.
The object override can be related with hardware platform, for example, MTK some AP chip platform;It can be with specific item Purpose hardware platform is related, such as some project made of some AP chip platform of MTK;Can be related with specific plank, than The plank provided such as some terminal company.The Compilation Method in the embodiment of the present invention can be made to compile out adaptation to each by overriding The file destination of the hardware environment configurations of kind various kinds so that entire compiled system framework can be fitted to any hardware environment.
In specific implementation, the source program of the compiling node is compiled and may include:Obtain the source program pair The Depending module inventory answered, the Depending module inventory record the Depending module that the compiling node relies on;Jump to it is described according to Rely and compiles the Depending module under the path of module.
Fig. 3 is please referred to, Fig. 3 is a kind of structural schematic diagram of compiling directory tree in the embodiment of the present invention.
In an embodiment of the present invention, compiling directory tree includes root node, subdirectory node and compiling node.
The top-level director (root) of root node corresponding software system, root generally may include each seed module Catalogue and some standards the catalogues such as tool, compilation tool, configuration, output.
May include in root node:Inherit the compilation script class in the root of baserootdir.makefile; Record has the file directory (for example, build) of various script types, record to have the file directory (for example, cfg) that project level configures, Record has the file directory (for example, bin) of the tool related data of various precompiles, record to have the file directory of system-level document (for example, doc), output-prj are the output packets after project compiling, and currdir.mk is root node configuration input file.
Wherein, it can have been stored under build catalogues:build/comdefs.env:Chinese base noun defines, such as various hosts The naming variable of order, naming variable of file extension etc.;build/common.cfg:Default configuration, project configuration Callback registration processing;build/common.env:The callback registration processing of the related script of nearly all environment;build/ outputdef.cfg:The configuration of output environment;build/outputdef.env:The processing of output environment;build/ premultilibs.env:More library (64/32) environmental treatments.
The subdirectory of subdirectory node corresponding software system, subdirectory are the subprime directory of root, this catalogue itself Any compiling object code is not generated, and subdirectory can be the parent directory of several software module catalogues simultaneously, play several modules Constitute the effect of a subsystem.
Subdirectory node may include:Several subdirectories, each catalogue are compiling node or subdirectory.And compilation script (namely inheriting in basesubdirs.makefile script types) and currdir.mk, wherein currdir.mk can be subdirectories Configure input file.
The catalogue of node respective software module is compiled, the catalogue of software module can store the software code of certain function, These software codes can generate a file destination together.In the methods of the invention, this catalogue is a compiling directory tree Leaf node.
Compiling node may include:It inherits in the compilation script of basetarget.makefile script types, adapter, Bin, bin64, dat, doc, lst, lst64, obj/obj64, src, test, tmp, tmp64, tool, makefile (file), Currdir.mk (file), currdir.cfg (file).
Wherein:Adapter is the third party software adapter that this module is used, and bin/bin64 is inside this module oneself Pretreating tool catalogue, dat are the data file contents used when the compiling of this module, and doc is the file catalogue of this inside modules, Inc is the header file catalogue of this module, and src is the source file catalogue of this module, and lst/lst64 is this module 32/64 LIST file directorys, obj/obj64 are 32/64 object file directorys that the compiling of this module generates, and tmp/tmp64 is this mould 32/64 temporary file directory that block compiling generates, test is this module testing code directory, and tool is this module Pretreatment of Source File directory, makefile (are inherited in basetarget.makefile), and currdir.mk/currdir.cfg is that this module is matched Set input file.Wherein, currdir.cfg is only compiling node, and secondary module Developmental Engineer can use this input script (namely input class), input class is also the overriding carried out in a manner of readjustment to default configuration file, compiles the input class of node The content of currdir.mk is as follows:It tells incoming source document or precompile file, exports the format of object code, the library of dependence Deng.
The compiled system of the embodiment of the present invention has similitude, refer to the frame of compiled system in any fundamental node or Person's primitive (META), in form should be with composition " as ".Symmetry:Refer to the frame of compiled system at each group At fundamental node be all similar.The source program for compiling node is located at the leaf node of compiling directory tree, in the embodiment of the present invention Compiled system in, only correspond to source program in the leaf node of the basecoat of catalogue, for each leaf node, have Similitude and symmetry, so that leaf node can move, and in the organizational process of compiling, rule is simpler It is single, so as to promote the efficiency of Compilation Method in the embodiment of the present invention.
In an alternative embodiment of the invention, Fig. 4 may refer to the reading order of file.
In step S401, common.cfg and common.env is read, to carry out succession and the callback registration of script type Processing, subsequently to carry out overwriting operations.Wherein common.cfg:Default configuration, the callback registration processing of project configuration; common.env:The callback registration processing of the related script of all environment.
In one embodiment of the invention, built-in basic script type can be placed under build catalogues, is placed under cfg catalogues Different project (for example, different planks and different software packet) configurations.
For example, build/comdefs.env:Chinese base noun defines, such as the naming variable of various Host Commands, file extent The naming variable etc. of name.
build/common.cfg:Default configuration, the callback registration processing of project configuration;
build/common.env:The callback registration processing of the related script of nearly all environment;
build/outputdef.cfg:The configuration of output environment;
build/outputdef.env:The processing of output environment;
build/premultilibs.env:More library (64/32) environmental treatments.
In step S402, read:basenodeprebuilt.mk、basenodelink.mk、 basenodeinfermetas.mk、basenodedirgen.mk、basenodedirectives.mk、 Basenodedirdef.mk and basenodedepends.mk, to complete the succession to compilation script class.
Wherein:basenodeprebuilt.mk:The installation module of the good object code of precompile;
basenodelink.mk:The link module of object code;
basenodeinfermetas.mk:Anonymous collector;
basenodedirgen.mk:The standard directories generation module of one basic compiling node;
basenodedirectives.mk:The processing module of built-in pragma control variable (directive);
basenodedirdef.mk:The standard directories definition module of one basic compiling node;
basenodedepends.mk:Compiling relies on the module of (dependency) processing.
It in step S403, is override, the source program of the compiling node is compiled according to the configuration after overriding.
In an alternative embodiment of the invention, flow when being compiled to a compiling node is referred to Fig. 5.
In step S501, the compilation script of compiling node is read.
In step S502, basenode.makefile and associated documents are read, such as basenodeprebuilt.mk、basenodelink.mk、basenodeinfermetas.mk、basenodedirgen.mk、 Basenodedirectives.mk, basenodedirdef.mk and basenodedepends.mk, to complete to compiling foot The succession of this class.
In step S503, reads common.cfg and compiling node corresponds to input configuration file, and carry out readjustment behaviour Make, to be override.
In step S504, compiling node is compiled according to the configuration after overriding.
In specific implementation, for a compiling node, input configuration file can be:Currdir.mk and currdir.cfg。
Output data can be:The object code file of the module can generally have 3 kinds of output formats:Such as:Module Name .so (dynamic base), module name .a (static library), module name (executable file).
Specifically, the data processing of subdirectory node can call compiling node or son one by one according to module inventory Directory node is compiled processing, can be recursive process.That is, input data of the subdirectory node in compiling is Submodule in currdir.mk or subdirectory inventory;Output data is:All submodules in currdir.mk or son The object code file exported after the compiling of catalogue.
Specifically, the data processing of root node can call compiling node or son one by one according to module inventory Directory node process of compilation can be recursive process.For example, input data of the root node in compiling is Submodule in currdir.mk or subdirectory inventory.Output data is all submodules or specific item in currdir.mk The object code file exported after the compiling of record.
The embodiment of the present invention is acted and is configured by reading the compiling that record has compilation process to utilize, can be to avoid each When compiling, the content repeated is write repeatedly, promotes compiling efficiency;The difference of different compiling nodes can be met by overriding Alienation demand so that the Compilation Method in the embodiment of the present invention more flexible can be suitable for various scenes.
The embodiment of the present invention also provides a kind of compilation device, and structural schematic diagram is referring to Fig. 6.
Compilation device 60 may include:Default configuration file reading unit 601, overriding unit 602 and compilation unit 603.
Wherein, default configuration file reading unit 601 is suitable for reading default configuration file, and the default configuration file is suitable for The environment configurations and input that record compilation process utilizes configure, and the input configuration is corresponding with the compiling node of directory tree.
Overriding unit 602 be suitable for in the default configuration file that reads the environment configurations and the public section At least part in the input configuration of point is override, described defeated after the input configuration and overriding for compiling node Entering configuration record has the compiling demand information of the compiling node.
Compilation unit 603 is suitable for being matched according to the environment after the corresponding input configuration of the compiling node, overriding It sets and the source program of all compiling nodes is compiled with the input configuration.
In specific implementation, compilation unit 603 may include that environment configurations subelement (not shown) and compiling subelement (are schemed not Show).Environment configurations subelement is suitable for calling different environment scripts, or readjustment difference according to the environment configurations after overriding Translation and compiling environment.Subelement is compiled suitable for configuring calling according to the input of input configuration and the compiling node after overriding Corresponding compilation script compiles the compiling rule file of node described in dynamic formation, with the source program to the compiling node into Row compiling.
The specific implementation mode of the embodiment of the present invention can refer to aforementioned corresponding embodiment, and details are not described herein again.
Fig. 7 is a kind of structural schematic diagram of compiling subelement in the embodiment of the present invention.
The compiling subelement may include:Depending module inventory obtains subelement 701 and redirects compiling subelement 702.
Wherein, Depending module inventory obtains subelement 701 suitable for obtaining the corresponding Depending module inventory of the source program, institute It states Depending module inventory and records the Depending module that the compiling node relies on;It is described suitable for jumping to redirect compiling subelement 702 The depended module is compiled under the path of depended module.
The specific implementation mode of the embodiment of the present invention can refer to aforementioned corresponding embodiment, and details are not described herein again.
One of ordinary skill in the art will appreciate that all or part of step in the various methods of above-described embodiment is can It is completed with instructing relevant hardware by program, which can be stored in computer readable storage medium, to store Medium may include:ROM, RAM, disk or CD etc..
Although present disclosure is as above, present invention is not limited to this.Any those skilled in the art are not departing from this It in the spirit and scope of invention, can make various changes or modifications, therefore protection scope of the present invention should be with claim institute Subject to the range of restriction.

Claims (18)

1. a kind of Compilation Method, which is characterized in that including:
Default configuration file is read, the default configuration file is suitable for recording the environment configurations that compilation process utilizes and input is matched It sets, the input configuration is corresponding with the compiling node of directory tree, and the node of the compiling directory tree includes common node and volume Translate node;
To in the input configuration of the environment configurations and the common node in the default configuration file that reads At least part override, it is described compiling node input configuration and overriding after the input configuration record have the volume Translate the compiling demand information of node;
According to the corresponding input of the compiling node configures, the environment configurations after overriding and the input are configured to institute There is the source program of compiling node to be compiled.
2. Compilation Method according to claim 1, which is characterized in that described corresponding described defeated according to the compiling node Enter the environment configurations after configuration, overriding and it is described input configuration to it is all compiling nodes source programs be compiled including:
Different environment scripts is called according to the environment configurations after overriding, or the translation and compiling environment that readjustment is different;
Corresponding compilation script, dynamic shape are called according to the input configuration of input configuration and the compiling node after overriding At the compiling rule file of the compiling node, it is compiled with the source program to the compiling node.
3. Compilation Method according to claim 2, which is characterized in that the environment script is according to the environment after overriding Compilation process is adapted to compiling host and running environment by the environmental variance in configuration.
4. Compilation Method according to claim 2, which is characterized in that the compilation script is according to the compiling rule file Compiling action is executed to the source program of the compiling node, exports file destination.
5. Compilation Method according to claim 4, which is characterized in that it is dynamic to execute compiling to the source program of the compiling node Work includes:
The corresponding depended module inventory of the source program is obtained, the depended module inventory records the compiling node and relies on Depended module;
It jumps under the path of the depended module and compiles the depended module.
6. Compilation Method according to claim 1, which is characterized in that the compiling node is located at the compiling directory tree Leaf node, in each node of the compiling directory tree storage have the compilation script that the compilation process needs.
7. Compilation Method according to claim 6, which is characterized in that the compilation script includes being located at the compiling catalogue The root script of the root node of tree, positioned at it is described compiling directory tree subdirectory node subdirectory script and be located at institute State the compiling node script of compiling node.
8. Compilation Method according to claim 1, which is characterized in that the input of the common node, which configures, includes: Baseline code configuration, each project configuration and the configuration of output directory structure.
9. Compilation Method according to claim 8, which is characterized in that in the described pair of default configuration file read The environment configurations and the common node the input configuration at least part carry out overriding include:
Readjustment is executed by the configuration script of public configuration script and each project configuration to the baseline code configuration Operation is to be override.
10. a kind of compilation device, which is characterized in that including:
Default configuration file reading unit, is suitable for reading default configuration file, and the default configuration file is suitable for recording compiled The environment configurations of Cheng Liyong and input configure, and the input configuration is corresponding with the compiling node of directory tree, the compiling catalogue The node of tree includes common node and compiling node;
Override unit, the institute suitable for the environment configurations and the common node in the default configuration file to reading At least part stated in input configuration is override, the input configuration and the input configuration after overriding of the compiling node Record has the compiling demand information of the compiling node;
Compilation unit, the environment configurations after being suitable for configuring, overriding according to the corresponding input of the compiling node and institute Input configuration is stated to be compiled the source program of all compiling nodes.
11. compilation device according to claim 10, which is characterized in that the compilation unit includes:
Environment configurations subelement, suitable for calling different environment scripts according to the environment configurations after overriding, or readjustment is not Same translation and compiling environment;
Subelement is compiled, is suitable for being called according to the input configuration of input configuration and the compiling node after overriding corresponding Compilation script compiles the compiling rule file of node described in dynamic formation, is compiled with the source program to the compiling node.
12. compilation device according to claim 11, which is characterized in that the environment script is according to the ring after overriding Compilation process is adapted to compiling host and running environment by the environmental variance in the configuration of border.
13. compilation device according to claim 11, which is characterized in that the compilation script is according to compiling rule text Part executes compiling action to the source program of the compiling node, exports file destination.
14. compilation device according to claim 13, which is characterized in that the compiling subelement includes:
Depending module inventory obtains subelement, is suitable for obtaining the corresponding depended module inventory of the source program, described to be relied on Module inventory records the depended module that the compiling node relies on;
Compiling subelement is redirected, the depended module is compiled under the path suitable for jumping to the depended module.
15. compilation device according to claim 10, which is characterized in that the compiling node is located at the compiling directory tree Leaf node, in each node of the compiling directory tree storage have the compilation script that the compilation process needs.
16. compilation device according to claim 15, which is characterized in that the compilation script includes being located at the compiling mesh Record tree root node root script, positioned at it is described compiling directory tree subdirectory node subdirectory script and be located at The compiling node script of the compiling node.
17. compilation device according to claim 10, which is characterized in that the input configuration packet of the common node It includes:Baseline code configuration, each project configuration and the configuration of output directory structure.
18. compilation device according to claim 17, which is characterized in that the overriding unit passes through to the baseline code The public configuration script of configuration and the configuration script of each project configuration execute callback operation to be override.
CN201610646882.8A 2016-08-09 2016-08-09 Compiling method and device Active CN108304184B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610646882.8A CN108304184B (en) 2016-08-09 2016-08-09 Compiling method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610646882.8A CN108304184B (en) 2016-08-09 2016-08-09 Compiling method and device

Publications (2)

Publication Number Publication Date
CN108304184A true CN108304184A (en) 2018-07-20
CN108304184B CN108304184B (en) 2021-04-23

Family

ID=62871259

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610646882.8A Active CN108304184B (en) 2016-08-09 2016-08-09 Compiling method and device

Country Status (1)

Country Link
CN (1) CN108304184B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109977043A (en) * 2019-03-22 2019-07-05 北京三快在线科技有限公司 Interface pre-heating mean, device, electronic equipment and storage medium
CN111309327A (en) * 2018-12-12 2020-06-19 厦门雅迅网络股份有限公司 Automatic compiling method of application program and computer readable storage medium
CN112685035A (en) * 2020-12-25 2021-04-20 京东数字科技控股股份有限公司 Project development method and device, computer-readable storage medium and electronic device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101697135A (en) * 2009-10-28 2010-04-21 北京东方网力科技有限公司 Method and device for compiling program
CN102508668A (en) * 2011-11-11 2012-06-20 西安交通大学 AOP (Aspect Oriented Programming) implementation method of EJB 3 (Enterprise Java Beans 3) containers based on dynamic stack
CN105468428A (en) * 2015-12-04 2016-04-06 上海斐讯数据通信技术有限公司 Android source code compiling method and system
US20160154585A1 (en) * 2014-11-28 2016-06-02 Renesas Electronics Corporation Data processing method, computer readable medium and data processing device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101697135A (en) * 2009-10-28 2010-04-21 北京东方网力科技有限公司 Method and device for compiling program
CN102508668A (en) * 2011-11-11 2012-06-20 西安交通大学 AOP (Aspect Oriented Programming) implementation method of EJB 3 (Enterprise Java Beans 3) containers based on dynamic stack
US20160154585A1 (en) * 2014-11-28 2016-06-02 Renesas Electronics Corporation Data processing method, computer readable medium and data processing device
CN105468428A (en) * 2015-12-04 2016-04-06 上海斐讯数据通信技术有限公司 Android source code compiling method and system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
吴昌昊: "基于龙芯1A 平台的PMON 源码编译和启动分析", 《兵工自动化》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111309327A (en) * 2018-12-12 2020-06-19 厦门雅迅网络股份有限公司 Automatic compiling method of application program and computer readable storage medium
CN109977043A (en) * 2019-03-22 2019-07-05 北京三快在线科技有限公司 Interface pre-heating mean, device, electronic equipment and storage medium
CN112685035A (en) * 2020-12-25 2021-04-20 京东数字科技控股股份有限公司 Project development method and device, computer-readable storage medium and electronic device

Also Published As

Publication number Publication date
CN108304184B (en) 2021-04-23

Similar Documents

Publication Publication Date Title
US11868745B2 (en) System and method for compiling high-level language code into a script executable on a blockchain platform
CN102902529B (en) Method and system for managing data source
KR101911793B1 (en) Managing data set objects in a dataflow graph that represents a computer program
CN108509185B (en) System and method for arbitrary software logic modeling
Zupan et al. Secure smart contract generation based on petri nets
US20070240102A1 (en) Software development tool for sharing test and deployment assets
US20180060065A1 (en) Advanced packaging techniques for improving work flows
US20090249284A1 (en) Automation for virtualized it environments
JP6217277B2 (en) Software development method and system therefor
CN109564540B (en) System, method, and apparatus for debugging of JIT compiler
US20130174133A1 (en) Adaptive selection of programming language versions for compilation of software programs
CN101866315B (en) Test method and system of software development tool
CN102930190B (en) A kind of method stoping user to obtain superuser right in Android system
CN108874438A (en) Patch generation method, device, electronic equipment and computer program product
US20160062754A1 (en) Coordinating Application Deployment with a Platform Tier
CN105678118B (en) A kind of software version generation method and device containing digital certificate
CN108304184A (en) Compilation Method and device
Cai et al. A pattern-based code transformation approach for cloud application migration
CN104885058A (en) System and method for generic product wiring in a virtual assembly builder environment
US10656922B2 (en) Systems and methods for providing an application transformation tool
CN105493033A (en) Declarative configuration elements
US11562105B2 (en) System and method for module engineering with sequence libraries
US9646118B1 (en) Linking of simulators into a circuit design tool
CN112181644A (en) Method, system and device for cross-domain machine learning component Jupitter
CN116225464B (en) Rapid deployment method of platform

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