Click here to Skip to main content
6,594,932 members and growing! (14,511 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Libraries » General     Intermediate License: The Code Project Open License (CPOL)

Batch Build VC Projects' Wizard

By f22_storm

Build all your projects using a wizard just like the 'BCGControl Bar Pro Build Wizard' including the ourputs.
VC6Win2K, WinXP, Win2003, Vista, Dev
Posted:7 Nov 2007
Updated:16 May 2008
Views:18,275
Bookmarked:21 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
6 votes for this article.
Popularity: 3.52 Rating: 4.53 out of 5

1

2
1 vote, 16.7%
3

4
5 votes, 83.3%
5
Screenshot - Snap.png

Introduction

This is a useful tool for building a serial projects of your team when your software contains many components, created using VC++6, VC++2003, VC++2005 and also VC++2008. At the same time, you can create some batch files to do some additional task, such as increasing the version of project, copying/deleting files, and calculating the MD5 of the final output binary, etc.

You can compile them by selecting, get the compile status from the 'Status' icon, and even stop the build process while compiling. Of course, you have the option to view the run-time output of compiling.

Background

Recently, I have an opportunity to manage a project which has many VC++ projects. We have to compile them one by one firstly, and then we using batch file to do this. But this is a long time to wait the final result, and what the bad is the control flow is poor: if one failed, we have to recompile them all. So, I search the web and know that CodeJock & BCGSoft are all have theirs GUI build wizard, why not create a common one for us? So, it is this. ^)^

Using the code

Here we used some common stuff in this tool, including the INI reader, the console redirector, and XListCtrl. All initialization start from:
CBuildWizDlg::OnInitDialog(): 

InitListCtrl(&m_List);
FillListCtrl(&m_List);

// Toggle the state of output
OnDetail();

// Center Main Dialog.
CenterWindow();
m_log.m_pWnd = this;

// Set the Header Control
m_HeaderCtrl.SetTitleText(m_objSet.m_stuBWS_COMM.szPrjName);
m_HeaderCtrl.SetDescText(m_objSet.m_stuBWS_COMM.szComments);

m_HeaderCtrl.SetIconHandle(AfxGetApp()->LoadIcon(IDI_MSDEV));
m_HeaderCtrl.Init(this);
m_HeaderCtrl.MoveCtrls(this);

// Init the Build Envirement.
InitBuildEnv();


Here is the details about our Initialization of List Control:

// Create the Project List items from the BuildWiz.ini.
void CBuildWizDlg::FillListCtrl(CXListCtrl *pList)
{
    // Read Settings From INI
    m_objSet.InitSettings();

    //
    CString        strTitle;
    strTitle.Format("BuildWiz - script by %s ", m_objSet.m_stuBWS_COMM.szAuthor);
    SetWindowText(strTitle);

    pList->LockWindowUpdate();    // ***** lock window updates while filling list *****
    
    pList->DeleteAllItems();
    
    CString                str = _T("");
    int                    nItem, nSubItem;
    STU_BWS_ITEM        bwsItem;

    for(nItem = 0; nItem < m_objSet.m_stuBWS_COMM.nItems; nItem ++)
    {
        for (nSubItem = 0; nSubItem < BWS_COLS; nSubItem++)
        {
            str = _T("");
            bwsItem = m_objSet.m_arrBWItems.GetAt(nItem);

            // Text
            if (nSubItem == 0)                // Enable
                str.Format("%s", bwsItem.szComponent);
            else if (nSubItem == 1)                // Label
                str.Format("%s", bwsItem.szComments);
            else if (nSubItem == 2)                // Status
            {
                str = _T(" ");
                pList ->SetItemImage(nItem, nSubItem, BLDWIZ_STATUS_NA);
            }

            // Do it.
            if (nSubItem == 0)
            {
                pList->InsertItem(nItem, str);

                if(strnicmp(bwsItem.szStatus, "yes", 3) == 0)
                    pList->SetCheckbox(nItem, nSubItem, ITEM_STATUS_CHECKED);
                else if(strnicmp(bwsItem.szStatus, "no", 2) == 0)
                    pList->SetCheckbox(nItem, nSubItem, ITEM_STATUS_UNCHECKED);
                else
                    pList->SetCheckbox(nItem, nSubItem, ITEM_STATUS_HIDDEN);
            }
            else
                pList->SetItemText(nItem, nSubItem, str);

        }

    }
    
    pList->UnlockWindowUpdate();    // ***** unlock window updates *****
}


For build projects, we may need some envirenment for compilers, such as 'include', 'lib', 'path', we do this in:

