diff --git a/caravel.py b/caravel.py index bff7c6c..4dbed1a 100644 --- a/caravel.py +++ b/caravel.py @@ -4,6 +4,7 @@ import yaml import json import glob import shutil +import git def copy_print(src: str, dest: str): logging.info(f" -> {dest}") @@ -14,6 +15,7 @@ def copy_print_glob(pattern: str, dest_dir: str): for file in glob.glob(pattern): copy_print(file, os.path.join(dest_dir, os.path.basename(file))) + class CaravelConfig(): def __init__(self, config, projects, modules_yaml_name: str): @@ -54,7 +56,13 @@ class CaravelConfig(): for module in placed_modules['modules']: mux_address = (module['y'] << 5) + module['x'] module_name = 'tt_um_' + module['name'] - mux_index[mux_address] = module_name + mux_index[mux_address] = { + "macro": "module_name", + "x": module['x'], + "y": module['y'], + "repo": project.git_url, + "commit": project.commit_id, + }, mux_index_reverse[module_name] = mux_address for project in self.projects: @@ -63,8 +71,17 @@ class CaravelConfig(): exit(1) project.mux_address = mux_index_reverse[project.top_module] - with open('mux_index.json', 'w') as mux_index_file: - json.dump(mux_index, mux_index_file) + repo = git.Repo(".") + + shuttle_index_data = { + "shuttle": self.config["name"], + "repo": list(repo.remotes[0].urls)[0], + "commit": repo.commit().hexsha, + "mux": mux_index, + } + + with open('shuttle_index.json', 'w') as shuttle_index_file: + json.dump(shuttle_index_data, shuttle_index_file, indent=2) def list(self): for project in self.projects: diff --git a/configure.py b/configure.py index fd049e6..2bd1b26 100755 --- a/configure.py +++ b/configure.py @@ -42,6 +42,7 @@ class Projects(): commit_id_data = json.load(open(commit_id_file)) project = Project(index, commit_id_data['repo'], project_dir, args) + project.commit_id = commit_id_data['commit'] # projects should now be installed, so load all the data from the yaml files # fill projects will load from the fill project's directory