Find a wasm/web asset (e.g. a ``.bc`` or ``.js`` file) under ``web/dist``. Specializes the asset search to the wasm build outputs that live under ``web/dist/wasm`` and ``web/dist``, anchored on ``TVM_HOME`` (when set) or the TVM source root otherwise. Parameters ----------
(name, optional=False)
| 25 | |
| 26 | |
| 27 | def find_wasm_lib(name, optional=False): |
| 28 | """Find a wasm/web asset (e.g. a ``.bc`` or ``.js`` file) under ``web/dist``. |
| 29 | |
| 30 | Specializes the asset search to the wasm build outputs that live under |
| 31 | ``web/dist/wasm`` and ``web/dist``, anchored on ``TVM_HOME`` (when set) or |
| 32 | the TVM source root otherwise. |
| 33 | |
| 34 | Parameters |
| 35 | ---------- |
| 36 | name : str |
| 37 | The asset file name to look for. |
| 38 | |
| 39 | optional : bool |
| 40 | When True, return None instead of raising if the asset is not found. |
| 41 | |
| 42 | Returns |
| 43 | ------- |
| 44 | found : list(str) or None |
| 45 | List of matching paths, or None when ``optional`` and nothing is found. |
| 46 | """ |
| 47 | # use extra TVM_HOME environment for finding libraries. |
| 48 | if os.environ.get("TVM_HOME", None): |
| 49 | tvm_source_home_dir = os.environ["TVM_HOME"] |
| 50 | else: |
| 51 | tvm_source_home_dir = os.fspath(libinfo._dev_top_directory()) |
| 52 | |
| 53 | dll_path = [ |
| 54 | os.path.join(tvm_source_home_dir, "web", "dist", "wasm"), |
| 55 | os.path.join(tvm_source_home_dir, "web", "dist"), |
| 56 | ] |
| 57 | found = [os.path.join(p, name) for p in dll_path if os.path.isfile(os.path.join(p, name))] |
| 58 | if not found: |
| 59 | if optional: |
| 60 | return None |
| 61 | raise RuntimeError(f"Cannot find {name}; searched {dll_path}") |
| 62 | return found |
| 63 | |
| 64 | |
| 65 | def create_tvmjs_wasm(output, objects, options=None, cc="emcc", libs=None): |
no test coverage detected
searching dependent graphs…