On 9 March 2012 04:48, Graydon Hoare <[email protected]> wrote: > On 3/7/2012 6:28 AM, Grahame Bowland wrote: > >> Hi all >> >> I've been wondering what the plan is in terms of build infrastructure >> for rust programmers. I'm working on a project using rust, and am using >> a shell script to compile. I've considered using a makefile, but the >> name of the output file for a crate isn't constant. >> >> I don't mind working on this if nobody else has looked at it. If it's >> already a solved problem but just isn't in the tutorial, I'll summarise >> responses and add a chapter to the tutorial :-) >> > > There are a few possibilities. > > - Add a flag to rustc like --print-lib-filename that asks it to > construct the filename it _would_ produce for a given crate, and > echo that back. This is not terribly hard; the hash you see in the > output filename is calculated from the crate linkage metadata, > not the compiled bits themselves. So it can be calculated quickly > just be parsing the crate file. > > - Modify your project, as rust's build system currently does, to touch > a stamp-file with a similar name in the output directory. When we > currently build we do "rustc ... foo.rc && touch libfoo.so". The > actual output will be libfoo-<hash>-<vers>.so, but it sits next to > the empty file libfoo.so we touched, and this seems to work ok in > practice. We then carefully use globs to pick up the versioned > files elsewhere. > > - Pass an explicit output filename. Mangling the hash and version > string into the filename is something rustc does as a convenience > to avoid name collision in installation directories. Multiple libs > with the same symbolic name can coexist; the compiler searches them > all for a metadata match when you 'use' a library. But it works > (or should work!) just as well if you set the output name explicitly > using -o to a filename that happens to have the right symbolic name > prefix: "rustc -o libfoo.so foo.rc" ought to work. > > The latter two work today. The first doesn't, but I'd be happy to see a > patch that implements it. Might do so myself, it's clearly helpful to > making robust makefiles. > > Longer term, Brian's right, we have to decide how to balance > responsibilities between cargo and rustc. That's a conversation we haven't > spent much time on lately, but it will have to happen eventually.
Hi Graydon and everyone Sorry I didn't reply earlier, have been quite busy. I think what I'll do then is pinch the rules rustc's build system is using, and see if I can come up with a simple "getting started" skeleton rust project Makefile. That should be helpful to get developers started. I'll email back the results once I'm done. Cheers Grahame
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
