Right now #[link] only takes library names (it gets passed through as a -l flag).
It doesn't seem much more brittle to use -C link-args than to have absolute paths, so you may wish to explore that route. On Wed, Mar 5, 2014 at 1:12 AM, Doug <[email protected]> wrote: > Hey~ > > I've been trying to hook rust up the v8 VM to play with, and although I've > got it working, it's kind of annoying to do. > > In CMake you can extract a list of build targets using something like: > > function(get_dependent_targets TARGET RETURN) > get_property(LOC TARGET ${TARGET} PROPERTY LOCATION) > set(RTN ${LOC}) > get_property(LIBS TARGET ${TARGET} PROPERTY LINK_LIBRARIES) > foreach(LIB ${LIBS}) > get_dependent_targets(${LIB} LIB_LIST) > foreach(LIBI ${LIB_LIST}) > list(APPEND RTN ${LIBI}) > endforeach() > endforeach() > set(${RETURN} ${RTN} PARENT_SCOPE) > endfunction() > > That generates a list of the absolute paths to the libraries you're linking > against for your target. > > So in my case I have some light V8 interop libraries in libv8i, and the > output list of static libraries to link against is: > > /Users/doug/projects/rust/rust-v8/build/libv8i.a > /Users/doug/projects/rust/rust-v8/build/src/v8/out/native/libv8_base.x64.a > /Users/doug/projects/rust/rust-v8/build/src/v8/out/native/libv8_snapshot.a > /Users/doug/projects/rust/rust-v8/build/src/v8/out/native/libicudata.a > /Users/doug/projects/rust/rust-v8/build/src/v8/out/native/libicui18n.a > /Users/doug/projects/rust/rust-v8/build/src/v8/out/native/libicuuc.a > > Now, what do I do with that list to link with rustc? > > I tried generating an include using a template, and the output was along the > lines of: > > #[link(name = "/Users/doug/projects/rust/rust-v8/build/libv8i.a", kind = > "static")] > #[link(name = > "/Users/doug/projects/rust/rust-v8/build/src/v8/out/native/libv8_base.x64.a", > kind = "static")] > #[link(name = > "/Users/doug/projects/rust/rust-v8/build/src/v8/out/native/libv8_snapshot.a", > kind = "static")] > #[link(name = > "/Users/doug/projects/rust/rust-v8/build/src/v8/out/native/libicudata.a", > kind = "static")] > #[link(name = > "/Users/doug/projects/rust/rust-v8/build/src/v8/out/native/libicui18n.a", > kind = "static")] > #[link(name = > "/Users/doug/projects/rust/rust-v8/build/src/v8/out/native/libicuuc.a", kind > = "static")] > extern { > ... etc. > } > > ...but that doesn't work. Instead I've had to fudge my template down to > non-absolute paths, and invoke it like this: > > rustc package.rs -Lbuild -Lbuild/src/v8/out/native > > It's not a huge deal in this trivial example, but as the number of > dependencies increases you end up stuck either have an absolutely massive > rustc call script to generate (or something like that), or having to copy > all your static libraries into a single folder post-build. > > So TLDR; is there some way to specify an absolute path for #[link]? > > (I did see #[link_args] but that's not portable as I understand it) > > ~ > Doug. > > > _______________________________________________ > Rust-dev mailing list > [email protected] > https://mail.mozilla.org/listinfo/rust-dev > _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
