CN104142846A - Method and device for compiling program scripts - Google Patents

Method and device for compiling program scripts Download PDF

Info

Publication number
CN104142846A
CN104142846A CN201410382719.6A CN201410382719A CN104142846A CN 104142846 A CN104142846 A CN 104142846A CN 201410382719 A CN201410382719 A CN 201410382719A CN 104142846 A CN104142846 A CN 104142846A
Authority
CN
China
Prior art keywords
source code
information
program
compilation
compiling
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
Application number
CN201410382719.6A
Other languages
Chinese (zh)
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.)
Opzoon Technology Co Ltd
Original Assignee
Opzoon 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 Opzoon Technology Co Ltd filed Critical Opzoon Technology Co Ltd
Priority to CN201410382719.6A priority Critical patent/CN104142846A/en
Publication of CN104142846A publication Critical patent/CN104142846A/en
Pending legal-status Critical Current

Links

Abstract

The invention discloses a method and device for compiling program scripts. The problem that in the prior art, compiled information can not be quickly acquired through file operation is solved. The method comprises the steps that an information source code including the compiled information defined as a global variable is generated, while a program source code is compiled, the information source code is compiled to link the information source code and the program source code, and therefore the compiled information is used as the global variable to be defined in a program; in the process of program operation, the global variable in the program is read so that the compiled information can be acquired. Accordingly, an independent file does not need to be opened to check the compiled information, namely file operation is of no need, and the compiled information such as version numbers and compiling time can be simply and quickly acquired.

Description

