mirror of
https://github.com/TinyTapeout/tt-support-tools.git
synced 2026-11-03 04:36:09 +01:00
fix: remove ".mk" config format support
It was a temporary hack to support OpenROAD-flow-scripts (ORFS) for early IHP shuttles
This commit is contained in:
+4
-36
@@ -1,7 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
|
||||||
from collections.abc import Iterable
|
from collections.abc import Iterable
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
@@ -21,35 +19,9 @@ def read_yaml_config(file: str):
|
|||||||
return yaml.safe_load(open(file))
|
return yaml.safe_load(open(file))
|
||||||
|
|
||||||
|
|
||||||
def read_mk_config(file: str, design_dir: str | None = None):
|
def read_config(
|
||||||
logging.warning(
|
basename: str, formats: Iterable[str] = ("json",), design_dir: str | None = None
|
||||||
"Reading Makefile configuration files is an experimental feature and could be removed"
|
):
|
||||||
)
|
|
||||||
env_pre = {} if design_dir is None else {"DESIGN_HOME": design_dir}
|
|
||||||
mk_cg = "all:\n\t@env"
|
|
||||||
mk_tg = f"-include {file}\n{mk_cg}"
|
|
||||||
env_cg = subprocess.run(
|
|
||||||
"make -f -",
|
|
||||||
shell=True,
|
|
||||||
env=env_pre,
|
|
||||||
input=mk_cg,
|
|
||||||
capture_output=True,
|
|
||||||
text=True,
|
|
||||||
).stdout.strip()
|
|
||||||
env_tg = subprocess.run(
|
|
||||||
"make -f -",
|
|
||||||
shell=True,
|
|
||||||
env=env_pre,
|
|
||||||
input=mk_tg,
|
|
||||||
capture_output=True,
|
|
||||||
text=True,
|
|
||||||
).stdout.strip()
|
|
||||||
env_diff = set(env_tg.split("\n")) - set(env_cg.split("\n"))
|
|
||||||
config = dict(i.split("=", 1) for i in env_diff)
|
|
||||||
return config
|
|
||||||
|
|
||||||
|
|
||||||
def read_config(basename: str, formats: Iterable[str], design_dir: str | None = None):
|
|
||||||
for fmt in formats:
|
for fmt in formats:
|
||||||
file = f"{basename}.{fmt}"
|
file = f"{basename}.{fmt}"
|
||||||
if os.path.exists(file):
|
if os.path.exists(file):
|
||||||
@@ -57,8 +29,6 @@ def read_config(basename: str, formats: Iterable[str], design_dir: str | None =
|
|||||||
return read_json_config(file)
|
return read_json_config(file)
|
||||||
elif fmt == "yaml":
|
elif fmt == "yaml":
|
||||||
return read_yaml_config(file)
|
return read_yaml_config(file)
|
||||||
elif fmt == "mk":
|
|
||||||
return read_mk_config(file)
|
|
||||||
else:
|
else:
|
||||||
raise ConfigFileError(f"Unexpected configuration file format: {fmt}")
|
raise ConfigFileError(f"Unexpected configuration file format: {fmt}")
|
||||||
raise ConfigFileError(
|
raise ConfigFileError(
|
||||||
@@ -86,14 +56,12 @@ def write_mk_config(config: dict, file: str):
|
|||||||
print(f"export {key} = {value}", file=f)
|
print(f"export {key} = {value}", file=f)
|
||||||
|
|
||||||
|
|
||||||
def write_config(config: dict, basename: str, formats: Iterable[str]):
|
def write_config(config: dict, basename: str, formats: Iterable[str] = ("json",)):
|
||||||
for fmt in formats:
|
for fmt in formats:
|
||||||
file = f"{basename}.{fmt}"
|
file = f"{basename}.{fmt}"
|
||||||
if fmt == "json":
|
if fmt == "json":
|
||||||
write_json_config(config, file)
|
write_json_config(config, file)
|
||||||
elif fmt == "yaml":
|
elif fmt == "yaml":
|
||||||
write_yaml_config(config, file)
|
write_yaml_config(config, file)
|
||||||
elif fmt == "mk":
|
|
||||||
write_mk_config(config, file)
|
|
||||||
else:
|
else:
|
||||||
raise ConfigFileError("Unexpected configuration file format: {fmt}")
|
raise ConfigFileError("Unexpected configuration file format: {fmt}")
|
||||||
|
|||||||
+3
-3
@@ -500,10 +500,10 @@ class Project:
|
|||||||
tt_version = self.get_tt_tools_version()
|
tt_version = self.get_tt_tools_version()
|
||||||
workflow_url = self.get_workflow_url()
|
workflow_url = self.get_workflow_url()
|
||||||
|
|
||||||
config = read_config("src/config", ("json", "tcl"))
|
config = read_config("src/config")
|
||||||
user_config = read_config("src/user_config", ("json",))
|
user_config = read_config("src/user_config")
|
||||||
config.update(user_config)
|
config.update(user_config)
|
||||||
write_config(config, "src/config_merged", ("json",))
|
write_config(config, "src/config_merged")
|
||||||
|
|
||||||
shutil.rmtree("runs/wokwi", ignore_errors=True)
|
shutil.rmtree("runs/wokwi", ignore_errors=True)
|
||||||
os.makedirs("runs/wokwi", exist_ok=True)
|
os.makedirs("runs/wokwi", exist_ok=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user