|
29 | 29 | 'devices.wasm_standalone', |
30 | 30 | 'Preferences for the WebAsm backend', |
31 | 31 | emsdk_directory=BrianPreference( |
32 | | - docs='''Path to the emsdk directory, containing the emsdk binary.''', |
33 | | - default='' |
| 32 | + default="", |
| 33 | + docs=""" |
| 34 | + Absolute path to the *emsdk* installation. Leave empty to use the |
| 35 | + EMSDK/CONDA_EMSDK_DIR environment variables or an already-activated |
| 36 | + emsdk in your shell. |
| 37 | + """, |
34 | 38 | ), |
35 | 39 | emsdk_version=BrianPreference( |
36 | | - docs='''Version of the emsdk to use, defaults to "latest"''', |
37 | | - default="latest" |
| 40 | + default="latest", |
| 41 | + docs=""" |
| 42 | + Version string passed to ``emsdk activate`` (e.g. ``"3.1.56"``). |
| 43 | + Ignored when *emsdk_directory* is empty and the SDK is pre-activated. |
| 44 | + """, |
38 | 45 | ), |
39 | 46 | emcc_compile_args=BrianPreference( |
40 | | - default=[ |
41 | | - "-w" |
42 | | - ], |
43 | | - docs="Extra flags appended to every emcc compile command", |
| 47 | + default=["-w"], |
| 48 | + docs=""" |
| 49 | + Extra flags appended to every *emcc* **compile** command. |
| 50 | + Example: ``["-O3", "-sASSERTIONS"]``. |
| 51 | + """, |
44 | 52 | ), |
45 | 53 | emcc_link_args=BrianPreference( |
46 | 54 | default=[], |
47 | | - docs="Extra flags passed at link time", |
| 55 | + docs=""" |
| 56 | + Extra flags appended to the final *emcc* **link** command that produces |
| 57 | + ``wasm_module.js`` / ``.wasm``. |
| 58 | + Example: ``["-sEXPORT_ES6", "-sEXPORTED_RUNTIME_METHODS=['cwrap']"]``. |
| 59 | + """, |
48 | 60 | ), |
49 | 61 | ) |
50 | 62 |
|
@@ -397,6 +409,43 @@ def run(self, directory, results_directory, with_output, run_args): |
397 | 409 | self.timers['run_binary'] = time.time() - start_time |
398 | 410 |
|
399 | 411 | def build(self, html_file=None, html_content=None, **kwds): |
| 412 | + """ |
| 413 | + Build the project for the WASM backend. |
| 414 | +
|
| 415 | + Parameters |
| 416 | + ---------- |
| 417 | + directory : str, optional |
| 418 | + Target folder for the generated project. If ``None`` a temporary |
| 419 | + directory is created. Default: ``"output"``. |
| 420 | + results_directory : str, optional |
| 421 | + Relative sub-folder used at runtime to store simulation results. |
| 422 | + Default: ``"results"``. |
| 423 | + compile : bool, optional |
| 424 | + Compile the generated sources with *emcc*. Default: ``True``. |
| 425 | + run : bool, optional |
| 426 | + Execute the produced JavaScript/WASM bundle after a successful |
| 427 | + build (headless node-style run). Default: ``True``. |
| 428 | + debug : bool, optional |
| 429 | + Add debug symbols and ``-g -DDEBUG`` flags. Default: ``False``. |
| 430 | + clean : bool, optional |
| 431 | + Remove previously compiled objects before building. Default: |
| 432 | + ``False``. |
| 433 | + with_output : bool, optional |
| 434 | + Forward the program’s stdout/stderr when running. Default: |
| 435 | + ``True``. |
| 436 | + additional_source_files : list[str] | None |
| 437 | + Extra ``.cpp`` files to compile alongside the generated Brian code. |
| 438 | + run_args : list[str] | None |
| 439 | + Additional command-line arguments passed to the executable HTML/ |
| 440 | + JS harness when *run* is ``True``. |
| 441 | + direct_call : bool, optional |
| 442 | + ``True`` when invoked by user code, ``False`` when invoked |
| 443 | + automatically because ``build_on_run=True``. |
| 444 | + **kwds |
| 445 | + Reserved for future keyword arguments; passing unknown names |
| 446 | + raises ``TypeError``. |
| 447 | + """ |
| 448 | + |
400 | 449 | self.build_options.update({'html_file': html_file, |
401 | 450 | 'html_content': html_content}) |
402 | 451 |
|
|
0 commit comments