Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Conversation

@kofigumbs
Copy link

Currently miniaudio-sys/build.rs uses the cfg! macro to determine the platform flags, but it seems like those values are not accurate for build.rs scripts. I think it's' implied by this part of the Cargo docs:

Cargo sets several environment variables when build scripts are run. Because these variables are not yet set when the build script is compiled, the above example using env! won't work and instead you'll need to retrieve the values when the build script is run:

This PR swaps the cfg! macro for the environment variables mentioned in the book. In my project, I encountered this when trying to cross-compile for wasm32 from macOS. Before the change, setting --target would have no effect on the miniaudio flags: I would still see cargo:rustc-cfg=feature="ma-enable-coreaudio" in the build log for instance. Now, when I target wasm32/emscripten, I see that the -webaudio is enabled and -coreaudio is not.

I see that you have a CI GitHub workflow, but please let me know if there's any other testing you'd like to see. I lifted the implementation from https://github.com/paritytech/rust-snappy/blob/1195dfa43e1e9b69464d5105d65ceea2619331c7/snappy-sys/build.rs#L26-L28

Fixes #39.

@kofigumbs kofigumbs changed the title Update build.rs for cross-compilation Update target checks to support cross-compilation Sep 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for cross compilation

1 participant