![]() |
Launch directory in Rake
Hi
I have a directory of projects and in the directory above that, I would like to put a Rakefile that manages tasks on those projects.=20 The problem is that I cannot obtain the directory from with rake is run. What I want is the following: projects/ Rakefile commandline/ pkg/ commandline.gem quiz42/ project_xyz.../ cd commandline rake gem Inside the gem file is a task: task :gem do sh "gem build pkg/*gem" end The problem is that the pwd is 'projects/=10', not 'projects/commandline'. Also, I cannot tell that there is a way to know that the rake command was run from 'projects/commandline'. If a way exists, I would be happy to hear about it. If not, can we add a @launch_dir (or @run_dir) to #load_rakefile? Thanks --=20 Jim Freeze |
Re: Launch directory in Rake
> The problem is that I cannot obtain the directory from with rake is
---------------------------------------------------------------------------= ------^^^^ =20 which > Inside the gem file is a task: ------------------^^^^ rakefile >=20 > task :gem do > sh "gem build pkg/*gem" > end --=20 Jim Freeze |
Re: Launch directory in Rake
On Tuesday 13 September 2005 03:48 pm, Jim Freeze wrote:
> If a way exists, I would be happy to hear about it. If not, can we > add a @launch_dir (or @run_dir) to #load_rakefile? Reasonable request. Committed to CVS. Use Rake.original_dir to get the original directory. If you are impatient, a beta is available at http://onestepback.org/betagems. -- -- Jim Weirich jim@weirichhouse.org http://onestepback.org ----------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas) |
Re: Launch directory in Rake
Thanks Jim
I'm really surprised this has not already been requested. On 9/14/05, Jim Weirich <jim@weirichhouse.org> wrote: > On Tuesday 13 September 2005 03:48 pm, Jim Freeze wrote: > > If a way exists, I would be happy to hear about it. If not, can we > > add a @launch_dir (or @run_dir) to #load_rakefile? >=20 > Reasonable request. Committed to CVS. Use Rake.original_dir to get the > original directory. >=20 > If you are impatient, a beta is available at http://onestepback.org/betag= ems. >=20 > -- > -- Jim Weirich jim@weirichhouse.org http://onestepback.org > ----------------------------------------------------------------- > "Beware of bugs in the above code; I have only proved it correct, > not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas) >=20 >=20 --=20 Jim Freeze |
Re: Launch directory in Rake
On 9/14/05, Jim Freeze <jim@freeze.org> wrote:
> Thanks Jim >=20 > I'm really surprised this has not already been requested. I'm not. If I'm not mistaken, Make and Ant both assume that you are running the makefile/Ant build file from the directory in which the file exists. All path names are relative to that file, not to the file in which you happen to be running the script. I always write my {rm}akefiles and build.xml files so that everything happens relative to the top-level directory where the file lives. Jim --=20 Jim Menard, jim.menard@gmail.com, jimm@io.com http://www.io.com/~jimm |
Re: Launch directory in Rake
Jim Menard said: > I'm not. If I'm not mistaken, Make and Ant both assume that you are > running the makefile/Ant build file from the directory in which the > file exists. All path names are relative to that file, not to the file > in which you happen to be running the script. Make (and I believe Ant) will not change the current directory to the build file directory when doing a build. Since (by default) both program= s look for a build file in the current directory, there is rarely a difference between the two. However, you can override this default behavior with a -f flag, in which case make runs in your current director= y with a Makefile (possibly) in a different directory. Rake works differently in this regard. It will search up the directory tree for a Rakefile if it does not find one locally (inspired by ant's -find flag). This allows you to fire off rake from anywhere in the project source tree and have it do the right thing. And since Rake aways cd's to the location of the Rakefile, you just write your build tasks assuming that. It makes everything very easy. However, Jim Freeze *wanted* location specific behavior. (Are there too many Jims in this conversation?). > I always write my {rm}akefiles and build.xml files so that everything > happens relative to the top-level directory where the file lives. Yes, the difference is that make/ant require you to cd into that top leve= l directory before running. Rake does not. --=20 -- Jim Weirich jim@weirichhouse.org http://onestepback.org ----------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas) |
Re: Launch directory in Rake
Jim Weirich wrote:
> However, Jim Freeze *wanted* location specific behavior. (Are there > too many Jims in this conversation?). Actually, the Jims currently in this conversation only represent a small sampling of the worldwide Jim contingency. It behooves all Jims, wherever they may be, to chime into this conversation immediately, to run rather than walk, to dash quickly past the street urchin and alleyway lieutenants and tambourine buccaneers, resisting urges to stop and play with a plastic lasso or an infant babboon. You have my license to topple watermelon stands or to block the mirror-carrying. Pop balloons, if you must. The fate of a certain working directory is at hand!! _why |
Re: Launch directory in Rake
On 9/14/05, Jim Menard <jim.menard@gmail.com> wrote:
> On 9/14/05, Jim Freeze <jim@freeze.org> wrote: > > Thanks Jim > > > > I'm really surprised this has not already been requested. >=20 > I'm not. If I'm not mistaken, Make and Ant both assume that you are > running the makefile/Ant build file from the directory in which the > file exists. All path names are relative to that file, not to the file > in which you happen to be running the script. >=20 > I always write my {rm}akefiles and build.xml files so that everything > happens relative to the top-level directory where the file lives. Maybe I just don't understand. Assume you have the following: proj/ [RM]akefile dira/ a.c dirb/ b.c How do you write the [RM]akefile such that if in proj/dira/, that it knows how to compile a.c? Without the orginal_dir, the only information you have is that the cwd is proj/ and you want to compile some file. --=20 Jim Freeze |
Re: Launch directory in Rake
I guess to put it succinctly, is that I want to use Rakefile
such that I have a single Rakefile for multiple projects and I am working in one of the project directories. NOT the case where I have a single Rakefile for a project with multiple directories and I am working in one of the project subdirectories. In the latter, the Rakefile can be more knowledgable, in=20 the former, the Rakefile needs to be told what directory is being worked in. On 9/14/05, Jim Weirich <jim@weirichhouse.org> wrote: >=20 > (Are there too > many Jims in this conversation?). :) You would think that there would not be so much confusion since, as James Edward Gray II says, "All Jim's program the same". --=20 Jim Freeze |
Re: Launch directory in Rake
On 9/14/05, why the lucky stiff <ruby-talk@whytheluckystiff.net> wrote:
> Jim Weirich wrote: >=20 > > However, Jim Freeze *wanted* location specific behavior. (Are there > > too many Jims in this conversation?). >=20 >=20 > Actually, the Jims currently in this conversation only represent a small > sampling of the worldwide Jim contingency. It behooves all Jims, > wherever they may be, to chime into this conversation immediately, to > run rather than walk, to dash quickly past the street urchin and > alleyway lieutenants and tambourine buccaneers, resisting urges to stop > and play with a plastic lasso or an infant babboon. You have my license > to topple watermelon stands or to block the mirror-carrying. Pop > balloons, if you must. The fate of a certain working directory is at han= d!! Once, I played in a band with a drummer named Jim. Our soundman was named Jim, too. I'll give you one guess as to the name of a guest guitarist one evening. It's not a trick question. Jim --=20 Jim Menard, jim.menard@gmail.com, jimm@io.com http://www.io.com/~jimm |
| All times are GMT. The time now is 12:02 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.