A kind of procedure script Compilation Method and device
Technical field
The invention belongs to computer programming technical field, be specifically related to a kind of procedure script Compilation Method and device.
Background technology
In the process of program design, need to compile the source code of program.When the compilation of source code process to program finishes, conventionally to record the compiling information such as version number, compilation time of compiled program.When program is issued, issue compiling information simultaneously.Whether the version that compiling information can be used for confirming current use is the version of normal issue, also can be used for when certain problem appears in program by checking that compiling information confirms whether the problem being occurred is revised in redaction as version number and compilation time etc.
In current program design, the information that normally will compile, as version number and compilation time etc., is write in an independent file, and to compiling information, give corresponding key word in this document, as: to version number, give key word " version ", to compilation time, give key word " time ".Like this, when working procedure, open this file, by coupling key word, just can obtain and check compiling information.
The above-mentioned process of obtaining compiling information, need to carry out file operation, need to be in service in program, open a file, and just can check compiling information, use extremely inconveniently, can not obtain simply, fast compiling information.
Summary of the invention
The object of this invention is to provide a kind of procedure script Compilation Method and device, do not need to carry out file operation, just can obtain simply, fast the compiling information such as version number, compilation time.
According to an aspect of the present invention, provide a kind of procedure script Compilation Method, comprising: information generated source code, in described information source code, will compile information definition is global variable;
Program source code is compiled together with program compilation information source code;
Read the global variable in the program after compiling, obtain compiling information.
In such scheme, described compiling information at least comprises: the version number of program compiler and compilation time.
In such scheme, the step of described information generated source code further comprises: in the Makefile of program file the inside, and invoke script, and generate described information source code by described script.
In such scheme, described invoke script the step by described script information generated source code further comprise:
To writing in described script, obtain the version number of program compiler and the code of compilation time with information generated source code, wherein, described information source code at least comprises following content:
cat>version.c<<EOV
Char*__version=" version number "
Char*__time=" compilation time "
EOV;
Wherein, _ _ version is version number's global variable of definition; _ _ time is the compilation time global variable of definition.
According to another aspect of the present invention, provide a kind of procedure script compilation device, comprising:
Information source code generation module, for information generated source code, in described information source code, will compile information definition is global variable;
Compiling link module, described compiling link module is connected to described information source code generation module, for program source code is compiled together with program compilation information source code;
Compiling information reading module, described compiling information reading module is connected to described compiling link module, for reading the global variable of the program after compiling, obtains compiling information.
In such scheme, described compiling information at least comprises: the version number of program compiler and compilation time.
In such scheme, described information source code generation module passes through following manner information generated source code: in the Makefile of program file the inside, and invoke script, and generate described information source code by described script.
In such scheme, described information source code generation module passes through following manner invoke script information generated source code:
To writing in described script, obtain the version number of program compiler and the code of compilation time with information generated source code, wherein, described information source code at least comprises following content:
cat>version.c<<EOV
Char*__version=" version number "
Char*__time=" compilation time "
EOV;
Wherein, _ _ version is version number's global variable of definition, and _ _ time is the compilation time global variable of definition.
Procedure script Compilation Method provided by the present invention, by generating an information source code that has comprised the compiling information that is defined as global variable, and when program source code is compiled, information source code is compiled, and the program after the compiling of information source code and program source code is linked, thereby be defined in program compiling information as global variable; In the process of program operation, global variable in fetch program, can obtain compiling information, and does not need to open an independent Fileview compiling information, do not need to carry out file operation, just can obtain simply, fast the compiling information such as version number, compilation time.
Accompanying drawing explanation
Fig. 1 is the procedure script Compilation Method process flow diagram that obtains compiling information in prior art;
Fig. 2 is the procedure script Compilation Method process flow diagram of the preferred embodiment of the present invention;
Fig. 3 is the structural representation of the procedure script compilation device of the preferred embodiment of the present invention;
Fig. 4 is that procedure script compilation device obtains compiling information flow chart according to the preferred embodiment of the invention.
Embodiment
For making the object, technical solutions and advantages of the present invention more cheer and bright, below in conjunction with embodiment and with reference to accompanying drawing, the present invention is described in more detail.Should be appreciated that, these descriptions are exemplary, and do not really want to limit the scope of the invention.In addition, in the following description, omitted the description to known configurations and technology, to avoid unnecessarily obscuring concept of the present invention.
Fig. 1 is the procedure script Compilation Method process flow diagram that obtains compiling information in prior art.
As shown in Figure 1, the procedure script Compilation Method of obtaining compiling information in prior art comprises the steps:
Step S01, is used echo order that the key word of compiling information is write in a file by a script.For example, by script edit echo order echo-n " _ _ version=" >product, product is exactly final file, and _ _ version is exactly the key word in writing in files.
Step S02 writes concrete compiling parameter under the key word of the compiling information of described file by echo order.For example, under _ _ version, write concrete version number.
Step S03, in program operation process, if query compiler information is opened described file, coupling key word, reads the compiling information under key word.For example, in the process of program operation, open product file, during Dang Xiangxun version number, coupling key word _ _ version, can show associated release number under version, and the concrete version number now reading is the compiling information that will inquire about.As from the foregoing, in prior art, obtain the procedure script Compilation Method of compiling information and need to carry out file operation, need to be in service in program, open a file, just can check compiling information, use extremely inconveniently, can not obtain simply, fast compiling information.
For overcoming above-mentioned defect, the invention provides a kind of procedure script Compilation Method, the method does not need to carry out file operation, just can be simply, quick obtaining compiling information.
Fig. 2 is the procedure script Compilation Method process flow diagram of the preferred embodiment of the present invention.
As shown in Figure 2, embodiment of the present invention procedure script Compilation Method comprises the steps:
Step S11: information generated source code, in described information source code, will compile information definition is global variable;
Step S12: program source code is compiled together with program compilation information source code;
Step S13: read the global variable in the program after compiling, obtain compiling information.
Here, described compiling information at least comprises version number and the compilation time of compiled program.By checking the whether version of normal issue of version that the compiling information such as version number and compilation time can confirm current use, if version number does not mate with key word with compilation time or do not conform to normal information, version is not the version of normally issuing; When there is certain problem in program, also can be by checking that the compiling information such as version number and compilation time confirm whether occurred problem has been revised in redaction, if find that by checking version number and compilation time the version of current use is not latest edition, can search the latest edition of present procedure, thereby whether the problem that judgement occurs is revised in redaction.Compiling information can also comprise that other are for confirming the information of program version.
In step S11, described information generated source code, can be in the Makefile of program file, invoke script, pass through called script information generated source code, this program compilation information source code is global variable by the program compilation information definition of aforementioned program source code, such as compiled version number and compilation time etc., so that the calling of later stage.For example, when compiling information is version number and compilation time, can invoke script, to writing in described script, obtain the version number of program compiler and the code of compilation time.The code sample of the code of program compilation information source in a preferred embodiment of the invention, is as follows:
cat>version.c<<EOV
Char*__version=" version number "
Char*__time=" compilation time "
EOV; (1)
Wherein, _ _ version is version number's global variable of definition; _ _ time is the compilation time global variable of definition, the respectively compiled version of representation program source code number and compilation time, but the present invention is not restricted to this.Described version number the serve as reasons character string that letter forms, for example f5.0; The form of described compilation time can be the order `date '+%a%d-%b-%y%R ' ` under linux, and by this order, obtaining current time is compilation time, and the result for example getting can be: Tue 22-Apr-1414:16.So, the compiling such as version number and compilation time information is defined as global variable, thereby can by present procedure, within the scope of universe, be called and read, and without generating separately a file of preserving compiling information, also without carrying out independent file operation, read compiling information.
Hence one can see that, at least comprises following content in information source code: the version number of program and the acquisition methods of compilation time.It should be noted that, the version number of program and the acquisition methods of compilation time are not limited to giving an example in formula (1), so the content of information source code can also, for other forms, not repeat them here.
In step S12, to program source code, as Makefile, when compiling, to information source code, the information source code as the script by being called generates, also compiles together, wherein, and when described information source code is
cat>version.c<<EOV
Char*__version=" version number "
Char*__time=" compilation time "
EOV;
Time, the compiling information after compiling be C language format.The information source code generating when called script is during for other forms, the compiling information after compiling also can be other language formats.For example, C Plus Plus form or java form.Owing to being global variable to the define styles of the version number of program and compilation time in described information source code, when compiling can with universe in other program source codes link, thereby in the process of other programs operation, by the access to global variable, realize the reading of compiling information, so realize to compiling information simply, read fast.
In this step, by program source code, compile together with program compilation information source code, can program source code and program compilation information source code chain be connected together by global variable, be actually like this global variable that embodies program compilation information has been compiled in program source code, program the inside has comprised this two variablees.Like this, when program is moved, can by calling global variable, obtain adjective compiling information easily.Than prior art, new files in addition, the inconvenience of avoiding the operation (open, read, revise etc.) of execute file to cause.
In the present invention, by the program compilation information source code and the program source code that have comprised program compilation information are linked together, and compile together, while making modification of program afterwards, debugging, by reading global variable, just can obtain compilation time and the compiled version information of program, when program goes wrong, can be by checking that version number and compilation time confirm whether this problem is revised in redaction, also can confirm that this version is normal released version.
With a specific embodiment, the flow process of embodiment of the present invention procedure script Compilation Method is once described below.
In the generator program source code stage of program design, call a script in Makefile file, to writing in described script, obtain the version number of program compiler and the code of compilation time, generate following information source code:
cat>version.c<<EOV
char*__version=“advertiser5.0”
char*__time=“`date‘+%a%d-%b-%y%R’`”
EOV;
Thereby the current time institute that the version number of " advertiser5.0 " and order " `date '+%a%d-%b-%y%R ' ` " are obtained as two compiling information definitions of compilation time be global variable.
In the program source code compilation phase of program design, when Makefile file is compiled, to information source code
cat>version.c<<EOV
char*__version=“advertiser5.0”
char*__time=“`date‘+%a%d-%b-%y%R’`”
EOV
Also compile, and version number and two compiling information of compilation time after compiling are linked with other programs, thereby these two global variables can be called by universe in the situation that of other program operations.
At program debug and the launch phase of program design, with the issue of program, version number and compilation time are issued simultaneously.
In the operation phase of program design, by calling of global variable, check version number and compilation time.Owing to not needing to carry out the operation of alternative document, can be in the process of program operation, simple and quick realization calling and checking compiling information such as version number and compilation times.
At the maintenance phase of program design, by calling of global variable, check version number and compilation time, thereby confirm that whether version is normal, and/or, when present procedure goes wrong, confirm whether described problem is revised in redaction.
Fig. 3 is the structural representation of the procedure script compilation device of the preferred embodiment of the present invention.
As shown in Figure 3, the procedure script compilation device of the embodiment of the present invention comprises:
Information source code generation module 1, for information generated source code, in described information source code, will compile information definition is global variable;
Described information generated source code, can be in the Makefile of program file, and invoke script is passed through called script information generated source code.For example, when compiling information is version number and compilation time, can invoke script, to writing in described script, obtain the version number of program compiler and the code of compilation time, generate following information source code:
cat>version.c<<EOV
Char*__version=" version number "
Char*__time=" compilation time "
EOV; (1)
Wherein, _ _ version is version number's global variable of definition; _ _ time is the compilation time global variable of definition.The compiling such as version number and compilation time information is defined as global variable, thereby can by present procedure, within the scope of universe, be called and read, and without generating separately a file of preserving compiling information, also without carrying out independent file operation, read compiling information.It should be noted that, the compiling information after compiling can be the C language format in formula (1).The information source code generating when called script is during for other forms, the compiling information after compiling also can be other language formats.For example, C Plus Plus form or java form.
Compiling link module 2, compiling link module 2 is connected to described information source code generation module 1, for program source code is compiled together with program compilation information source code;
Compiling information reading module 3, compiling information reading module 3 is connected to described compiling link module 2, for reading the global variable of the program after compiling, obtains compiling information.
Fig. 4 is that procedure script compilation device obtains compiling information flow chart according to the preferred embodiment of the invention.
As shown in Figure 4, in the generator program source code stage of program design, by information source code generation module 1 execution step 101 of compiling information acquisition device, call a script in Makefile, generate following information source code:
cat>version.c<<EOV
char*__version=“advertiser5.0”
char*__time=“`date‘+%a%d-%b-%y%R’`”
EOV;
Thereby the current time institute that the version number of " advertiser5.0 " and order " `date '+%a%d-%b-%y%R ' ` " are obtained as two compiling information definitions of compilation time be global variable.
In the program source code compilation phase of program design, when Makefile is compiled, by compiling link module 2 execution steps 102 of compiling information acquisition device, to information source code
cat>version.c<<EOV
char*__version=“advertiser5.0”
char*__time=“`date‘+%a%d-%b-%y%R’`”
EOV
Also compile, to realize, version number and two compiling information of compilation time after compiling are linked with other programs, thereby these two global variables can be called by universe in the situation that of other program operations.
At program debug and the launch phase of program design, with the issue of program, execution step 103 is issued version number and compilation time simultaneously.
In the operation phase of program design, by compiling information reading module 3 execution steps 104 of compiling acquisition of information module, by calling of global variable, check version number and compilation time.Owing to not needing to carry out the operation of alternative document, can be in the process of program operation, simple and quick realization calling and checking compiling information such as version number and compilation times.
Maintenance phase in program design, compiling information reading module 3 execution step 105 and steps 106 by compiling acquisition of information module, by calling of global variable, check version number and compilation time, thereby confirm that whether version is normal, and/or, when present procedure goes wrong, confirm whether described problem is revised in redaction.
By said procedure script compile method and apparatus, by generating an information source code that has comprised the compiling information that is defined as global variable, and when program source code is compiled, information source code is compiled, and the program after the compiling of information source code and program source code is linked, thereby be defined in program compiling information as global variable; In the process of program operation, global variable in fetch program, can obtain compiling information, and does not need to open an independent Fileview compiling information, do not need to carry out file operation, just can obtain simply, fast the compiling information such as version number, compilation time.
Should be understood that, above-mentioned embodiment of the present invention is only for exemplary illustration or explain principle of the present invention, and is not construed as limiting the invention.Therefore any modification of, making, be equal to replacement, improvement etc., within protection scope of the present invention all should be included in without departing from the spirit and scope of the present invention in the situation that.In addition, claims of the present invention are intended to contain whole variations and the modification in the equivalents that falls into claims scope and border or this scope and border.

