Skip to content

Commit 7b27b8f

Browse files
committed
Unify skip and only logic for build scripts
And switch to a single file that can include mcu, family or board.
1 parent 4fe0a30 commit 7b27b8f

File tree

85 files changed

+136
-82
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+136
-82
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ cov-int
2626
# cppcheck build directories
2727
*-build-dir
2828
/_bin/
29+
__pycache__
30+

examples/device/audio_4_channel_mic/.skip.MCU_SAMD11

Whitespace-only changes.

examples/device/audio_4_channel_mic/.skip.MCU_SAME5X

Whitespace-only changes.

examples/device/audio_4_channel_mic/.skip.MCU_SAMG

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mcu:SAMD11
2+
mcu:SAME5X
3+
mcu:SAMG

examples/device/audio_test/.skip.MCU_SAMD11

Whitespace-only changes.

examples/device/audio_test/.skip.MCU_SAME5X

Whitespace-only changes.

examples/device/audio_test/.skip.MCU_SAMG

Whitespace-only changes.

examples/device/audio_test/skip.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mcu:SAMD11
2+
mcu:SAME5X
3+
mcu:SAMG

examples/device/cdc_msc/.skip.MCU_SAMD11

Whitespace-only changes.

examples/device/cdc_msc/skip.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mcu:SAMD11

examples/device/cdc_msc_freertos/.skip.MCU_BCM2711

Whitespace-only changes.

examples/device/cdc_msc_freertos/.skip.MCU_BCM2835

Whitespace-only changes.

examples/device/cdc_msc_freertos/.skip.MCU_BCM2837

Whitespace-only changes.

examples/device/cdc_msc_freertos/.skip.MCU_CXD56

Whitespace-only changes.

examples/device/cdc_msc_freertos/.skip.MCU_GD32VF103

Whitespace-only changes.

examples/device/cdc_msc_freertos/.skip.MCU_MKL25ZXX

Whitespace-only changes.

examples/device/cdc_msc_freertos/.skip.MCU_MSP430x5xx

Whitespace-only changes.

examples/device/cdc_msc_freertos/.skip.MCU_RP2040

Whitespace-only changes.

examples/device/cdc_msc_freertos/.skip.MCU_SAMD11

Whitespace-only changes.

examples/device/cdc_msc_freertos/.skip.MCU_SAMX7X

Whitespace-only changes.

examples/device/cdc_msc_freertos/.skip.MCU_VALENTYUSB_EPTRI

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
mcu:CXD56
2+
mcu:MSP430x5xx
3+
mcu:SAMD11
4+
mcu:VALENTYUSB_EPTRI
5+
mcu:MKL25ZXX
6+
mcu:RP2040
7+
mcu:SAMX7X
8+
mcu:GD32VF103
9+
family:broadcom_64bit
10+
family:broadcom_32bit

examples/device/dfu/.skip.MCU_TM4C123

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/device/dfu/skip.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mcu:TM4C123

examples/device/dynamic_configuration/.skip.MCU_SAMD11

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mcu:SAMD11

examples/device/hid_composite_freertos/.skip.MCU_BCM2711

Whitespace-only changes.

examples/device/hid_composite_freertos/.skip.MCU_BCM2835

Whitespace-only changes.

examples/device/hid_composite_freertos/.skip.MCU_BCM2837

Whitespace-only changes.

examples/device/hid_composite_freertos/.skip.MCU_CXD56

Whitespace-only changes.

examples/device/hid_composite_freertos/.skip.MCU_GD32VF103

Whitespace-only changes.

examples/device/hid_composite_freertos/.skip.MCU_MSP430x5xx

Whitespace-only changes.

examples/device/hid_composite_freertos/.skip.MCU_RP2040

Whitespace-only changes.

examples/device/hid_composite_freertos/.skip.MCU_SAMD11

Whitespace-only changes.

examples/device/hid_composite_freertos/.skip.MCU_SAMX7X

Whitespace-only changes.

examples/device/hid_composite_freertos/.skip.MCU_VALENTYUSB_EPTRI

Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
mcu:CXD56
2+
mcu:MSP430x5xx
3+
mcu:SAMD11
4+
mcu:VALENTYUSB_EPTRI
5+
mcu:RP2040
6+
mcu:SAMX7X
7+
mcu:GD32VF103
8+
family:broadcom_64bit
9+
family:broadcom_32bit

