Chris X

Dear experts,

My project contains several #define build directives that define the product's name depends on our customer's requirements. For example:

--------------------------------------------

#define Customer1

//#define Customer2 //<----------commented out when compiling for customer 1

.....

#ifdef Customer1

this.Text = "Customer 1's Product Name";

#elif defined Customer2

this.Text = "Customer 2's Product Name";

...

#endif

--------------------------------------------

Each time there is an update in our code, we'll have to build each individual customer's code. Is there any possible way that this process can be automated that the project will build for all customers using different #define directive combination Or perhaps there is a better way to do this besides using #define

Thanks in advance!



Re: Visual C++ General Auto batch build with different #define directives

Jonathan Caves - MSFT

If all the customer specific changes you have to deal with are just resources (like strings) then I would look at using a resource file instead of hard coded strings.






Re: Visual C++ General Auto batch build with different #define directives

Chris X

Thanks for the reply. Even if they are just strings, I would still have to build different versions for each customer manually, specifies the program to retrive different string from the resource manager, am I correct In additon, some customers would like to have certain blocked out from the users, which means certain block of codes will only be complied for some specific customers. Any solutions to this





Re: Visual C++ General Auto batch build with different #define directives

Jerry Goodwin

Just use the cl.exe command line option /D to define your customer define instead of defining it in the .h file.

Then have your build process build with each customer define in turn. You're simply pushing the control over which customer you're compiling for up out of the code into the make system, where you can automate making several different ways easily.






Re: Visual C++ General Auto batch build with different #define directives

Chris X

Still haven't found a solution to auto batch build all defination combination yet. However, thanks for Jerry's suggestion, I've found a way to do #define based on the Build Configuration - put the #define variable in the Project setting under the Processor Defination. Setting this value in different Build Configuration will at least release me from manually messing with (commenting out) various #define combination in the code to get it complie. Is there any suggestion on how to make Visual Studio chain-up and build each configuration automatically





Re: Visual C++ General Auto batch build with different #define directives

Bite Qiu - MSFT

Use makefile you'll be able to build one project with different configuration at a time, see: http://msdn2.microsoft.com/en-us/library/dd9y37ha(VS.80).aspx

You may also try to write a batch file that calls vcbuild.exe several times with different configurations as you will set up for different customers: http://msdn2.microsoft.com/en-us/library/8xcy2245.aspx

hope it makes sense

rico






Re: Visual C++ General Auto batch build with different #define directives

Bite Qiu - MSFT

Chris X wrote:

Still haven't found a solution to auto batch build all defination combination yet. However, thanks for Jerry's suggestion, I've found a way to do #define based on the Build Configuration - put the #define variable in the Project setting under the Processor Defination. Setting this value in different Build Configuration will at least release me from manually messing with (commenting out) various #define combination in the code to get it complie. Is there any suggestion on how to make Visual Studio chain-up and build each configuration automatically

Just get a hint from another thread, you can create your own build configurations for different customers, see: http://msdn2.microsoft.com/en-us/library/kkz9kefa(VS.80).aspx