Claims (8)

1. a procedure script Compilation Method, is characterized in that, described method comprises:
Information generated source code, in described information source code, will compile information definition is global variable;
Program source code is compiled together with program compilation information source code;
Read the global variable in the program after compiling, obtain compiling information.
2. procedure script Compilation Method according to claim 1, is characterized in that, described compiling information at least comprises: the version number of program compiler and compilation time.
3. according to the procedure script Compilation Method described in claims 1 to 3 any one, it is characterized in that, the step of described information generated source code further comprises: in the Makefile of program file the inside, and invoke script, and generate described information source code by described script.
4. procedure script Compilation Method according to claim 3, is characterized in that, described invoke script the step by described script information generated source code further comprise:
To writing in described script, obtain the version number of program compiler and the code of compilation time with information generated source code, wherein, described information source code at least comprises following content:
cat>version.c<<EOV
Char*__version=" version number "
Char*__time=" compilation time "
EOV;
Wherein, _ _ version is version number's global variable of definition; _ _ time is the compilation time global variable of definition.
5. a procedure script compilation device, is characterized in that, described device comprises:
Information source code generation module, for information generated source code, in described information source code, will compile information definition is global variable;
Compiling link module, described compiling link module is connected to described information source code generation module, for program source code is compiled together with program compilation information source code;
Compiling information reading module, described compiling information reading module is connected to described compiling link module, for reading the global variable of the program after compiling, obtains compiling information.
6. procedure script compilation device according to claim 5, is characterized in that, described compiling information at least comprises: the version number of program compiler and compilation time.
7. according to the procedure script compilation device described in claim 6 or 7, it is characterized in that, described information source code generation module passes through following manner information generated source code: in the Makefile of program file the inside, and invoke script, and generate described information source code by described script.
8. procedure script compilation device according to claim 7, is characterized in that, described information source code generation module passes through following manner invoke script information generated source code:
To writing in described script, obtain the version number of program compiler and the code of compilation time with information generated source code, wherein, described information source code at least comprises following content:
cat>version.c<<EOV
Char*__version=" version number "
Char*__time=" compilation time "
EOV;
Wherein, _ _ version is version number's global variable of definition, and _ _ time is the compilation time global variable of definition.
CN201410382719.6A 2014-08-06 2014-08-06 Method and device for compiling program scripts Pending CN104142846A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410382719.6A CN104142846A (en) 2014-08-06 2014-08-06 Method and device for compiling program scripts

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410382719.6A CN104142846A (en) 2014-08-06 2014-08-06 Method and device for compiling program scripts

