fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
2bad96d9
cleanup
1"""Rust WASM-bindgen rules for interfacing with bazelbuild/rules_nodejs""" 2 3load ( "@rules_nodejs//nodejs:providers.bzl" , "DeclarationInfo" , "JSModuleInfo" ) 4load ( "//private:wasm_bindgen.bzl" , "WASM_BINDGEN_ATTR" , "rust_wasm_bindgen_action" ) 5 6def _nodejs_rust_wasm_bindgen_impl ( ctx ): 7toolchain = ctx . toolchains [ Label ( "//: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), 25DeclarationInfo ( 26declarations = declarations , 27transitive_declarations = declarations , 28type_blocklisted_declarations = depset ([]), 29), 30JSModuleInfo ( 31direct_sources = es5_sources , 32sources = es5_sources , 33), 34info , 35] 36 37nodejs_rust_wasm_bindgen = rule ( 38doc = """\ 39Generates javascript and typescript bindings for a webassembly module using [wasm-bindgen][ws] that interface with [bazelbuild/rules_nodejs][bbnjs]. 40 41[ws]: https://rustwasm.github.io/docs/wasm-bindgen/ 42[bbnjs]: https://github.com/bazelbuild/rules_nodejs 43""" , 44implementation = _nodejs_rust_wasm_bindgen_impl , 45attrs = WASM_BINDGEN_ATTR , 46toolchains = [ 47str ( Label ( "//:toolchain_type" )), 48], 49)