Fix invalid computation of hask keys.

This commit is contained in:
Sleepy Monax 2023-04-20 08:18:37 +02:00
parent 49bdb4ebad
commit 5f6ca201fc
3 changed files with 62 additions and 5 deletions

View file

@ -41,9 +41,13 @@ def runCmd(args: Args):
if componentSpec is None:
raise Exception("Component not specified")
exe = builder.build(componentSpec, targetSpec).outfile()
component = builder.build(componentSpec, targetSpec)
shell.exec(exe, *args.args)
os.environ["OSDK_TARGET"] = component.context.target.id
os.environ["OSDK_COMPONENT"] = component.id()
os.environ["OSDK_BUILDDIR"] = component.context.builddir()
shell.exec(component.outfile(), *args.args)
cmds += [Cmd("r", "run", "Run the target", runCmd)]
@ -67,9 +71,13 @@ def debugCmd(args: Args):
if componentSpec is None:
raise Exception("Component not specified")
exe = builder.build(componentSpec, targetSpec).outfile()
component = builder.build(componentSpec, targetSpec)
shell.exec("lldb", "-o", "run", exe)
os.environ["OSDK_TARGET"] = component.context.target.id
os.environ["OSDK_COMPONENT"] = component.id()
os.environ["OSDK_BUILDDIR"] = component.context.builddir()
shell.exec("lldb", "-o", "run", component.outfile(), *args.args)
cmds += [Cmd("d", "debug", "Debug the target", debugCmd)]

View file

@ -12,6 +12,8 @@ logger = Logger("context")
class IContext(Protocol):
target: TargetManifest
def builddir(self) -> str:
...
@ -109,7 +111,7 @@ class Context(IContext):
return self.target.cdefs()
def hashid(self) -> str:
return utils.hash((self.target.props, str(self.tools)))[0:8]
return utils.hash((self.target.props, [self.tools[t].toJson() for t in self.tools]))[0:8]
def builddir(self) -> str:
return os.path.join(const.BUILD_DIR, f"{self.target.id}-{self.hashid()[:8]}")

View file

@ -43,6 +43,13 @@ class Manifest:
for key in kwargs:
setattr(self, key, kwargs[key])
def toJson(self) -> Json:
return {
"id": self.id,
"type": self.type.value,
"path": self.path
}
def __str__(self):
return f"Manifest(id={self.id}, type={self.type}, path={self.path})"
@ -74,6 +81,12 @@ class Extern:
for key in kwargs:
setattr(self, key, kwargs[key])
def toJson(self) -> Json:
return {
"git": self.git,
"tag": self.tag
}
def __str__(self):
return f"Extern(git={self.git}, tag={self.tag})"
@ -99,6 +112,13 @@ class ProjectManifest(Manifest):
super().__init__(json, path, strict, **kwargs)
def toJson(self) -> Json:
return {
**super().toJson(),
"description": self.description,
"extern": {k: v.toJson() for k, v in self.extern.items()}
}
def __str__(self):
return f"ProjectManifest(id={self.id}, type={self.type}, path={self.path}, description={self.description}, extern={self.extern})"
@ -130,6 +150,13 @@ class Tool:
for key in kwargs:
setattr(self, key, kwargs[key])
def toJson(self) -> Json:
return {
"cmd": self.cmd,
"args": self.args,
"files": self.files
}
def __str__(self):
return f"Tool(cmd={self.cmd}, args={self.args}, files={self.files})"
@ -161,6 +188,14 @@ class TargetManifest(Manifest):
super().__init__(json, path, strict, **kwargs)
def toJson(self) -> Json:
return {
**super().toJson(),
"props": self.props,
"tools": {k: v.toJson() for k, v in self.tools.items()},
"routing": self.routing
}
def __repr__(self):
return f"TargetManifest({self.id})"
@ -206,6 +241,18 @@ class ComponentManifest(Manifest):
super().__init__(json, path, strict, **kwargs)
def toJson(self) -> Json:
return {
**super().toJson(),
"description": self.decription,
"props": self.props,
"tools": {k: v.toJson() for k, v in self.tools.items()},
"enableIf": self.enableIf,
"requires": self.requires,
"provides": self.provides,
"subdirs": self.subdirs
}
def __repr__(self):
return f"ComponentManifest({self.id})"