Publications (1)

Publication Number Publication Date
CN104142846A true CN104142846A (en) 2014-11-12

Family

ID=51852028

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410382719.6A Pending CN104142846A (en) 2014-08-06 2014-08-06 Method and device for compiling program scripts

Country Status (1)

Country Link
CN (1) CN104142846A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105183507A (en) * 2015-08-24 2015-12-23 汉柏科技有限公司 Version matching method and system of application programs
CN107291437A (en) * 2016-04-13 2017-10-24 上海思立微电子科技有限公司 Issue bag version information production method, device and terminal
CN107436771A (en) * 2017-08-17 2017-12-05 郑州云海信息技术有限公司 The method and system that a kind of (SuSE) Linux OS release version judges
CN108170465A (en) * 2018-01-04 2018-06-15 武汉斗鱼网络科技有限公司 A kind of version information management method, electronic equipment and readable storage medium storing program for executing
CN110750266A (en) * 2019-09-20 2020-02-04 平安普惠企业管理有限公司 Program compiling method, program compiling device, computer equipment and storage medium
CN113157322A (en) * 2020-12-29 2021-07-23 深圳微步信息股份有限公司 Method and system for automatically displaying software compiling time

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101131635A (en) * 2006-08-24 2008-02-27 凌阳科技股份有限公司 Method for dynamic linking function library sharing static linking function library with primary application
US20090106745A1 (en) * 2004-08-30 2009-04-23 International Business Machines Corporation Method and Apparatus for Optimizing Software Program Using Inter-Procedural Strength Reduction
CN101706735A (en) * 2009-11-26 2010-05-12 中兴通讯股份有限公司 Embedded system and method for acquiring symbol table by same

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090106745A1 (en) * 2004-08-30 2009-04-23 International Business Machines Corporation Method and Apparatus for Optimizing Software Program Using Inter-Procedural Strength Reduction
CN101131635A (en) * 2006-08-24 2008-02-27 凌阳科技股份有限公司 Method for dynamic linking function library sharing static linking function library with primary application
CN101706735A (en) * 2009-11-26 2010-05-12 中兴通讯股份有限公司 Embedded system and method for acquiring symbol table by same

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
谢伟: "《嵌入式LINUX系统工程师标准培训教材 2 进阶篇 嵌入式Linux内核驱动 》", 31 October 2011, 清华大学出版社 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105183507A (en) * 2015-08-24 2015-12-23 汉柏科技有限公司 Version matching method and system of application programs
CN107291437A (en) * 2016-04-13 2017-10-24 上海思立微电子科技有限公司 Issue bag version information production method, device and terminal
CN107436771A (en) * 2017-08-17 2017-12-05 郑州云海信息技术有限公司 The method and system that a kind of (SuSE) Linux OS release version judges
CN108170465A (en) * 2018-01-04 2018-06-15 武汉斗鱼网络科技有限公司 A kind of version information management method, electronic equipment and readable storage medium storing program for executing
CN110750266A (en) * 2019-09-20 2020-02-04 平安普惠企业管理有限公司 Program compiling method, program compiling device, computer equipment and storage medium
CN113157322A (en) * 2020-12-29 2021-07-23 深圳微步信息股份有限公司 Method and system for automatically displaying software compiling time

