Collection article. Original author: snaill, from http://blog.9cbs.net/snaill/archive/2004/10/12/133673.aspx
Daily build practice articles
Look at Joel Spolsky's "Software Development Success 12 Specification" and "Daily Builds Are Your Friend", which are deeply in touch with the necessity and practicality of daily build. So add a script to your project to achieve a fast daily construction, and describe the entire process of this attempt, which is convenient for reference.
The so-called daily construction is a re-creation of the entire project at least once a day. The daily construction itself can only be considered a means of protecting code validity and quickly modifying the quick-selling means, but it is necessary to quickly build the project results from code to build a final product form ( Such as installation programs, CD mirroring, etc.) requires a set of tools to support the corresponding scripts, and the work that needs to be done daily is to implement this process.
There are many links in the daily construction process, the basic process is to remove the latest version of the source code from the source code management system, then compile by the compiler, and finally package it using the installer. I first started from the source code from the source management system.
It is the process of Visual SourceSafe.
The VSS itself has a Command Line mode. Follow the help documentation, command line commands all the features of the VSS interface program. And I only need his GET now (get the most recent version), the command line is as follows:
SS Get $ / vss_code -i-y -r -glc: / daily_build_code -o@mycode.log
SS
Launch program name for VSS Command Line mode
Get
Get the most recent version of the command name
$ / VSS_CODE
The program path that wants to get, the path can be obtained by the right click Properties function functionality through the VSS form program
-I-y
Answer Y, if this parameter is not allowed, the command will wait for the user to enter when you ask. Answer N, is -i-n
-R
Recursive acquisition, will take all subdirectories in this directory
-Glc: / daily_build_code
Used to specify the path to obtain the source code, if it is not set, use the default work directory of VSS
-O@mycode.log
Specify all information to output to log files
Note 1: The work path is specified here. Generally, it is best to re-establish the path each time for the construction of the original environment. If it is possible to provide a machine to be used to do daily build.
Note 2: If you do not specify the absolute path of the log file, the log file will be established to the current path. If you frequently use the CD, the MD command is likely to make this location uncertain, so it is recommended to use the absolute path to specify the log file. s position.
Although the above command is used to get the most recent version, it also needs to set the current environment variable in reality.
If your VSS server is not in this machine, you need to specify the service path as follows:
SET SSDIR = // my_vss_server / vss_code
You also need to specify the username and password, as follows:
Set SSUSER = SNAIL
Set sspwd = chinaos.com
Also, if you don't add the VSS path to the system settings, you need to specify the VSS path:
SET PATH = C: / Program Files / Microsoft Visual Studio / Common / VSS / Win32 /
Finally, pay attention is that because the new work path is specified, you need to ensure the validity of the directory.
These work have been completed, and the obtained script is expressed as the sample:
// vss.bat
SET SSDIR = // my_vss_server / vss_codset ssuser = snail
Set sspwd = chinaos.com
SET PATH = C: / Program Files / Microsoft Visual Studio / Common / VSS / Win32 /
C:
CD /
MD daily_build_code
SS Get $ / vss_code -i-y -r -glc: / daily_build_code -o@mycode.log
Other commands and parameters provided by VSS Common Line, please see the help document for VSS
We have got all the code of the current project and put them in the specified directory. Here's how to build these code. This article introduces the vc batch process, it is to be noted that the process of VC6 is different, first we see how VC6 commands line build code.
1. Create a MAK file
The project file directly using VC6 cannot be compiled in the command line, so you must first guide the .mak file.
In the menu of the VC IDE, there is exportable feature, and he generates a corresponding MAK file in the project directory. In addition, in the VC settings can be set to export the MAK file at the same time, select this feature, your MAK file and the project file are synchronized.
The last job is to add the MAK file to the version management software. This should have a DEP file, which describes the dependencies of the file in the project. Since these items are relative path, it is a quite dangerous thing, it is recommended not to join, although this will not find it when this is compiled. Tip of the DEP file.
It should be noted that when your project is controlled under version management software, if the MAK file does not check out, the export failure is no prompt, so when the project file check out, the check out mak file is a must develop. good habits.
2. Set compilation path
If there is no option to set an environment variable when installing, you need to set the desired path before the compiler is running.
The standard path of the VC, and the VC6 is saved in VC98 / BIN / VCVARS32.BAT, you can copy the contents of the BAT to your own script. The standard script is as follows:
@echo off
REM
Rem Root of Visual Developer Studio Common Files.
Set vscommondir = c: / progra ~ 1 / micros ~ 3 / Common
REM
Rem Root of Visual Developer Studio INSTALLED FILES.
REM
SET MSDEVDIR = C: / Progra ~ 1 / Micros ~ 3 / Common / MSDEV98
REM
Rem Root of Visual C Installed Files.
REM
SET MSVCDIR = C: / Progra ~ 1 / Micros ~ 3 / VC98
REM
Rem vcosdir is buy to help create Either A Windows 95 or Windows NT Specific Path.
REM
Set vcosdir = Win95
IF "% os%" == "windows_nt" set vcosdir = Winnt
REM
Echo Setting Environment for Using Microsoft Visual C Tools.
REM
IF "% OS%" == "Windows_NT" set path =% msdevdir% / bin;% msvcdir% / bin;% vscommondir% / Tools /% vcosdir%;% vscommondir% / Tools;% PATH% IF "% OS% "==" "SET PATH ="% msdevdir% / bin ";"% mscommondir% / Tools /% vscommondir% / Tools /% vcosdir% ";"% vscommondir% / Tools ";"% windir% / system ""% PATH% "
Set include =% msvcdir% / atl / include;% msvcdir% / include;% msvcdir% / mfc / include;% incrude%
Set lib =% msvcdir% / lib;% msvcdir% / mfc / lib;% lib%
SET VCOSDIR =
SET vscommondir =
Then you need to add a custom path, add an executable files in front of the path settings in VC to add an executable files;% include% before adding include files;% lib% Add library files.
Note: If you use the instructions similar to #Import
% WINDIR% / system32
3. Build using Namke.exe
After the catalog settings are compiled, you can use the command build project directly:
NMAKE MyProject.mak
Use the-Clean parameter to clear the complication item:
nmake -clean myproject.mak
Use CFG to set compilation settings
Nmake mapchina.mak cfg = "MyProject - Win32 debug"
Note: The value of the CFG can be obtained from the MAK file and the project file. The MAK file contains a default setting. If the value of the CFG is not provided, this default setting is compiled.
Other commands and parameters provided by nmake, please see the documentation of MSDN