21
21
import yaml
22
22
23
23
import build_board_info
24
+ from shared_bindings_matrix import get_settings_from_makefile
24
25
25
26
PORT_TO_ARCH = {
26
27
"atmel-samd" : "arm" ,
@@ -53,6 +54,7 @@ def set_boards_to_build(build_all):
53
54
all_board_ids = set ()
54
55
port_to_boards = {}
55
56
board_to_port = {}
57
+ board_settings = {}
56
58
for board_id in boards_info_json :
57
59
info = boards_info_json [board_id ]
58
60
if info .get ("alias" , False ):
@@ -70,6 +72,9 @@ def set_boards_to_build(build_all):
70
72
boards_to_build = set ()
71
73
board_pattern = re .compile (r"^ports/[^/]+/boards/([^/]+)/" )
72
74
port_pattern = re .compile (r"^ports/([^/]+)/" )
75
+ module_pattern = re .compile (
76
+ r"^(ports/[^/]+/common-hal|shared-bindings|shared-module)/([^/]+)/"
77
+ )
73
78
for p in changed_files :
74
79
# See if it is board specific
75
80
board_matches = board_pattern .search (p )
@@ -80,7 +85,8 @@ def set_boards_to_build(build_all):
80
85
81
86
# See if it is port specific
82
87
port_matches = port_pattern .search (p )
83
- if port_matches :
88
+ module_matches = module_pattern .search (p )
89
+ if port_matches and not module_matches :
84
90
port = port_matches .group (1 )
85
91
if port != "unix" :
86
92
boards_to_build .update (port_to_boards [port ])
@@ -94,14 +100,56 @@ def set_boards_to_build(build_all):
94
100
if p .startswith ("tests" ):
95
101
continue
96
102
103
+ # As a (nearly) last resort, for some certain files, we compute the settings from the
104
+ # makefile for each board and determine whether to build them that way.
105
+ if p .startswith ("frozen" ) or p .startswith ("supervisor" ) or module_matches :
106
+ for board in all_board_ids :
107
+ if board not in board_settings :
108
+ board_settings [board ] = get_settings_from_makefile (
109
+ "../ports/" + board_to_port [board ], board
110
+ )
111
+ settings = board_settings [board ]
112
+
113
+ # Check frozen files to see if they are in each board.
114
+ frozen = settings .get ("FROZEN_MPY_DIRS" , "" )
115
+ if frozen and p .startswith ("frozen" ) and p in frozen :
116
+ boards_to_build .add (board )
117
+ continue
118
+
119
+ # Check supervisor files. This is useful for limiting workflow changes to the
120
+ # relevant boards.
121
+ supervisor = settings ["SRC_SUPERVISOR" ]
122
+ if p .startswith ("supervisor" ):
123
+ if p in supervisor :
124
+ boards_to_build .add (board )
125
+ continue
126
+
127
+ web_workflow = settings ["CIRCUITPY_WEB_WORKFLOW" ]
128
+ while web_workflow .startswith ("$(" ):
129
+ web_workflow = settings [web_workflow [2 :- 1 ]]
130
+ if (
131
+ p .startswith ("supervisor/shared/web_workflow/static/" )
132
+ and web_workflow != "0"
133
+ ):
134
+ boards_to_build .add (board )
135
+ continue
136
+
137
+ # Check module matches
138
+ if module_matches :
139
+ module = module_matches .group (2 ) + "/"
140
+ if module in settings ["SRC_PATTERNS" ]:
141
+ boards_to_build .add (board )
142
+ continue
143
+ continue
144
+
97
145
# Otherwise build it all
98
146
boards_to_build = all_board_ids
99
147
break
100
148
101
149
# Split boards by architecture.
102
150
print ("Building boards:" )
103
151
arch_to_boards = {"aarch" : [], "arm" : [], "riscv" : [], "espressif" : []}
104
- for board in boards_to_build :
152
+ for board in sorted ( boards_to_build ) :
105
153
print (" " , board )
106
154
port = board_to_port .get (board )
107
155
# A board can appear due to its _deletion_ (rare)
0 commit comments