예제 #1
0
 def getArchivableResults(self, use_relpath=True, single=False):
     for file_path, archive_path in super(LibtoolNativeProject, self).getArchivableResults(use_relpath):
         path_in_lt_objdir = mx.basename(mx.dirname(file_path)) == '.libs'
         yield file_path, mx.basename(archive_path) if path_in_lt_objdir else archive_path
         if single:
             assert path_in_lt_objdir, 'the first build result must be from LT_OBJDIR'
             break
예제 #2
0
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
예제 #3
0
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
예제 #4
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
예제 #5
0
    def generate_manifest(self, path):
        unsupported_source_files = list(self._source['files'].viewkeys() -
                                        {'.h', '.c', '.cc', '.S'})
        if unsupported_source_files:
            mx.abort(
                '{} source files are not supported by default native projects'.
                format(unsupported_source_files))

        with NinjaManifestGenerator(self, open(path, 'w')) as gen:
            gen.comment('Project rules')
            cc = cxx = asm = None
            if self.c_files:
                cc = gen.cc_rule()
            if self.cxx_files:
                cxx = gen.cc_rule(cxx=True)
            if self.asm_sources:
                asm = gen.asm_rule() if mx.is_windows(
                ) else cc if cc else gen.cc_rule()

            ar = link = None
            if self._kind == self._kinds['static_lib']:
                ar = gen.ar_rule()
            else:
                link = gen.link_rule(cxx=bool(self.cxx_files))

            gen.variables(
                cflags=self.cflags,
                ldflags=self.ldflags if link else None,
                ldlibs=self.ldlibs if link else None,
            )
            gen.include(
                collections.OrderedDict.fromkeys(
                    # remove the duplicates while maintaining the ordering
                    [mx.dirname(h_file) for h_file in self.h_files] + list(
                        itertools.chain.from_iterable(
                            getattr(d, 'include_dirs', [])
                            for d in self.buildDependencies))).keys())

            gen.comment('Compiled project sources')
            object_files = [cc(f) for f in self.c_files]
            gen.newline()
            object_files += [cxx(f) for f in self.cxx_files]
            gen.newline()
            object_files += [asm(f) for f in self.asm_sources]
            gen.newline()

            gen.comment('Project deliverable')
            if self._kind == self._kinds['static_lib']:
                ar(self._target, object_files)
            else:
                link(
                    self._target, object_files + list(
                        itertools.chain.from_iterable(
                            getattr(d, 'libs', [])
                            for d in self.buildDependencies)))
예제 #6
0
    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
예제 #7
0
    def generate_manifest(self, path):
        unsupported_source_files = list(
            set(self._source['files'].keys()) - {'.h', '.c', '.cc', '.S'})
        if unsupported_source_files:
            mx.abort(
                '{} source files are not supported by default native projects'.
                format(unsupported_source_files))

        with NinjaManifestGenerator(self, open(path, 'w')) as gen:
            gen.comment("Toolchain configuration")
            gen.include(mx.join(self.toolchain.get_output(),
                                'toolchain.ninja'))
            gen.newline()
            gen.variables(cflags=[
                mx_subst.path_substitutions.substitute(cflag)
                for cflag in self.cflags
            ])
            if self._kind != self._kinds['static_lib']:
                gen.variables(
                    ldflags=[
                        mx_subst.path_substitutions.substitute(ldflag)
                        for ldflag in self.ldflags
                    ],
                    ldlibs=self.ldlibs,
                )
            gen.include_dirs(
                collections.OrderedDict.fromkeys(
                    # remove the duplicates while maintaining the ordering
                    [mx.dirname(h_file) for h_file in self.h_files] + list(
                        itertools.chain.from_iterable(
                            getattr(d, 'include_dirs', [])
                            for d in self.buildDependencies))).keys())

            gen.comment('Compiled project sources')
            object_files = [gen.cc(f) for f in self.c_files]
            gen.newline()
            object_files += [gen.cxx(f) for f in self.cxx_files]
            gen.newline()
            object_files += [gen.asm(f) for f in self.asm_sources]
            gen.newline()

            gen.comment('Project deliverable')
            if self._kind == self._kinds['static_lib']:
                gen.ar(self._target, object_files)
            else:
                link = gen.linkxx if self.cxx_files else gen.link
                dep_libs = list(
                    itertools.chain.from_iterable(
                        getattr(d, 'libs', [])
                        for d in self.buildDependencies))
                link(self._target, object_files + dep_libs)