[Omake] Re: Building in subdirectories and variant builds revisited

David Kågedal davidk at lysator.liu.se
Fri Jun 8 04:58:35 PDT 2007


"Jesper Eskilson" <jesper at eskilson.se> writes:

> Hi all,
>
> I'm really having trouble in getting variant builds to work nicely
> with subdirectory builds. The setup is as follows:
>
> - At the toplevel there are a bunch of project, each one builds a
> shared or static library.
> - Each project is located in a subdirectory.
> - The source code for each project is spread out over several
> subdirectories under the project's directory.
>
> I want to be able to do "variant builds" (i.e. Debug, Release, etc.).
> Ideally I would like to be able to parametrize the build directory
> (i.e. where all compiled stuff is placed).
>
> What is the "canonical" way of doing this? My main problems at the moment are:

Can't you do something like this:

.SUBDIR: builds
    .SUBDIR: Debug
        BUILDTYPE = debug
        include Buildtree.om
    .SUBDIR: Release
        BUILDTYPE = release
        include Buildtree.om

and then write a Buildtree.om that creates all the vmounts etc and
that uses $(BUILDTYPE) to set compiler options etc.

> - vmount is not transparent; I need to explicitly use $(file ...) in
> order for files to be translated properly, and even that causes
> problems.

Many omake functions (CProgram etc) makes you specify the file names
without suffix (files = foo bar), and then you can make that into file names
using something like "src = $(file $(addsuffix $(files), .c))".

> - vmount requires that the target directory exists, this means that I
> must manually create the entire build directory.

Yeah.  This is hard to get around since omake needs to scan everything
before it even starts to consider what to actually build. This means
that you cannot have e.g. build directories created depending on which
targets you give on the command line.

I suggested a solution to this some time ago, which would involve
something like this:

    # "module" here is probaly one of many modules or variants
    .PHONY: module
    if $(not $(file-exists module-subdir))
        module: module-subdir/module.so
        .SUBDIR: module-subdir
            vmount(module-srcdir, .)
    else
        module:
            mkdir module-subdir
            RestartOMake()

Unfortunately, the RestartOMake function doesn't exist yet, but it
would probably do the trick.

I'm not sure how well the above matches what you might want to do.
You might find a way to avoid the phony somehow, but I'm not sure.

-- 
David Kågedal



More information about the Omake mailing list