servo / rust-mozjs

DEPRECATED - moved to servo/mozjs instead.
Mozilla Public License 2.0
293 stars 122 forks source link

Updating Bindgen Instructions for Glue #563

Open Redfire75369 opened 1 year ago

Redfire75369 commented 1 year ago

I was looking to add a wrapper for JSExternalStringCallbacks so it could be used for rust, and I've updated jsglue.cpp for it.

I was wondering how I can update glue.rs since it seems to be automatically generated. I was looking at the instructions in comments in gen.py but it seems to be very outdated.

# To generate jsglue:
# DYLD_LIBRARY_PATH=~/versioned/rust-mozilla/build/llvm/x86_64-apple-darwin/Release+Asserts/lib/ ~/versioned/rust-bindgen/bindgen ./jsglue.c -I ../../build/src/mozjs/dist/include/ -match glue > glue.rs

# jdm used
# LD_LIBRARY_PATH=~/sdb/rust/build/llvm/x86_64-unknown-linux-gnu/Release+Asserts/lib/ ~/sdb/rust-bindgen/bindgen ./jsglue.c -I ../../build/src/mozjs/dist/include/ -isystem /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/ -match glue >glue.rs
# on Fedora 17
#
# and remember to mark all generated functions as #[rust_stack]

I think it would be useful if we updated this so that anyone can modify jsglue.cpp easily.

Here's the change I was trying to make: https://github.com/Redfire75369/rust-mozjs/commit/689394068b6318da63dca7444fe896fc455d064e

jdm commented 1 year ago

I actually strongly suspect that glue.rs has not been automatically generated for many years, and is only updated by hand.

Redfire75369 commented 1 year ago

Oh, that would certainly explain it. It seems gen.py was last updated 10 years ago, which explains the wrong command line arguments and the usage of gcc 4.8.

Redfire75369 commented 1 year ago

So far, the furthest I've gotten is this, but that seems to maybe generate a bunch of stuff that's not needed?

// cwd: ./src
bindgen jsglue.cpp --allow-file jsglue.cpp -- -std=c++17 -I ../target/debug/build/mozjs-1d605e44d5141b22/out -I ../target/debug/build/mozjs_sys-253b4187986dd3b4/out/build/dist/include