2023-05-30 03:15:58 +00:00
|
|
|
################################################################################
|
|
|
|
# Initial setup of Makefile environment.
|
|
|
|
|
|
|
|
# Select the variant to build for:
|
|
|
|
ifdef VARIANT_DIR
|
|
|
|
# Custom variant path - remove trailing slash and get the final component of
|
|
|
|
# the path as the variant name.
|
|
|
|
VARIANT ?= $(notdir $(VARIANT_DIR:/=))
|
|
|
|
else
|
|
|
|
# If not given on the command line, then default to standard.
|
|
|
|
VARIANT ?= standard
|
|
|
|
VARIANT_DIR ?= variants/$(VARIANT)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(wildcard $(VARIANT_DIR)/.),)
|
|
|
|
$(error Invalid VARIANT specified: $(VARIANT_DIR))
|
|
|
|
endif
|
|
|
|
|
|
|
|
# If the build directory is not given, make it reflect the variant name.
|
|
|
|
BUILD ?= build-$(VARIANT)
|
2018-01-19 07:35:42 +00:00
|
|
|
|
2023-05-30 03:15:58 +00:00
|
|
|
include ../../py/mkenv.mk
|
|
|
|
include $(VARIANT_DIR)/mpconfigvariant.mk
|
2018-01-19 07:35:42 +00:00
|
|
|
|
2023-05-30 03:15:58 +00:00
|
|
|
# Qstr definitions (must come before including py.mk).
|
2018-01-19 07:35:42 +00:00
|
|
|
QSTR_DEFS = qstrdefsport.h
|
|
|
|
|
2023-05-30 03:15:58 +00:00
|
|
|
# Include py core make definitions.
|
2018-01-19 07:35:42 +00:00
|
|
|
include $(TOP)/py/py.mk
|
2022-06-17 16:11:30 +00:00
|
|
|
include $(TOP)/extmod/extmod.mk
|
2018-01-19 07:35:42 +00:00
|
|
|
|
2023-05-30 03:15:58 +00:00
|
|
|
################################################################################
|
|
|
|
# Project specific settings and compiler/linker flags.
|
|
|
|
|
2021-06-24 00:04:15 +00:00
|
|
|
CC = emcc
|
|
|
|
LD = emcc
|
2023-05-30 03:15:58 +00:00
|
|
|
TERSER ?= npx terser
|
2018-01-19 07:35:42 +00:00
|
|
|
|
|
|
|
INC += -I.
|
|
|
|
INC += -I$(TOP)
|
|
|
|
INC += -I$(BUILD)
|
2023-05-30 03:15:58 +00:00
|
|
|
INC += -I$(VARIANT_DIR)
|
2018-01-19 07:35:42 +00:00
|
|
|
|
2021-06-24 00:04:15 +00:00
|
|
|
CFLAGS += -std=c99 -Wall -Werror -Wdouble-promotion -Wfloat-conversion
|
2022-11-07 04:11:14 +00:00
|
|
|
CFLAGS += -Os -DNDEBUG
|
2021-06-24 00:04:15 +00:00
|
|
|
CFLAGS += $(INC)
|
2018-01-19 07:35:42 +00:00
|
|
|
|
webassembly: Add JavaScript proxying, and js and jsffi modules.
This commit improves the webassembly port by adding:
- Proxying of Python objects to JavaScript with a PyProxy type that lives
on the JavaScript side. PyProxy implements JavaScript Proxy traps such
as has, get, set and ownKeys, to make Python objects have functionality
on the JavaScript side.
- Proxying of JavaScript objects to Python with a JsProxy type that lives
on the Python side. JsProxy passes through calls, attributes,
subscription and iteration from Python to JavaScript.
- A top-level API on the JavaScript side to construct a MicroPython
interpreter instance via `loadMicroPython()`. That function returns an
object that can be used to execute Python code, access the Python globals
dict, access the Emscripten filesystem, and other things. This API is
based on the API provided by Pyodide (https://pyodide.org/). As part of
this, the top-level file is changed from `micropython.js` to
`micropython.mjs`.
- A Python `js` module which can be used to access all JavaScript-side
symbols, for example the DOM when run within a browser.
- A Python `jsffi` module with various helper functions like
`create_proxy()` and `to_js()`.
- A dedenting lexer which automatically dedents Python source code if every
non-empty line in that source starts with a common whitespace prefix.
This is very helpful when Python source code is indented within a string
within HTML or JavaScript for formatting reasons.
Signed-off-by: Damien George <damien@micropython.org>
2023-05-31 01:45:34 +00:00
|
|
|
EXPORTED_FUNCTIONS_EXTRA += ,\
|
|
|
|
_mp_js_do_exec,\
|
2023-06-24 07:19:05 +00:00
|
|
|
_mp_js_do_exec_async,\
|
webassembly: Add JavaScript proxying, and js and jsffi modules.
This commit improves the webassembly port by adding:
- Proxying of Python objects to JavaScript with a PyProxy type that lives
on the JavaScript side. PyProxy implements JavaScript Proxy traps such
as has, get, set and ownKeys, to make Python objects have functionality
on the JavaScript side.
- Proxying of JavaScript objects to Python with a JsProxy type that lives
on the Python side. JsProxy passes through calls, attributes,
subscription and iteration from Python to JavaScript.
- A top-level API on the JavaScript side to construct a MicroPython
interpreter instance via `loadMicroPython()`. That function returns an
object that can be used to execute Python code, access the Python globals
dict, access the Emscripten filesystem, and other things. This API is
based on the API provided by Pyodide (https://pyodide.org/). As part of
this, the top-level file is changed from `micropython.js` to
`micropython.mjs`.
- A Python `js` module which can be used to access all JavaScript-side
symbols, for example the DOM when run within a browser.
- A Python `jsffi` module with various helper functions like
`create_proxy()` and `to_js()`.
- A dedenting lexer which automatically dedents Python source code if every
non-empty line in that source starts with a common whitespace prefix.
This is very helpful when Python source code is indented within a string
within HTML or JavaScript for formatting reasons.
Signed-off-by: Damien George <damien@micropython.org>
2023-05-31 01:45:34 +00:00
|
|
|
_mp_js_do_import,\
|
|
|
|
_mp_js_register_js_module,\
|
|
|
|
_proxy_c_init,\
|
|
|
|
_proxy_c_to_js_call,\
|
|
|
|
_proxy_c_to_js_delete_attr,\
|
|
|
|
_proxy_c_to_js_dir,\
|
|
|
|
_proxy_c_to_js_get_array,\
|
|
|
|
_proxy_c_to_js_get_dict,\
|
|
|
|
_proxy_c_to_js_get_type,\
|
|
|
|
_proxy_c_to_js_has_attr,\
|
|
|
|
_proxy_c_to_js_lookup_attr,\
|
2023-06-24 07:19:05 +00:00
|
|
|
_proxy_c_to_js_resume,\
|
webassembly: Add JavaScript proxying, and js and jsffi modules.
This commit improves the webassembly port by adding:
- Proxying of Python objects to JavaScript with a PyProxy type that lives
on the JavaScript side. PyProxy implements JavaScript Proxy traps such
as has, get, set and ownKeys, to make Python objects have functionality
on the JavaScript side.
- Proxying of JavaScript objects to Python with a JsProxy type that lives
on the Python side. JsProxy passes through calls, attributes,
subscription and iteration from Python to JavaScript.
- A top-level API on the JavaScript side to construct a MicroPython
interpreter instance via `loadMicroPython()`. That function returns an
object that can be used to execute Python code, access the Python globals
dict, access the Emscripten filesystem, and other things. This API is
based on the API provided by Pyodide (https://pyodide.org/). As part of
this, the top-level file is changed from `micropython.js` to
`micropython.mjs`.
- A Python `js` module which can be used to access all JavaScript-side
symbols, for example the DOM when run within a browser.
- A Python `jsffi` module with various helper functions like
`create_proxy()` and `to_js()`.
- A dedenting lexer which automatically dedents Python source code if every
non-empty line in that source starts with a common whitespace prefix.
This is very helpful when Python source code is indented within a string
within HTML or JavaScript for formatting reasons.
Signed-off-by: Damien George <damien@micropython.org>
2023-05-31 01:45:34 +00:00
|
|
|
_proxy_c_to_js_store_attr,\
|
|
|
|
_proxy_convert_mp_to_js_obj_cside
|
|
|
|
|
|
|
|
EXPORTED_RUNTIME_METHODS_EXTRA += ,\
|
|
|
|
PATH,\
|
|
|
|
PATH_FS,\
|
|
|
|
UTF8ToString,\
|
|
|
|
getValue,\
|
|
|
|
lengthBytesUTF8,\
|
|
|
|
setValue,\
|
|
|
|
stringToUTF8
|
|
|
|
|
2023-05-30 03:15:58 +00:00
|
|
|
JSFLAGS += -s EXPORTED_FUNCTIONS="\
|
webassembly: Add JavaScript proxying, and js and jsffi modules.
This commit improves the webassembly port by adding:
- Proxying of Python objects to JavaScript with a PyProxy type that lives
on the JavaScript side. PyProxy implements JavaScript Proxy traps such
as has, get, set and ownKeys, to make Python objects have functionality
on the JavaScript side.
- Proxying of JavaScript objects to Python with a JsProxy type that lives
on the Python side. JsProxy passes through calls, attributes,
subscription and iteration from Python to JavaScript.
- A top-level API on the JavaScript side to construct a MicroPython
interpreter instance via `loadMicroPython()`. That function returns an
object that can be used to execute Python code, access the Python globals
dict, access the Emscripten filesystem, and other things. This API is
based on the API provided by Pyodide (https://pyodide.org/). As part of
this, the top-level file is changed from `micropython.js` to
`micropython.mjs`.
- A Python `js` module which can be used to access all JavaScript-side
symbols, for example the DOM when run within a browser.
- A Python `jsffi` module with various helper functions like
`create_proxy()` and `to_js()`.
- A dedenting lexer which automatically dedents Python source code if every
non-empty line in that source starts with a common whitespace prefix.
This is very helpful when Python source code is indented within a string
within HTML or JavaScript for formatting reasons.
Signed-off-by: Damien George <damien@micropython.org>
2023-05-31 01:45:34 +00:00
|
|
|
_free,\
|
|
|
|
_malloc,\
|
2023-05-30 03:15:58 +00:00
|
|
|
_mp_js_init,\
|
|
|
|
_mp_js_init_repl,\
|
|
|
|
_mp_js_do_str,\
|
|
|
|
_mp_js_process_char,\
|
|
|
|
_mp_hal_get_interrupt_char,\
|
|
|
|
_mp_sched_keyboard_interrupt$(EXPORTED_FUNCTIONS_EXTRA)"
|
|
|
|
JSFLAGS += -s EXPORTED_RUNTIME_METHODS="\
|
|
|
|
ccall,\
|
|
|
|
cwrap,\
|
|
|
|
FS$(EXPORTED_RUNTIME_METHODS_EXTRA)"
|
|
|
|
JSFLAGS += --js-library library.js
|
|
|
|
JSFLAGS += -s SUPPORT_LONGJMP=emscripten
|
webassembly: Add JavaScript proxying, and js and jsffi modules.
This commit improves the webassembly port by adding:
- Proxying of Python objects to JavaScript with a PyProxy type that lives
on the JavaScript side. PyProxy implements JavaScript Proxy traps such
as has, get, set and ownKeys, to make Python objects have functionality
on the JavaScript side.
- Proxying of JavaScript objects to Python with a JsProxy type that lives
on the Python side. JsProxy passes through calls, attributes,
subscription and iteration from Python to JavaScript.
- A top-level API on the JavaScript side to construct a MicroPython
interpreter instance via `loadMicroPython()`. That function returns an
object that can be used to execute Python code, access the Python globals
dict, access the Emscripten filesystem, and other things. This API is
based on the API provided by Pyodide (https://pyodide.org/). As part of
this, the top-level file is changed from `micropython.js` to
`micropython.mjs`.
- A Python `js` module which can be used to access all JavaScript-side
symbols, for example the DOM when run within a browser.
- A Python `jsffi` module with various helper functions like
`create_proxy()` and `to_js()`.
- A dedenting lexer which automatically dedents Python source code if every
non-empty line in that source starts with a common whitespace prefix.
This is very helpful when Python source code is indented within a string
within HTML or JavaScript for formatting reasons.
Signed-off-by: Damien George <damien@micropython.org>
2023-05-31 01:45:34 +00:00
|
|
|
JSFLAGS += -s MODULARIZE -s EXPORT_NAME=_createMicroPythonModule
|
2023-05-30 03:15:58 +00:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Source files and libraries.
|
|
|
|
|
2021-07-09 04:19:15 +00:00
|
|
|
SRC_SHARED = $(addprefix shared/,\
|
|
|
|
runtime/interrupt_char.c \
|
|
|
|
runtime/stdout_helpers.c \
|
|
|
|
runtime/pyexec.c \
|
|
|
|
readline/readline.c \
|
2023-12-13 02:48:32 +00:00
|
|
|
timeutils/timeutils.c \
|
2018-01-19 07:35:42 +00:00
|
|
|
)
|
|
|
|
|
2023-05-30 03:15:58 +00:00
|
|
|
SRC_C += \
|
webassembly: Add JavaScript proxying, and js and jsffi modules.
This commit improves the webassembly port by adding:
- Proxying of Python objects to JavaScript with a PyProxy type that lives
on the JavaScript side. PyProxy implements JavaScript Proxy traps such
as has, get, set and ownKeys, to make Python objects have functionality
on the JavaScript side.
- Proxying of JavaScript objects to Python with a JsProxy type that lives
on the Python side. JsProxy passes through calls, attributes,
subscription and iteration from Python to JavaScript.
- A top-level API on the JavaScript side to construct a MicroPython
interpreter instance via `loadMicroPython()`. That function returns an
object that can be used to execute Python code, access the Python globals
dict, access the Emscripten filesystem, and other things. This API is
based on the API provided by Pyodide (https://pyodide.org/). As part of
this, the top-level file is changed from `micropython.js` to
`micropython.mjs`.
- A Python `js` module which can be used to access all JavaScript-side
symbols, for example the DOM when run within a browser.
- A Python `jsffi` module with various helper functions like
`create_proxy()` and `to_js()`.
- A dedenting lexer which automatically dedents Python source code if every
non-empty line in that source starts with a common whitespace prefix.
This is very helpful when Python source code is indented within a string
within HTML or JavaScript for formatting reasons.
Signed-off-by: Damien George <damien@micropython.org>
2023-05-31 01:45:34 +00:00
|
|
|
lexer_dedent.c \
|
2018-01-19 07:35:42 +00:00
|
|
|
main.c \
|
webassembly: Add JavaScript proxying, and js and jsffi modules.
This commit improves the webassembly port by adding:
- Proxying of Python objects to JavaScript with a PyProxy type that lives
on the JavaScript side. PyProxy implements JavaScript Proxy traps such
as has, get, set and ownKeys, to make Python objects have functionality
on the JavaScript side.
- Proxying of JavaScript objects to Python with a JsProxy type that lives
on the Python side. JsProxy passes through calls, attributes,
subscription and iteration from Python to JavaScript.
- A top-level API on the JavaScript side to construct a MicroPython
interpreter instance via `loadMicroPython()`. That function returns an
object that can be used to execute Python code, access the Python globals
dict, access the Emscripten filesystem, and other things. This API is
based on the API provided by Pyodide (https://pyodide.org/). As part of
this, the top-level file is changed from `micropython.js` to
`micropython.mjs`.
- A Python `js` module which can be used to access all JavaScript-side
symbols, for example the DOM when run within a browser.
- A Python `jsffi` module with various helper functions like
`create_proxy()` and `to_js()`.
- A dedenting lexer which automatically dedents Python source code if every
non-empty line in that source starts with a common whitespace prefix.
This is very helpful when Python source code is indented within a string
within HTML or JavaScript for formatting reasons.
Signed-off-by: Damien George <damien@micropython.org>
2023-05-31 01:45:34 +00:00
|
|
|
modjs.c \
|
|
|
|
modjsffi.c \
|
2018-01-19 07:35:42 +00:00
|
|
|
mphalport.c \
|
webassembly: Add JavaScript proxying, and js and jsffi modules.
This commit improves the webassembly port by adding:
- Proxying of Python objects to JavaScript with a PyProxy type that lives
on the JavaScript side. PyProxy implements JavaScript Proxy traps such
as has, get, set and ownKeys, to make Python objects have functionality
on the JavaScript side.
- Proxying of JavaScript objects to Python with a JsProxy type that lives
on the Python side. JsProxy passes through calls, attributes,
subscription and iteration from Python to JavaScript.
- A top-level API on the JavaScript side to construct a MicroPython
interpreter instance via `loadMicroPython()`. That function returns an
object that can be used to execute Python code, access the Python globals
dict, access the Emscripten filesystem, and other things. This API is
based on the API provided by Pyodide (https://pyodide.org/). As part of
this, the top-level file is changed from `micropython.js` to
`micropython.mjs`.
- A Python `js` module which can be used to access all JavaScript-side
symbols, for example the DOM when run within a browser.
- A Python `jsffi` module with various helper functions like
`create_proxy()` and `to_js()`.
- A dedenting lexer which automatically dedents Python source code if every
non-empty line in that source starts with a common whitespace prefix.
This is very helpful when Python source code is indented within a string
within HTML or JavaScript for formatting reasons.
Signed-off-by: Damien George <damien@micropython.org>
2023-05-31 01:45:34 +00:00
|
|
|
objjsproxy.c \
|
|
|
|
proxy_c.c \
|
2018-01-19 07:35:42 +00:00
|
|
|
|
2023-05-30 03:15:58 +00:00
|
|
|
# List of sources for qstr extraction.
|
2022-07-01 19:06:10 +00:00
|
|
|
SRC_QSTR += $(SRC_C) $(SRC_SHARED)
|
2018-01-19 07:35:42 +00:00
|
|
|
|
webassembly: Add JavaScript proxying, and js and jsffi modules.
This commit improves the webassembly port by adding:
- Proxying of Python objects to JavaScript with a PyProxy type that lives
on the JavaScript side. PyProxy implements JavaScript Proxy traps such
as has, get, set and ownKeys, to make Python objects have functionality
on the JavaScript side.
- Proxying of JavaScript objects to Python with a JsProxy type that lives
on the Python side. JsProxy passes through calls, attributes,
subscription and iteration from Python to JavaScript.
- A top-level API on the JavaScript side to construct a MicroPython
interpreter instance via `loadMicroPython()`. That function returns an
object that can be used to execute Python code, access the Python globals
dict, access the Emscripten filesystem, and other things. This API is
based on the API provided by Pyodide (https://pyodide.org/). As part of
this, the top-level file is changed from `micropython.js` to
`micropython.mjs`.
- A Python `js` module which can be used to access all JavaScript-side
symbols, for example the DOM when run within a browser.
- A Python `jsffi` module with various helper functions like
`create_proxy()` and `to_js()`.
- A dedenting lexer which automatically dedents Python source code if every
non-empty line in that source starts with a common whitespace prefix.
This is very helpful when Python source code is indented within a string
within HTML or JavaScript for formatting reasons.
Signed-off-by: Damien George <damien@micropython.org>
2023-05-31 01:45:34 +00:00
|
|
|
SRC_JS += \
|
|
|
|
api.js \
|
|
|
|
objpyproxy.js \
|
|
|
|
proxy_js.js \
|
2023-05-30 03:15:58 +00:00
|
|
|
|
2021-06-24 00:04:15 +00:00
|
|
|
OBJ += $(PY_O)
|
2021-07-09 04:19:15 +00:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_SHARED:.c=.o))
|
2018-01-19 07:35:42 +00:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
|
|
|
|
2023-05-30 03:15:58 +00:00
|
|
|
################################################################################
|
|
|
|
# Main targets.
|
|
|
|
|
webassembly: Add JavaScript proxying, and js and jsffi modules.
This commit improves the webassembly port by adding:
- Proxying of Python objects to JavaScript with a PyProxy type that lives
on the JavaScript side. PyProxy implements JavaScript Proxy traps such
as has, get, set and ownKeys, to make Python objects have functionality
on the JavaScript side.
- Proxying of JavaScript objects to Python with a JsProxy type that lives
on the Python side. JsProxy passes through calls, attributes,
subscription and iteration from Python to JavaScript.
- A top-level API on the JavaScript side to construct a MicroPython
interpreter instance via `loadMicroPython()`. That function returns an
object that can be used to execute Python code, access the Python globals
dict, access the Emscripten filesystem, and other things. This API is
based on the API provided by Pyodide (https://pyodide.org/). As part of
this, the top-level file is changed from `micropython.js` to
`micropython.mjs`.
- A Python `js` module which can be used to access all JavaScript-side
symbols, for example the DOM when run within a browser.
- A Python `jsffi` module with various helper functions like
`create_proxy()` and `to_js()`.
- A dedenting lexer which automatically dedents Python source code if every
non-empty line in that source starts with a common whitespace prefix.
This is very helpful when Python source code is indented within a string
within HTML or JavaScript for formatting reasons.
Signed-off-by: Damien George <damien@micropython.org>
2023-05-31 01:45:34 +00:00
|
|
|
.PHONY: all min test test_min
|
2018-01-19 07:35:42 +00:00
|
|
|
|
webassembly: Add JavaScript proxying, and js and jsffi modules.
This commit improves the webassembly port by adding:
- Proxying of Python objects to JavaScript with a PyProxy type that lives
on the JavaScript side. PyProxy implements JavaScript Proxy traps such
as has, get, set and ownKeys, to make Python objects have functionality
on the JavaScript side.
- Proxying of JavaScript objects to Python with a JsProxy type that lives
on the Python side. JsProxy passes through calls, attributes,
subscription and iteration from Python to JavaScript.
- A top-level API on the JavaScript side to construct a MicroPython
interpreter instance via `loadMicroPython()`. That function returns an
object that can be used to execute Python code, access the Python globals
dict, access the Emscripten filesystem, and other things. This API is
based on the API provided by Pyodide (https://pyodide.org/). As part of
this, the top-level file is changed from `micropython.js` to
`micropython.mjs`.
- A Python `js` module which can be used to access all JavaScript-side
symbols, for example the DOM when run within a browser.
- A Python `jsffi` module with various helper functions like
`create_proxy()` and `to_js()`.
- A dedenting lexer which automatically dedents Python source code if every
non-empty line in that source starts with a common whitespace prefix.
This is very helpful when Python source code is indented within a string
within HTML or JavaScript for formatting reasons.
Signed-off-by: Damien George <damien@micropython.org>
2023-05-31 01:45:34 +00:00
|
|
|
all: $(BUILD)/micropython.mjs
|
2018-01-19 07:35:42 +00:00
|
|
|
|
webassembly: Add JavaScript proxying, and js and jsffi modules.
This commit improves the webassembly port by adding:
- Proxying of Python objects to JavaScript with a PyProxy type that lives
on the JavaScript side. PyProxy implements JavaScript Proxy traps such
as has, get, set and ownKeys, to make Python objects have functionality
on the JavaScript side.
- Proxying of JavaScript objects to Python with a JsProxy type that lives
on the Python side. JsProxy passes through calls, attributes,
subscription and iteration from Python to JavaScript.
- A top-level API on the JavaScript side to construct a MicroPython
interpreter instance via `loadMicroPython()`. That function returns an
object that can be used to execute Python code, access the Python globals
dict, access the Emscripten filesystem, and other things. This API is
based on the API provided by Pyodide (https://pyodide.org/). As part of
this, the top-level file is changed from `micropython.js` to
`micropython.mjs`.
- A Python `js` module which can be used to access all JavaScript-side
symbols, for example the DOM when run within a browser.
- A Python `jsffi` module with various helper functions like
`create_proxy()` and `to_js()`.
- A dedenting lexer which automatically dedents Python source code if every
non-empty line in that source starts with a common whitespace prefix.
This is very helpful when Python source code is indented within a string
within HTML or JavaScript for formatting reasons.
Signed-off-by: Damien George <damien@micropython.org>
2023-05-31 01:45:34 +00:00
|
|
|
$(BUILD)/micropython.mjs: $(OBJ) library.js $(SRC_JS)
|
2023-05-30 03:15:58 +00:00
|
|
|
$(ECHO) "LINK $@"
|
|
|
|
$(Q)emcc $(LDFLAGS) -o $@ $(OBJ) $(JSFLAGS)
|
|
|
|
$(Q)cat $(SRC_JS) >> $@
|
2018-01-19 07:35:42 +00:00
|
|
|
|
webassembly: Add JavaScript proxying, and js and jsffi modules.
This commit improves the webassembly port by adding:
- Proxying of Python objects to JavaScript with a PyProxy type that lives
on the JavaScript side. PyProxy implements JavaScript Proxy traps such
as has, get, set and ownKeys, to make Python objects have functionality
on the JavaScript side.
- Proxying of JavaScript objects to Python with a JsProxy type that lives
on the Python side. JsProxy passes through calls, attributes,
subscription and iteration from Python to JavaScript.
- A top-level API on the JavaScript side to construct a MicroPython
interpreter instance via `loadMicroPython()`. That function returns an
object that can be used to execute Python code, access the Python globals
dict, access the Emscripten filesystem, and other things. This API is
based on the API provided by Pyodide (https://pyodide.org/). As part of
this, the top-level file is changed from `micropython.js` to
`micropython.mjs`.
- A Python `js` module which can be used to access all JavaScript-side
symbols, for example the DOM when run within a browser.
- A Python `jsffi` module with various helper functions like
`create_proxy()` and `to_js()`.
- A dedenting lexer which automatically dedents Python source code if every
non-empty line in that source starts with a common whitespace prefix.
This is very helpful when Python source code is indented within a string
within HTML or JavaScript for formatting reasons.
Signed-off-by: Damien George <damien@micropython.org>
2023-05-31 01:45:34 +00:00
|
|
|
$(BUILD)/micropython.min.mjs: $(BUILD)/micropython.mjs
|
2023-05-30 03:15:58 +00:00
|
|
|
$(TERSER) $< --compress --module -o $@
|
|
|
|
|
webassembly: Add JavaScript proxying, and js and jsffi modules.
This commit improves the webassembly port by adding:
- Proxying of Python objects to JavaScript with a PyProxy type that lives
on the JavaScript side. PyProxy implements JavaScript Proxy traps such
as has, get, set and ownKeys, to make Python objects have functionality
on the JavaScript side.
- Proxying of JavaScript objects to Python with a JsProxy type that lives
on the Python side. JsProxy passes through calls, attributes,
subscription and iteration from Python to JavaScript.
- A top-level API on the JavaScript side to construct a MicroPython
interpreter instance via `loadMicroPython()`. That function returns an
object that can be used to execute Python code, access the Python globals
dict, access the Emscripten filesystem, and other things. This API is
based on the API provided by Pyodide (https://pyodide.org/). As part of
this, the top-level file is changed from `micropython.js` to
`micropython.mjs`.
- A Python `js` module which can be used to access all JavaScript-side
symbols, for example the DOM when run within a browser.
- A Python `jsffi` module with various helper functions like
`create_proxy()` and `to_js()`.
- A dedenting lexer which automatically dedents Python source code if every
non-empty line in that source starts with a common whitespace prefix.
This is very helpful when Python source code is indented within a string
within HTML or JavaScript for formatting reasons.
Signed-off-by: Damien George <damien@micropython.org>
2023-05-31 01:45:34 +00:00
|
|
|
min: $(BUILD)/micropython.min.mjs
|
|
|
|
|
|
|
|
test: $(BUILD)/micropython.mjs $(TOP)/tests/run-tests.py
|
|
|
|
cd $(TOP)/tests && MICROPY_MICROPYTHON_MJS=../ports/webassembly/$< ./run-tests.py --target webassembly
|
2018-01-19 07:35:42 +00:00
|
|
|
|
webassembly: Add JavaScript proxying, and js and jsffi modules.
This commit improves the webassembly port by adding:
- Proxying of Python objects to JavaScript with a PyProxy type that lives
on the JavaScript side. PyProxy implements JavaScript Proxy traps such
as has, get, set and ownKeys, to make Python objects have functionality
on the JavaScript side.
- Proxying of JavaScript objects to Python with a JsProxy type that lives
on the Python side. JsProxy passes through calls, attributes,
subscription and iteration from Python to JavaScript.
- A top-level API on the JavaScript side to construct a MicroPython
interpreter instance via `loadMicroPython()`. That function returns an
object that can be used to execute Python code, access the Python globals
dict, access the Emscripten filesystem, and other things. This API is
based on the API provided by Pyodide (https://pyodide.org/). As part of
this, the top-level file is changed from `micropython.js` to
`micropython.mjs`.
- A Python `js` module which can be used to access all JavaScript-side
symbols, for example the DOM when run within a browser.
- A Python `jsffi` module with various helper functions like
`create_proxy()` and `to_js()`.
- A dedenting lexer which automatically dedents Python source code if every
non-empty line in that source starts with a common whitespace prefix.
This is very helpful when Python source code is indented within a string
within HTML or JavaScript for formatting reasons.
Signed-off-by: Damien George <damien@micropython.org>
2023-05-31 01:45:34 +00:00
|
|
|
test_min: $(BUILD)/micropython.min.mjs $(TOP)/tests/run-tests.py
|
|
|
|
cd $(TOP)/tests && MICROPY_MICROPYTHON_MJS=../ports/webassembly/$< ./run-tests.py --target webassembly
|
2018-01-19 07:35:42 +00:00
|
|
|
|
2023-05-30 03:15:58 +00:00
|
|
|
################################################################################
|
|
|
|
# Remaining make rules.
|
|
|
|
|
2018-01-19 07:35:42 +00:00
|
|
|
include $(TOP)/py/mkrules.mk
|