<commit_before>#!/usr/bin/env python3
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
r"""Script to prepare SW for non-earlgrey tops
"""

import sys
import subprocess
import re
from pathlib import Path


def main():

    # Config
    name_old = 'earlgrey'
    name = 'englishbreakfast'

    topname = 'top_' + name

    # We first need to run topgen in order to create all auto-generated files.
    path_root = str(Path(__file__).resolve().parents[3])
    path_in = path_root + '/hw/' + topname + '/data/'
    path_out = path_root + '/hw/' + topname
    cmd = [path_root + '/util/topgen.py',  # "--verbose",
           "-t", path_in + topname + '.hjson',
           "-c", path_in,<commit_msg>[top_englishbreakfast] Remove auto-gen files before creating boot ROM<commit_after>#!/usr/bin/env python3
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
r"""Script to prepare SW for non-earlgrey tops
"""

import sys
import subprocess
import re
from pathlib import Path


def main():

    # Config
    name_old = 'earlgrey'
    name = 'englishbreakfast'

    topname = 'top_' + name

    path_root = str(Path(__file__).resolve().parents[3])

    # We start by removing any previously generated auto-gen files for the
    # selected non-earlgrey top. These might be stale and confuse topgen.
    cmd = [path_root + '/hw/' + topname + '/util/remove_autogen_files.sh']

    try:
        print("Removing auto-generated files...")
        subprocess.run(cmd,
                       check=True,
                       stdout=subprocess.PIPE,
                       stderr=subprocess.STDOUT,
                       universal_newlines=True)

    except subprocess.CalledProcessError as e:
        print("Removing auto-generated files failed: " + str(e))
        sys.exit(1)

    # Next, we need to run topgen in order to create all auto-generated files.
    path_in = path_root + '/hw/' + topname + '/data/'
    path_out = path_root + '/hw/' + topname
    cmd = [path_root + '/util/topgen.py',  # "--verbose",
           "-t", path_in + topname + '.hjson',
           "-c", path_in,
{'fraction_non_alphanumeric': 0.11969964664310954, 'fraction_numerical': 0.005742049469964664, 'mean_word_length': 2.6591276252019385, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '121258', 'n_tokens_mistral': 714, 'n_tokens_neox': 685, 'n_words': 209}