You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that the RT-Thread MicroPython port does not generate QSTRs at compile time. This makes it very difficult to add new libraries to MicroPython for RT-Thread.
I have been able to write a simple solution to add QSTR generation to RT-Thread MicroPython.
It is fast, less than 1 second on my computer. (The official way takes over 5 seconds.)
The only changes necessary are to the following files:
packages/micropython-v1.13.0/SConscript
replace end of file with this:
print ("MicroPython: generate QSTR list")
from subprocess import call
# call the Python script, redirect the output to the desired file. using "W" to create the file if it is not found.
# shell instruction: python3 ./gen_qstr_auto.py -> ./port/genhdr/qstrdefs.generated.h
f = open(cwd + "/port/genhdr/qstrdefs.generated.h",'w')
call(["python3", cwd + "/gen_qstr_auto.py"], stdout = f, cwd = cwd) # must set CWD (current working directory) to the MicroPython path, as the SCONS CWD is useless
f.close()
Return('group')
And then add the attached Python script to the "packages/micropython-v1.13.0" folder.
It scans every C source file in the MicroPython folder, and outputs a sorted, correct, and tweaked list of QSTRdefs.
Note that the QSTR list is of every available QSTR, it is not changed by project build configuration. (Making the project build configuration affect the QSTR generation is a very difficult process.)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I noticed that the RT-Thread MicroPython port does not generate QSTRs at compile time. This makes it very difficult to add new libraries to MicroPython for RT-Thread.
I have been able to write a simple solution to add QSTR generation to RT-Thread MicroPython.
It is fast, less than 1 second on my computer. (The official way takes over 5 seconds.)
The only changes necessary are to the following files:
packages/micropython-v1.13.0/SConscript
replace end of file with this:
And then add the attached Python script to the "packages/micropython-v1.13.0" folder.
It scans every C source file in the MicroPython folder, and outputs a sorted, correct, and tweaked list of QSTRdefs.
Note that the QSTR list is of every available QSTR, it is not changed by project build configuration. (Making the project build configuration affect the QSTR generation is a very difficult process.)
tested to work with Python3 anyway ;-)
gen_qstr_auto.zip
If there are any plans to update MicroPython to a newer version (i.e. 1.19), a few changes will be necessary to the "gen_qstr_auto" script.
Enjoy!
Beta Was this translation helpful? Give feedback.
All reactions