Search code examples
buildtupbuild-target

Tup with named targets


I just switched to tup from make and I can't seem to understand how to make named targets..

Makefiles allow for multiple targets to be defined, like make clean, make foo, etc.

However, tup only seems to accept variable switches, not true targets...

Is there a way around this?


Solution

  • The answer to this turns out to be in the variants settings of tup.

    For example a clean target is approximated by (from a similar answer):

    # Build files in build-default
    touch default.config # An empty config file is ok
    tup variant default
    tup
    

    Actually this is the use case for variants as described in the manual.

    $ ls configs/
    bar.config
    foo.config
    $ tup variant configs/*.config
    tup: Added variant 'build-bar' using config file 'configs/bar.config'
    tup: Added variant 'build-foo' using config file 'configs/foo.config'
    

    For projects that commonly use several variants, the files in the configs/ directory could be checked in to source control. Each developer would run the 'tup variant' after 'tup init' during the initial checkout of the software. Variants can also be created manually by making a build directory and creating a tup.config file in it (see the VARIANTS section). This command merely helps save some steps, so that you don't have to make each build directory and tup.config symlink manually.

    However, tup no longer works as the right update command since that will update all the variants.

    Instead target them like this:

    tup build-default