Recipe 19.3. Cleaning Up Generated FilesCredit: Stefan Lang ProblemYou want to clean up files that aren't actually part of your project: generated files, backup files, and so on. SolutionWithin your Rakefile, require the By default, CLEAN also includes the patterns **/*~, **/*.bak, and **/core. Here's a typical set of CLOBBER and CLEAN files:
Run rake clean to remove all files specified by the CLEAN filelist, and rake clobber to remove the files specified by both file lists. DiscussionThe rake/clean library initializes the constants CLEAN and CLOBBER to new Rake:: FileList instances. It also defines the tasks clean and clobber, making clean a prerequisite of clobber. The idea is that rake clean removes any files that might need to be recreated once your program changes, while rake clobber returns your source tree to a completely pristine state. Other Rake libraries define cleanup tasks that remove certain products of their main tasks. An example: the packaging libraries create a task called clobber_package, and make it a prerequisite of clobber. Running rake clobber on such a project removes the package files: you don't have to explicitly include them in your CLOBBER list. You can do the same thing for your own tasks: rather than manipulate CLEAN and CLOBBER, you can create a custom cleanup task and make it a prerequisite of clean or clobber. The following code is a different way of making sure that rake clobber removes any precompiled object files:
Now you can run rake clobber_objects to remove all object files, and rake clobber to remove all other unwanted files as well. See Also
|
Sunday, October 25, 2009
Recipe 19.3. Cleaning Up Generated Files
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment