[summary of the invention]
Based on this, it is necessary to provide the baseline version manager of a kind of software program that can obtain code release accurately
Method.
The baseline version management method of a kind of software program, comprises the following steps:
Binary program is carried out source code parsing, records the sound code file that described binary program is corresponding;
Single state of reaching the standard grade of monitoring binary program;
According to the sound code file that the described lookup of state binary program reaching the standard grade single is corresponding, to the described source code found literary composition
The baseline version number of part is updated.
In a preferred embodiment, described sound code file includes the hpp file that cpp file and described cpp file are quoted;Institute
Stating and binary program carries out source code parsing, the step of the sound code file that record binary program is corresponding includes:
Perform instruction, obtain compiling intermediate object program;
Described compiling intermediate object program is scanned, obtains cpp file composition and the hpp file composition quoted thereof;
Formed by the described cpp file obtained, hpp file composition recorded binary system with the corresponding relation of binary program
Source code resolves in corresponding table.
In a preferred embodiment, the source code literary composition that the lookup of state binary program of reaching the standard grade single described in described basis is corresponding
Part, the step being updated the baseline version number of the described sound code file found includes:
When described single state of reaching the standard grade is for reaching the standard grade successful comprehensively, search the sound code file that binary program is corresponding, from version
This management server obtains the current version number of described sound code file, is recorded as by the current version number of described sound code file described
The current basic line version number that sound code file is corresponding.
In a preferred embodiment, the described step being updated the baseline version number of described sound code file includes:
When described single state of reaching the standard grade is comprehensive rollback, search the sound code file that binary program is corresponding, by described source
The current basic line version number modification of code file is last revision number.
In a preferred embodiment, described method also includes: create baseline version tables of data, described baseline version tables of data
For recording sound code file and the current basic line version number of sound code file, the corresponding relation of at least one historical baseline version number.
Additionally, there is a need to provide a kind of baseline version that can obtain the software program of code release accurately to manage system
System.
A kind of baseline version management system of software program, including:
Source code parsing module, for binary program is carried out source code parsing, records the source that described binary program is corresponding
Code file;
Monitoring module, for monitoring single state of reaching the standard grade of binary program;
Baseline version management module, for according to described in reach the standard grade single lookup of state binary program corresponding source code literary composition
Part, is updated the baseline version number of the described sound code file found.
In a preferred embodiment, described sound code file includes the hpp file that cpp file and described cpp file are quoted;Institute
State source code parsing module to include:
Instruction performs module, is used for performing instruction, obtains compiling intermediate object program;
Scan module, for being scanned described compiling intermediate object program, obtains cpp file composition and the hpp quoted thereof
File forms;
Logging modle, for by the described cpp file obtained composition, hpp file composition pass corresponding with binary program
System recorded binary system source code and resolves in corresponding table.
In a preferred embodiment, described baseline version management module reaches the standard grade single state for reach the standard grade comprehensively described in working as
During success, search the sound code file that binary program is corresponding, obtain the current version of described sound code file from version management server
This number, the current version number of described sound code file is recorded as the current basic line version number that described sound code file is corresponding.
In a preferred embodiment, described baseline version management module be additionally operable to when described in reach the standard grade single state for returning comprehensively
When moving back, search the sound code file that binary program is corresponding, be upper one edition by the current basic line version number modification of described sound code file
This number.
In a preferred embodiment, baseline version tables of data creation module, it is used for creating baseline version tables of data, described base
Line edition data table is for recording sound code file and the current basic line version number of sound code file, at least one historical baseline version number
Corresponding relation.
The baseline version management method of above-mentioned software program and system, by monitoring single shape of reaching the standard grade of binary program
State, is updated according to the baseline version number of sound code file corresponding to single state binary program to reaching the standard grade of reaching the standard grade, due to
The baseline version number of the sound code file of binary program is carried out effective management, therefore, it is possible to obtain code version accurately
This.
[detailed description of the invention]
The present invention, by binary program carries out source code parsing, records the sound code file that binary program is corresponding, due to
During the reaching the standard grade of binary program, single state of reaching the standard grade of binary program can be modified, by monitoring binary system
Single state of reaching the standard grade of program, according to single lookup of state of reaching the standard grade to sound code file corresponding to binary program, to find
The baseline version number of these sound code files is updated.Due to the difference of the single state of reaching the standard grade according to binary program, can be right
The baseline version number of the sound code file that binary program is corresponding is updated, thus the baseline of the sound code file to binary program
Version number has carried out effective management, can obtain code release accurately by the baseline version number updated.
In one embodiment, as it is shown in figure 1, the baseline version management method of a kind of software program, comprise the following steps:
Step S10, carries out source code parsing, the sound code file that record binary program is corresponding to binary program.
In one embodiment, the binary program reached the standard grade is to be generated, such as by a series of c/c++ compilation of source code
.so file .cgi file etc..Here c/c++ source code includes cpp file and hpp file, and wherein cpp file is by c++ language
The source code file (i.e. sound code file) that speech is write, and the header file that hpp file is cpp file.In the present embodiment, to binary system
Program carries out source code parsing and includes the parsing to cpp file and the parsing to hpp file.
In one embodiment, as in figure 2 it is shown, the detailed process of step S10 is:
Step S102, performs instruction, obtains compiling intermediate object program.
Step S104, is scanned compiling intermediate object program, obtains cpp file composition and the hpp file composition quoted thereof.
When resolving cpp file, can be by the make instrument of Linux GNU plus specifying parameter to generate the detailed of binary system compiling
Feelings (i.e. compile intermediate object program), and this instruction is: make-n-B-i-k file destination program name.Wherein, target program file name is
Refer to need the filename carrying out the binary program of source code parsing, such as libA.so, Axx.cgi etc.;-n represents that printing simulation is compiled
Translate process, but the most really perform compiling;-B represents that all of target is required for more newly compiled;-i represent ignore upon execution all
Mistake;-k represent make mistakes the most out of service.After running above-mentioned instruction, obtain compiling intermediate object program, such as shape such as " g++-g-
The text of I/path1-I/path2-I.../pathN-o xxxxx.o.
Text obtained above is scanned, obtains complete cpp file composition.Below with the binary system of a .so
Above-mentioned scanning process is described as a example by program.By performing instruction make-n-B libtest.so, obtain exporting text.By solid
Determine the separator such as “ r n of feature " text obtained is divided into several rows, every a line is then a .o file (object literary composition
Part) generation process;Circulate all line of text obtained above successively, whether there is .cpp/.c literary composition by canonical matching judgment
Part, if it is present canonical mates this row, and determines whether to generate .o file, if having generation .o file, then record
.cpp/.c with the mapping relations of .o, next line otherwise it is recycled to;If canonical matching judgment is to there is not .cpp/.c file, then
Further determining whether to there is .so file, if there is .so file, then canonical matches the institute that current line .so file comprises
There is .o file, and record the mapping relations of .so Yu .o;By above-mentioned two mapping relations, i.e. can get .so's Yu .cpp/.c
Mapping relations, thus obtain the complete cpp file composition of .so file.
When resolving hpp file, can be by Linux g++ compiler plus specifying parameter to obtain the institute that cpp/c source code is quoted
Having .h header file, specific instruction is as follows: g++-MM xxxx.cpp | xxxx.c-I1-I2-I3.Wherein ,-MM represents appointment cpp/c
The h of the nonsystematic definition that source code refers to defines file;-I specifies and compiles the h file path that this source program refers to.Run
After above-mentioned instruction, obtain compiling intermediate object program, such as shape such as " xxxx.0:xxxx.cpp
hpp1\
hpp2\
hpp3\
Hpp4 " text.
Text obtained above is scanned, i.e. can get the hpp file composition arrived cited in complete cpp file.Should
Scanning process is: by the separator of fixed character such as " r n ", the text obtained is divided into several rows;Scanning is every successively
A line, remove null and end n and some useless pilot process information;To every a line, perform: if one's own profession includes many
Individual .h/.hpp file, then by multiple .h/.hpp file declusterings, be divided into multirow;If one's own profession comprises ../relative path, then recover
The absolute path of this document;If one's own profession comprises ./relative path, then recover the absolute path of this document;If one's own profession bag
Containing/current path, then recover the absolute path of this document.After scanning all of line of text, all of .h/.hpp file is arranged
Weight, then obtain the .h/.hpp file set arrived cited in cpp file.
In one embodiment, remove to scan the file of binary program according to fixed frequency (such as every 3 hours) every day
Composition, the cpp file every time obtained after scanning and hpp file are instructed and delete instruction and update in data base by insertion.Example
Once binary program liba.so being scanned obtains file consist of a.cpp, b.cpp and c.cpp, Current Scan as front
The file obtained consists of a.cpp, b.cpp and d.cpp, the file composition obtained at front single pass due to a.cpp and b.cpp
In exist, therefore need not a.cpp and b.cpp process.And d.cpp is in the file composition that front single pass obtains
Do not exist, therefore need to perform d.cpp to insert instruction (i.e. Insert instruction), d.cpp is inserted.Separately obtain due to Current Scan
File composition in there is not c.cpp, it is therefore desirable to c.cpp perform delete instruction (i.e. Delete instruction), c.cpp is deleted
Remove, and more new database.
Step S106, recorded the cpp file obtained composition, hpp file composition with the corresponding relation of binary system degree
Binary system source code resolves in corresponding table.
In one embodiment, the corresponding table of binary system source code parsing is as shown in table 1:
Table 1
In table 1, have recorded binary program Libtest.so is carried out all cpp files obtained by after source code parsing and
The hpp file that it is quoted.
Step S20, single state of reaching the standard grade of monitoring binary program.
Binary program is reached the standard grade and is referred to the binary program that compiling produces is published to the Internet that user accesses.Each two
The upper line process of binary program can use to reach the standard grade and singly carry out record, be such as recorded as " Zhang San 12:00 bill of lading A need reach the standard grade
LibA.so, Axx.cgi ", wherein, libA.so, Axx.cgi are the binary program needing to reach the standard grade.Upper at binary program
In line process, user revises, according to situation about reaching the standard grade, single state of reaching the standard grade.
Single state of reaching the standard grade of binary program includes the bill of lading, reach the standard grade comprehensively in, reach the standard grade successfully comprehensively, reach the standard grade unsuccessfully comprehensively
With comprehensive rollback.Wherein, the bill of lading refers to that submission is reached the standard grade list;Refer in reaching the standard grade that binary program is in the shape reached the standard grade comprehensively
State, due to major part internet sites be all made up of some peer server, need once by binary program from some
Station server is reached the standard grade one by one, time course of therefore having reached the standard grade;Reach the standard grade comprehensively and successfully refer to that binary program is all reached the standard grade successfully;
Failure of comprehensively reaching the standard grade refers to that binary program is reached the standard grade unsuccessfully;Comprehensively rollback refers to that binary program is reached the standard grade after failure, needs upper
The binary program of line withdraws the Internet that user accesses, and changes the binary program operating in the Internet into original version
This.
Step S30, according to the sound code file that the lookup of state binary program reaching the standard grade single is corresponding, to the source code literary composition found
The baseline version number of part is updated.
In one embodiment, said method also includes: create baseline version tables of data, record in baseline version tables of data
Sound code file and the current basic line version number of sound code file, the corresponding relation of at least one historical baseline version number.At one
In embodiment, in baseline version tables of data, the field of record is as shown in table 2, wherein have recorded two nearest historical baseline versions
Number:
Table 2
Sound code file name |
Current basic line version number |
Historical baseline version number 1 |
Historical baseline version number 2 |
In one embodiment, after binary program is reached the standard grade successfully comprehensively, it is comprehensive that user revises single state of reaching the standard grade
Reach the standard grade successfully, when monitoring single state of reaching the standard grade for reaching the standard grade successful comprehensively, search the source code that binary program is corresponding the most immediately
File, obtains the current version number of sound code file, the current version number of sound code file is recorded as source from version management server
The current basic line version number that code file is corresponding.
In the present embodiment, resolve corresponding table from above-mentioned generation binary system source code and search successful binary system journey of comprehensively reaching the standard grade
Sound code file corresponding to sequence.The version management server of above-mentioned embodiment is svn (subversion, a kind of version management
Instrument) server, source code can be managed by svn service, and svn service is increased income free, record on svn server
The various versions of source code.Such as, A.cpp file is uploaded by Zhang San on January 1st, 2011 and is created in svn server,
Svn server be its to be assigned with version number be V1, on February 23rd, 2011 by being revised by Li Si and uploading to svn server,
Svn server is that it is assigned with version number V2.In the present embodiment, get the current version number of sound code file from svn server,
The current version number got is recorded as the current basic line version number that sound code file is corresponding.In the present embodiment, by get
Current version number updates the current basic line version number field in baseline version tables of data, and updates two historical baseline versions accordingly
This number.
In another embodiment, after binary program reaches the standard grade failure comprehensively, need the binary system journey that will currently reach the standard grade
Sequence withdraws the Internet that user accesses, and changes the binary program of original version into, and single status modifier of reaching the standard grade is then complete by user
Face rollback, i.e. return back to the binary program of last revision.When monitoring single state of reaching the standard grade and being comprehensive rollback, search two and enter
The sound code file that processing procedure ordered pair is answered, is last revision number by the current basic line version number modification of this sound code file.
In the present embodiment, the binary program searching above-mentioned generation resolves the source code literary composition that binary program in corresponding table is corresponding
Part, is last revision number by current basic line version number modification corresponding for this sound code file in baseline version tables of data.Last revision
Number may be configured as historical baseline version number 1 or historical baseline version number 2, so, be directly revised as going through by current basic line version number
History baseline version number 1 or historical baseline 2, update the historical baseline version number in baseline version tables of data simultaneously.
As it is shown on figure 3, the baseline version management system of a kind of software program, including source code parsing module 10, monitoring module
20 and baseline version management module 30, wherein:
Source code parsing module 10 for carrying out source code parsing to binary program, and the source code that record binary program is corresponding is civilian
Part.
In one embodiment, the binary program reached the standard grade is to be generated, such as by a series of c/c++ compilation of source code
.so file .cgi file etc..Here c/c++ source code includes cpp file and hpp file, and wherein cpp file is by c++ language
The source code file (i.e. sound code file) that speech is write, and the header file that hpp file is cpp file.In the present embodiment, to binary system
Program carries out source code parsing and includes the parsing to cpp file and the parsing to hpp file.
In one embodiment, sound code file includes the hpp file that cpp file and cpp file are quoted.As shown in Figure 4, source
Code parsing module 10 includes that instruction performs module 110, scan module 120 and logging modle 130, wherein:
Instruction performs module 110 and is used for performing instruction, obtains compiling intermediate object program.
Scan module 120, for being scanned compiling intermediate object program, obtains cpp file composition and the hpp literary composition quoted thereof
Part forms.
Source code parsing module 10, can be raw plus specifying parameter by the make instrument of Linux GNU when resolving cpp file
Become the details (i.e. compiling intermediate object program) of binary system compiling.Instruction performs the instruction of module 110 execution: make-n-B-i-k mesh
Mark program name.Wherein, target program file name refers to the filename needing to carry out the binary program of source code parsing, such as
LibA.so, Axx.cgi etc.;-n represents printing simulation compilation process, but the most really performs compiling;-B represents all of target
Need more newly compiled;-i represents and ignores all of mistake upon execution;-k represent make mistakes the most out of service.Run above-mentioned instruction
After, obtain compiling the literary composition of intermediate object program, such as shape such as " g++-g-I/path1-I/path2-I.../pathN-o xxxxx.o "
This.The text is scanned by scan module 120, obtains complete cpp file composition.
When source code parsing module 10 resolves hpp file, can be by Linux g++ compiler plus specifying parameter to obtain cpp/
All .h header files that c source code is quoted.The instruction that instruction performs module 110 execution is as follows: g++-MM xxxx.cpp | xxxx.c-
I1-I2-I3.Wherein ,-MM represents that the h of the nonsystematic definition specifying cpp/c source code to refer to defines file;-I specifies compiling
The h file path that this source program refers to.After running above-mentioned instruction, obtain compile intermediate object program, such as shape as " xxxx.0:
xxxx.cpp
hpp1\
hpp2\
hpp3\
Hpp4 " text.The text obtained is scanned by scan module 120, i.e. can get cited in complete cpp file
The hpp file composition arrived.About the scanning algorithm of cpp file and hpp file with reference to mentioned above.
In one embodiment, scan module 120 can go to scan two according to fixed frequency (such as every 3 hours) enter every day
The file composition of processing procedure sequence, the cpp file every time obtained after scanning and hpp file are instructed and delete instruction renewal and arrive by insertion
In data base.Once be scanned binary program liba.so before such as obtaining file consist of a.cpp, b.cpp and
C.cpp, the file that Current Scan obtains consists of a.cpp, b.cpp and d.cpp, owing to a.cpp and b.cpp is at front single pass
The file composition obtained exists, therefore need not a.cpp and b.cpp process.And d.cpp obtains at front single pass
To file composition in do not exist, therefore d.cpp need to be performed insert instruction (i.e. Insert instruction), by d.cpp insertion.Separately by
C.cpp is there is not, it is therefore desirable to c.cpp performs delete instruction, and (i.e. Delete refers in the file composition that Current Scan obtains
Make), c.cpp is deleted, and more new database.
Logging modle 130 is for the cpp file composition that will obtain, hpp file composition and the corresponding relation of binary system degree
Recorded binary system source code to resolve in corresponding table.
In one embodiment, the corresponding table of binary system source code parsing is as shown in table 1:
In table 1, have recorded binary program Libtest.so is carried out all cpp files obtained by after source code parsing and
The hpp file that it is quoted.
Monitoring module 20 is for monitoring single state of reaching the standard grade of binary program.
Binary program is reached the standard grade and is referred to the binary program that compiling produces is published to the Internet that user accesses.Each two
The upper line process of binary program can use to reach the standard grade and singly carry out record, be such as recorded as " Zhang San 12:00 bill of lading A need reach the standard grade
LibA.so, Axx.cgi ", wherein, libA.so, Axx.cgi are the binary program needing to reach the standard grade.Upper at binary program
In line process, user revises, according to situation about reaching the standard grade, single state of reaching the standard grade.
Single state of reaching the standard grade of binary program includes the bill of lading, reach the standard grade comprehensively in, reach the standard grade successfully comprehensively, reach the standard grade unsuccessfully comprehensively
With comprehensive rollback.Wherein, the bill of lading refers to that submission is reached the standard grade list;Refer in reaching the standard grade that binary program is in the shape reached the standard grade comprehensively
State, due to major part internet sites be all made up of some peer server, need once by binary program from some
Station server is reached the standard grade one by one, time course of therefore having reached the standard grade;Reach the standard grade comprehensively and successfully refer to that binary program is all reached the standard grade successfully;
Failure of comprehensively reaching the standard grade refers to that binary program is reached the standard grade unsuccessfully;Comprehensively rollback refers to that binary program is reached the standard grade after failure, needs upper
The binary program of line withdraws the Internet that user accesses, and changes the binary program operating in the Internet into original version
This.
Baseline version management module 30 is for the sound code file corresponding according to the lookup of state binary program reaching the standard grade single, right
The baseline version number of the sound code file found is updated.
In one embodiment, said system also includes: baseline version tables of data creation module (not shown), is used for
Create baseline version tables of data, baseline version tables of data have recorded sound code file and sound code file current basic line version number,
The corresponding relation of at least one historical baseline version number.In one embodiment, the field recorded in baseline version tables of data is such as
Shown in table 2, wherein have recorded two nearest historical baseline version numbers.
In one embodiment, after binary program is reached the standard grade successfully comprehensively, it is comprehensive that user revises single state of reaching the standard grade
Reach the standard grade successfully.When monitoring modular 20 monitors single state of reaching the standard grade for reaching the standard grade successful comprehensively, then notice baseline version management mould
Block 30.Baseline version management module 30, for searching the sound code file that binary program is corresponding, obtains from version management server
The current version number of sound code file, is recorded as the current basic line version that sound code file is corresponding by the current version number of sound code file
Number.
In the present embodiment, baseline version management module 30 resolves corresponding table from above-mentioned generation binary system source code and searches comprehensively
Reach the standard grade the sound code file corresponding to successful binary program.The version management server of above-mentioned embodiment is svn
(subversion, a kind of Version) server, source code can be managed by svn service, and svn service is to increase income
Free, svn server have recorded the various versions of source code.Such as, A.cpp file on January 1st, 2011 by Zhang San
Upload and be created in svn server, svn server be its to be assigned with version number be V1, repair by by Li Si on February 23rd, 2011
Correcting one's mistakes and upload to svn server, svn server is that it is assigned with version number V2.In the present embodiment, obtain from svn server
To the current version number of sound code file, the current version number got is recorded as the current basic line version that sound code file is corresponding
Number.In the present embodiment, the current version number got is updated the current basic line version number field in baseline version tables of data,
And update Liang Ge historical baseline version number accordingly.
In another embodiment, after binary program reaches the standard grade failure comprehensively, need the binary system journey that will currently reach the standard grade
Sequence withdraws the Internet that user accesses, and changes the binary program of original version into, and single status modifier of reaching the standard grade is then complete by user
Face rollback, i.e. return back to the binary program of last revision.It is comprehensive rollback when monitoring module 20 monitors single state of reaching the standard grade
Time, then notice baseline version management module 30.Baseline version management module 30 is for searching the source code literary composition that binary program is corresponding
Part, is last revision number by the current basic line version number modification of this sound code file.
In the present embodiment, baseline version management module 30 resolves in corresponding table for searching the binary program of above-mentioned generation
The sound code file that binary program is corresponding, by current basic line version number modification corresponding for this sound code file in baseline version tables of data
For last revision number.Last revision number may be configured as historical baseline version number 1 or historical baseline version number 2, so, by current base
Historical baseline version number 1 or historical baseline 2 are directly revised as in line version number, update going through in baseline version tables of data simultaneously
History baseline version number.
In the baseline version management method of above-mentioned software program and system, when binary program is carried out source code parsing, logical
Cross the simple instruction of execution can obtain compiling intermediate object program, this intermediate object program is scanned, it is possible to quick obtaining enters to two
The sound code file that processing procedure ordered pair is answered.Owing to can be scanned according to fixing frequency, therefore, it is possible to timing updates binary system journey
The sound code file composition of sequence.During binary program is reached the standard grade, by monitoring single state of reaching the standard grade of binary program,
When single state is reached the standard grade in user's amendment, it is possible to update the baseline version number of sound code file immediately according to the state reaching the standard grade single, logical
Cross baseline version tables of data and the baseline version of sound code file has been carried out effective management so that at the concurrent product development of software
Under, it is possible to get code release accurately.
In the sub-project being in a large project splits, by the baseline version management method of above-mentioned software program and be
System, it is possible to each get subitem destination code easily, therefore can arrange the baseline version environment of a sub-project.This
Outward, by the sound code file (such as cpp file, hpp file) of indicated release, can be compiled according to a definite sequence by compilation tool
Out a whole set of binary program system, (Common Gateway Interface, CGI(Common gateway interface) are real such as to compile CGI
A kind of program technic of existing web terminal http protocol interaction, is by a series of compilation of source code binary program out) program groups
Time, by baseline version management method and the system of above-mentioned software program, it is possible to get code release accurately, hence with
The baseline version management method of above-mentioned software program and system, it is possible to dispose a brand-new development environment and test environment.
Embodiment described above only have expressed the several embodiments of the present invention, and it describes more concrete and detailed, but also
Therefore the restriction to the scope of the claims of the present invention can not be interpreted as.It should be pointed out that, for those of ordinary skill in the art
For, without departing from the inventive concept of the premise, it is also possible to make some deformation and improvement, these broadly fall into the guarantor of the present invention
Protect scope.Therefore, the protection domain of patent of the present invention should be as the criterion with claims.