servo/rust-mozjs

Add a script to regenerate the bindings.

Closed this issue · 10 comments

Right now, the necessary knowledge is hidden in the minds of @michaelwu and maybe @vvuk. This is not a sustainable situation. We should ensure anyone can update the bindings with minimal work ASAP.

@michaelwu this is waiting for you.

Apparently @tschneidereit is planning to do this.

I want to have this happen automatically, including an upload to a public place, as happens for the jsshell packages.

I'm all for it happening automatically, but unless that will happen soon, I'd like to at least be able to do a manual upgrade.

Doing one more manual upgrade is all but required anyway. I'd like to do it
in a slightly more useful way than just mergin in a new SM dump, though: by
getting rid of the patches that're no longer required and upstreaming
(clean versions of) those that are. We have buy-in for that from the SM
team.

If you're blocked on this right now, I'm not opposed to a further "quick
and dirty" update before that, though. Otherwise: first half of January.

# Download and build mozjs
git clone git@github.com:servo/mozjs.git
cd mozjs
cargo build
cd ..

# Download and build clang
git clone https://github.com/llvm-mirror/llvm
cd llvm
git checkout release_37
cd tools
git clone https://github.com/llvm-mirror/clang
cd clang
git remote add mwu https://github.com/michaelwu/clang
git fetch mwu
git checkout release_37_smhacks
cd ../.. # llvm root dir
mkdir build
cd build
../configure --enable-optimized
make -sj8
cd ../..

# Download and build bindgen
git clone git@github.com:michaelwu/rust-bindgen.git
cd rust-bindgen
git checkout sm-hacks
# Fix to build with current master
LIBCLANG_PATH=../llvm/build/Release+Asserts/lib cargo build

# Generate bindings
LIBCLANG_PATH=../llvm/build/Release+Asserts/lib \
LD_LIBRARY_PATH=../llvm/build/Release+Asserts/lib \
cargo run \
../mozjs/mozjs/js/src/jsapi.hpp \
-allow-unknown-types \
-- \
-I ../mozjs/target/debug/build/mozjs_sys-*/out/dist/include/ \
-isystem /usr/lib/gcc/x86_64-linux-gnu/4.8.4/include \
-isystem /usr/lib/gcc/x86_64-linux-gnu/4.8.4/include-fixed/ \
-std=c++11 \
> jsapi.rs
nox commented

AFAICT, all the patches on release_37_smhacks are already in LLVM's master.

I upstreamed both of them. LLVM master isn't a release though, so that branch is still useful until a release is made with the patches. (if one hasn't been made yet)

jdm commented

Bindings are generated automatically.