examples/device/msc_dual_lun/.skip.MCU_MKL25ZXX

Whitespace-only changes.

examples/device/msc_dual_lun/.skip.MCU_SAMD11

Whitespace-only changes.

examples/device/msc_dual_lun/skip.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mcu:SAMD11
2+
mcu:MKL25ZXX

examples/device/net_lwip_webserver/.skip.MCU_BCM2711

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/device/net_lwip_webserver/.skip.MCU_BCM2835

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/device/net_lwip_webserver/.skip.MCU_BCM2837

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/device/net_lwip_webserver/.skip.MCU_LPC11UXX

Whitespace-only changes.

examples/device/net_lwip_webserver/.skip.MCU_LPC13XX

Whitespace-only changes.

examples/device/net_lwip_webserver/.skip.MCU_MKL25ZXX

Whitespace-only changes.

examples/device/net_lwip_webserver/.skip.MCU_MSP430x5xx

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/device/net_lwip_webserver/.skip.MCU_NUC121

Whitespace-only changes.

examples/device/net_lwip_webserver/.skip.MCU_SAMD11

Whitespace-only changes.

examples/device/net_lwip_webserver/.skip.MCU_STM32L0

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
mcu:LPC11UXX
2+
mcu:LPC13XX
3+
mcu:MSP430x5xx
4+
mcu:NUC121
5+
mcu:SAMD11
6+
mcu:STM32L0
7+
mcu:MKL25ZXX
8+
family:broadcom_64bit
9+
family:broadcom_32bit
10+
board:curiosity_nano

examples/device/uac2_headset/.skip.MCU_LPC11UXX

Whitespace-only changes.

examples/device/uac2_headset/.skip.MCU_LPC13XX

Whitespace-only changes.

examples/device/uac2_headset/.skip.MCU_NUC121

Whitespace-only changes.

examples/device/uac2_headset/.skip.MCU_SAMD11

Whitespace-only changes.

examples/device/uac2_headset/.skip.MCU_SAME5X

Whitespace-only changes.

examples/device/uac2_headset/.skip.MCU_SAMG

Whitespace-only changes.

examples/device/uac2_headset/skip.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
mcu:LPC11UXX
2+
mcu:LPC13XX
3+
mcu:NUC121
4+
mcu:SAMD11
5+
mcu:SAME5X
6+
mcu:SAMG

examples/device/video_capture/.skip.MCU_MSP430x5xx

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/device/video_capture/.skip.MCU_SAMD11

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mcu:MSP430x5xx
2+
mcu:SAMD11

examples/host/cdc_msc_hid/.only.MCU_LPC175X_6X

Whitespace-only changes.

examples/host/cdc_msc_hid/.only.MCU_LPC177X_8X

Whitespace-only changes.

examples/host/cdc_msc_hid/.only.MCU_LPC18XX

Whitespace-only changes.

examples/host/cdc_msc_hid/.only.MCU_LPC40XX

Whitespace-only changes.

examples/host/cdc_msc_hid/.only.MCU_LPC43XX

Whitespace-only changes.

examples/host/cdc_msc_hid/.only.MCU_MIMXRT10XX

Whitespace-only changes.

examples/host/cdc_msc_hid/.only.MCU_MSP432E4

Whitespace-only changes.

examples/host/cdc_msc_hid/.only.MCU_RP2040

Whitespace-only changes.

examples/host/cdc_msc_hid/only.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
mcu:LPC175X_6X
2+
mcu:LPC177X_8X
3+
mcu:LPC18XX
4+
mcu:LPC40XX
5+
mcu:LPC43XX
6+
mcu:MIMXRT10XX
7+
mcu:RP2040
8+
mcu:MSP432E4

examples/host/hid_controller/.only.MCU_LPC175X_6X

Whitespace-only changes.

examples/host/hid_controller/.only.MCU_LPC177X_8X

Whitespace-only changes.

examples/host/hid_controller/.only.MCU_LPC18XX

Whitespace-only changes.

examples/host/hid_controller/.only.MCU_LPC40XX

Whitespace-only changes.

examples/host/hid_controller/.only.MCU_LPC43XX

Whitespace-only changes.

examples/host/hid_controller/.only.MCU_MIMXRT10XX

Whitespace-only changes.

examples/host/hid_controller/.only.MCU_MSP432E4

Whitespace-only changes.

examples/host/hid_controller/.only.MCU_RP2040

Whitespace-only changes.

