Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make running cbindgen with own create expansion from build.rs #371

Merged
merged 2 commits into from
Aug 6, 2019

Commits on Aug 3, 2019

  1. Run cargo expand outside the normal target directory

    When crates should get expanded, then cargo is run again from within cbindgen.
    When cbindgen is started from a build.rs file, this means that cargo is starting
    another cargo run.
    
    Cargo locks the directory it is running on. If two cargos spawn by each other
    run with the same target directory, then they both want to accquire a lock and
    hence deadlock.
    
    This commit fixes the problem with running the spawned cargo at a different
    directory. Please note that this will always be the same directory, hence
    any subsequent runs will be faster (as you would exepct it to be).
    
    This is part of mozilla#347.
    vmx committed Aug 3, 2019
    Configuration menu
    Copy the full SHA
    f69dd54 View commit details
    Browse the repository at this point in the history
  2. Don't call cbindgen recursively

    To expand a crate, cbindgen calls cargo on that crate. cbindgen can be called from a build.rs
    file. But if cargo is called again, it will also call cbindgen again and hence end up in an
    endless recursion.
    
    This commit makes sure that cbindgen isn't called again if it is already running.
    
    You can verify this fix with this minimal example https://github.com/vmx/cbindgen-expand-bug
    
    Fixes mozilla#347.
    vmx committed Aug 3, 2019
    Configuration menu
    Copy the full SHA
    8a73f80 View commit details
    Browse the repository at this point in the history