fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
53830aa0
patching
1"""Rust WASM-bindgen rules for interfacing with aspect-build/rules_js""" 2 3load ( "@aspect_rules_js//js:providers.bzl" , "js_info" ) 4load ( "//wasm_bindgen/private:wasm_bindgen.bzl" , "WASM_BINDGEN_ATTR" , "rust_wasm_bindgen_action" ) 5 6def _js_rust_wasm_bindgen_impl ( ctx ): 7toolchain = ctx . toolchains [ Label ( "//wasm_bindgen:toolchain_type" )] 8 9info = rust_wasm_bindgen_action ( 10ctx = ctx , 11toolchain = toolchain , 12wasm_file = ctx . attr . wasm_file , 13target_output = ctx . attr . target , 14bindgen_flags = ctx . attr . bindgen_flags , 15) 16 17# Return a structure that is compatible with the deps[] of a ts_library. 18declarations = info . ts 19es5_sources = info . js 20 21return [ 22DefaultInfo ( 23files = depset ([ info . wasm ], transitive = [ info . js , info . ts ]), 24), 25info , 26js_info ( 27declarations = declarations , 28sources = es5_sources , 29transitive_declarations = declarations , 30transitive_sources = es5_sources , 31), 32] 33 34js_rust_wasm_bindgen = rule ( 35doc = """\ 36Generates javascript and typescript bindings for a webassembly module using [wasm-bindgen][ws] that interface with [aspect-build/rules_js][abjs]. 37 38[ws]: https://rustwasm.github.io/docs/wasm-bindgen/ 39[abjs]: https://github.com/aspect-build/rules_js 40 41An example of this rule in use can be seen at [@rules_rust//examples/wasm_bindgen/rules_js](../examples/wasm_bindgen/rules_js) 42""" , 43implementation = _js_rust_wasm_bindgen_impl , 44attrs = WASM_BINDGEN_ATTR , 45toolchains = [ 46str ( Label ( "//wasm_bindgen:toolchain_type" )), 47], 48)