help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sentinel files with Visual Studio projects


From: David Boyce
Subject: sentinel files with Visual Studio projects
Date: Thu, 5 Nov 2009 20:12:12 -0500

I have a very solvable problem but am looking for people who may have
gone before and could suggest their preferred solutions ...

Background: I need to build a bunch of Windows code using Visual
Studio. VS breaks code into "projects" described by a project file
(e.g. Foo.vcproj), along with a "solution file" (e.g.
Masterbuild.sln). The solution is simply a container which groups a
bunch of projects together.

The command line way of building with VS is "devenv", which can be run
on the solution as a whole or on individual projects. In other words
the command "devenv MasterBuild.sln" would iterate through the list of
projects building each one and exiting on failure, while "devenv
MasterBuild.sln /project Foo.vcproj" would build only project Foo. As
you can see devenv is, or contains, a debased form of make.

My goal is to build the same codebase with real make in order to take
advantage of parallelism and so on, but at this point I don't have the
time to break things down into individual compile units (we're talking
hundreds of projects and many thousands of source files in the
solution). Instead, I've written a Perl script which reads the
solution file and spits out a non-recursive makefile[*] capable of
building each project via devenv. I.e. the granularity is at the
project level, which is not ideal, but OTOH this is simple and robust
because devenv takes care of compiler flags and include paths and so
on. It's a design requirement that the makefiles be generated
dynamically from solution/project files and not maintained in
parallel.

[*] Actually it spits out one makefile per project plus a global file
which simply includes all the others. The project makefiles are
designed to be used individually or collectively. See below for an
exanple.

Anyway, the above is all implemented and I'm just trying to decide
what the resulting makefiles should look like. The following is a
sample of what I generate now for a project called Foo. Note that
variable names are placed in a Foo_ namespace so as to not collide
with other included files, except for CFG which needs to be consistent
(don't ask - the answer is "*&@#$ Windows!").

This iteration is broken because it's all phony targets, and thus
everything builds every time. Unfortunately it appears that there's no
file which VS touches iff it succeeds (&address@hidden Windows!) so I'm
wondering if a sentinel file is the best approach or if anyone knows a
trick that works better.

Thanks,
David Boyce

########################################################################

CFG := Debug

Foo_SLNFILE := Z:\SourceDir\MasterBuild\MasterBuild.sln

Foo_PROJDIR := Z:\SourceDir\Foo

.PHONY: all
all: build_Foo

.PHONY: build build_Foo
build: build_Foo
build_Foo:
        cd "$(Foo_PROJDIR)" &&\
        devenv "$(Foo_SLNFILE)" /useenv /project "Foo" /build "$(CFG)"

[clean target etc elided]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]