Getting started by daily compilation

xiaoxiao2021-03-06  68

Getting started by daily compilation

(Author: Jackey, Website: www.kuihua.net)

1 Introduction:

Discussions on Daily-Build, Night-Build have a lot of online, but most of them stay in the form or is purely a talker, rarely see some real useful, operable things. However, there are many open source daily compilation systems, Ant, nant, etc. support.

In view of this, I use the BAT and Perl scripts to implement an entry-level daily compilation system.

2 Working environment that requires this article:

2.1 System operating environment:

l Development environment: Visual C 6.0

l Packing environment: install shield 6.1

l Script Environment: Active Perl 5.6.1

l operating system: Win2000 / WinXP

l CVS environment: WinCVS (1.3.13.1), CVSNT (2.0.4)

l CVS Settings :: PSERVER: JACKEY @ Server: D: / khbuild

l CVS2CL: Change Log Tool, is a perl script, download address: http://www.red-bean.com/cvs2cl

l Environment Variables: The Path system variables need to be manually established for Install Shield, and other tools are automatically added when installing.

2.2 Catalog Environment and Example Engineering Settings:

l Test Engineering Catalog Structure in CVS:

/ TestProject / Source // Test Engineering Source Code Directory

/ TestProject / Install // Test Engineering Installation Code Directory

l Compile directory environment settings per day:

D: / cvsbuild // temporary compilation directory

D: / DailyBuild / / Daily Compile Directory

/ Product // All product catalog

/ TestProject // Test Product Catalog

/ 2004-9-1 // 2004.9.1 Products

/ 2004-9-2 / / 2004.9.2 Products

/ 2004-9-3 // 2004.9.3 Products

/ Buildlog // log of all products

/ TestProject // Test the log of the product

/Changelog.txt // Test the code change log of the product

/ 2004-9-1 // 2004.9.1 Compilation log

/ 2004-9-2 / / 2004.9.2 Compilation log

/ 2004-9-3 // 2004.9.3 Compilation log

/SYS.LOG / / System log

/ cvs.log // CVS code download log

/VC6.LOG / / VC6 code compile log

/install.log // Package compile log

/ Script

/cvs2cl.pl // Generate Changelog's Perl script

/Filepath.pl // Modify the perl script of the absolute path of Install Shield

/LoadTest.bat // Batch for Windows Automatic Task Call

/BUILDTEST.BAT / / The actual automatic compile script called by loadtest.bat

3 buildest.bat implementation ideas:

l Parameter description:

1. Specify the disk letter stored in the compilation intermediate process. (Such as: D:)

2. Specify the multiple-compilation-stored drive letter, which can be a network disk. (Such as: E:)

3. Specify the code warehouse information required for CVS.

l Specific steps:

1. Judgment the legality of the input parameters;

2. Get the current date, the usual format is: 2004-9-5

3. Set the environment variable to make further operations;

4. Go to the script where you are located;

5. Delete the catalog compiled on the same day to ensure only one product;

6. Create a storage directory for the day product;

7. Write the current system environment status into the Sys.log log file;

8. Download the source code and installation code from the TestProjet from the CVSNT;

9. Use cvs2cl.pl for the downloaded code generated code change log (Changelog.txt)

10. Use FilePath.pl to modify the absolute path in the installation code;

11. Compile TestProject Project using MSDev.exe;

12. Compile the installation code for TestProject using isbuild.exe;

13. Copy the compiled installer to the specified daily compile directory;

14. Delete some unwanted temporary directories;

15. Compilation end.

l In order to achieve automation of daily compilation, a Windows system task is required to automatically call LoadTest.bat every day to achieve true DAILY-Build or Night-Build.

4 For reference only, the script:

4.1 LoadTest.bat implementation reference:

Buildtest.bat D: D: Jackey @ Server: D: / khbuild

4.2 BuildTest.bat Implementation Reference:

@echo off

Rem ------- Check The Input Param is Validate! --------

IF "% 1" == "" GOTO: USAGE

IF "% 2" == "" GOTO: USAGE