examples/host/hid_controller/only.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
mcu:LPC175X_6X
2+
mcu:LPC177X_8X
3+
mcu:LPC18XX
4+
mcu:LPC40XX
5+
mcu:LPC43XX
6+
mcu:MIMXRT10XX
7+
mcu:RP2040
8+
mcu:MSP432E4

hw/bsp/samd21/boards/curiosity_nano/.skip.device.net_lwip_webserver

Whitespace-only changes.

tools/build_board.py

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import subprocess
55
import time
66

7+
import build_utils
8+
79
SUCCEEDED = "\033[32msucceeded\033[0m"
810
FAILED = "\033[31mfailed\033[0m"
911
SKIPPED = "\033[33mskipped\033[0m"
@@ -50,7 +52,7 @@ def build_board(example, board):
5052
sram_size = "-"
5153

5254
# Check if board is skipped
53-
if skip_example(example, board):
55+
if build_utils.skip_example(example, board):
5456
success = SKIPPED
5557
skip_count += 1
5658
print(build_format.format(example, board, success, '-', flash_size, sram_size))
@@ -82,33 +84,6 @@ def build_size(example, board):
8284
sram_size = int(size_list[1]) + int(size_list[2])
8385
return (flash_size, sram_size)
8486

85-
def skip_example(example, board):
86-
ex_dir = 'examples/' + example
87-
board_mk = 'hw/bsp/{}/board.mk'.format(board)
88-
with open(board_mk) as mk:
89-
mk_contents = mk.read()
90-
91-
# Skip all OPT_MCU_NONE these are WIP port
92-
if '-DCFG_TUSB_MCU=OPT_MCU_NONE' in mk_contents:
93-
return 1
94-
95-
# Skip if CFG_TUSB_MCU in board.mk to match skip file
96-
for skip_file in glob.iglob(ex_dir + '/.skip.MCU_*'):
97-
mcu_cflag = '-DCFG_TUSB_MCU=OPT_' + os.path.basename(skip_file).split('.')[2]
98-
if mcu_cflag in mk_contents:
99-
return 1
100-
101-
# Build only list, if exists only these MCU are built
102-
only_list = list(glob.iglob(ex_dir + '/.only.MCU_*'))
103-
if len(only_list) > 0:
104-
for only_file in only_list:
105-
mcu_cflag = '-DCFG_TUSB_MCU=OPT_' + os.path.basename(only_file).split('.')[2]
106-
if mcu_cflag in mk_contents:
107-
return 0
108-
return 1
109-
110-
return 0
111-
11287
print(build_separator)
11388
print(build_format.format('Example', 'Board', '\033[39mResult\033[0m', 'Time', 'Flash', 'SRAM'))
11489

tools/build_esp32sx.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import subprocess
55
import time
66

7+
import build_utils
8+
79
SUCCEEDED = "\033[32msucceeded\033[0m"
810
FAILED = "\033[31mfailed\033[0m"
911
SKIPPED = "\033[33mskipped\033[0m"
@@ -51,7 +53,7 @@ def build_board(example, board):
5153
sram_size = "-"
5254

5355
# Check if board is skipped
54-
if skip_example(example, board):
56+
if build_utils.skip_example(example, board):
5557
success = SKIPPED
5658
skip_count += 1
5759
print(build_format.format(example, board, success, '-', flash_size, sram_size))
@@ -83,9 +85,6 @@ def build_size(example, board):
8385
sram_size = int(size_list[1]) + int(size_list[2])
8486
return (flash_size, sram_size)
8587

86-
def skip_example(example, board):
87-
return 0
88-
8988
print(build_separator)
9089
print(build_format.format('Example', 'Board', '\033[39mResult\033[0m', 'Time', 'Flash', 'SRAM'))
9190
print(build_separator)

tools/build_family.py

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import subprocess
55
import time
66

7+
import build_utils
8+
79
SUCCEEDED = "\033[32msucceeded\033[0m"
810
FAILED = "\033[31mfailed\033[0m"
911
SKIPPED = "\033[33mskipped\033[0m"
@@ -62,7 +64,7 @@ def build_board(example, board):
6264
sram_size = "-"
6365

6466
# Check if board is skipped
65-
if skip_example(example, board):
67+
if build_utils.skip_example(example, board):
6668
success = SKIPPED
6769
skip_count += 1
6870
print(build_format.format(example, board, success, '-', flash_size, sram_size))
@@ -95,46 +97,6 @@ def build_size(example, board):
9597
sram_size = int(size_list[1]) + int(size_list[2])
9698
return (flash_size, sram_size)
9799

98-
def skip_example(example, board):
99-
ex_dir = 'examples/' + example
100-
101-
# Check if example is skipped by family or board directory
102-
skip_file = ".skip." + example.replace('/', '.');
103-
if os.path.isfile("hw/bsp/{}/{}".format(family, skip_file)) or os.path.isfile("hw/bsp/{}/boards/{}/{}".format(family, board, skip_file)):
104-
return 1
105-
106-
# Otherwise check if mcu is excluded by example directory
107-
108-
# family CMake
109-
family_mk = 'hw/bsp/{}/family.cmake'.format(family)
110-
111-
# family.mk
112-
if not os.path.exists(family_mk):
113-
family_mk = 'hw/bsp/{}/family.mk'.format(family)
114-
115-
with open(family_mk) as mk:
116-
mk_contents = mk.read()
117-
118-
# Skip all OPT_MCU_NONE these are WIP port
119-
if 'CFG_TUSB_MCU=OPT_MCU_NONE' in mk_contents:
120-
return 1
121-
122-
# Skip if CFG_TUSB_MCU in family.mk to match skip file
123-
for skip_file in glob.iglob(ex_dir + '/.skip.MCU_*'):
124-
mcu_cflag = 'CFG_TUSB_MCU=OPT_' + os.path.basename(skip_file).split('.')[2]
125-
if mcu_cflag in mk_contents:
126-
return 1
127-
128-
# Build only list, if exists only these MCU are built
129-
only_list = list(glob.iglob(ex_dir + '/.only.MCU_*'))
130-
if len(only_list) > 0:
131-
for only_file in only_list:
132-
mcu_cflag = 'CFG_TUSB_MCU=OPT_' + os.path.basename(only_file).split('.')[2]
133-
if mcu_cflag in mk_contents:
134-
return 0
135-
return 1
136-
return 0
137-
138100
print(build_separator)
139101
print(build_format.format('Example', 'Board', '\033[39mResult\033[0m', 'Time', 'Flash', 'SRAM'))
140102

tools/build_utils.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import pathlib
2+
3+
def skip_example(example, board):
4+
ex_dir = pathlib.Path('examples/') / example
5+
bsp = pathlib.Path("hw/bsp")
6+
7+
board_dir = list(bsp.glob("*/boards/" + board))
8+
if not board_dir:
9+
# Skip unknown boards
10+
return True
11+
12+
board_dir = list(board_dir)[0]
13+
14+
family_dir = board_dir.parent.parent
15+
family = family_dir.name
16+
17+
# family CMake
18+
family_mk = family_dir / "family.cmake"
19+
20+
# family.mk
21+
if not family_mk.exists():
22+
family_mk = family_dir / "family.mk"
23+
24+
mk_contents = family_mk.read_text()
25+
26+
# Find the mcu
27+
if "CFG_TUSB_MCU=OPT_MCU_" not in mk_contents:
28+
board_mk = board_dir / "board.cmake"
29+
if not board_mk.exists():
30+
board_mk = board_dir / "board.mk"
31+
32+
mk_contents = board_mk.read_text()
33+
34+
for token in mk_contents.split():
35+
if "CFG_TUSB_MCU=OPT_MCU_" in token:
36+
# Strip " because cmake files has them.
37+
token = token.strip("\"")
38+
_, opt_mcu = token.split("=")
39+
mcu = opt_mcu[len("OPT_MCU_"):]
40+
41+
# Skip all OPT_MCU_NONE these are WIP port
42+
if mcu == "NONE":
43+
return True
44+
45+
skip_file = ex_dir / "skip.txt"
46+
only_file = ex_dir / "only.txt"
47+
48+
if skip_file.exists() and only_file.exists():
49+
raise RuntimeError("Only have a skip or only file. Not both.")
50+
elif skip_file.exists():
51+
skips = skip_file.read_text().split()
52+
return ("mcu:" + mcu in skips or
53+
"board:" + board in skips or
54+
"family:" + family in skips)
55+
elif only_file.exists():
56+
onlys = only_file.read_text().split()
57+
return not ("mcu:" + mcu in onlys or
58+
"board:" + board in onlys or
59+
"family:" + family in onlys)
60+
61+
return False

0 commit comments

Comments
 (0)