Re: [A-A-P-develop] BDIR, was: More than one matching rule?
Brought to you by:
vimboss
From: Bram M. <Br...@mo...> - 2003-03-24 15:43:06
|
George Bronnikov wrote: > OK. This means I misunderstood what you meant by A. My understanding was > (call it A') that BDIR is created under the place where the toplevel > main.aap is invoked (this, of course, does not have to be the toplevel > directory of the project). I suppose we actually have four possibilities then, for creating the build directory: A. In the directory of the recipe that contains the build commands B. In the directory of the source file C. In the toplevel directory of the project D. In the directory of the current toplevel recipe Of these four only the last one uses a different build directory for a source file depending on which recipe you execute. The first one can have the problem that a default rule is used, thus it's not clear which recipe triggers the file to be build and therefore it is not clear which build directory to use. This may result in "D" to be used for targets without explicit build commands. > > Unfortunately, this example doesn't show a difference between A and B. > > Another one? It would at least have to use a source file in a > > subdirectory of the directory where the recipe is. > > OK. So here is an example that shows the difference: > > .../proj: > main.aap > a.c > > .../proj/sub: > b.c > > The toplevel (and only) main.aap: > > SRC = a.c sub/b.c > OBJ = `src2obj(SRC)` > > prog: $OBJ > :do build {target=$target} $source > > With A, you'll get .../proj/build-.../a.o and .../proj/build-.../sub/b.o. > With B, .../proj/build-.../a.o and .../proj/sub/build-.../b.o > > An argument for B: you know where to search the object for b.c without > looking at the recipe (well, of course, you need to know which variant you > compile). Src2obj does not need to know the recipe's position, either. > > An argument for A: with B, you don't have BDIR at all. With A, the > variable is local to the recipe, but at least it exists. > > I'm not sure any of these arguments is compelling enough to choose one > variant over another. It seems this quickly turns into a list of less important arguments, such as whether it's nice to have everything below one build directory or have a build directory that doesn't contain subdirectories. I can at least say that "D" is not nice, since the build directory would depend on what sub-project of a larger project you are building. If you have a package with several programs, building the whole package would use a different build directory than building each program in a subdirectory. A disadvantage of "C" is that you need to specify what the toplevel directory is. It's an extra choice to make when writing the recipe. And you probably need some default mechanism for when the toplevel isn't specified. A disadvantage I see for "A" is that the directory is unclear for targets that are build by default rules instead of explicit dependencies. This unpredictability is not nice. The disadvantage of "B" is that it doesn't work for read-only directories. You need to work around that by explicitly specifying a different build directory. This would not happen very often, and manually specifying a directory is not that much of a problem. Or you can make a copy of the source files with the "fetch" mechanism. An advantage of "B" is that you could also build a source file in a directory level upwards without much trouble. E.g., "../common/file.c". With "A" this is difficult to take care of, because "$BDIR/../common/file.o" is not what you want. Thus I tend to prefer "B" at the moment: create a build directory where the source file is. What would be the remaining problems to be solved? - If the source file is build in different ways, this requires different build directories. When using variants this is done automatically. When the user writes two recipes he has to take care that the build directories used are different. - $BDIR cannot be a full path to which the object file name is appended. This requires using "sub/$BSUBDIR/file.o" for "sub/file.c". Can anyone think of an example where "B" does not work well? -- hundred-and-one symptoms of being an internet addict: 193. You ask your girlfriend to drive home so you can sit back with your PDA and download the information to your laptop /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html /// |