Closed Bug 1319156 Opened 8 years ago Closed 8 years ago

Allow specifying cargo features for Rust libraries from moz.build

Categories

(Firefox Build System :: General, defect)

defect
Not set
normal

Tracking

(firefox53 fixed)

RESOLVED FIXED
mozilla53
Tracking Status
firefox53 --- fixed

People

(Reporter: manishearth, Assigned: froydnj)

References

Details

Attachments

(3 files)

It should be possible to set `RUST_LIBRARIES['foo'].features += ["random-feature"]` and have the contents passed to `--features` in `cargo build`
Ideally, people will just use the extra argument to RustLibrary to
define features for their library.
Attachment #8815310 - Flags: review?(cmanchester)
This commit also adds an overdue test for plain Rust libraries in the
recursivemake backend, but said test also serves to ensure that we don't
emit features for a library if none were defined in moz.build.
Attachment #8815313 - Flags: review?(cmanchester)
Blocks: oxidation
Attachment #8815310 - Flags: review?(cmanchester) → review+
Attachment #8815312 - Flags: review?(cmanchester) → review+
Comment on attachment 8815313 [details] [diff] [review]
part 3 - tests for Rust library features, frontend and backend

Review of attachment 8815313 [details] [diff] [review]:
-----------------------------------------------------------------

::: python/mozbuild/mozbuild/test/frontend/data/rust-library-features/moz.build
@@ +15,5 @@
> +    IS_RUST_LIBRARY = True
> +    RUST_LIBRARY_FEATURES = features
> +
> +
> +RustLibrary('random-crate', ['musthave', 'cantlivewithout'])

Do we get a nice error message is someone passes a string instead of a list for features?
Attachment #8815313 - Flags: review?(cmanchester) → review+
(In reply to Chris Manchester (:chmanchester) from comment #4)
> > +RustLibrary('random-crate', ['musthave', 'cantlivewithout'])
> 
> Do we get a nice error message is someone passes a string instead of a list
> for features?

I believe we'll get an exception when the non-list thing is assigned to RUST_LIBRARY_FEATURES in the template.  Is that sufficient, do you think, or should we try to provide a higher level error from the template itself?  (Can templates even raise exceptions?)
Flags: needinfo?(cmanchester)
Maybe we could do an explicit check and call `error` in the template, but really, that sounds fine.
Flags: needinfo?(cmanchester)
Pushed by nfroyd@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/8276296cd505
part 1 - add features to RustLibrary objects and moz.build definitions; r=chmanchester
https://hg.mozilla.org/integration/mozilla-inbound/rev/b5de6b777970
part 2 - handle Rust library features in the recursivemake backend; r=chmanchester
https://hg.mozilla.org/integration/mozilla-inbound/rev/db686076ae29
part 3 - tests for Rust library features, frontend and backend; r=chmanchester
Pushed by nfroyd@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/a7ab3fbb933f
followup - only assign RUST_LIBRARY_FEATURES when features are provided to RustLibrary; r=me
Blocks: 1321035
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: