Skip to content

Commit 0263d6a

Browse files
committed
Use BuildArtifactsJSON in build_tests_image().
1 parent 7a0b6a8 commit 0263d6a

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

vm/mx.vm/mx_vm_gate.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,9 @@ def gate_svm_truffle_tck_js(tasks):
560560
def build_tests_image(image_dir, options, unit_tests=None, additional_deps=None, shared_lib=False):
561561
native_image_context, svm = graalvm_svm()
562562
with native_image_context(svm.IMAGE_ASSERTION_FLAGS) as native_image:
563+
import json
563564
import mx_compiler
564-
build_options = [] + options
565+
build_options = ['-H:BuildArtifactsJSON='] + options
565566
if shared_lib:
566567
build_options = build_options + ['--shared']
567568
build_deps = []
@@ -586,21 +587,26 @@ def build_tests_image(image_dir, options, unit_tests=None, additional_deps=None,
586587
if additional_deps:
587588
build_deps = build_deps + additional_deps
588589
extra_image_args = mx.get_runtime_jvm_args(build_deps, jdk=mx_compiler.jdk, exclude_names=mx_sdk_vm_impl.NativePropertiesBuildTask.implicit_excludes)
589-
tests_image = native_image(build_options + extra_image_args)
590-
import configparser
591-
artifacts = configparser.RawConfigParser(allow_no_value=True)
592-
artifacts_file_path = tests_image + '.build_artifacts.txt'
590+
native_image(build_options + extra_image_args)
591+
artifacts_file_path = join(image_dir, 'build-artifacts.json')
593592
if not exists(artifacts_file_path):
594-
mx.abort('Tests image build artifacts not found.')
595-
artifacts.read(artifacts_file_path)
593+
mx.abort(f'{artifacts_file_path} for tests image not found.')
594+
with open(artifacts_file_path) as f:
595+
artifacts = json.load(f)
596+
from urllib.parse import urlparse
597+
from urllib.request import url2pathname
596598
if shared_lib:
597-
if not any(s == 'SHARED_LIB' for s in artifacts.sections()):
598-
mx.abort('Shared lib not found in image build artifacts.')
599-
tests_image_path = join(image_dir, str(artifacts.items('SHARED_LIB')[0][0]))
599+
if 'shared_library' not in artifacts:
600+
mx.abort(f'No shared library found in {artifacts_file_path}.')
601+
if len(artifacts['shared_library']) != 1:
602+
mx.abort(f"Expected one shared library, found {len(artifacts['shared_library'])}: {', '.join(artifacts['shared_library'])}.")
603+
tests_image_path = url2pathname(urlparse(artifacts['shared_library'][0]).path)
600604
else:
601-
if not any(s == 'EXECUTABLE' for s in artifacts.sections()):
602-
mx.abort('Executable not found in image build artifacts.')
603-
tests_image_path = join(image_dir, str(artifacts.items('EXECUTABLE')[0][0]))
605+
if 'executable' not in artifacts:
606+
mx.abort(f'No executable found in {artifacts_file_path}.')
607+
if len(artifacts['executable']) != 1:
608+
mx.abort(f"Expected one executable, found {len(artifacts['executable'])}: {', '.join(artifacts['executable'])}.")
609+
tests_image_path = url2pathname(urlparse(artifacts['executable'][0]).path)
604610
mx.logv('Test image path: {}'.format(tests_image_path))
605611
return tests_image_path, unittests_file
606612

0 commit comments

Comments
 (0)