Exemple #1
0
def _espresso_gate_runner(args, tasks):
    # Jackpot configuration is inherited from Truffle.
    with Task('Jackpot', tasks, tags=[EspressoTags.jackpot]) as t:
        if t:
            jackpot(['--fail-on-warnings'], suite=None, nonZeroIsFatal=True)

    with Task('Espresso: GraalVM dist names', tasks, tags=['names']) as t:
        if t:
            mx_sdk_vm.verify_graalvm_configs(suites=['espresso'])

    mokapot_header_gate_name = 'Verify consistency of mokapot headers'
    with Task(mokapot_header_gate_name, tasks, tags=[EspressoTags.verify]) as t:
        if t:
            import mx_sdk_vm_impl
            run_instructions = "$ mx --dynamicimports=/substratevm --native-images=lib:espresso gate --all-suites --task '{}'".format(mokapot_header_gate_name)
            if mx_sdk_vm_impl._skip_libraries(espresso_library_config):
                mx.abort("""\
The registration of the Espresso library ('lib:espresso') is skipped. Please run this gate as follows:
{}""".format(run_instructions))

            errors = False
            mokapot_dir = join(mx.project('com.oracle.truffle.espresso.mokapot').dir, 'include')
            libespresso_dir = mx.project(mx_sdk_vm_impl.GraalVmNativeImage.project_name(espresso_library_config)).get_output_root()

            for header in ['libespresso_dynamic.h', 'graal_isolate_dynamic.h']:
                committed_header = join(mokapot_dir, header)
                if not mx.exists(committed_header):
                    mx.abort("Cannot locate '{}'. Was the file moved or renamed?".format(committed_header))

                generated_header = join(libespresso_dir, header)
                if not mx.exists(generated_header):
                    mx.abort("Cannot locate '{}'. Did you forget to build? Example:\n'mx --dynamicimports=/substratevm --native-images=lib:espresso build'".format(generated_header))

                committed_header_copyright = []
                with open(committed_header, 'r') as committed_header_file:
                    for line in committed_header_file.readlines():
                        if line == '/*\n' or line.startswith(' *') or line == '*/\n':
                            committed_header_copyright.append(line)
                        else:
                            break

                with open(generated_header, 'r') as generated_header_file:
                    generated_header_lines = []
                    for line in generated_header_file.readlines():
                        # Ignore definitions that are not needed for Espresso
                        if not line.startswith("typedef") or "(*Espresso_" in line or "__graal" in line or "(*graal_" in line:
                            generated_header_lines.append(line)
                        else:
                            newline = generated_header_lines.pop()  # Remove newline before ignored declaration
                            assert newline == "\n"

                errors = errors or mx.update_file(committed_header, ''.join(committed_header_copyright + generated_header_lines), showDiff=True)

            if errors:
                mx.abort("""\
One or more header files in the include dir of the mokapot project ('{committed}/') do not match those generated by Native Image ('{generated}/').
To fix the issue, run this gate locally:
{instructions}
And adapt the code to the modified headers in '{committed}'.
""".format(committed=os.path.relpath(mokapot_dir, _suite.vc_dir), generated=os.path.relpath(libespresso_dir, _suite.vc_dir), instructions=run_instructions))
Exemple #2
0
    def build(self):
        if not mx.exists(self._manifest) \
                or self._reason is None \
                or mx.basename(self._manifest) in self._reason \
                or 'phony' in self._reason:
            with mx.SafeFileCreation(self._manifest) as sfc:
                self.subject.generate_manifest(sfc.tmpPath)

                if mx.exists(self._manifest) \
                        and not filecmp.cmp(self._manifest, sfc.tmpPath, shallow=False):
                    self.ninja.clean()

        self.ninja.build()
 def substitution_path():
     bench_suite = mx.suite('substratevm')
     root_dir = mx.join(bench_suite.dir, 'mxbuild')
     path = os.path.abspath(mx.join(root_dir, 'src', 'com.oracle.svm.bench', 'bin'))
     if not mx.exists(path):
         mx.abort('Path to substitutions for scala dacapo not present: ' + path + '. Did you build all of substratevm?')
     return path