// Set the Env: 'include', 'lib', 'path'.
void CBuildWizDlg::InitBuildEnv()
{
    TCHAR        tszEnv[MAX_ENVVAR_LEN + 1] = {0};
    CString        strEnv;

    // Include
    if(strlen(m_objSet.m_stuBWS_COMM.szIncDir) > 0)
    {
        GetEnvironmentVariable("INCLUDE", tszEnv, sizeof(tszEnv));
        strEnv.Format("%s;%s", m_objSet.m_stuBWS_COMM.szIncDir, tszEnv);
        SetEnvironmentVariable("INCLUDE", strEnv);
    }

    // Library 
    if(strlen(m_objSet.m_stuBWS_COMM.szLibDir ) > 0)
    {
        GetEnvironmentVariable("LIB", tszEnv, sizeof(tszEnv));
        strEnv.Format("%s;%s", m_objSet.m_stuBWS_COMM.szLibDir, tszEnv);
        SetEnvironmentVariable("LIB", strEnv);
    }

    // Path 
    if(strlen(m_objSet.m_stuBWS_COMM.szExeDir) > 0)
    {
        GetEnvironmentVariable("PATH", tszEnv, sizeof(tszEnv));
        strEnv.Format("%s;%s", m_objSet.m_stuBWS_COMM.szExeDir, tszEnv);
        SetEnvironmentVariable("PATH", strEnv);
    }

    // 'BWBaseDir' variable
    if(strlen(m_objSet.m_stuBWS_COMM.szBaseDir) > 0)
    {
        SetEnvironmentVariable("BWBASEDIR", m_objSet.m_stuBWS_COMM.szBaseDir);
    }
    else
        SetEnvironmentVariable("BWBASEDIR", "");


    // Change the current directory.
    if(strlen(m_objSet.m_stuBWS_COMM.szBaseDir) > 0)
    {
        if(!SetCurrentDirectory(m_objSet.m_stuBWS_COMM.szBaseDir))
            OutputDebugString("\nError! Base Directory is invalid.");
        else
        {
            
        }
    }
}


For some reason, we use the 'redirect' technology for msdev.exe, .bat , .cmd; But, we have to use 'pipe line' technology for vs2005's devenv.exe. You can see them in 'CBuildWizDlg::OnBuild()' function, look:

    // This is the Piper.
    CTraceCollector objTracer(&m_log);
    objTracer.Run();

    // Here we start build and create a redirected application.
    if(!RunScript(m_objSet.m_stuBWS_COMM.szPreCompile))
    {
     ... ...

How to Use This Tool

First you should know something about the BuildWiz.ini. There is a [common] section for the common settings of your project, and there are many [item?] sections for each of you project of your product. What I am sure is, once you run BuildWiz.exe after reviewing the demo BuildWiz.ini, you should know the meanings of each tags.

Please download the Binary 1st.

Points of Interest

* BuildWiz supports VC++6 and VC++ 2005 projects, and mingw, cygin, c51 are also supported, I think;

* We used Pipe-Line and redirect techonology;

* BuildWiz can be improved to support user defined envirement varibles;

* As a project manager, you can make your software build more faster and easier than ever. :)

* It gives you more control while building sources.


History

* 2008-05-16 rev. 1.2 BuildWiz.ini now have new 'BaseDir={PWD}' support.

* 2008-01-23 rev. 1.1 BuildWiz.ini now have new %basedir% varible support.

by using this new var. we can simplify the .ini.

* 2007-10-08 1st Step. (This is my 3rd topic on codeproject)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

f22_storm


Member
software development is so nice and we can make our world better than ever, even the real world.
vc++6 is enough for me, althought i tried to upgrade to higher version, each time, i down-grade to vc6. ^_^
Occupation: Software Developer
Company: Sysoft Forum
Location: China China

Other popular Libraries articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 11 of 11 (Total in Forum: 11) (Refresh)FirstPrevNext
General'vcbuild' instead 'devenv' or 'msbuild' for VS.net project Pinmemberf22_storm1:11 16 May '08  
Questionclick button"build" second ,question Pinmemberandrew20030704@yahoo.com0:01 25 Jan '08  
AnswerRe: click button"build" second ,question Pinmemberf22_storm1:12 16 May '08  
GeneralIt is not 100% right Pinmember_elli_19:40 23 Jan '08  
GeneralYou know MSBuild ? Pinmember_elli_2:07 23 Jan '08  
GeneralRe: You know MSBuild ? Pinmemberf22_storm18:25 23 Jan '08  
GeneralPurpose? Pinmemberbolivar12310:50 9 Nov '07  
GeneralRe: Purpose? Pinmemberf22_storm15:25 11 Nov '07  
GeneralRe: Purpose? Pinmemberbolivar12316:37 11 Nov '07  
GeneralBuildWiz_Binary download not working Pinmemberrajas4:07 9 Nov '07  
GeneralRe: BuildWiz_Binary download not working Pinmemberf22_storm15:18 11 Nov '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 16 May 2008
Editor:
Copyright 2007 by f22_storm
Everything else Copyright © CodeProject, 1999-2009
Web15 | Advertise on the Code Project