@@ -727,13 +727,21 @@ def getBuildTask(self, args):
727
727
728
728
729
729
class EspressoRuntimeResourceBuildTask (mx .JavaBuildTask ):
730
+ subject : EspressoRuntimeResourceProject
731
+
730
732
def __str__ (self ):
731
733
return f'Generating { self .subject .name } internal resource and compiling it with { self ._getCompiler ().name ()} '
732
734
733
735
@staticmethod
734
736
def _template_file ():
735
737
return join (_suite .mxDir , 'espresso_runtime_resource.template' )
736
738
739
+ def witness_file (self ):
740
+ return join (self .subject .get_output_root (), 'witness' )
741
+
742
+ def witness_contents (self ):
743
+ return self .subject .resource_id
744
+
737
745
def needsBuild (self , newestInput ):
738
746
is_needed , reason = mx .ProjectBuildTask .needsBuild (self , newestInput )
739
747
if is_needed :
@@ -748,6 +756,13 @@ def needsBuild(self, newestInput):
748
756
])
749
757
if newestInput is None or newestInput .isOlderThan (template_ts ):
750
758
newestInput = template_ts
759
+ witness_file = self .witness_file ()
760
+ if not exists (witness_file ):
761
+ return True , witness_file + " doesn't exist"
762
+ expected = self .witness_contents ()
763
+ with open (witness_file , 'r' , encoding = 'utf-8' ) as f :
764
+ if f .read () != expected :
765
+ return True , "Outdated content"
751
766
return super ().needsBuild (newestInput )
752
767
753
768
@staticmethod
@@ -791,6 +806,10 @@ def build(self):
791
806
with mx_util .SafeFileCreation (target_file ) as sfc , open (sfc .tmpPath , 'w' , encoding = 'utf-8' ) as f :
792
807
f .write (file_content )
793
808
super (EspressoRuntimeResourceBuildTask , self ).build ()
809
+ witness_file = self .witness_file ()
810
+ mx_util .ensure_dirname_exists (witness_file )
811
+ with mx_util .SafeFileCreation (witness_file ) as sfc , io .open (sfc .tmpFd , mode = 'w' , closefd = False , encoding = 'utf-8' ) as outfile :
812
+ outfile .write (self .witness_contents ())
794
813
795
814
796
815
mx_sdk_vm .register_graalvm_component (mx_sdk_vm .GraalVmJreComponent (
0 commit comments