Skip to content

Commit d76c65f

Browse files
janbraiinsdpgeorge
authored andcommitted
py: Add rules for automated extraction of qstrs from sources.
- add template rule that converts a specified source file into a qstring file - add special rule for generating a central header that contains all extracted/autogenerated strings - defined by QSTR_DEFS_COLLECTED variable. Each platform appends a list of sources that may contain qstrings into a new build variable: SRC_QSTR. Any autogenerated prerequisities are should be appened to SRC_QSTR_AUTO_DEPS variable. - remove most qstrings from py/qstrdefs, keep only qstrings that contain special characters - these cannot be easily detected in the sources without additional annotations - remove most manual qstrdefs, use qstrdef autogen for: py, cc3200, stmhal, teensy, unix, windows, pic16bit: - remove all micropython generic qstrdefs except for the special strings that contain special characters (e.g. /,+,<,> etc.) - remove all port specific qstrdefs except for special strings - append sources for qstr generation in platform makefiles (SRC_QSTR)
1 parent dbbf082 commit d76c65f

File tree

14 files changed

+87
-1861
lines changed

14 files changed

+87
-1861
lines changed

cc3200/application.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ OBJ += $(addprefix $(BUILD)/, $(APP_MODS_SRC_C:.c=.o) $(APP_CC3100_SRC_C:.c=.o)
171171
OBJ += $(addprefix $(BUILD)/, $(APP_MAIN_SRC_C:.c=.o) $(APP_LIB_SRC_C:.c=.o) $(APP_STM_SRC_C:.c=.o))
172172
OBJ += $(BUILD)/pins.o
173173

174+
# List of sources for qstr extraction
175+
SRC_QSTR += $(APP_MODS_SRC_C) $(APP_MISC_SRC_C) $(APP_STM_SRC_C)
176+
# Append any auto-generated sources that are needed by sources listed in
177+
# SRC_QSTR
178+
SRC_QSTR_AUTO_DEPS +=
179+
174180
# Add the linker script
175181
LINKER_SCRIPT = application.lds
176182
LDFLAGS += -T $(LINKER_SCRIPT)

cc3200/qstrdefsport.h

Lines changed: 1 addition & 361 deletions
Original file line numberDiff line numberDiff line change
@@ -26,367 +26,7 @@
2626
*/
2727

2828
// for machine module
29-
Q(umachine)
30-
#ifdef DEBUG
31-
Q(info)
32-
#endif
33-
Q(reset)
34-
Q(main)
35-
Q(sync)
36-
Q(rng)
37-
Q(freq)
38-
Q(unique_id)
39-
Q(disable_irq)
40-
Q(enable_irq)
41-
Q(idle)
42-
Q(sleep)
43-
Q(deepsleep)
44-
Q(reset_cause)
45-
Q(wake_reason)
46-
Q(IDLE)
47-
Q(SLEEP)
48-
Q(DEEPSLEEP)
49-
Q(POWER_ON)
50-
Q(HARD_RESET)
51-
Q(WDT_RESET)
52-
Q(DEEPSLEEP_RESET)
53-
Q(SOFT_RESET)
54-
Q(WLAN_WAKE)
55-
Q(PIN_WAKE)
56-
Q(RTC_WAKE)
57-
58-
// for wipy module
59-
Q(wipy)
60-
Q(heartbeat)
61-
29+
Q(/)
6230
// entries for sys.path
6331
Q(/flash)
6432
Q(/flash/lib)
65-
66-
// interactive help
67-
Q(help)
68-
69-
// for module weak links
70-
Q(struct)
71-
Q(binascii)
72-
Q(re)
73-
Q(json)
74-
Q(heapq)
75-
//Q(hashlib)
76-
77-
// for os module
78-
Q(os)
79-
Q(uos)
80-
Q(sysname)
81-
Q(nodename)
82-
Q(release)
83-
Q(version)
84-
Q(machine)
85-
Q(uname)
86-
Q(/)
87-
Q(flash)
88-
Q(chdir)
89-
Q(getcwd)
90-
Q(listdir)
91-
Q(mkdir)
92-
Q(rename)
93-
Q(remove)
94-
Q(rmdir)
95-
Q(unlink)
96-
Q(sep)
97-
Q(stat)
98-
Q(urandom)
99-
Q(mkfs)
100-
Q(mount)
101-
Q(unmount)
102-
Q(dupterm)
103-
Q(readonly)
104-
Q(readblocks)
105-
Q(writeblocks)
106-
Q(sync)
107-
Q(count)
108-
109-
// for file class
110-
Q(seek)
111-
Q(tell)
112-
Q(input)
113-
Q(flush)
114-
115-
// for Pin class
116-
Q(Pin)
117-
Q(board)
118-
Q(init)
119-
Q(value)
120-
Q(toggle)
121-
Q(id)
122-
Q(mode)
123-
Q(pull)
124-
Q(drive)
125-
Q(alt)
126-
Q(alt_list)
127-
Q(IN)
128-
Q(OUT)
129-
Q(OPEN_DRAIN)
130-
Q(ALT)
131-
Q(ALT_OPEN_DRAIN)
132-
Q(PULL_UP)
133-
Q(PULL_DOWN)
134-
Q(LOW_POWER)
135-
Q(MED_POWER)
136-
Q(HIGH_POWER)
137-
Q(IRQ_RISING)
138-
Q(IRQ_FALLING)
139-
Q(IRQ_LOW_LEVEL)
140-
Q(IRQ_HIGH_LEVEL)
141-
142-
// for UART class
143-
Q(UART)
144-
Q(init)
145-
Q(deinit)
146-
Q(any)
147-
Q(sendbreak)
148-
Q(id)
149-
Q(baudrate)
150-
Q(bits)
151-
Q(stop)
152-
Q(parity)
153-
Q(pins)
154-
Q(EVEN)
155-
Q(ODD)
156-
Q(RX_ANY)
157-
158-
// for I2C class
159-
Q(I2C)
160-
Q(id)
161-
Q(mode)
162-
Q(baudrate)
163-
Q(pins)
164-
Q(addr)
165-
Q(nbytes)
166-
Q(buf)
167-
Q(stop)
168-
Q(memaddr)
169-
Q(addrsize)
170-
Q(init)
171-
Q(deinit)
172-
Q(scan)
173-
Q(readfrom)
174-
Q(readfrom_into)
175-
Q(writeto)
176-
Q(readfrom_mem)
177-
Q(readfrom_mem_into)
178-
Q(writeto_mem)
179-
Q(MASTER)
180-
181-
// for ADC class
182-
Q(ADC)
183-
Q(ADCChannel)
184-
Q(value)
185-
Q(init)
186-
Q(deinit)
187-
Q(channel)
188-
Q(id)
189-
Q(pin)
190-
191-
// for SD class
192-
Q(SD)
193-
Q(init)
194-
Q(deinit)
195-
Q(id)
196-
Q(pins)
197-
198-
// for RTC class
199-
Q(RTC)
200-
Q(id)
201-
Q(init)
202-
Q(alarm)
203-
Q(alarm_left)
204-
Q(alarm_cancel)
205-
Q(now)
206-
Q(deinit)
207-
Q(datetime)
208-
Q(repeat)
209-
Q(ALARM0)
210-
211-
// for time class
212-
Q(time)
213-
Q(utime)
214-
Q(localtime)
215-
Q(mktime)
216-
Q(sleep)
217-
Q(sleep_ms)
218-
Q(sleep_us)
219-
Q(ticks_ms)
220-
Q(ticks_us)
221-
Q(ticks_cpu)
222-
Q(ticks_diff)
223-
224-
// for select class
225-
Q(select)
226-
Q(uselect)
227-
Q(register)
228-
Q(unregister)
229-
Q(modify)
230-
Q(poll)
231-
Q(POLLIN)
232-
Q(POLLOUT)
233-
Q(POLLERR)
234-
Q(POLLHUP)
235-
236-
// for socket class
237-
Q(socket)
238-
Q(usocket)
239-
Q(getaddrinfo)
240-
Q(family)
241-
Q(type)
242-
Q(send)
243-
Q(sendall)
244-
Q(sendto)
245-
Q(recv)
246-
Q(recvfrom)
247-
Q(listen)
248-
Q(accept)
249-
Q(bind)
250-
Q(settimeout)
251-
Q(setblocking)
252-
Q(setsockopt)
253-
Q(close)
254-
Q(makefile)
255-
Q(protocol)
256-
Q(error)
257-
Q(timeout)
258-
Q(AF_INET)
259-
Q(SOCK_STREAM)
260-
Q(SOCK_DGRAM)
261-
Q(IPPROTO_SEC)
262-
Q(IPPROTO_TCP)
263-
Q(IPPROTO_UDP)
264-
265-
// for ssl class
266-
Q(ssl)
267-
Q(ussl)
268-
Q(wrap_socket)
269-
Q(sock)
270-
Q(keyfile)
271-
Q(certfile)
272-
Q(server_side)
273-
Q(cert_reqs)
274-
Q(ca_certs)
275-
Q(SSLError)
276-
Q(CERT_NONE)
277-
Q(CERT_OPTIONAL)
278-
Q(CERT_REQUIRED)
279-
280-
// for network class
281-
Q(network)
282-
Q(Server)
283-
Q(init)
284-
Q(deinit)
285-
Q(login)
286-
Q(timeout)
287-
Q(isrunning)
288-
289-
// for WLAN class
290-
Q(WLAN)
291-
Q(id)
292-
Q(init)
293-
Q(mode)
294-
Q(auth)
295-
Q(ssid)
296-
Q(bssid)
297-
Q(mac)
298-
Q(antenna)
299-
Q(scan)
300-
Q(connect)
301-
Q(isconnected)
302-
Q(disconnect)
303-
Q(sec)
304-
Q(channel)
305-
Q(rssi)
306-
Q(ifconfig)
307-
Q(config)
308-
//Q(connections)
309-
//Q(urn)
310-
Q(STA)
311-
Q(AP)
312-
Q(OPEN)
313-
Q(WEP)
314-
Q(WPA)
315-
Q(WPA2)
316-
Q(INT_ANT)
317-
Q(EXT_ANT)
318-
Q(ANY_EVENT)
319-
320-
// for WDT class
321-
Q(WDT)
322-
Q(feed)
323-
Q(timeout)
324-
325-
// for irq class
326-
Q(irq)
327-
Q(init)
328-
Q(enable)
329-
Q(disable)
330-
Q(flags)
331-
Q(trigger)
332-
Q(handler)
333-
Q(priority)
334-
Q(wake)
335-
336-
// for SPI class
337-
Q(SPI)
338-
Q(id)
339-
Q(mode)
340-
Q(baudrate)
341-
Q(bits)
342-
Q(polarity)
343-
Q(phase)
344-
Q(firstbit)
345-
Q(init)
346-
Q(deinit)
347-
Q(write)
348-
Q(read)
349-
Q(readinto)
350-
Q(write_readinto)
351-
Q(nbytes)
352-
Q(buf)
353-
Q(MASTER)
354-
Q(MSB)
355-
356-
// for Timer class
357-
Q(Timer)
358-
Q(TimerChannel)
359-
Q(init)
360-
Q(deinit)
361-
Q(freq)
362-
Q(period)
363-
Q(mode)
364-
Q(width)
365-
Q(channel)
366-
Q(polarity)
367-
Q(duty_cycle)
368-
Q(A)
369-
Q(B)
370-
Q(ONE_SHOT)
371-
Q(PERIODIC)
372-
Q(PWM)
373-
Q(POSITIVE)
374-
Q(NEGATIVE)
375-
Q(TIMEOUT)
376-
Q(MATCH)
377-
378-
// for uhashlib module
379-
//Q(uhashlib)
380-
//Q(update)
381-
//Q(digest)
382-
//Q(md5)
383-
//Q(sha1)
384-
//Q(sha256)
385-
386-
// for ubinascii module
387-
Q(ubinascii)
388-
Q(hexlify)
389-
Q(unhexlify)
390-
Q(a2b_base64)
391-
Q(b2a_base64)
392-

pic16bit/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ SRC_S = \
4949
5050
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(SRC_S:.s=.o))
5151

52+
# List of sources for qstr extraction
53+
SRC_QSTR += $(SRC_C)
54+
# Append any auto-generated sources that are needed by sources listed in
55+
# SRC_QSTR
56+
SRC_QSTR_AUTO_DEPS +=
57+
5258
all: $(BUILD)/firmware.hex
5359

5460
$(BUILD)/firmware.hex: $(BUILD)/firmware.elf

0 commit comments

Comments
 (0)