Rake: Looking for shortcut to file targets list from within a rakefile

Discussion in 'Ruby' started by mikshir, Sep 8, 2006.

  1. mikshir

    mikshir Guest

    I have several projects that are growing and I'm using rake to manage
    the builds. These are NOT C builds and I cannot use patterns or globs
    or suffixes to reliably collect all of the built files and
    intermediates. So right now, for every file target that I specify I
    have to manually add it to the CLOBBER list if I hope to completely
    clean out the build to pristine condition.

    I'm looking for a shortcut to all file targets from within a rakefile.
    It has to be in there somewhere but looking through the rdoc, it
    doesn't seem to be exposed.

    I guess it's akin to using the results of "rake -T" but from within the
    rakefile and keeping only targets of type "file". That way I can
    simply do a "CLOBBER.include(ALL_FILE_TARGETS_ARY_OR_METHOD)" at the
    end of the rakefile and be done with it and not have to remember to
    push every file target on the clobber list.

    Secondary hope: Sometimes I don't want to do a complete clean/clobber
    and I'd like to prune all file targets that are in the dependency
    "ancestor" tree of a specific target.

    short example:

    # rakefile
    file f1 => [f_source1]do ... end
    file f2 => [f1,f_source2] do ... end
    file f3 => [f2] do ... end
    file g1 do ... end
    file g2 => [g1,g_source1] do ... end
    file g3 => [g2] do ... end

    CLOBBER.include(meth_that_returns_file_task_ancestors(g3))
    # will clobber g3, g2, g1 but not any of the f's and not g_source1
    since it's a dependency but not a file target

    task :clean_f_also
    CLOBBER.include(meth_that_returns_file_task_ancestors(f3))
    # adds f3, f2, f1 only
    end

    # end rakefile

    then from shell

    #removes only g items
    > rake clobber

    # removes both f and g items
    > rake clean_f_also clobber


    I know this example hardly motivates the desire but for a large growing
    build where I can't rely on globs or suffixes, such a shortcut would be
    a godsend.

    SCons has some functionality like this but I wish to use Rake.
    mikshir, Sep 8, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. T. Onoma

    Don't know how to rake Rakefile

    T. Onoma, Aug 23, 2004, in forum: Ruby
    Replies:
    8
    Views:
    144
    James Britt
    Aug 23, 2004
  2. Joe Van Dyk
    Replies:
    2
    Views:
    93
    Damphyr
    Jan 31, 2006
  3. John Gabriele
    Replies:
    1
    Views:
    152
    Suraj Kurapati
    Dec 5, 2006
  4. peppermonkey
    Replies:
    1
    Views:
    226
    Gregory Brown
    Feb 10, 2007
  5. Peter Pk

    rakefile "$0" path in rake

    Peter Pk, Jan 13, 2009, in forum: Ruby
    Replies:
    3
    Views:
    98
    Peter Pk
    Jan 13, 2009
Loading...

Share This Page