@@ -45,13 +45,13 @@ def read_mpconfig():
4545 return configs
4646
4747
48- def build_json (modules , configs ):
48+ def build_module_map (modules , configs ):
4949 """ Establish the base of the JSON file, based on the contents from
5050 `configs`. Base will contain module names, if they're part of
5151 the `FULL_BUILD`, or their default value (0 | 1).
5252
5353 """
54- base_json = dict ()
54+ base = dict ()
5555 full_build = False
5656 for module in modules :
5757 full_name = module
@@ -67,22 +67,22 @@ def build_json(modules, configs):
6767 default_val = find_config .group (1 )
6868 else :
6969 default_val = "None"
70- base_json [search_name ] = {
70+ base [search_name ] = {
7171 "name" : full_name ,
7272 "full_build" : str (full_build ),
7373 "default_value" : default_val ,
7474 "excluded" : []
7575 }
7676
77- return get_excluded_boards (base_json )
77+ return get_excluded_boards (base )
7878
7979
80- def get_excluded_boards (base_json ):
80+ def get_excluded_boards (base ):
8181 """ Cycles through each board's `mpconfigboard.mk` file to determine
8282 if each module is included or not. Boards are selected by existence
8383 in a port listed in `SUPPORTED_PORTS` (e.g. `/port/nrf/feather_52840`)
8484 """
85- modules = list (base_json .keys ())
85+ modules = list (base .keys ())
8686 for port in SUPPORTED_PORTS :
8787 port_dir = "ports/{}/boards" .format (port )
8888 for entry in os .scandir (port_dir ):
@@ -97,8 +97,8 @@ def get_excluded_boards(base_json):
9797 # check if board uses `SMALL_BUILD`. if yes, and current
9898 # module is marked as `FULL_BUILD`, board is excluded
9999 small_build = re .search ("CIRCUITPY_SMALL_BUILD = 1" , contents )
100- if small_build and base_json [module ]["full_build" ] == "1" :
101- base_json [module ]["excluded" ].append (entry .name )
100+ if small_build and base [module ]["full_build" ] == "1" :
101+ base [module ]["excluded" ].append (entry .name )
102102 continue
103103
104104 # check if module is specifically disabled for this board
@@ -107,27 +107,19 @@ def get_excluded_boards(base_json):
107107 if not find_module :
108108 # check if default inclusion is off ('0'). if the board doesn't
109109 # have it explicitly enabled, its excluded.
110- if base_json [module ]["default_value" ] == "0" :
111- base_json [module ]["excluded" ].append (entry .name )
110+ if base [module ]["default_value" ] == "0" :
111+ base [module ]["excluded" ].append (entry .name )
112112 continue
113113 if (find_module .group (1 ) == "0" and
114- find_module .group (1 ) != base_json [module ]["default_value" ]):
115- base_json [module ]["excluded" ].append (entry .name )
114+ find_module .group (1 ) != base [module ]["default_value" ]):
115+ base [module ]["excluded" ].append (entry .name )
116116
117- return base_json
117+ return base
118118
119- if __name__ == "__main__" :
119+
120+ def support_matrix ():
120121 modules = get_shared_bindings ()
121122 configs = read_mpconfig ()
122- base = build_json (sorted (modules ), configs )
123-
124- final_json = json .dumps (base , indent = 2 )
125-
126- shared_bindings_json = 'support_matrix.json'
127- if 'TRAVIS' in os .environ :
128- shared_bindings_json = os .path .join (os .environ ['HOME' ], shared_bindings_json )
129- else :
130- print (final_json )
131- shared_bindings_json = os .path .join ('shared-bindings' , shared_bindings_json )
132- with open (shared_bindings_json , "w" ) as matrix :
133- json .dump (base , matrix , indent = 2 )
123+ base = build_module_map (sorted (modules ), configs )
124+
125+ return base
0 commit comments