jakejs / jake

JavaScript build tool, similar to Make or Rake. Built to work with Node.js.
http://jakejs.com
Apache License 2.0
1.97k stars 190 forks source link

Rules should be able to define multiple sources/prereqs for a target #339

Open myklemykle opened 7 years ago

myklemykle commented 7 years ago

Normal file tasks allow any given file to have N dependencies, but the file tasks that are auto-generated (or simulated, or whatever) by rules can only have a single dependency. This is not quite how our file dependencies work, so I've had to do a lot of awkward workarounds.

One way this could work: if the second argument to rule() is a function, and that function returns an array of strings instead of a single string, then all of those strings should be considered prereq's. I think this might only take a little bit more logic in Rule.prototype, rule.js lines 260-275 (or so).

mde commented 7 years ago

You're absolutely right, the API for rule is a bit weird and different from the rest of the Jake API, obviously driven from the idea of its use as a rule-driven engine for compiling binaries from source files. It would be awesome having a bit more unity in the APIs, and allowing Rules to have multiple prereqs would be a great start.

Maybe a better way to approach it would be to allow that second argument to be either a single string or Array of string prereqs, which is how prereqs work for generic Jake tasks. Would you be at all interested in throwing together a PR that implements this?

myklemykle commented 7 years ago

Thanks for getting back to me! I can have a shot at it, it looked straightforward at first glance. But I havent looked at how yr test suite is set up, so i might ask yr advice on that. Ill be back at work next week.

-m-

IM IN MY IPHON MISPELIN UR W0RDZ

On Jun 18, 2017, at 2:26 PM, Matthew Eernisse notifications@github.com wrote:

You're absolutely right, the API for rule is a bit weird and different from the rest of the Jake API, obviously driven from the idea of its use as a rule-driven engine for compiling binaries from source files. It would be awesome having a bit more unity in the APIs, and allowing Rules to have multiple prereqs would be a great start.

Maybe a better way to approach it would be to allow that second argument to be either a single string or Array of string prereqs, which is how prereqs work for generic Jake tasks. Would you be at all interested in throwing together a PR that implements this?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

myklemykle commented 7 years ago

PR filed.

stephenfrancis commented 4 years ago

This sounds exactly like what I need. Did that PR get merged? Is Jake under active maintenance and development?