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

Update DM XML generation script to use new path format #37148

Merged
merged 4 commits into from
Jan 22, 2025
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
19 changes: 4 additions & 15 deletions scripts/spec_xml/generate_spec_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,18 @@
import os
import re
import subprocess
import sys
import xml.etree.ElementTree as ElementTree
from pathlib import Path

import click
from paths import Branch, get_chip_root, get_data_model_path, get_documentation_file_path, get_in_progress_defines
from chip.testing.spec_parsing import build_xml_clusters
from paths import get_chip_root, get_documentation_file_path, get_in_progress_defines

# Use the get_in_progress_defines() function to fetch the in-progress defines
CURRENT_IN_PROGRESS_DEFINES = get_in_progress_defines()

# Replace hardcoded paths with dynamic paths using paths.py functions
DEFAULT_CHIP_ROOT = get_chip_root()
DEFAULT_OUTPUT_DIR_1_4 = get_data_model_path(Branch.V1_4)
DEFAULT_OUTPUT_DIR_IN_PROGRESS = get_data_model_path(Branch.IN_PROGRESS)
DEFAULT_OUTPUT_DIR_TOT = get_data_model_path(Branch.MASTER)
DEFAULT_DOCUMENTATION_FILE = get_documentation_file_path()


Expand Down Expand Up @@ -71,6 +68,7 @@ def make_asciidoc(target: str, include_in_progress: str, spec_dir: str, dry_run:
help='Path to the spec root')
@click.option(
'--output-dir',
required=True,
help='Path to output xml files')
@click.option(
'--dry-run',
Expand All @@ -81,9 +79,6 @@ def make_asciidoc(target: str, include_in_progress: str, spec_dir: str, dry_run:
'--include-in-progress',
type=click.Choice(['All', 'None', 'Current']), default='All')
def main(scraper, spec_root, output_dir, dry_run, include_in_progress):
if not output_dir:
output_dir_map = {'All': DEFAULT_OUTPUT_DIR_TOT, 'None': DEFAULT_OUTPUT_DIR_1_4, 'Current': DEFAULT_OUTPUT_DIR_IN_PROGRESS}
output_dir = output_dir_map[include_in_progress]
scrape_clusters(scraper, spec_root, output_dir, dry_run, include_in_progress)
scrape_device_types(scraper, spec_root, output_dir, dry_run, include_in_progress)
if not dry_run:
Expand Down Expand Up @@ -195,18 +190,12 @@ def dump_versions(scraper, spec_root, output_dir):


def dump_cluster_ids(output_dir):
python_testing_path = os.path.abspath(
os.path.join(DEFAULT_CHIP_ROOT, 'src', 'python_testing'))
sys.path.insert(0, python_testing_path)
clusters_output_dir = os.path.abspath(
os.path.join(output_dir, 'clusters'))

from spec_parsing_support import build_xml_clusters

header = '# List of currently defined spec clusters\n'
header += 'This file was **AUTOMATICALLY** generated by `python scripts/generate_spec_xml.py`. DO NOT EDIT BY HAND!\n\n'

clusters, problems = build_xml_clusters(clusters_output_dir)
clusters, problems = build_xml_clusters(Path(clusters_output_dir))
all_name_lens = [len(c.name) for c in clusters.values()]
name_len = max(all_name_lens)
title_id_decimal = ' ID (Decimal) '
Expand Down
Loading