Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter generate board #23885

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 71 additions & 71 deletions Tools/ci/generate_board_targets_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@
help='Pretty output instead of a single line')
parser.add_argument('-g', '--groups', dest='group', action='store_true',
help='Groups targets')
parser.add_argument('-f', '--filter', dest='filter', help='comma separated list of board names to use instead of all')

args = parser.parse_args()
verbose = args.verbose

board_filter = []
if args.filter:
for board in args.filter.split(','):
board_filter.append(board)

build_configs = []
grouped_targets = {}
excluded_boards = ['modalai_voxl2', 'px4_ros2'] # TODO: fix and enable
Expand Down Expand Up @@ -141,6 +147,10 @@ def process_target(px4board_file, target_name):
label = files.name[:-9]
target_name = manufacturer.name + '_' + board.name + '_' + label

if board_filter and not board_name in board_filter:
if verbose: print(f'excluding board {board_name} ({target_name})')
continue

if board_name in excluded_boards:
if verbose: print(f'excluding board {board_name} ({target_name})')
continue
Expand Down Expand Up @@ -189,8 +199,6 @@ def process_target(px4board_file, target_name):
# nuttx-0
# nuttx-1
final_groups = []
temp_group = []
group_number = {}
last_man = ''
last_arch = ''
SPLIT_LIMIT = 10
Expand All @@ -199,88 +207,80 @@ def process_target(px4board_file, target_name):
print(f'=:Architectures: [{grouped_targets.keys()}]')
for arch in grouped_targets:
if(verbose):
print(f'=:Processing: [{arch}] Last: [{last_arch}]')

if(last_arch == ''):
last_arch = arch
if(arch not in group_number):
group_number[arch] = 0

if(last_arch != arch and len(temp_group) > 0):
print(f'=:Processing: [{arch}]')
temp_group = []
for man in grouped_targets[arch]['manufacturers']:
if(verbose):
print(f'=:Processing: [{arch}][{man}]')
man_len = len(grouped_targets[arch]['manufacturers'][man])
if(man_len > LOWER_LIMIT and man_len < (SPLIT_LIMIT + 1)):
# Manufacturers can have their own group
if(verbose):
print(f'=:Processing: [{arch}][{man}][{man_len}]==Manufacturers can have their own group')
group_name = arch + "-" + man
targets = comma_targets(grouped_targets[arch]['manufacturers'][man])
final_groups.append({
"container": grouped_targets[arch]['container'],
"targets": targets,
"arch": arch,
"group": group_name,
"len": len(grouped_targets[arch]['manufacturers'][man])
})
elif(man_len >= (SPLIT_LIMIT + 1)):
# Split big man groups into subgroups
# example: Pixhawk
if(verbose):
print(f'=:Processing: [{arch}][{man}][{man_len}]==Manufacturers has multiple own groups')
chunk_limit = SPLIT_LIMIT
chunk_counter = 0
for chunk in chunks(grouped_targets[arch]['manufacturers'][man], chunk_limit):
group_name = arch + "-" + man + "-" + str(chunk_counter)
targets = comma_targets(chunk)
final_groups.append({
"container": grouped_targets[arch]['container'],
"targets": targets,
"arch": arch,
"group": group_name,
"len": len(chunk),
})
chunk_counter += 1
else:
if(verbose):
print(f'=:Processing: [{arch}][{man}][{man_len}]==Manufacturers too small group with others')
temp_group.extend(grouped_targets[arch]['manufacturers'][man])

group_name = last_arch + "-" + str(group_number[last_arch])
group_number[last_arch] += 1
targets = comma_targets(temp_group)
temp_len = len(temp_group)
chunk_counter = 0
if(temp_len > 0 and temp_len < (SPLIT_LIMIT + 1)):
if(verbose):
print(f'=:Orphan: [{arch}][{last_arch}][{targets}]')
print(f'=:Processing: [{arch}][orphan][{temp_len}]==Leftover arch can have their own group')
group_name = arch + "-" + str(chunk_counter)
targets = comma_targets(temp_group)
final_groups.append({
"container": grouped_targets[last_arch]['container'],
"container": grouped_targets[arch]['container'],
"targets": targets,
"arch": last_arch,
"arch": arch,
"group": group_name,
"len": len(temp_group)
"len": temp_len
})
last_arch = arch
temp_group = []

for man in grouped_targets[arch]['manufacturers']:
elif(temp_len >= (SPLIT_LIMIT + 1)):
# Split big man groups into subgroups
# example: Pixhawk
if(verbose):
print(f'=:Processing: [{arch}][{man}]')
for tar in grouped_targets[arch]['manufacturers'][man]:
man_len = len(grouped_targets[arch]['manufacturers'][man])
if(verbose):
print(f'=:Processing: [{arch}][{man}][{man_len}][{tar}]')
if(last_man != man):
# if(verbose):
# print(f'=:Processing: [{arch}][{man}][{tar}][{man_len}]')
if(man_len > LOWER_LIMIT and man_len < (SPLIT_LIMIT + 1)):
# Manufacturers can have their own group
if(verbose):
print(f'=:Processing: ==Manufacturers can have their own group')
print(f'=:Processing: Limits[{LOWER_LIMIT}][{SPLIT_LIMIT}]')
group_name = arch + "-" + man
targets = comma_targets(grouped_targets[arch]['manufacturers'][man])
last_man = man
final_groups.append({
"container": grouped_targets[arch]['container'],
"targets": targets,
"arch": arch,
"group": group_name,
"len": len(grouped_targets[arch]['manufacturers'][man])
})
elif(man_len >= (SPLIT_LIMIT + 1)):
# Split big man groups into subgroups
# example: Pixhawk
chunk_limit = SPLIT_LIMIT
chunk_counter = 0
for chunk in chunks(grouped_targets[arch]['manufacturers'][man], chunk_limit):
group_name = arch + "-" + man + "-" + str(chunk_counter)
targets = comma_targets(chunk)
last_man = man
final_groups.append({
"container": grouped_targets[arch]['container'],
"targets": targets,
"arch": arch,
"group": group_name,
"len": len(chunk),
})
chunk_counter += 1
else:
temp_group.append(tar)

if(len(temp_group) > (LOWER_LIMIT - 1)):
group_name = arch + "-" + str(group_number[arch])
last_arch = arch
group_number[arch] += 1
targets = comma_targets(temp_group)
print(f'=:Processing: [{arch}][orphan][{temp_len}]==Leftover arch can has multpile group')
chunk_limit = SPLIT_LIMIT
chunk_counter = 0
for chunk in chunks(temp_group, chunk_limit):
group_name = arch + "-" + str(chunk_counter)
targets = comma_targets(chunk)
final_groups.append({
"container": grouped_targets[arch]['container'],
"targets": targets,
"arch": arch,
"group": group_name,
"len": len(temp_group)
"len": len(chunk),
})
temp_group = []
chunk_counter += 1
if(verbose):
import pprint
print("================")
Expand Down
Loading