@@ -576,8 +576,9 @@ def gate_svm_truffle_tck_python(tasks):
576576def build_tests_image (image_dir , options , unit_tests = None , additional_deps = None , shared_lib = False ):
577577 native_image_context , svm = graalvm_svm ()
578578 with native_image_context (svm .IMAGE_ASSERTION_FLAGS ) as native_image :
579+ import json
579580 import mx_compiler
580- build_options = [] + options
581+ build_options = ['-H:+GenerateBuildArtifactsFile' ] + options
581582 if shared_lib :
582583 build_options = build_options + ['--shared' ]
583584 build_deps = []
@@ -602,21 +603,18 @@ def build_tests_image(image_dir, options, unit_tests=None, additional_deps=None,
602603 if additional_deps :
603604 build_deps = build_deps + additional_deps
604605 extra_image_args = mx .get_runtime_jvm_args (build_deps , jdk = mx_compiler .jdk , exclude_names = mx_sdk_vm_impl .NativePropertiesBuildTask .implicit_excludes )
605- tests_image = native_image (build_options + extra_image_args )
606- import configparser
607- artifacts = configparser .RawConfigParser (allow_no_value = True )
608- artifacts_file_path = tests_image + '.build_artifacts.txt'
606+ native_image (build_options + extra_image_args )
607+ artifacts_file_path = join (image_dir , 'build-artifacts.json' )
609608 if not exists (artifacts_file_path ):
610- mx .abort ('Tests image build artifacts not found.' )
611- artifacts .read (artifacts_file_path )
612- if shared_lib :
613- if not any (s == 'SHARED_LIB' for s in artifacts .sections ()):
614- mx .abort ('Shared lib not found in image build artifacts.' )
615- tests_image_path = join (image_dir , str (artifacts .items ('SHARED_LIB' )[0 ][0 ]))
616- else :
617- if not any (s == 'EXECUTABLE' for s in artifacts .sections ()):
618- mx .abort ('Executable not found in image build artifacts.' )
619- tests_image_path = join (image_dir , str (artifacts .items ('EXECUTABLE' )[0 ][0 ]))
609+ mx .abort (f'{ artifacts_file_path } for tests image not found.' )
610+ with open (artifacts_file_path ) as f :
611+ artifacts = json .load (f )
612+ kind = 'shared_libraries' if shared_lib else 'executables'
613+ if kind not in artifacts :
614+ mx .abort (f'{ kind } not found in { artifacts_file_path } .' )
615+ if len (artifacts [kind ]) != 1 :
616+ mx .abort (f"Expected { kind } list with one element, found { len (artifacts [kind ])} : { ', ' .join (artifacts [kind ])} ." )
617+ tests_image_path = join (image_dir , artifacts [kind ][0 ])
620618 mx .logv (f'Test image path: { tests_image_path } ' )
621619 return tests_image_path , unittests_file
622620
0 commit comments