Skip to content

[GR-65517] Espresso: Ensure runtime resource is rebuilt when its id changes. #11351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions espresso/mx.espresso/mx_espresso.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,13 +727,21 @@ def getBuildTask(self, args):


class EspressoRuntimeResourceBuildTask(mx.JavaBuildTask):
subject: EspressoRuntimeResourceProject

def __str__(self):
return f'Generating {self.subject.name} internal resource and compiling it with {self._getCompiler().name()}'

@staticmethod
def _template_file():
return join(_suite.mxDir, 'espresso_runtime_resource.template')

def witness_file(self):
return join(self.subject.get_output_root(), 'witness')

def witness_contents(self):
return self.subject.resource_id

def needsBuild(self, newestInput):
is_needed, reason = mx.ProjectBuildTask.needsBuild(self, newestInput)
if is_needed:
Expand All @@ -748,6 +756,13 @@ def needsBuild(self, newestInput):
])
if newestInput is None or newestInput.isOlderThan(template_ts):
newestInput = template_ts
witness_file = self.witness_file()
if not exists(witness_file):
return True, witness_file + " doesn't exist"
expected = self.witness_contents()
with open(witness_file, 'r', encoding='utf-8') as f:
if f.read() != expected:
return True, "Outdated content"
return super().needsBuild(newestInput)

@staticmethod
Expand Down Expand Up @@ -791,6 +806,10 @@ def build(self):
with mx_util.SafeFileCreation(target_file) as sfc, open(sfc.tmpPath, 'w', encoding='utf-8') as f:
f.write(file_content)
super(EspressoRuntimeResourceBuildTask, self).build()
witness_file = self.witness_file()
mx_util.ensure_dirname_exists(witness_file)
with mx_util.SafeFileCreation(witness_file) as sfc, io.open(sfc.tmpFd, mode='w', closefd=False, encoding='utf-8') as outfile:
outfile.write(self.witness_contents())


mx_sdk_vm.register_graalvm_component(mx_sdk_vm.GraalVmJreComponent(
Expand Down