From jim.weirich at gmail.com Wed Jan 2 22:46:28 2008 From: jim.weirich at gmail.com (Jim Weirich) Date: Wed, 2 Jan 2008 22:46:28 -0500 Subject: [Rake-devel] redefine rake task broken in 0.8.x for a rails app In-Reply-To: <274343.4851198998542537.JavaMail.root@pyramid.gbdev.com> References: <274343.4851198998542537.JavaMail.root@pyramid.gbdev.com> Message-ID: <67D1A969-60B4-4696-A066-FCE1DF8C4E19@gmail.com> On Dec 30, 2007, at 2:09 AM, John Dell wrote: > Hi Charlie, > > Awesome! That was it. I also had to change the code for > last_comment to last_description. > > I also found that after I fixed my rake task, that the same problem > exists in rails engines tasks that is doing the same thing. I'll > post a patch for engines on their forums. > > Thanks, > John > > Here is the rake task code I'm using now: > > unless Rake::TaskManager.methods.include?(:redefine_task) > module Rake > module TaskManager > def redefine_task(task_class, args, &block) > task_name, deps = resolve_args([args]) > task_name = task_class.scope_name(@scope, task_name) > deps = [deps] unless deps.respond_to?(:to_ary) > deps = deps.collect {|d| d.to_s } > task = @tasks[task_name.to_s] = task_class.new(task_name, > self) > task.application = self > task.add_description(@last_description) > @last_description = nil > task.enhance(deps, &block) > task > end > end > class Task > class << self > def redefine_task(args, &block) > Rake.application.redefine_task(self, args, &block) > end > end > end > end > end Hmmm ... there are several problem with this patch. Although it works, it doesn't support the new named argument syntax for tasks (not that I should talk, I just noticed that the file task in rake itself is broken in the same way). To fix that, change the calling sequence to *args and then the resolve_args argument can go back to being just plain args (rather than [args]). But a more fundamental problem is that this code is extremely fragile. Changes to internal rake implementation (such as the 0.7.x to 0.8.x) is likely to break this code. Since redefine/clear_task functionally is something several people have asked for, I'm thinking about adding something like that to rake directly. So I'm trying to understand what people need out of this feature. Are you trying to ... (1) Clear existing prerequisites and actions and introduce new ones, or (2) Completely delete the existing task and replace it with a different task (of a possibly different task type)? If you have use cases for this, I would like to hear them. Thanks. -- -- Jim Weirich -- jim.weirich at gmail.com From cfis at savagexi.com Thu Jan 3 01:03:15 2008 From: cfis at savagexi.com (Charlie Savage) Date: Wed, 02 Jan 2008 23:03:15 -0700 Subject: [Rake-devel] redefine rake task broken in 0.8.x for a rails app In-Reply-To: <67D1A969-60B4-4696-A066-FCE1DF8C4E19@gmail.com> References: <274343.4851198998542537.JavaMail.root@pyramid.gbdev.com> <67D1A969-60B4-4696-A066-FCE1DF8C4E19@gmail.com> Message-ID: <477C7AA3.9040807@savagexi.com> > > Are you trying to ... > > (1) Clear existing prerequisites and actions and introduce new ones, or That is what we do. Rails provides tasks to run tests, which include prerequisites that rebuild the appropriate database. However, we have our own code to do that since what we do is a bit specialized. Thus we have to remove the prerequisites Rails uses and slot in our own. We do that by using redefine task. Charlie -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3237 bytes Desc: S/MIME Cryptographic Signature Url : http://rubyforge.org/pipermail/rake-devel/attachments/20080102/b8e2bcc9/attachment.bin From assaf at labnotes.org Thu Jan 3 02:53:01 2008 From: assaf at labnotes.org (Assaf Arkin) Date: Wed, 2 Jan 2008 23:53:01 -0800 Subject: [Rake-devel] redefine rake task broken in 0.8.x for a rails app In-Reply-To: <477C7AA3.9040807@savagexi.com> References: <274343.4851198998542537.JavaMail.root@pyramid.gbdev.com> <67D1A969-60B4-4696-A066-FCE1DF8C4E19@gmail.com> <477C7AA3.9040807@savagexi.com> Message-ID: <5037b6e40801022353m7bb70e14i56fb02ba19824577@mail.gmail.com> On Jan 2, 2008 10:03 PM, Charlie Savage wrote: > > > > Are you trying to ... > > > > (1) Clear existing prerequisites and actions and introduce new ones, or > > That is what we do. Rails provides tasks to run tests, which include > prerequisites that rebuild the appropriate database. However, we have > our own code to do that since what we do is a bit specialized. Thus we > have to remove the prerequisites Rails uses and slot in our own. We do > that by using redefine task. task('foo').prerequisites.clear -- Assaf http://labnotes.org > > Charlie > > _______________________________________________ > Rake-devel mailing list > Rake-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rake-devel > From jim.weirich at gmail.com Thu Jan 3 10:09:59 2008 From: jim.weirich at gmail.com (Jim Weirich) Date: Thu, 3 Jan 2008 10:09:59 -0500 Subject: [Rake-devel] redefine rake task broken in 0.8.x for a rails app In-Reply-To: <5037b6e40801022353m7bb70e14i56fb02ba19824577@mail.gmail.com> References: <274343.4851198998542537.JavaMail.root@pyramid.gbdev.com> <67D1A969-60B4-4696-A066-FCE1DF8C4E19@gmail.com> <477C7AA3.9040807@savagexi.com> <5037b6e40801022353m7bb70e14i56fb02ba19824577@mail.gmail.com> Message-ID: On Jan 3, 2008, at 2:53 AM, Assaf Arkin wrote: > task('foo').prerequisites.clear Ha! Clever! I was going to suggest Rake::Task['foo'].prerequisites.clear, but then realized that although the task method's main purpose is to create and enhance tasks, it also returns the task object. So task ('foo').prerequisites is perfectly valid. Good job! -- -- Jim Weirich -- jim.weirich at gmail.com From spovich at gmail.com Thu Jan 3 14:07:58 2008 From: spovich at gmail.com (John Dell) Date: Thu, 3 Jan 2008 11:07:58 -0800 (PST) Subject: [Rake-devel] redefine rake task broken in 0.8.x for a rails app In-Reply-To: <1804890.6711199346326774.JavaMail.root@pyramid.gbdev.com> Message-ID: <3966664.6921199387278925.JavaMail.root@pyramid.gbdev.com> ----- "Jim Weirich" wrote: > To fix that, change the calling sequence to *args and then the > resolve_args argument can go back to being just plain args (rather > than [args]). Seems like it should work, but it isn't. No errors reported, but tasks are not redefined. > Since redefine/clear_task functionally is something several people > have asked for, I'm thinking about adding something like that to rake > directly. So I'm trying to understand what people need out of this > feature. Awesome! I was really hoping you would say that! Thanks! > Are you trying to ... > > (1) Clear existing prerequisites and actions and introduce new ones, > or Yes, this is what we are doing. This makes it easy to pop into the right point in the large rails task list. For example, the default rails 'rake test' does all kinds of stuff to prepare the test database. To allow our custom test db build, we just redefine the task for prepare environment to call our new task: namespace :db do namespace :test do desc 'Drop/recreate test database, migrate schema, and load fixtures in order' Rake::Task.redefine_task :prepare => :environment do Rake::Task['db:test:custom_db_setup'].invoke end desc 'Drop/recreate test database, migrate schema, and load fixtures in order' task :custom_db_setup do `script/setup-db test` end end end > (2) Completely delete the existing task and replace it with a > different task (of a possibly different task type)? Probably useful for somebody. Given the choice, more flexibility and options the better. > If you have use cases for this, I would like to hear them. For us, the main scenario use case is we are redefining 'rake test' for our rails app to make tests run in a reasonable amount of time. Because we use foreign key constraints in Postgres during development, the unit test method for loading/cleaning up fixtures is not useable. To get around this, we have a custom script that drops/recreates test db, loads fixtures only once (and in order to preserve FK constraints), and then tests have 'transactional-fixtures = true' so everything rolls back, and we don't reload fixtures continually with each test. This simple step cuts test runs down by an order of magnitude for us. Another use case is the 'engines' plugin which monkey patches rake to add redefine_task. This is to enhance certain rails rake tasks. From the 'engines' docs: The engines plugin enhances and adds to the suite of default rake tasks for working with plugins. The doc:plugins task now includes controllers, helpers and models under app, and anything other code found under the plugin's code_paths attribute. New testing tasks have been added to run unit, functional and integration tests from plugins, whilst making it easier to load fixtures from plugins. See Engines::Testing for more details about testing, and run 'rake -T' to see the set of rake tasks available. Here is the custom rake task engines is using: http://svn.rails-engines.org/engines/trunk/tasks/engines.rake From james.adam at gmail.com Thu Jan 3 14:55:51 2008 From: james.adam at gmail.com (James Adam) Date: Thu, 3 Jan 2008 19:55:51 +0000 Subject: [Rake-devel] redefine rake task broken in 0.8.x for a rails app Message-ID: <9ec5d0aa0801031155r70db4cdayc18d0cb27c649abf@mail.gmail.com> > Since redefine/clear_task functionally is something several people have asked for, I'm > thinking about adding something like that to rake directly. So I'm trying to understand > what people need out of this feature. > > Are you trying to ... > > (1) Clear existing prerequisites and actions and introduce new ones, or > > (2) Completely delete the existing task and replace it with a different task (of a possibly > different task type)? > > If you have use cases for this, I would like to hear them. I think the engines plugin is looking for option (2), where it's the "body" of the rake task that needs to change, rather than any of the prerequisites. In my specific case, it's really only to add a single line of code to one of the pre-existing rake tasks (as John Dell described earlier). I can see pluses for enabling both (1) and (2) though - certainly in some cases it'd be good to "mock out" the prerequisites of a rake task to test only a single stage. For example: task :process_data => :generate_data do # do the processing end If the ":generate_data" task takes a long time and/or depends on other inputs, it may be useful to "stub" the :generate_data task to simply copy in some fixture data to where :process_data expects it. Then again, perhaps such "mocking" would be done via re-implementation (i.e. option (2)) anyway? Sorry if that's not very clear; my real-world use case is the situation where a plugin in Rails wishes to change the behaviour of an existing Rake task :) -- * J * ~ From jim.weirich at gmail.com Thu Jan 3 17:26:02 2008 From: jim.weirich at gmail.com (Jim Weirich) Date: Thu, 3 Jan 2008 17:26:02 -0500 Subject: [Rake-devel] redefine rake task broken in 0.8.x for a rails app In-Reply-To: <9ec5d0aa0801031155r70db4cdayc18d0cb27c649abf@mail.gmail.com> References: <9ec5d0aa0801031155r70db4cdayc18d0cb27c649abf@mail.gmail.com> Message-ID: <3E452ABE-B2BF-485A-8C30-7CC1146EB76C@gmail.com> On Jan 3, 2008, at 2:55 PM, James Adam wrote: >> Since redefine/clear_task functionally is something several people >> have asked for, I'm >> thinking about adding something like that to rake directly. So I'm >> trying to understand >> what people need out of this feature. >> >> Are you trying to ... >> >> (1) Clear existing prerequisites and actions and introduce new >> ones, or >> >> (2) Completely delete the existing task and replace it with a >> different task (of a possibly >> different task type)? >> >> If you have use cases for this, I would like to hear them. > > I think the engines plugin is looking for option (2), where it's the > "body" of the rake task that needs to change, rather than any of the > prerequisites. Actually, that counts as clearing/replacing one of the actions, which falls under option (1). Option (2) is more like you have: task "xyz" and you want to replace it with: file "xyz" Which seems a bizzare thing to do, but I want to ask the question. > In my specific case, it's really only to add a single > line of code to one of the pre-existing rake tasks (as John Dell > described earlier). > > I can see pluses for enabling both (1) and (2) though - certainly in > some cases it'd be good to "mock out" the prerequisites of a rake task > to test only a single stage. For example: > > task :process_data => :generate_data do > # do the processing > end > > If the ":generate_data" task takes a long time and/or depends on other > inputs, it may be useful to "stub" the :generate_data task to simply > copy in some fixture data to where :process_data expects it. Then > again, perhaps such "mocking" would be done via re-implementation > (i.e. option (2)) anyway? I'm thinking of something along the lines of: task(:generate_data).clear(:actions) task :generate_data do # copy predefined fixtures end The problem I have with the whole "clear out the task" idea is that it doesn't play well with multiple plugins. Suppose you have the following: # In the original .rake file: task :generate_data do # Really Generate the data end # In plugin number 1, you want to also generate some additional data. task :generate_data do # generate some additional data end # Now, in plugin number 2, you want to overwrite the original action task(:generate_data).clear(:actions) task :generate_data do # Copy fixtures end The second plugin not only overwrites the original generate data actions as intended, but also any actions added by the first plugin (which is probably not intended). The same issue can happen with prequisites too, where multiple plugins clear and and redefine them. That's one reason I've resisted the idea of clearing tasks. It might solve YOUR issues, but it will cause headaches for those using your plugins with other plugins. Maybe we need pointcuts and AOP for Rake tasks (now my head is spinning). -- -- Jim Weirich -- jim.weirich at gmail.com From assaf at labnotes.org Thu Jan 3 17:57:25 2008 From: assaf at labnotes.org (Assaf Arkin) Date: Thu, 3 Jan 2008 14:57:25 -0800 Subject: [Rake-devel] redefine rake task broken in 0.8.x for a rails app In-Reply-To: <3E452ABE-B2BF-485A-8C30-7CC1146EB76C@gmail.com> References: <9ec5d0aa0801031155r70db4cdayc18d0cb27c649abf@mail.gmail.com> <3E452ABE-B2BF-485A-8C30-7CC1146EB76C@gmail.com> Message-ID: <5037b6e40801031457v65243054v55844f786a561c69@mail.gmail.com> On Jan 3, 2008 2:26 PM, Jim Weirich wrote: > > On Jan 3, 2008, at 2:55 PM, James Adam wrote: > > >> Since redefine/clear_task functionally is something several people > >> have asked for, I'm > >> thinking about adding something like that to rake directly. So I'm > >> trying to understand > >> what people need out of this feature. > >> > >> Are you trying to ... > >> > >> (1) Clear existing prerequisites and actions and introduce new > >> ones, or > >> > >> (2) Completely delete the existing task and replace it with a > >> different task (of a possibly > >> different task type)? > >> > >> If you have use cases for this, I would like to hear them. > > > > I think the engines plugin is looking for option (2), where it's the > > "body" of the rake task that needs to change, rather than any of the > > prerequisites. > > Actually, that counts as clearing/replacing one of the actions, which > falls under option (1). > > Option (2) is more like you have: > > task "xyz" > > and you want to replace it with: > > file "xyz" > > Which seems a bizzare thing to do, but I want to ask the question. > > > In my specific case, it's really only to add a single > > line of code to one of the pre-existing rake tasks (as John Dell > > described earlier). > > > > I can see pluses for enabling both (1) and (2) though - certainly in > > some cases it'd be good to "mock out" the prerequisites of a rake task > > to test only a single stage. For example: > > > > task :process_data => :generate_data do > > # do the processing > > end > > > > If the ":generate_data" task takes a long time and/or depends on other > > inputs, it may be useful to "stub" the :generate_data task to simply > > copy in some fixture data to where :process_data expects it. Then > > again, perhaps such "mocking" would be done via re-implementation > > (i.e. option (2)) anyway? > > I'm thinking of something along the lines of: > > task(:generate_data).clear(:actions) > task :generate_data do > # copy predefined fixtures > end > > The problem I have with the whole "clear out the task" idea is that > it doesn't play well with multiple plugins. Suppose you have the > following: > > # In the original .rake file: > task :generate_data do > # Really Generate the data > end > > # In plugin number 1, you want to also generate some additional > data. > task :generate_data do > # generate some additional data > end > > # Now, in plugin number 2, you want to overwrite the original action > task(:generate_data).clear(:actions) > task :generate_data do > # Copy fixtures > end > > The second plugin not only overwrites the original generate data > actions as intended, but also any actions added by the first plugin > (which is probably not intended). > > The same issue can happen with prequisites too, where multiple > plugins clear and and redefine them. That's one reason I've resisted > the idea of clearing tasks. It might solve YOUR issues, but it will > cause headaches for those using your plugins with other plugins. > > Maybe we need pointcuts and AOP for Rake tasks (now my head is > spinning). Rake::Task.send :attr_reader, :actions task('foo').actions.clear task('bar').actions.unshift lambda { puts 'Me first!' } task('baz').actions.reverse! # Let's mess with people! -- -- Assaf http://labnotes.org -- > -- Jim Weirich > -- jim.weirich at gmail.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rake-devel/attachments/20080103/0ae3ba1f/attachment.html From james.adam at gmail.com Thu Jan 3 18:00:14 2008 From: james.adam at gmail.com (James Adam) Date: Thu, 3 Jan 2008 23:00:14 +0000 Subject: [Rake-devel] redefine rake task broken in 0.8.x for a rails app In-Reply-To: <3E452ABE-B2BF-485A-8C30-7CC1146EB76C@gmail.com> References: <9ec5d0aa0801031155r70db4cdayc18d0cb27c649abf@mail.gmail.com> <3E452ABE-B2BF-485A-8C30-7CC1146EB76C@gmail.com> Message-ID: <9ec5d0aa0801031500m723b3931r96524924774bc974@mail.gmail.com> On Jan 3, 2008 10:26 PM, Jim Weirich wrote: > On Jan 3, 2008, at 2:55 PM, James Adam wrote: > > I think the engines plugin is looking for option (2), where it's the > > "body" of the rake task that needs to change, rather than any of the > > prerequisites. > > Actually, that counts as clearing/replacing one of the actions, which > falls under option (1). I'll defer to your (clearly better) understanding of Rake :) > The problem I have with the whole "clear out the task" idea is that > it doesn't play well with multiple plugins. Certainly; but that's a problem for Rails (or rather, Rails developers) to solve, if indeed it really is a problem. I'd say this shares more in common with reopening classes - certainly any number of files might reopen a class and redefine a method, obliterating what was there before, but it still qualifies as a "feature" :) If the "task => method" analogy holds, might it be possible to define an alias to the current implementation of a task, and then redefine it to call the aliased task along with any custom behaviour? Maybe something like this: alias_task :new_task_name, :original_task redefine_task :original_task do task(:new_task_name).invoke do_something_else end ... perhaps something like that? It may be that this is simply not practical, in which case I think that it's still fine to simply lose the previous implementation - that feels Rubyish to me. -- * J * ~ From spovich at gmail.com Fri Jan 4 17:27:32 2008 From: spovich at gmail.com (John Dell) Date: Fri, 4 Jan 2008 14:27:32 -0800 (PST) Subject: [Rake-devel] redefine rake task broken in 0.8.x for a rails app In-Reply-To: <3E452ABE-B2BF-485A-8C30-7CC1146EB76C@gmail.com> Message-ID: <26614751.7651199485652152.JavaMail.root@pyramid.gbdev.com> ----- "Jim Weirich" wrote: > The problem I have with the whole "clear out the task" idea is that > it doesn't play well with multiple plugins. Suppose you have the > following: > > # In the original .rake file: > task :generate_data do > # Really Generate the data > end > > # In plugin number 1, you want to also generate some additional > data. > task :generate_data do > # generate some additional data > end > > # Now, in plugin number 2, you want to overwrite the original > action > task(:generate_data).clear(:actions) > task :generate_data do > # Copy fixtures > end > > The second plugin not only overwrites the original generate data > actions as intended, but also any actions added by the first plugin > (which is probably not intended). > > The same issue can happen with prequisites too, where multiple > plugins clear and and redefine them. That's one reason I've resisted > > the idea of clearing tasks. It might solve YOUR issues, but it will > > cause headaches for those using your plugins with other plugins. Hi Jim, I understand your concerns here, but I think that like any good tool, there are ways to abuse/misuse it. How about this idea? Perhaps you could add a 'whiney' param where if a plugin author is concerned about their task being clobbered, you allow them to emit a warning if their task is clobbered. Add an extra param for task creation during the original task definition that contains the whiney message. Either way, ultimately, rake is a tool for developers and programmers should be in control, even with the possibility of self-inflicted wounds. Regards, John From meihome at gmail.com Tue Jan 8 11:32:54 2008 From: meihome at gmail.com (Andrew Chen) Date: Tue, 8 Jan 2008 11:32:54 -0500 Subject: [Rake-devel] How to execute before the '.o' => '.f90' tasks? In-Reply-To: <9619ddc90801080832q52f50525u1b406ce98438bb4e@mail.gmail.com> References: <9619ddc90801080832q52f50525u1b406ce98438bb4e@mail.gmail.com> Message-ID: <9619ddc90801080832l67f16489v4d30b99ffc71c871@mail.gmail.com> Hi, First time to the list. Thanks for your good work. I'm trying to use Rake to compile some FORTRAN and C codes. I have a task: rule '.o' => '.f90' do |t| sh "#{$compiler} -c -o #{t.name} #{t.source} -module #{$build_dir}" end But I have another task: generate_code, this task will make some more .f90 source files. I want to my generate code task to be executed before my rule '.o' Rake::Task[:gen].invoke if Rake::Task.task_defined?('gen') How to do that? Thanks ~Andrew Chen From bradphelan at xtargets.com Wed Jan 9 03:45:19 2008 From: bradphelan at xtargets.com (bradphelan) Date: Wed, 09 Jan 2008 09:45:19 +0100 Subject: [Rake-devel] How to execute before the '.o' => '.f90' tasks? In-Reply-To: <9619ddc90801080832l67f16489v4d30b99ffc71c871@mail.gmail.com> References: <9619ddc90801080832q52f50525u1b406ce98438bb4e@mail.gmail.com> <9619ddc90801080832l67f16489v4d30b99ffc71c871@mail.gmail.com> Message-ID: <4784899F.5040104@xtargets.com> Andrew Chen wrote: > Hi, > > First time to the list. Thanks for your good work. > > I'm trying to use Rake to compile some FORTRAN and C codes. > > I have a task: > > rule '.o' => '.f90' do |t| > sh "#{$compiler} -c -o #{t.name} #{t.source} -module #{$build_dir}" > end > > But I have another task: generate_code, this task will make some more > .f90 source files. > > I want to my generate code task to be executed before my rule '.o' > > Rake::Task[:gen].invoke if Rake::Task.task_defined?('gen') > > How to do that? > I don't know but I played around with Rake for a while to build C/C++ and found it unsuitable. Whilst Rake is a great dependency tracking system for tasks it is not so great a tool for a general build system. I ended up turning to SCons which is a Python package though I prefer to do my general scripting in Ruby. The things that SCons does better - Construction environments - Hierarchical project management - Automatic clean rules - The ability to glob the dependency tree as well as the file system which is great for when using code generators - Many builders for C/C++/Fortran and others come by default with the SCons package. Most of the builders are automatically cross platform too. Windows/Linux builds are done with exactly the same commands. That being said I think the Rake notation is nicer than SCons because Ruby is a nicer language. However Rake seems to be used primarily in Ruby based projects and there is not much development effort in making it friendly to other areas. This is not a criticism. Rake seems extremely good at what it does for the customers that use it. However for a general build engine I would recommend at least a look at SCons. Regards Brad http://xtargets.com From devi.webmaster at gmail.com Wed Jan 9 08:33:24 2008 From: devi.webmaster at gmail.com (Daniel Brumbaugh Keeney) Date: Wed, 9 Jan 2008 07:33:24 -0600 Subject: [Rake-devel] require not .rb Message-ID: <3bceeb2d0801090533v3a757532h9c627dec3851523d@mail.gmail.com> Is there some way to require a file that doesn't end in `.rb' within a Rakefile? Thanks. Daniel Brumbaugh Keeney From jim.weirich at gmail.com Wed Jan 9 08:37:15 2008 From: jim.weirich at gmail.com (Jim Weirich) Date: Wed, 9 Jan 2008 08:37:15 -0500 Subject: [Rake-devel] require not .rb In-Reply-To: <3bceeb2d0801090533v3a757532h9c627dec3851523d@mail.gmail.com> References: <3bceeb2d0801090533v3a757532h9c627dec3851523d@mail.gmail.com> Message-ID: On Jan 9, 2008, at 8:33 AM, Daniel Brumbaugh Keeney wrote: > Is there some way to require a file that doesn't end in `.rb' > within a Rakefile? > Thanks. You can use load rather than require. You will need to give a path to the file and include the extension. Also load is not idempotent like require (i.e. multiple loads on the same file will actually load the file multiple times). And Rake is just plain ruby, so any other exotic technique that works in Ruby will work with rake too (e.g. explicitly reading and evaling the file contents). -- -- Jim Weirich -- jim.weirich at gmail.com From assaf at labnotes.org Mon Jan 14 03:45:06 2008 From: assaf at labnotes.org (Assaf Arkin) Date: Mon, 14 Jan 2008 00:45:06 -0800 Subject: [Rake-devel] Circular dependency reporting for nested invokes Message-ID: <5037b6e40801140045o4c4217f1x4c2abbe3b34b8a3f@mail.gmail.com> One nice addition in Rake 0.8 is better reporting for circular dependency errors. Unfortunately, it only works for prerequisites. We have a lot of cases where one task invokes another, either using these tasks as post-requisites, or when the task body is the logic deciding which tasks to execute. When circular dependencies happen, they're still reported as sleeping threads. Any chance of extending invoke_with_call_chain so it can carry InvocationChain through invokes happening inside execute? -- Assaf http://labnotes.org From meihome at gmail.com Wed Jan 16 13:42:55 2008 From: meihome at gmail.com (Andrew Chen) Date: Wed, 16 Jan 2008 13:42:55 -0500 Subject: [Rake-devel] How to execute before the '.o' => '.f90' tasks? In-Reply-To: <4784899F.5040104@xtargets.com> References: <9619ddc90801080832q52f50525u1b406ce98438bb4e@mail.gmail.com> <9619ddc90801080832l67f16489v4d30b99ffc71c871@mail.gmail.com> <4784899F.5040104@xtargets.com> Message-ID: <9619ddc90801161042p2f6a94n6a96a19f4f8f42e8@mail.gmail.com> Sorry, this email was never sent out due to mailing list problems. Here it is again... ---- Brad, Thanks for your input. SCons is a good tool. I investigated in SCons 4 years ago. What I had problem with SCons was that it insisted on knowing too much about the language to be built. It builds internal dependencies. At that time, it does understand much of new FORTRAN 95 syntax, and we spent a few days trying to write a F95 parser for SCons, and that turned me off. Maybe my knowledge is limited on new SCons features. My build environment is mixed FORTRAN (F66, F90), C, Java. I need finer control of what the build tool would do. What's good about Rake (and make included) is, it separate concerns language parser and a build tool. Also, I figured out a way to compile generated code already (see http://fortranxunit.cvs.sourceforge.net/fortranxunit/fruit/sample/test/rakefile?view=markup) At the start of rake file, I included one call: FruitProcessor.new.pre_process So that the generated files are created before SRC, and OBJ are built. I switched totally from make to rake in the FORTRAN unit testing framework. It can handle multiple directories pretty well. And the amount of code I need to write for a new package is very minimal. Rake experts - is this a "preferred/better" way to handle generated source files to be compiled? Thanks ~Andrew Chen On 09/01/2008, bradphelan wrote: > Andrew Chen wrote: > > Hi, > > > > First time to the list. Thanks for your good work. > > > > I'm trying to use Rake to compile some FORTRAN and C codes. > > > > I have a task: > > > > rule '.o' => '.f90' do |t| > > sh "#{$compiler} -c -o #{t.name} #{t.source} -module #{$build_dir}" > > end > > > > But I have another task: generate_code, this task will make some more > > .f90 source files. > > > > I want to my generate code task to be executed before my rule '.o' > > > > Rake::Task[:gen].invoke if Rake::Task.task_defined?('gen') > > > > How to do that? > > > I don't know but I played around with Rake for a while to build C/C++ > and found it unsuitable. Whilst Rake is a great dependency tracking > system for tasks it is not so great a tool for a general build system. I > ended up turning to SCons which is a Python package though I prefer to > do my general scripting in Ruby. > > The things that SCons does better > > - Construction environments > - Hierarchical project management > - Automatic clean rules > - The ability to glob the dependency tree as well as the file system > which is great for > when using code generators > - Many builders for C/C++/Fortran and others come by default with the > SCons package. Most of the builders > are automatically cross platform too. Windows/Linux builds are done > with exactly the same commands. > > That being said I think the Rake notation is nicer than SCons because > Ruby is a nicer language. However Rake seems to be used primarily in > Ruby based projects and there is not much development effort in making > it friendly to other areas. This is not a criticism. Rake seems > extremely good at what it does for the customers that use it. However > for a general build engine I would recommend at least a look at SCons. > > Regards > > Brad > > http://xtargets.com > > _______________________________________________ > Rake-devel mailing list > Rake-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rake-devel > From meihome at gmail.com Wed Jan 16 13:49:15 2008 From: meihome at gmail.com (Andrew Chen) Date: Wed, 16 Jan 2008 13:49:15 -0500 Subject: [Rake-devel] How to execute before the '.o' => '.f90' tasks? In-Reply-To: <9619ddc90801161042p2f6a94n6a96a19f4f8f42e8@mail.gmail.com> References: <9619ddc90801080832q52f50525u1b406ce98438bb4e@mail.gmail.com> <9619ddc90801080832l67f16489v4d30b99ffc71c871@mail.gmail.com> <4784899F.5040104@xtargets.com> <9619ddc90801161042p2f6a94n6a96a19f4f8f42e8@mail.gmail.com> Message-ID: <9619ddc90801161049u725a2e2bt9bdd2f3133808a03@mail.gmail.com> Rake experts, I still have problem to control the exact order of the compilation. I have a_test.f90, b_test.f90 file. From those files, I have a pre-processor, that will generate: fruit_basket.f90, and fruit_driver.f90 files. The question is, I want make sure the order of compilation is: a.f90, b.f90, fruit_basket.f90, and fruit_driver.f90 I used the file tasks: rule '.o' => '.f90' do |t| Rake::Task[:dirs].invoke sh "#{$compiler} -c -o #{t.name} #{t.source} -module #{$build_dir} #{lib_name_flag} #{lib_dir_flag}" end Question: how do I add the rules that will allow names with certain patterns compiled last? My working files are located here: http://fortranxunit.cvs.sourceforge.net/fortranxunit/fruit/sample/test/rakefile , and http://fortranxunit.cvs.sourceforge.net/fortranxunit/fruit/rake_base.rb Thanks ~Andrew Chen From assaf at labnotes.org Wed Jan 16 14:27:19 2008 From: assaf at labnotes.org (Assaf Arkin) Date: Wed, 16 Jan 2008 11:27:19 -0800 Subject: [Rake-devel] How to execute before the '.o' => '.f90' tasks? In-Reply-To: <9619ddc90801161049u725a2e2bt9bdd2f3133808a03@mail.gmail.com> References: <9619ddc90801080832q52f50525u1b406ce98438bb4e@mail.gmail.com> <9619ddc90801080832l67f16489v4d30b99ffc71c871@mail.gmail.com> <4784899F.5040104@xtargets.com> <9619ddc90801161042p2f6a94n6a96a19f4f8f42e8@mail.gmail.com> <9619ddc90801161049u725a2e2bt9bdd2f3133808a03@mail.gmail.com> Message-ID: <5037b6e40801161127h4b3e623clfb9604d6d82304d6@mail.gmail.com> On Jan 16, 2008 10:49 AM, Andrew Chen wrote: > Rake experts, > > I still have problem to control the exact order of the compilation. > > I have a_test.f90, b_test.f90 file. From those files, I have a > pre-processor, that will generate: > fruit_basket.f90, and fruit_driver.f90 files. > > The question is, I want make sure the order of compilation is: > a.f90, b.f90, fruit_basket.f90, and fruit_driver.f90 > > I used the file tasks: > rule '.o' => '.f90' do |t| > Rake::Task[:dirs].invoke > sh "#{$compiler} -c -o #{t.name} #{t.source} -module #{$build_dir} > #{lib_name_flag} #{lib_dir_flag}" > end You can add this: file('fruit_driver.f90'=>'fruit_basket.o') file('fruit_basket.f90'=>'b.o') file('b.f90'=>'a.o') Or do something like this: task 'compile'=>['a.o', 'b.o', 'fruit_basket.o', 'fruit_driver.o'] -- Assaf http://labnotes.org > > Question: how do I add the rules that will allow names with certain > patterns compiled last? > > My working files are located here: > http://fortranxunit.cvs.sourceforge.net/fortranxunit/fruit/sample/test/rakefile > , and http://fortranxunit.cvs.sourceforge.net/fortranxunit/fruit/rake_base.rb > > Thanks > ~Andrew Chen > > _______________________________________________ > Rake-devel mailing list > Rake-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rake-devel > From bradphelan at xtargets.com Wed Jan 16 14:53:44 2008 From: bradphelan at xtargets.com (Brad Phelan) Date: Wed, 16 Jan 2008 20:53:44 +0100 Subject: [Rake-devel] How to execute before the '.o' => '.f90' tasks? In-Reply-To: <9619ddc90801161042p2f6a94n6a96a19f4f8f42e8@mail.gmail.com> References: <9619ddc90801080832q52f50525u1b406ce98438bb4e@mail.gmail.com> <9619ddc90801080832l67f16489v4d30b99ffc71c871@mail.gmail.com> <4784899F.5040104@xtargets.com> <9619ddc90801161042p2f6a94n6a96a19f4f8f42e8@mail.gmail.com> Message-ID: <478E60C8.1020407@xtargets.com> Andrew Chen wrote: > Sorry, this email was never sent out due to mailing list problems. > Here it is again... > > ---- > > Brad, > > Thanks for your input. > > SCons is a good tool. I investigated in SCons 4 years ago. What I > had problem with SCons was that it insisted on knowing too much about > the language to be built. It builds internal dependencies. At that > time, it does understand much of new FORTRAN 95 syntax, and we spent a > few days trying to write a F95 parser for SCons, and that turned me > off. Maybe my knowledge is limited on new SCons features. > > My build environment is mixed FORTRAN (F66, F90), C, Java. I need > finer control of what the build tool would do. > > What's good about Rake (and make included) is, it separate concerns > language parser and a build tool. > The language parser or Scanner as the SCons folks prefer to call is a modular as you wish it to be. It's only unseperated in that both everything is written in Python. I've written a few Scanners for SCons for custom builders and at least one for Rake. I ported the Rant C scanner to Rake. It may give you some inspiration for a Fortran one if you use Rake. http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/264870 It seems that Fortran 95 support was added to SCons in 2004 if you want to take another peek. Regards Brad > > Also, I figured out a way to compile generated code already (see > http://fortranxunit.cvs.sourceforge.net/fortranxunit/fruit/sample/test/rakefile?view=markup) > > At the start of rake file, I included one call: > FruitProcessor.new.pre_process > > So that the generated files are created before SRC, and OBJ are built. > > I switched totally from make to rake in the FORTRAN unit testing > framework. It can handle multiple directories pretty well. And the > amount of code I need to write for a new package is very minimal. > > > Rake experts - is this a "preferred/better" way to handle generated > source files to be compiled? > > Thanks > ~Andrew Chen > > On 09/01/2008, bradphelan wrote: > >> Andrew Chen wrote: >> >>> Hi, >>> >>> First time to the list. Thanks for your good work. >>> >>> I'm trying to use Rake to compile some FORTRAN and C codes. >>> >>> I have a task: >>> >>> rule '.o' => '.f90' do |t| >>> sh "#{$compiler} -c -o #{t.name} #{t.source} -module #{$build_dir}" >>> end >>> >>> But I have another task: generate_code, this task will make some more >>> .f90 source files. >>> >>> I want to my generate code task to be executed before my rule '.o' >>> >>> Rake::Task[:gen].invoke if Rake::Task.task_defined?('gen') >>> >>> How to do that? >>> >>> >> I don't know but I played around with Rake for a while to build C/C++ >> and found it unsuitable. Whilst Rake is a great dependency tracking >> system for tasks it is not so great a tool for a general build system. I >> ended up turning to SCons which is a Python package though I prefer to >> do my general scripting in Ruby. >> >> The things that SCons does better >> >> - Construction environments >> - Hierarchical project management >> - Automatic clean rules >> - The ability to glob the dependency tree as well as the file system >> which is great for >> when using code generators >> - Many builders for C/C++/Fortran and others come by default with the >> SCons package. Most of the builders >> are automatically cross platform too. Windows/Linux builds are done >> with exactly the same commands. >> >> That being said I think the Rake notation is nicer than SCons because >> Ruby is a nicer language. However Rake seems to be used primarily in >> Ruby based projects and there is not much development effort in making >> it friendly to other areas. This is not a criticism. Rake seems >> extremely good at what it does for the customers that use it. However >> for a general build engine I would recommend at least a look at SCons. >> >> Regards >> >> Brad >> >> http://xtargets.com >> >> _______________________________________________ >> Rake-devel mailing list >> Rake-devel at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rake-devel >> >> > _______________________________________________ > Rake-devel mailing list > Rake-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rake-devel > From hangfei at gmail.com Wed Jan 16 16:44:38 2008 From: hangfei at gmail.com (Andrew Chen) Date: Wed, 16 Jan 2008 16:44:38 -0500 Subject: [Rake-devel] How to execute before the '.o' => '.f90' tasks? In-Reply-To: <5037b6e40801161127h4b3e623clfb9604d6d82304d6@mail.gmail.com> References: <9619ddc90801080832q52f50525u1b406ce98438bb4e@mail.gmail.com> <9619ddc90801080832l67f16489v4d30b99ffc71c871@mail.gmail.com> <4784899F.5040104@xtargets.com> <9619ddc90801161042p2f6a94n6a96a19f4f8f42e8@mail.gmail.com> <9619ddc90801161049u725a2e2bt9bdd2f3133808a03@mail.gmail.com> <5037b6e40801161127h4b3e623clfb9604d6d82304d6@mail.gmail.com> Message-ID: <9619ddc90801161344i182b2df2ke36cebb5fe4cf9e4@mail.gmail.com> Assaf: > file('fruit_driver.f90'=>'fruit_basket.o') > file('fruit_basket.f90'=>'b.o') > file('b.f90'=>'a.o') 1. I don't want to maintain the list of all the *.f90 file in the build file. I may have 20 of them. 2. The fruit_basket.f90 is generated code, it depending on all other *.f90 files in the directory. Is there a way I can add a rule like this? file('fruit_basket.f90'=>'*.o') or use ruby code to generate this file rule? Thanks ~Andrew Chen On 16/01/2008, Assaf Arkin wrote: > On Jan 16, 2008 10:49 AM, Andrew Chen wrote: > > Rake experts, > > > > I still have problem to control the exact order of the compilation. > > > > I have a_test.f90, b_test.f90 file. From those files, I have a > > pre-processor, that will generate: > > fruit_basket.f90, and fruit_driver.f90 files. > > > > The question is, I want make sure the order of compilation is: > > a.f90, b.f90, fruit_basket.f90, and fruit_driver.f90 > > > > I used the file tasks: > > rule '.o' => '.f90' do |t| > > Rake::Task[:dirs].invoke > > sh "#{$compiler} -c -o #{t.name} #{t.source} -module #{$build_dir} > > #{lib_name_flag} #{lib_dir_flag}" > > end > > You can add this: > > file('fruit_driver.f90'=>'fruit_basket.o') > file('fruit_basket.f90'=>'b.o') > file('b.f90'=>'a.o') > > Or do something like this: > > task 'compile'=>['a.o', 'b.o', 'fruit_basket.o', 'fruit_driver.o'] > > -- Assaf > http://labnotes.org > > > > > Question: how do I add the rules that will allow names with certain > > patterns compiled last? > > > > My working files are located here: > > http://fortranxunit.cvs.sourceforge.net/fortranxunit/fruit/sample/test/rakefile > > , and http://fortranxunit.cvs.sourceforge.net/fortranxunit/fruit/rake_base.rb > > > > Thanks > > ~Andrew Chen > > > > _______________________________________________ > > Rake-devel mailing list > > Rake-devel at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rake-devel > > > _______________________________________________ > Rake-devel mailing list > Rake-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rake-devel > From assaf at labnotes.org Wed Jan 16 17:18:10 2008 From: assaf at labnotes.org (Assaf Arkin) Date: Wed, 16 Jan 2008 14:18:10 -0800 Subject: [Rake-devel] How to execute before the '.o' => '.f90' tasks? In-Reply-To: <9619ddc90801161344i182b2df2ke36cebb5fe4cf9e4@mail.gmail.com> References: <9619ddc90801080832q52f50525u1b406ce98438bb4e@mail.gmail.com> <9619ddc90801080832l67f16489v4d30b99ffc71c871@mail.gmail.com> <4784899F.5040104@xtargets.com> <9619ddc90801161042p2f6a94n6a96a19f4f8f42e8@mail.gmail.com> <9619ddc90801161049u725a2e2bt9bdd2f3133808a03@mail.gmail.com> <5037b6e40801161127h4b3e623clfb9604d6d82304d6@mail.gmail.com> <9619ddc90801161344i182b2df2ke36cebb5fe4cf9e4@mail.gmail.com> Message-ID: <5037b6e40801161418p541ce3d6xb4f97edf12203e05@mail.gmail.com> On Jan 16, 2008 1:44 PM, Andrew Chen wrote: > Assaf: > > > file('fruit_driver.f90'=>'fruit_basket.o') > > file('fruit_basket.f90'=>'b.o') > > file('b.f90'=>'a.o') > > 1. I don't want to maintain the list of all the *.f90 file in the > build file. I may have 20 of them. > 2. The fruit_basket.f90 is generated code, it depending on all other > *.f90 files in the directory. > > Is there a way I can add a rule like this? > file('fruit_basket.f90'=>'*.o') # Determine all the .o files from the .f90 files. objs = FileList['*.f90'].map { |f| f.ext('o') } # Depends on everything but itself. file('fruit_basket.f90'=>objs - ['fruit_basket.o']) Assaf > > or use ruby code to generate this file rule? > > Thanks > ~Andrew Chen > > > On 16/01/2008, Assaf Arkin wrote: > > On Jan 16, 2008 10:49 AM, Andrew Chen wrote: > > > Rake experts, > > > > > > I still have problem to control the exact order of the compilation. > > > > > > I have a_test.f90, b_test.f90 file. From those files, I have a > > > pre-processor, that will generate: > > > fruit_basket.f90, and fruit_driver.f90 files. > > > > > > The question is, I want make sure the order of compilation is: > > > a.f90, b.f90, fruit_basket.f90, and fruit_driver.f90 > > > > > > I used the file tasks: > > > rule '.o' => '.f90' do |t| > > > Rake::Task[:dirs].invoke > > > sh "#{$compiler} -c -o #{t.name} #{t.source} -module #{$build_dir} > > > #{lib_name_flag} #{lib_dir_flag}" > > > end > > > > You can add this: > > > > file('fruit_driver.f90'=>'fruit_basket.o') > > file('fruit_basket.f90'=>'b.o') > > file('b.f90'=>'a.o') > > > > Or do something like this: > > > > task 'compile'=>['a.o', 'b.o', 'fruit_basket.o', 'fruit_driver.o'] > > > > -- Assaf > > http://labnotes.org > > > > > > > > Question: how do I add the rules that will allow names with certain > > > patterns compiled last? > > > > > > My working files are located here: > > > http://fortranxunit.cvs.sourceforge.net/fortranxunit/fruit/sample/test/rakefile > > > , and http://fortranxunit.cvs.sourceforge.net/fortranxunit/fruit/rake_base.rb > > > > > > Thanks > > > ~Andrew Chen > > > > > > _______________________________________________ > > > Rake-devel mailing list > > > Rake-devel at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rake-devel > > > > > _______________________________________________ > > Rake-devel mailing list > > Rake-devel at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rake-devel > > > _______________________________________________ > Rake-devel mailing list > Rake-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rake-devel > -- -- Assaf http://labnotes.org From hangfei at gmail.com Wed Jan 16 19:06:18 2008 From: hangfei at gmail.com (Andrew Chen) Date: Wed, 16 Jan 2008 19:06:18 -0500 Subject: [Rake-devel] How to execute before the '.o' => '.f90' tasks? In-Reply-To: <5037b6e40801161418p541ce3d6xb4f97edf12203e05@mail.gmail.com> References: <9619ddc90801080832q52f50525u1b406ce98438bb4e@mail.gmail.com> <9619ddc90801080832l67f16489v4d30b99ffc71c871@mail.gmail.com> <4784899F.5040104@xtargets.com> <9619ddc90801161042p2f6a94n6a96a19f4f8f42e8@mail.gmail.com> <9619ddc90801161049u725a2e2bt9bdd2f3133808a03@mail.gmail.com> <5037b6e40801161127h4b3e623clfb9604d6d82304d6@mail.gmail.com> <9619ddc90801161344i182b2df2ke36cebb5fe4cf9e4@mail.gmail.com> <5037b6e40801161418p541ce3d6xb4f97edf12203e05@mail.gmail.com> Message-ID: <9619ddc90801161606s5ffe33fbm6805441ce32a218d@mail.gmail.com> Assaf and all rake guys, Thanks, that works! I just released FRUIT, a FORTRAN unit testing framework on sourceforge. (https://sourceforge.net/projects/fortranxunit/) The FORTRAN stuff was not exciting, but those 2 points are worth mentioning: 1. Rake is really a flexible build system. It can handle many things over make file, such as handling generated source codes. It is astonishing to compare the size of rakefile and makefile (about 30 lines vs. 500 lines). I used one technique of rake_base, so that all common tasks are defined in this file, and each rakefile includes it. 2. I implemented rSpec features in FORTRAN, that is pretty cool :-) So that someone who have to do FORTRAN can make TDD, and executable requirements! Thanks ~Andrew Chen > # Determine all the .o files from the .f90 files. > objs = FileList['*.f90'].map { |f| f.ext('o') } > # Depends on everything but itself. > file('fruit_basket.f90'=>objs - ['fruit_basket.o']) > From jim.weirich at gmail.com Wed Jan 16 23:12:40 2008 From: jim.weirich at gmail.com (Jim Weirich) Date: Wed, 16 Jan 2008 23:12:40 -0500 Subject: [Rake-devel] How to execute before the '.o' => '.f90' tasks? In-Reply-To: <5037b6e40801161418p541ce3d6xb4f97edf12203e05@mail.gmail.com> References: <9619ddc90801080832q52f50525u1b406ce98438bb4e@mail.gmail.com> <9619ddc90801080832l67f16489v4d30b99ffc71c871@mail.gmail.com> <4784899F.5040104@xtargets.com> <9619ddc90801161042p2f6a94n6a96a19f4f8f42e8@mail.gmail.com> <9619ddc90801161049u725a2e2bt9bdd2f3133808a03@mail.gmail.com> <5037b6e40801161127h4b3e623clfb9604d6d82304d6@mail.gmail.com> <9619ddc90801161344i182b2df2ke36cebb5fe4cf9e4@mail.gmail.com> <5037b6e40801161418p541ce3d6xb4f97edf12203e05@mail.gmail.com> Message-ID: On Jan 16, 2008, at 5:18 PM, Assaf Arkin wrote: > > # Determine all the .o files from the .f90 files. > objs = FileList['*.f90'].map { |f| f.ext('o') } Or ... obj = FileList['*.f90'].ext('o') -- -- Jim Weirich -- jim.weirich at gmail.com From adam.q.salter at gmail.com Wed Jan 23 01:46:26 2008 From: adam.q.salter at gmail.com (Adam Salter) Date: Wed, 23 Jan 2008 17:46:26 +1100 Subject: [Rake-devel] Merge Task Arguments Patch for Rake Message-ID: <9F8BEC5C-4786-49BB-AF85-CB77BE88F58E@gmail.com> Dear all, I have been wanting to do something like the following with the new Rake task arguments, but it wasn't previously possible. task :my_task, :task_arg do |t, args| options = { :task_arg => "default_val"} args = options.merge(args) ... etc. end Here is a patch with updated tests to allow the above. I hope this is considered a good thing to do, as it really makes life a lot easier when using task arguments. Cheers, -Adam -------------- next part -------------- A non-text attachment was scrubbed... Name: merge_task_arguments.patch Type: application/octet-stream Size: 2895 bytes Desc: not available Url : http://rubyforge.org/pipermail/rake-devel/attachments/20080123/4c6035bb/attachment.obj -------------- next part -------------- From adamm at zombino.com Sat Jan 26 14:06:17 2008 From: adamm at zombino.com (Adam Majer) Date: Sat, 26 Jan 2008 13:06:17 -0600 Subject: [Rake-devel] Non-ruby stuff in tarball + broken unit test Message-ID: <479B84A9.9040406@zombino.com> Hi all, I just noticed that the tarball for rake contains a bunch of MacOS specific files that nothing to do with ruby. For example, adamm at mira:~/work/debian/rake/rake-0.8.1/lib/rake$ file .* .: directory ..: directory ._classic_namespace.rb: AppleDouble encoded Macintosh file ._clean.rb: AppleDouble encoded Macintosh file ._gempackagetask.rb: AppleDouble encoded Macintosh file ._packagetask.rb: AppleDouble encoded Macintosh file ._rake_test_loader.rb: AppleDouble encoded Macintosh file ._rdoctask.rb: AppleDouble encoded Macintosh file ._ruby182_test_unit_fix.rb: AppleDouble encoded Macintosh file ._runtest.rb: AppleDouble encoded Macintosh file ._tasklib.rb: AppleDouble encoded Macintosh file ._testtask.rb: AppleDouble encoded Macintosh file Furthermore, the test/data/unittest/subdir directory is missing making the rakefile execution from a subdirectory unit test test_load_rakefile_from_subdir in test_application.rb Cheers, Adam From adamm at zombino.com Mon Jan 28 00:35:43 2008 From: adamm at zombino.com (Adam Majer) Date: Sun, 27 Jan 2008 23:35:43 -0600 Subject: [Rake-devel] Rake unit tests broken on ext3 FS Message-ID: <479D69AF.8020707@zombino.com> The unit tests below work perfectly on ext2 and xfs. They break on a default ext3 filesystem. 1) Failure: test_inspect_pending(TestFileList) [./test/test_filelist.rb:212]: <"[\"testdata/abc.c\", \"testdata/abc.h\", \"testdata/abc.x\"]"> expected but was <"[\"testdata/abc.x\", \"testdata/abc.h\", \"testdata/abc.c\"]">. 2) Failure: test_to_s_pending(TestFileList) [./test/test_filelist.rb:207]: <"testdata/abc.c testdata/abc.h testdata/abc.x"> expected but was <"testdata/abc.x testdata/abc.h testdata/abc.c">. The problem seems to be that rake does not order the file list, just relies on the underlying file system to return it in the "correct" order. For the complete bug report, see http://bugs.debian.org/462817 Any thoughts? Or the fix is just to use sort after resolve_add is done? - Adam From adamm at zombino.com Mon Jan 28 00:46:12 2008 From: adamm at zombino.com (Adam Majer) Date: Sun, 27 Jan 2008 23:46:12 -0600 Subject: [Rake-devel] Rake unit tests broken on ext3 FS In-Reply-To: <479D69AF.8020707@zombino.com> References: <479D69AF.8020707@zombino.com> Message-ID: <479D6C24.6030502@zombino.com> Just a quick followup, the Dir[ pattern ] results in reverse order on ext3 from ext2 or xfs in my testing. The result is the unit tests fail on ext3. I guess one fix is to sort all output from Dir[pattern]. - Adam From jim.weirich at gmail.com Mon Jan 28 01:06:49 2008 From: jim.weirich at gmail.com (Jim Weirich) Date: Mon, 28 Jan 2008 01:06:49 -0500 Subject: [Rake-devel] Non-ruby stuff in tarball + broken unit test In-Reply-To: <479B84A9.9040406@zombino.com> References: <479B84A9.9040406@zombino.com> Message-ID: On Jan 26, 2008, at 2:06 PM, Adam Majer wrote: > Hi all, > > I just noticed that the tarball for rake contains a bunch of MacOS > specific files that nothing to do with ruby. Thanks. This is an annoying "feature" of the tar command on Macs that is really annoying. Especially so since it's invisible to me unless I explicitly check for it. I've updated my profile so it shouldn't do this by default. > Furthermore, the test/data/unittest/subdir directory is missing making > the rakefile execution from a subdirectory unit test Thanks, fixed. > Just a quick followup, the > > Dir[ pattern ] > > results in reverse order on ext3 from ext2 or xfs in my testing. The > result is the unit tests fail on ext3. FileList shouldn't assume any particular order. That's a bug in the test that is assuming too much. -- -- Jim Weirich -- jim.weirich at gmail.com From jim.weirich at gmail.com Mon Jan 28 01:23:21 2008 From: jim.weirich at gmail.com (Jim Weirich) Date: Mon, 28 Jan 2008 01:23:21 -0500 Subject: [Rake-devel] Rake unit tests broken on ext3 FS In-Reply-To: <479D69AF.8020707@zombino.com> References: <479D69AF.8020707@zombino.com> Message-ID: <2E0D20BC-A2C8-4599-AB71-4A0F8C4EC4D6@gmail.com> On Jan 28, 2008, at 12:35 AM, Adam Majer wrote: > The problem seems to be that rake does not order the file list, just > relies on the underlying file system to return it in the "correct" > order. Fixed in subversion. The test now checks that the string is properly formatted, not that the individual elements are in any particular order. -- -- Jim Weirich -- jim.weirich at gmail.com From adamm at zombino.com Wed Jan 30 00:29:30 2008 From: adamm at zombino.com (Adam Majer) Date: Tue, 29 Jan 2008 23:29:30 -0600 Subject: [Rake-devel] Destroying and/or redefining a task Message-ID: <47A00B3A.8090606@zombino.com> Hi, For example, let's say an application has a default rakefile includes that include's a task defined as, .... namespace :a task :b do blah_blah( blah ) end end .... Then in the rakefile I have is require 'default_tasks.rb' namespace :a task :b do my_blah( foo_foo ) end end I want the second task a:b to replace the default one. As it is right now, the default one is executed as is my own task. So two questions arise, 1. How do I get a task redefined? 2. How can I remove the original task from available tasks? Cheers, Adam PS. The a:b task is also called by some other tasks from the original rakefile so a replacement or redefinition is probably what is best in my case. From kondzior.p at gmail.com Wed Jan 30 05:12:21 2008 From: kondzior.p at gmail.com (=?UTF-8?Q?Pawe=C5=82_Kondzior?=) Date: Wed, 30 Jan 2008 11:12:21 +0100 Subject: [Rake-devel] Rake and --directory option Message-ID: Hello, about 2 years ago someone posted patch for rake to be abbe to change current working directory before doing any tasks, this future is great when you want to use rake and crontab, its easier to change directory from rake than from sh, is there any chance to see this patch in rake trunk and next release of rake ? Here is a post about patch http://rubyforge.org/pipermail/rake-devel/2006-March/000194.html -- Pawel Kondzior From andrea.fazzi at alca.le.it Wed Jan 30 08:54:43 2008 From: andrea.fazzi at alca.le.it (Andrea Fazzi) Date: Wed, 30 Jan 2008 14:54:43 +0100 Subject: [Rake-devel] Rake and --directory option In-Reply-To: References: Message-ID: <47A081A3.9040407@alca.le.it> Pawe? Kondzior ha scritto: > Hello, about 2 years ago someone posted patch for rake to be abbe to > change current working directory before doing any tasks, this future > is great when you want to use rake and crontab, its easier to change > directory from rake than from sh, is there any chance to see this > patch in rake trunk and next release of rake ? > > Here is a post about patch > http://rubyforge.org/pipermail/rake-devel/2006-March/000194.html > > On December 2006 I submitted the following patch to ruby-talk: http://groups.google.it/group/ruby-talk-google/browse_thread/thread/11f28c87a28f276d/225ebe1cc745ec34?hl=it&lnk=st&q=andrea+fazzi+rake+patch#225ebe1cc745ec34 Bye. Andrea Fazzi From jim.weirich at gmail.com Wed Jan 30 09:30:57 2008 From: jim.weirich at gmail.com (Jim Weirich) Date: Wed, 30 Jan 2008 09:30:57 -0500 Subject: [Rake-devel] Rake and --directory option In-Reply-To: <47A081A3.9040407@alca.le.it> References: <47A081A3.9040407@alca.le.it> Message-ID: On Jan 30, 2008, at 8:54 AM, Andrea Fazzi wrote: > Pawe? Kondzior ha scritto: >> Hello, about 2 years ago someone posted patch for rake to be abbe to >> change current working directory before doing any tasks, this future >> is great when you want to use rake and crontab, its easier to change >> directory from rake than from sh, is there any chance to see this >> patch in rake trunk and next release of rake ? >> >> Here is a post about patch >> http://rubyforge.org/pipermail/rake-devel/2006-March/000194.html >> >> > On December 2006 I submitted the following patch to ruby-talk: > > http://groups.google.it/group/ruby-talk-google/browse_thread/thread/ > 11f28c87a28f276d/225ebe1cc745ec34?hl=it&lnk=st&q=andrea+fazzi+rake > +patch#225ebe1cc745ec34 Since rake automatically changes directories to the directory containing the rakefile, why not just specify the rakefile directly (with the -f) option? -- -- Jim Weirich -- jim.weirich at gmail.com From hgs at dmu.ac.uk Wed Jan 30 09:41:32 2008 From: hgs at dmu.ac.uk (Hugh Sasse) Date: Wed, 30 Jan 2008 14:41:32 +0000 (WET) Subject: [Rake-devel] Rake and --directory option In-Reply-To: References: <47A081A3.9040407@alca.le.it> Message-ID: On Wed, 30 Jan 2008, Jim Weirich wrote: > On Jan 30, 2008, at 8:54 AM, Andrea Fazzi wrote: > > > Pawe?? Kondzior ha scritto: > >> Hello, about 2 years ago someone posted patch for rake to be abbe to > >> change current working directory before doing any tasks, this future > [...] > > Since rake automatically changes directories to the directory > containing the rakefile, why not just specify the rakefile directly > (with the -f) option? You might want to keep the rakefile outside to work for work on a directory that regularly gets messed up. And Ruby has a -C option, so for the same reasons as that. > Hugh From hgs at dmu.ac.uk Wed Jan 30 09:57:07 2008 From: hgs at dmu.ac.uk (Hugh Sasse) Date: Wed, 30 Jan 2008 14:57:07 +0000 (WET) Subject: [Rake-devel] Rake and --directory option In-Reply-To: References: <47A081A3.9040407@alca.le.it> Message-ID: On Wed, 30 Jan 2008, I wrote: > You might want to keep the rakefile outside to work for work on a s/work for//; Hugh From jim.weirich at gmail.com Wed Jan 30 10:12:52 2008 From: jim.weirich at gmail.com (Jim Weirich) Date: Wed, 30 Jan 2008 10:12:52 -0500 Subject: [Rake-devel] Rake and --directory option In-Reply-To: References: <47A081A3.9040407@alca.le.it> Message-ID: On Jan 30, 2008, at 9:41 AM, Hugh Sasse wrote: > You might want to keep the rakefile outside to work for work on a > directory that regularly gets messed up. And Ruby has a -C option, > so for the same reasons as that. Perhaps. But Rake has always guaranteed that the run directory is the location of the Rakefile, allowing Rakefiles to take advantage of that assumption. I hesitate to introduce an option that will give the illusion of working with arbitrary Rakefiles, but which will in fact break most of them. If a Rakefile is written *expecting* to be run from a different directory, that's OK. But if a Rakefile is written to expect a different directory, it can easily be written to change the directory itself. And since current versions of Rake allow easy parameter passing from the command line, I think I would rather see it done through the rakefile rather a rake command line option. -- -- Jim Weirich -- jim.weirich at gmail.com From hgs at dmu.ac.uk Wed Jan 30 10:34:00 2008 From: hgs at dmu.ac.uk (Hugh Sasse) Date: Wed, 30 Jan 2008 15:34:00 +0000 (WET) Subject: [Rake-devel] Rake and --directory option In-Reply-To: References: <47A081A3.9040407@alca.le.it> Message-ID: On Wed, 30 Jan 2008, Jim Weirich wrote: > On Jan 30, 2008, at 9:41 AM, Hugh Sasse wrote: > > > You might want to keep the rakefile outside to [...] work on a > > directory that regularly gets messed up. And Ruby has a -C option, > > so for the same reasons as that. > > Perhaps. But Rake has always guaranteed that the run directory is > the location of the Rakefile, allowing Rakefiles to take advantage of > that assumption. I hesitate to introduce an option that will give > the illusion of working with arbitrary Rakefiles, but which will in > fact break most of them. It could scream loudly at you before doing so. I agree that it should not be a default, and that your present choice is rarely not what people want. > > If a Rakefile is written *expecting* to be run from a different > directory, that's OK. But if a Rakefile is written to expect a > different directory, it can easily be written to change the directory > itself. And since current versions of Rake allow easy parameter > passing from the command line, I think I would rather see it done > through the rakefile rather a rake command line option. > OK. Then I suppose one case against the idea is that it will add another branch to many tests to give good coverage. Maybe this is a "fix it in the docs" case? :-) I wonder what Andrea thinks about that. Hugh From adamm at zombino.com Wed Jan 30 11:05:58 2008 From: adamm at zombino.com (Adam Majer) Date: Wed, 30 Jan 2008 10:05:58 -0600 Subject: [Rake-devel] Rake and --directory option In-Reply-To: References: Message-ID: <47A0A066.2060900@zombino.com> Pawe? Kondzior wrote: > its easier to change directory from rake than from sh * * * * * cd my_path_with_rakefile; rake Maybe it's just me, but I don't really understand what is so difficult about this. - Adam From adam.q.salter at gmail.com Wed Jan 30 17:47:14 2008 From: adam.q.salter at gmail.com (Adam Salter) Date: Thu, 31 Jan 2008 09:47:14 +1100 Subject: [Rake-devel] Rake and --directory option In-Reply-To: <47A0A066.2060900@zombino.com> References: <47A0A066.2060900@zombino.com> Message-ID: <3C4F045F-FB22-471E-BFA7-63398C33BB24@gmail.com> I think the poster meant they want the rake file in one directory, and rake to operate in another. I actually use Sake[1] for this, so: cd my_path_for_rakefile; sake my_task [1] http://errtheblog.com/posts/60-sake-bomb On 31/01/2008, at 3:05 AM, Adam Majer wrote: > Pawe? Kondzior wrote: >> its easier to change directory from rake than from sh > > * * * * * cd my_path_with_rakefile; rake > > Maybe it's just me, but I don't really understand what is so difficult > about this. > > - Adam > _______________________________________________ > Rake-devel mailing list > Rake-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rake-devel From adamm at zombino.com Thu Jan 31 12:08:27 2008 From: adamm at zombino.com (Adam Majer) Date: Thu, 31 Jan 2008 11:08:27 -0600 Subject: [Rake-devel] Destroying and/or redefining a task In-Reply-To: <47A00B3A.8090606@zombino.com> References: <47A00B3A.8090606@zombino.com> Message-ID: <47A2008B.3040900@zombino.com> I hate to be replying to myself, but is there a way of redefining already defined tasks? I figured out that rake adds the task to the current list of items executed for that task label. I'm guessing the functionality to remove the task is not supplied and a patch required? (and welcome? :) - Adam From jim.weirich at gmail.com Thu Jan 31 13:04:11 2008 From: jim.weirich at gmail.com (Jim Weirich) Date: Thu, 31 Jan 2008 13:04:11 -0500 Subject: [Rake-devel] Destroying and/or redefining a task In-Reply-To: <47A2008B.3040900@zombino.com> References: <47A00B3A.8090606@zombino.com> <47A2008B.3040900@zombino.com> Message-ID: On Jan 31, 2008, at 12:08 PM, Adam Majer wrote: > I hate to be replying to myself, but is there a way of redefining > already defined tasks? > > I figured out that rake adds the task to the current list of items > executed for that task label. I'm guessing the functionality to remove > the task is not supplied and a patch required? (and welcome? :) This has been a recent conversation in this list. Redefining tasks is a common request. I'm considering several approaches, but am looking for a way to make it easier for multiple plugins to work together (rather than the last plugin to just clobber the previous one). If you are looking for a particular patch, I think the list archives has several solutions (http://rubyforge.org/pipermail/rake-devel/). -- -- Jim Weirich -- jim.weirich at gmail.com