forked from espressif/esp-idf
Merge branch 'feat/diag_cpuinfo' into 'master'
feat(tools): add basic system information to diag report Closes IDF-12100 See merge request espressif/esp-idf!36627
This commit is contained in:
@@ -90,6 +90,11 @@ variable, format it as `${NAME}`, such as `${IDF_PATH}`.
|
|||||||
Brief description of the `step`, displayed in the `idf.py diag` progress
|
Brief description of the `step`, displayed in the `idf.py diag` progress
|
||||||
beneath the `recipe` description.
|
beneath the `recipe` description.
|
||||||
|
|
||||||
|
* system: string (optional)
|
||||||
|
Can be used to restrict the operating system on which the step will be
|
||||||
|
executed. It should be Linux, Darwin, or Windows. If specified, the step
|
||||||
|
will only run on the designated system.
|
||||||
|
|
||||||
* output: string (optional)
|
* output: string (optional)
|
||||||
|
|
||||||
Global output directory for the `step`. This directory serves as the main
|
Global output directory for the `step`. This directory serves as the main
|
||||||
|
@@ -6,7 +6,6 @@ steps:
|
|||||||
cmds:
|
cmds:
|
||||||
- exec:
|
- exec:
|
||||||
cmd: 'idf.py --version'
|
cmd: 'idf.py --version'
|
||||||
timeout: 10
|
|
||||||
output: esp_idf.ver
|
output: esp_idf.ver
|
||||||
|
|
||||||
- name: 'ESP-IDF Git Version'
|
- name: 'ESP-IDF Git Version'
|
||||||
@@ -14,16 +13,3 @@ steps:
|
|||||||
- exec:
|
- exec:
|
||||||
cmd: 'git -C ${IDF_PATH} describe'
|
cmd: 'git -C ${IDF_PATH} describe'
|
||||||
output: esp_idf_git.ver
|
output: esp_idf_git.ver
|
||||||
|
|
||||||
- name: 'Platform Information'
|
|
||||||
cmds:
|
|
||||||
- exec:
|
|
||||||
cmd:
|
|
||||||
- python
|
|
||||||
- -c
|
|
||||||
- |
|
|
||||||
import platform
|
|
||||||
print(f'system: {platform.system()}')
|
|
||||||
print(f'release: {platform.release()}')
|
|
||||||
print(f'machine: {platform.machine()}')
|
|
||||||
output: platform.inf
|
|
||||||
|
49
tools/idf_py_actions/diag/recipes/system.yml
Normal file
49
tools/idf_py_actions/diag/recipes/system.yml
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
description: System information
|
||||||
|
tags: [system, base, project]
|
||||||
|
steps:
|
||||||
|
- name: 'Platform Information'
|
||||||
|
cmds:
|
||||||
|
- exec:
|
||||||
|
cmd:
|
||||||
|
- python
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
import platform
|
||||||
|
print(f'system: {platform.system()}')
|
||||||
|
print(f'release: {platform.release()}')
|
||||||
|
print(f'machine: {platform.machine()}')
|
||||||
|
output: platform.inf
|
||||||
|
|
||||||
|
- name: 'Linux System Information'
|
||||||
|
system: Linux
|
||||||
|
output: linux
|
||||||
|
cmds:
|
||||||
|
- file:
|
||||||
|
path: '/proc/cpuinfo'
|
||||||
|
- file:
|
||||||
|
path: '/etc/os-release'
|
||||||
|
- exec:
|
||||||
|
cmd: 'uname -a'
|
||||||
|
output: uname
|
||||||
|
|
||||||
|
- name: 'Darwin Information'
|
||||||
|
system: Darwin
|
||||||
|
output: darwin
|
||||||
|
cmds:
|
||||||
|
- exec:
|
||||||
|
cmd: 'sysctl machdep.cpu'
|
||||||
|
output: machdep.cpu
|
||||||
|
- exec:
|
||||||
|
cmd: 'sw_vers'
|
||||||
|
output: sw_vers
|
||||||
|
- exec:
|
||||||
|
cmd: 'uname -a'
|
||||||
|
output: uname
|
||||||
|
|
||||||
|
- name: 'Windows Information'
|
||||||
|
system: Windows
|
||||||
|
output: windows
|
||||||
|
cmds:
|
||||||
|
- exec:
|
||||||
|
cmd: 'systeminfo'
|
||||||
|
output: systeminfo
|
@@ -3,6 +3,7 @@
|
|||||||
import atexit
|
import atexit
|
||||||
import difflib
|
import difflib
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
@@ -289,7 +290,7 @@ def validate_recipe(recipe: Dict) -> None:
|
|||||||
dependencies and to provide more informative error messages.
|
dependencies and to provide more informative error messages.
|
||||||
"""
|
"""
|
||||||
recipe_keys = ['description', 'tags', 'output', 'steps']
|
recipe_keys = ['description', 'tags', 'output', 'steps']
|
||||||
step_keys = ['name', 'cmds', 'output']
|
step_keys = ['name', 'cmds', 'output', 'system']
|
||||||
recipe_description = recipe.get('description')
|
recipe_description = recipe.get('description')
|
||||||
recipe_tags = recipe.get('tags')
|
recipe_tags = recipe.get('tags')
|
||||||
recipe_output = recipe.get('output')
|
recipe_output = recipe.get('output')
|
||||||
@@ -330,6 +331,7 @@ def validate_recipe(recipe: Dict) -> None:
|
|||||||
step_name = step.get('name')
|
step_name = step.get('name')
|
||||||
step_output = step.get('output')
|
step_output = step.get('output')
|
||||||
step_cmds = step.get('cmds')
|
step_cmds = step.get('cmds')
|
||||||
|
step_system = step.get('system')
|
||||||
|
|
||||||
if not step_name:
|
if not step_name:
|
||||||
raise RuntimeError(f'Recipe step is missing "name" key')
|
raise RuntimeError(f'Recipe step is missing "name" key')
|
||||||
@@ -342,6 +344,12 @@ def validate_recipe(recipe: Dict) -> None:
|
|||||||
if step_output:
|
if step_output:
|
||||||
if type(step_output) is not str:
|
if type(step_output) is not str:
|
||||||
raise RuntimeError(f'Step "output" key is not of type "str"')
|
raise RuntimeError(f'Step "output" key is not of type "str"')
|
||||||
|
if step_system:
|
||||||
|
if type(step_system) is not str:
|
||||||
|
raise RuntimeError(f'Step "system" key is not of type "str"')
|
||||||
|
if step_system not in ['Linux', 'Windows', 'Darwin']:
|
||||||
|
raise RuntimeError((f'Unknown "system" key value "{step_system}", '
|
||||||
|
f'expecting "Linux", "Windows" or "Darwin"'))
|
||||||
|
|
||||||
for cmd in step_cmds:
|
for cmd in step_cmds:
|
||||||
if 'exec' in cmd:
|
if 'exec' in cmd:
|
||||||
@@ -769,6 +777,12 @@ def process_recipe(recipe: Dict) -> None:
|
|||||||
"""execute commands for every stage in a recipe"""
|
"""execute commands for every stage in a recipe"""
|
||||||
for step in recipe['steps']:
|
for step in recipe['steps']:
|
||||||
step_name = step['name']
|
step_name = step['name']
|
||||||
|
step_system = step.get('system')
|
||||||
|
|
||||||
|
if step_system and step_system != platform.system():
|
||||||
|
dbg(f'Skipping step "{step_name}" for "{step_system}"')
|
||||||
|
continue
|
||||||
|
|
||||||
dbg(f'Processing step "{step_name}"')
|
dbg(f'Processing step "{step_name}"')
|
||||||
print(f'* {step_name}')
|
print(f'* {step_name}')
|
||||||
for cmd in step['cmds']:
|
for cmd in step['cmds']:
|
||||||
@@ -1014,6 +1028,7 @@ def create(action: str,
|
|||||||
dbg(f'Recipe variables: {recipe_variables}')
|
dbg(f'Recipe variables: {recipe_variables}')
|
||||||
dbg(f'Project directory: {project_dir}')
|
dbg(f'Project directory: {project_dir}')
|
||||||
dbg(f'Build directory: {build_dir}')
|
dbg(f'Build directory: {build_dir}')
|
||||||
|
dbg(f'System: {platform.system()}')
|
||||||
|
|
||||||
if list_recipes:
|
if list_recipes:
|
||||||
# List recipes command
|
# List recipes command
|
||||||
|
Reference in New Issue
Block a user