mirror of
https://github.com/TinyTapeout/tt-support-tools.git
synced 2026-11-02 20:26:10 +01:00
feat(configure): support for multiple mux config files in TT_CONFIG
This commit is contained in:
@@ -65,3 +65,12 @@ def write_config(config: dict, basename: str, formats: Iterable[str] = ("json",)
|
||||
write_yaml_config(config, file)
|
||||
else:
|
||||
raise ConfigFileError("Unexpected configuration file format: {fmt}")
|
||||
|
||||
|
||||
def merge_dicts(a: dict, b: dict, path=[]):
|
||||
for key in b:
|
||||
if key in a and isinstance(a[key], dict) and isinstance(b[key], dict):
|
||||
merge_dicts(a[key], b[key], path + [str(key)])
|
||||
else:
|
||||
a[key] = b[key]
|
||||
return a
|
||||
|
||||
+11
-4
@@ -10,6 +10,7 @@ import klayout.db as pya
|
||||
import yaml
|
||||
|
||||
from config import Config
|
||||
from config_utils import merge_dicts
|
||||
from project import Project
|
||||
from shuttle_index import ShuttleIndex, ShuttleIndexLayout, ShuttleIndexProject
|
||||
from tech import tech_map
|
||||
@@ -71,10 +72,16 @@ class ShuttleConfig:
|
||||
self.layout["muxes"][x][y] = ""
|
||||
|
||||
def read_mux_config_file(self):
|
||||
with open(
|
||||
f"tt-multiplexer/cfg/{self.mux_config_yaml_name}", "r"
|
||||
) as mux_config_file:
|
||||
self.mux_config = yaml.safe_load(mux_config_file)
|
||||
self.mux_config: dict = {}
|
||||
for cfg_file in self.mux_config_yaml_name.split(":"):
|
||||
cfg_file_path = os.path.join("tt-multiplexer/cfg", cfg_file)
|
||||
if not os.path.exists(cfg_file_path):
|
||||
logging.error(f"mux config file {cfg_file_path} does not exist!")
|
||||
exit(1)
|
||||
with open(cfg_file_path, "r") as mux_config_file:
|
||||
self.mux_config = merge_dicts(
|
||||
self.mux_config, yaml.safe_load(mux_config_file)
|
||||
)
|
||||
|
||||
def configure_mux(self):
|
||||
with open(self.modules_yaml_name, "r") as modules_file:
|
||||
|
||||
Reference in New Issue
Block a user