IF "% 3" == "" GOTO: USAGeecho Starting Daily-Build for TestProject Product Product ...

Date / T> Date.inf

FOR / F "tokens = 1 * delims =," %% I in (date.inf) do set date = %% i

Del date.inf

Set project = TestProject

Set build_path =% 1 / cvsbuild

Set script_path =% 2 / DailyBuild / Script

Set product_path =% 2 / DailyBuild / Product / TestProject /% DATE%

Set log_path =% 2 / DailyBuild / Buildlog / TestProject /% DATE%

Set cvsroot = -d: pserver:% 3

Set code_path =% build_path% / testproject

SET SYS_LOG =% log_path% / sys.log

SET CVS_LOG =% log_path% / cvs.log

SET VC6_LOG =% log_path% / vc6.log

Set install_log =% log_path% / install.log

SET CHANGE_LOG =% 2 / DailyBuild / Buildlog / TestProject / Changelog.txt

CD / D% script_path%

Rd / s / q% product_path%

RD / S / Q% log_path%

MD% build_path%

MD% product_path%

MD% LOG_PATH%

Time / T >>% SYS_LOG%

Date / T >>% SYS_LOG%

ECHO project name =% project% >>% sys_log%

Echo Product Path =% Product_Path% >>% SYS_LOG%

ECHO Compilation Path =% Build_Path% >>% SYS_LOG%

ECHO code path =% code_path% >>% sys_log%

Echo log path =% log_path% >>% SYS_LOG%

Echo CVS parameter =% cvsroot% >>% sys_log%

Echo CVS log =% cvs_log% >>% sys_log%

Echo vc6 log =% vc6_log% >>% sys_log%

ECHO system log =% sys_log% >>% sys_log%

Echo installation log =% install_log% >>% SYS_LOG%

Echo update log =% change_log% >>% SYS_LOG%

Echo [... Checkout Source Code ...] >>% CVS_LOG%

CVS% CVSROOT% Checkout -D% Build_Path% / Source TestProject / Source >>% CVS_LOG% Echo [... Checkout Install Code ...] >>% CVS_LOG%

CVS% cvsroot% checkout -d% build_path% / install testproject / install >>% cvs_log%

echo [... building change hole for this version ...]

CD / D% code_path%

% Script_path% / cvs2cl.pl --hide-filenames -p -f channelelog.txt

COPY / y CHANGELOG.TXT% CHANGE_LOG%

Del Changelog.txt

CD / D% script_path%

echo [... building testproject ...]

MSDEV% code_path% / source / testproject.dsw / make "testproject - win32 release" / rebuild >>% vc6_log%

echo [... building installshield code ...]

FilePath.pl% Project%% Code_Path%% Code_Path% / Install / >>% install_log%

ISBUILD -M "default" -p "% code_path% / install / testproject.iPR" -b "% build_path% / test" -r >>% install_log%

echo [Copy Install Files to Daily-Build Repository ...]

