diff --git a/mozjs/src/generate_wrappers.sh b/mozjs/src/generate_wrappers.sh index 0a2e9ad65ff..52a5a8c5b4e 100755 --- a/mozjs/src/generate_wrappers.sh +++ b/mozjs/src/generate_wrappers.sh @@ -27,12 +27,16 @@ grep_heur() { grep -v 'MutableHandleObjectVector' # GetDebuggeeGlobals has it } -# clone file and reformat -cp target/debug/build/mozjs_sys-*/out/build/jsapi.rs target/jsapi.rs -rustfmt target/jsapi.rs --config max_width=1000 -cp target/debug/build/mozjs-*/out/gluebindings.rs target/glue.rs -rustfmt target/glue.rs --config max_width=1000 +# usage find_latest_version_of_file_and_parse $input_file $out_wrapper_module_name +find_latest_version_of_file_and_parse() { + # clone file and reformat (this is needed for grep_heur to work properly) + # this $(find) only gets last modified file + cp $(find target -name "$1" -printf "%T@ %p\n" | sort -n | tail -n 1 | tr ' ' '\n' | tail -n 1) "target/wrap_$1" + rustfmt "target/wrap_$1" --config max_width=1000 + + # parse reformated file + grep_heur "target/wrap_$1" | $gsed 's/\(.*\)/wrap!('"$2"': \1);/g' > "mozjs/src/$2_wrappers.in" +} -# parse file -grep_heur target/jsapi.rs | $gsed 's/\(.*\)/wrap!(jsapi: \1);/g' > mozjs/src/jsapi_wrappers.in -grep_heur target/glue.rs | $gsed 's/\(.*\)/wrap!(glue: \1);/g' > mozjs/src/glue_wrappers.in +find_latest_version_of_file_and_parse jsapi.rs jsapi +find_latest_version_of_file_and_parse gluebindings.rs glue