Similar Documents

Publication Publication Date Title
CN104142846A (en) Method and device for compiling program scripts
US20150169294A1 (en) Management of mixed programming languages for a simulation environment
US8122440B1 (en) Method and apparatus for enumerating external program code dependencies
US10747653B2 (en) Software testing systems and methods
GB2508643A (en) Method for Performing a Regression Test after Modifying Source Code File
US9311077B2 (en) Identification of code changes using language syntax and changeset data
Kramer et al. Change-driven consistency for component code, architectural models, and contracts
Romano et al. An empirical study of bugs in webassembly compilers
Nie et al. A framework for writing trigger-action todo comments in executable format
CN104572238A (en) Method and system for generating executable software package efficiently
Dantas et al. Reconciling the past and the present: An empirical study on the application of source code transformations to automatically rejuvenate java programs
Passier et al. Maintaining unit tests during refactoring
Schuts et al. Large‐scale semi‐automated migration of legacy C/C++ test code
CN103927213B (en) A kind of file compiling method and compilation device
Johnson Software development is program transformation
Schneid et al. Static analysis of BPMN-based process-driven applications
Zaytsev Open challenges in incremental coverage of legacy software languages
CN117215558A (en) Visual software development method, device, equipment and medium for android
Sharma Exploiting undefined behaviors for efficient symbolic execution
Al-Kofahi et al. Escaping AutoHell: a vision for automated analysis and migration of autotools build systems
France et al. Why it is so hard to use models in software development: observations
Nguyen et al. Analyzing the cmake build system
Zakharov et al. Compositional environment modelling for verification of GNU C programs
Da Rocha Learning SQLite for iOS
Jablonski Managing the copy-and-paste programming practice in modern IDEs

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20141112

WD01 Invention patent application deemed withdrawn after publication