Xcopy / Y% Build_Path% / Test / Diskim ~ 1 / disk1 /*.*% Product_path%

echo [now, delete the temporary build-path ...]

Rd / s / q% build_path%

Goto: EOF

Rem ------- Print the usage for this .bat file --------

: USAGE

Echo ------------------------------------------------------------------------------- --------------------------------------------

Echo

Echo % 0 [Temp Disk Volume] [DEST Disk Volume] [user @ server: path]

Echo

ECHO [EXAMPLE]:% 0 D: E: Administrator @ localhost: D: / khbuild

Echo [Temp Disk Volume]: Specifies the disk letter stored in the compilation intermediate process. (Such as: D:)

Echo [Desk Disk Volume]: Specifies the daily compilation of the drive letter, which can be a network disk. (Such as: E:)

Echo [User @ Server: Path]: Specifies the code warehouse information required for CVS.

Echo

Echo ------------------------------------------------------------------------------- --------------------------------------------

: Eof

4.3 FilePath.pl Implementation Reference: #! / User / bin / perl -w

MY $ search = "=. * $ argv [0]"; # search value

MY $ replace = "= $ argv [1]"; # replace value

MY $ DIRNAME = "$ Argv [2] File Groups"; # search Directory

Print "/ r / n";

Print "Search IS /" $ Search / "/ R / N";

Print "Replace IS /" $ REPLACE / "/ R / N";

Print "Directory IS /" $ DIRNAME / "/ R / N";

Print "/ r / n";

OpenDir Dir, $ DIRNAME OR DIE "Cannot Open $ DIRNAME: $!"; # Open Directory

Foreach MY $ FileName (ReadDir Dir) # ENUMERATE DIRECTORY FILE

{

Next if $ filename = ~ //./; # skip. and ..

Next if $ filename = ~ / cvs /;

Next if $ filename = ~ //.fdf/;

$ filename = "$ dirName // $ filename"; # append directory path

Open (Infile, "$ FileName") || Die "Cannot Open $ FileName: $!";

Open (Outfile, "> $ filename". "_ bak") || DIE "$!"; # Open and create file

Print "[Processing File IS /" $ filename / "...] / r / n / r / n";

While () # ENUMERATE All Lines

{

S / $ search / $ replace / g; # Search and Replace in Global

Print $ _; #print the replace result

Print outfile $ _; # save in new file

}

Close Infile; # close in_file

Close Outfile; # close out_filerename $ filename. "_bak", $ filename; # rent_file to in_file

}

CloseDir Dir; # close the directory

5 Application of daily compilation:

5.1 Establishing a core chain idea:

Source Code Management Tool => BUG Tracking Tool => Daily Compilation Tool

WinCVS / CVSNT => bugzilla => BAT and Perl scripts

5.2 How to use these tools:

l The version control system of the source code must be established, which is CVS, basic code submission principle:

1. Programmer tries to submit it once before get off work;

2. Submitted code must be normal operation on its own machine;

3. Each submission must use a short voice to explain the function description of your submitted code.

l Establish an error tracking system, use bugzilla very well, configure the mail system, making Bugzilla a bridge that testers communicated with developers.

l With the BAT and Perl scripts, the simple daily compilation tool in CVS is implemented as the core, put this automation tool written on a specialized compilation machine, and automatically download code in the middle of the night, automatically Compile the code, the automatic package installer, automatically record various compile logs, automatically place the installer to a fixed-time public area with a reply. (You get the code update log uploaded by programmers with cvs2cl.pl for test personnel.

l The second day of the test personnel should go to the public area to get the latest version of the day, and the new version of the new version according to Changelog. And the bug found in the test, feedback to the programmer via Bugzilla. The programmer can decide to modify these bugs according to its own situation, or the company's provisions. And the modification of these bugs is written when the code is submitted.

l The second day of the developer should go to the public area to view the compilation log, see if your module is properly compiled, correct, see if there is a bug report in your own mailbox, timely modification.

l The second day of the management personnel, based on the progress of the integrated project and the progress of the top day, you can judge the development direction of the product. If there is or to understand the error or have a new demand, it can be adjusted according to the current situation.

LYS, through cvs => bugzilla => Daily-build, you can interact with the tester, and Reduce communication and human trouble. For management, you can do it in your heart: Because there is a new version every day, you can always master the trend of the product. . . and many more.

5.3 I write the documentation of related tools:

l WinCVS / CVSNT concise hand:

http://blog.9cbs.net/ycw/archive/2003/12/29/4183.aspx

http://blog.9cbs.net/ycw/archive/2003/07/18/4184.aspx

Http://blog.9cbs.net/ycw/archive/2003/07/18/4185.aspxhttp://blog.9cbs.net/ycw/archive/2003/07/18/4186.aspx

l Bugzilla installation record:

http://blog.9cbs.net/ycw/archive/2004/02/07/4187.aspx

http://blog.9cbs.net/ycw/archive/2004/02/07/4188.aspx

http://blog.9cbs.net/ycw/archive/2004/02/07/4189.aspx

Http://blog.9cbs.net/ycw/archive/2004/09/05/95076.aspx

转载请注明原文地址:https://www.9cbs.com/read-120055.html

New Post(0)