tools/mpy-tool.py: Add support for self-hosting of mpy-tool.
This allows running mpy-tool using MicroPython itself. An appropriate test is added to CI to make sure it continues to work. Signed-off-by: Volodymyr Shymanskyy <vshymanskyi@gmail.com> Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
committed by
Damien George
parent
fc71f7832f
commit
e1b2f2e078
10
tools/ci.sh
10
tools/ci.sh
@@ -118,9 +118,19 @@ function ci_mpy_format_test {
|
|||||||
python2.7 ./tools/mpy-tool.py -xd tests/frozen/frozentest.mpy
|
python2.7 ./tools/mpy-tool.py -xd tests/frozen/frozentest.mpy
|
||||||
python3 ./tools/mpy-tool.py -xd tests/frozen/frozentest.mpy
|
python3 ./tools/mpy-tool.py -xd tests/frozen/frozentest.mpy
|
||||||
|
|
||||||
|
# Build MicroPython
|
||||||
|
ci_unix_standard_build
|
||||||
|
micropython=./ports/unix/build-standard/micropython
|
||||||
|
$micropython -m mip install --target . argparse __future__
|
||||||
|
export MICROPYPATH=.
|
||||||
|
|
||||||
|
# Test mpy-tool.py running under MicroPython
|
||||||
|
$micropython ./tools/mpy-tool.py -x -d tests/frozen/frozentest.mpy
|
||||||
|
|
||||||
# Test mpy-tool.py dump feature on native code
|
# Test mpy-tool.py dump feature on native code
|
||||||
make -C examples/natmod/features1
|
make -C examples/natmod/features1
|
||||||
./tools/mpy-tool.py -xd examples/natmod/features1/features1.mpy
|
./tools/mpy-tool.py -xd examples/natmod/features1/features1.mpy
|
||||||
|
$micropython ./tools/mpy-tool.py -x -d examples/natmod/features1/features1.mpy
|
||||||
}
|
}
|
||||||
|
|
||||||
########################################################################################
|
########################################################################################
|
||||||
|
|||||||
@@ -24,11 +24,11 @@
|
|||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
# Python 2/3 compatibility code
|
# Python 2/3/MicroPython compatibility code
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import platform
|
import sys
|
||||||
|
|
||||||
if platform.python_version_tuple()[0] == "2":
|
if sys.version_info[0] == 2:
|
||||||
from binascii import hexlify as hexlify_py2
|
from binascii import hexlify as hexlify_py2
|
||||||
|
|
||||||
str_cons = lambda val, enc=None: str(val)
|
str_cons = lambda val, enc=None: str(val)
|
||||||
@@ -41,7 +41,7 @@ if platform.python_version_tuple()[0] == "2":
|
|||||||
x = hexlify_py2(b)
|
x = hexlify_py2(b)
|
||||||
return ":".join(x[i : i + 2] for i in range(0, len(x), 2))
|
return ":".join(x[i : i + 2] for i in range(0, len(x), 2))
|
||||||
|
|
||||||
else:
|
elif sys.version_info[0] == 3: # Also handles MicroPython
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
|
|
||||||
str_cons = str
|
str_cons = str
|
||||||
|
|||||||
Reference in New Issue
Block a user