def extract_archive(path, extracted_name):
    extracted_archive = mx.join(mx.dirname(path), extracted_name)
    if not mx.exists(extracted_archive):
        # There can be multiple processes doing this so be atomic about it
        with mx.SafeDirectoryUpdater(extracted_archive, create=True) as sdu:
            with zipfile.ZipFile(path, 'r') as zf:
                zf.extractall(sdu.directory)
    return extracted_archive
def extract_archive(path, extracted_name):
    extracted_archive = mx.join(mx.dirname(path), extracted_name)
    if not mx.exists(extracted_archive):
        os.makedirs(extracted_archive)
        arc = zipfile.ZipFile(path, 'r')
        arc.extractall(extracted_archive)
        arc.close()
    return extracted_archive
Exemple #6
0
    def patches(self):
        """A list of patches that will be applied during a build."""
        os_arch_dir = mx.join(self.source_dirs()[0], '{}-{}'.format(mx.get_os(), mx.get_arch()))
        if mx.exists(os_arch_dir):
            return [mx.join(os_arch_dir, patch) for patch in os.listdir(os_arch_dir)]

        others_dir = mx.join(self.source_dirs()[0], 'others')
        return [mx.join(others_dir, patch) for patch in os.listdir(others_dir)]
Exemple #7
0
 def renaissance_unpacked(self):
     renaissance_unpacked = mx.join(mx.dirname(self.renaissancePath()),
                                    'renaissance.extracted')
     if not mx.exists(renaissance_unpacked):
         os.makedirs(renaissance_unpacked)
         arc = zipfile.ZipFile(self.renaissancePath(), 'r')
         arc.extractall(renaissance_unpacked)
         arc.close()
     return renaissance_unpacked
Exemple #8
0
    def needsBuild(self, newestInput):
        is_needed, self._reason = super(NinjaBuildTask, self).needsBuild(newestInput)
        if is_needed:
            return True, self._reason

        if not mx.exists(self._manifest):
            self._reason = 'no build manifest'
            return True, self._reason

        mx.logv('Checking whether to build {} with Ninja...'.format(self.name))
        is_needed, self._reason = self.ninja.needs_build()
        return is_needed, self._reason
    def _archivable_results(self, target_arch, use_relpath, single):
        out_dir_arch = self._install_dir
        for file_path in self.getResults():
            assert not mx.isabs(file_path)
            abs_path = mx.join(out_dir_arch, file_path)
            archive_path = file_path if use_relpath else mx.basename(file_path)

            # if test.skip exists the test should be skipped
            if mx.exists(mx.join(mx.dirname(abs_path), "test.skip")):
                continue

            yield abs_path, archive_path
Exemple #10
0
    def build(self):
        assert not mx.exists(self.subject.out_dir), '{} must be cleaned before build'.format(self.subject.name)

        mx.log('Extracting {}...'.format(self.subject.sources))
        mx.Extractor.create(self.subject.sources.get_path(False)).extract(self.subject.out_dir)

        mx.log('Applying patches...')
        git_apply = ['git', 'apply', '--whitespace=nowarn', '--directory',
                     os.path.relpath(self.subject.delegate.dir, self.subject.suite.vc_dir).replace(os.sep, '/')]
        for patch in self.subject.patches:
            mx.run(git_apply + [patch], cwd=self.subject.suite.vc_dir)

        self.delegate.logBuild()
        self.delegate.build()
Exemple #11
0
    def patches(self):
        """A list of patches that will be applied during a build."""
        def patch_dir(d):
            return mx.join(self.source_dirs()[0], d)

        def get_patches(patchdir):
            for patch in os.listdir(patchdir):
                yield mx.join(patchdir, patch)

        for p in get_patches(patch_dir('common')):
            yield p
        os_arch_dir = patch_dir('{}-{}'.format(mx.get_os(), mx.get_arch()))
        if mx.exists(os_arch_dir):
            for p in get_patches(os_arch_dir):
                yield p
        else:
            for p in get_patches(patch_dir('others')):
                yield p
 def substitution_path():
     path = mx.project('com.oracle.svm.bench').classpath_repr()
     if not mx.exists(path):
         mx.abort('Path to substitutions for scala dacapo not present: ' +
                  path + '. Did you build all of substratevm?')
     return path