Merge remote-tracking branch 'upstream/master' into h7rs
Signed-off-by: HiFiPhile <admin@hifiphile.com>
This commit is contained in:
105
tools/gen_presets.py
Executable file
105
tools/gen_presets.py
Executable file
@@ -0,0 +1,105 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
def main():
|
||||
board_list = []
|
||||
|
||||
# Find all board.cmake files
|
||||
for root, dirs, files in os.walk("hw/bsp"):
|
||||
for file in files:
|
||||
if file == "board.cmake":
|
||||
board_list.append(os.path.basename(root))
|
||||
|
||||
print('Generating presets for the following boards:')
|
||||
print(board_list)
|
||||
|
||||
# Generate the presets
|
||||
presets = {}
|
||||
presets['version'] = 6
|
||||
|
||||
# Configure presets
|
||||
presets['configurePresets'] = [
|
||||
{"name": "default",
|
||||
"hidden": True,
|
||||
"description": r"Configure preset for the ${presetName} board",
|
||||
"generator": "Ninja Multi-Config",
|
||||
"binaryDir": r"${sourceDir}/build/${presetName}",
|
||||
"cacheVariables": {
|
||||
"CMAKE_DEFAULT_BUILD_TYPE": "RelWithDebInfo",
|
||||
"BOARD": r"${presetName}"
|
||||
}}]
|
||||
|
||||
presets['configurePresets'].extend(
|
||||
sorted(
|
||||
[
|
||||
{
|
||||
'name': board,
|
||||
'inherits': 'default'
|
||||
}
|
||||
for board in board_list
|
||||
], key=lambda x: x['name']
|
||||
)
|
||||
)
|
||||
|
||||
# Build presets
|
||||
# no inheritance since 'name' doesn't support macro expansion
|
||||
presets['buildPresets'] = sorted(
|
||||
[
|
||||
{
|
||||
'name': board,
|
||||
'description': "Build preset for the " + board + " board",
|
||||
'configurePreset': board
|
||||
}
|
||||
for board in board_list
|
||||
], key=lambda x: x['name']
|
||||
)
|
||||
|
||||
# Workflow presets
|
||||
presets['workflowPresets'] = sorted(
|
||||
[
|
||||
{
|
||||
"name": board,
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": board
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": board
|
||||
}
|
||||
]
|
||||
}
|
||||
for board in board_list
|
||||
], key=lambda x: x['name']
|
||||
)
|
||||
|
||||
path_boardpresets = "hw/bsp/BoardPresets.json"
|
||||
with open(path_boardpresets, "w") as f:
|
||||
f.write('{}\n'.format(json.dumps(presets, indent=2)))
|
||||
|
||||
# Generate presets for examples
|
||||
presets = {
|
||||
"version": 6,
|
||||
"include": [
|
||||
]
|
||||
}
|
||||
|
||||
example_list = []
|
||||
for root, dirs, files in os.walk("examples"):
|
||||
for file in files:
|
||||
# Filter out ESP-IDF CMakeLists.txt in src folder
|
||||
if file == "CMakeLists.txt" and os.path.basename(root) != 'src':
|
||||
presets['include'] = [os.path.relpath(path_boardpresets, root).replace(os.sep, '/')]
|
||||
with open(os.path.join(root, 'CMakePresets.json'), 'w') as f:
|
||||
f.write('{}\n'.format(json.dumps(presets, indent=2)))
|
||||
example_list.append(os.path.basename(root))
|
||||
|
||||
print('Generating presets for the following examples:')
|
||||
print(example_list)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@@ -59,7 +59,7 @@ deps_optional = {
|
||||
'144f1eb7ea8c06512e12f12b27383601c0272410',
|
||||
'kinetis_k kinetis_k32l2 kinetis_kl lpc51 lpc54 lpc55 mcx imxrt'],
|
||||
'hw/mcu/raspberry_pi/Pico-PIO-USB': ['https://github.com/sekigon-gonnoc/Pico-PIO-USB.git',
|
||||
'fe9133fc513b82cc3dc62c67cb51f2339cf29ef7',
|
||||
'0ca3657d55ea20e7fa4483bbd21ce951bc1d6fa5',
|
||||
'rp2040'],
|
||||
'hw/mcu/renesas/fsp': ['https://github.com/renesas/fsp.git',
|
||||
'edcc97d684b6f716728a60d7a6fea049d9870bd6',
|
||||
@@ -223,7 +223,12 @@ TOP = Path(__file__).parent.parent.resolve()
|
||||
|
||||
|
||||
def run_cmd(cmd):
|
||||
return subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
r = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
title = f'Command Error: {cmd}'
|
||||
if r.returncode != 0:
|
||||
print(title)
|
||||
print(r.stdout.decode("utf-8"))
|
||||
return r
|
||||
|
||||
|
||||
def get_a_dep(d):
|
||||
|
Reference in New Issue
Block a user