def testMergeFiles(self):
     for arch in [Architecture.X86, Architecture.X86_64]:
         with open(os.path.join(self.tmp, arch, 'share', 'test'), 'w') as f:
             f.write("test")
     gen = OSXUniversalGenerator(
             os.path.join(self.tmp, Architecture.UNIVERSAL))
     gen.merge_files(['share/test'],
             [os.path.join(self.tmp, Architecture.X86),
              os.path.join(self.tmp, Architecture.X86_64)])
     self.assertTrue(os.path.exists(os.path.join(self.tmp,
     Architecture.UNIVERSAL, 'share', 'test')))
 def testMergePCFiles(self):
     for arch in [Architecture.X86, Architecture.X86_64]:
         pc_file = os.path.join(self.tmp, arch, 'test.pc')
         with open(pc_file, 'w') as f:
             f.write(os.path.join(self.tmp, arch, 'lib', 'test'))
     gen = OSXUniversalGenerator(
             os.path.join(self.tmp, Architecture.UNIVERSAL))
     gen.merge_files(['test.pc'],
             [os.path.join(self.tmp, Architecture.X86),
              os.path.join(self.tmp, Architecture.X86_64)])
     pc_file = os.path.join(self.tmp, Architecture.UNIVERSAL, 'test.pc')
     self.assertEqual(open(pc_file).readline(),
             os.path.join(self.tmp, Architecture.UNIVERSAL, 'lib', 'test'))
Esempio n. 3
0
    def merge(self):
        arch_inputs = {}
        for arch, recipe in self._recipes.items():
            # change the prefix temporarly to the arch prefix where files are
            # actually installed
            recipe.config.prefix = os.path.join(self.config.prefix, arch)
            arch_inputs[arch] = set(recipe.files_list())
            recipe.config.prefix = self._config.prefix

        # merge the common files
        inputs = reduce(lambda x, y: x & y, arch_inputs.values())
        output = self._config.prefix
        generator = OSXUniversalGenerator(output)
        dirs = [
            os.path.join(self._config.prefix, arch)
            for arch in self._recipes.keys()
        ]
        generator.merge_files(inputs, dirs)

        # merge the architecture specific files
        for arch in self._recipes.keys():
            ainputs = list(inputs ^ arch_inputs[arch])
            output = self._config.prefix
            generator = OSXUniversalGenerator(output)
            generator.merge_files(ainputs,
                                  [os.path.join(self._config.prefix, arch)])
Esempio n. 4
0
 def testMergeFiles(self):
     for arch in [Architecture.X86, Architecture.X86_64]:
         with open(os.path.join(self.tmp, arch, 'share', 'test'), 'w') as f:
             f.write("test")
     gen = OSXUniversalGenerator(
         os.path.join(self.tmp, Architecture.UNIVERSAL))
     gen.merge_files(['share/test'], [
         os.path.join(self.tmp, Architecture.X86),
         os.path.join(self.tmp, Architecture.X86_64)
     ])
     self.assertTrue(
         os.path.exists(
             os.path.join(self.tmp, Architecture.UNIVERSAL, 'share',
                          'test')))
Esempio n. 5
0
 def testMergePCFiles(self):
     for arch in [Architecture.X86, Architecture.X86_64]:
         pc_file = os.path.join(self.tmp, arch, 'test.pc')
         with open(pc_file, 'w') as f:
             f.write(os.path.join(self.tmp, arch, 'lib', 'test'))
     gen = OSXUniversalGenerator(
         os.path.join(self.tmp, Architecture.UNIVERSAL))
     gen.merge_files(['test.pc'], [
         os.path.join(self.tmp, Architecture.X86),
         os.path.join(self.tmp, Architecture.X86_64)
     ])
     pc_file = os.path.join(self.tmp, Architecture.UNIVERSAL, 'test.pc')
     self.assertEquals(
         open(pc_file).readline(),
         os.path.join(self.tmp, Architecture.UNIVERSAL, 'lib', 'test'))
    def testMergeCopyAndLink(self):
        for arch in [Architecture.X86, Architecture.X86_64]:
            file1 = os.path.join(self.tmp, arch, 'share', 'test1')
            file2 = os.path.join(self.tmp, arch, 'share', 'test2')
            with open(file1, 'w') as f:
                f.write("test")
            os.symlink(file1, file2)

        gen = OSXUniversalGenerator(
                os.path.join(self.tmp, Architecture.UNIVERSAL))
        gen.merge_dirs([
                os.path.join(self.tmp, Architecture.X86),
                os.path.join(self.tmp, Architecture.X86_64)])

        file1 = os.path.join(self.tmp, Architecture.UNIVERSAL, 'share', 'test1')
        file2 = os.path.join(self.tmp, Architecture.UNIVERSAL, 'share', 'test2')

        self.assertTrue(os.path.exists(file1))
        self.assertTrue(os.path.exists(file2))
        self.assertEqual(os.readlink(file2), file1)
    def testMergedLibraryPaths(self):
        def check_prefix(path):
            if self.tmp not in path:
                return
            self.assertTrue(uni_prefix in path)
            self.assertTrue(x86_prefix not in path)
            self.assertTrue(x86_64_prefix not in path)

        self._compile(Architecture.X86)
        self._compile(Architecture.X86_64)
        self._check_compiled_files()
        uni_prefix = os.path.join(self.tmp, Architecture.UNIVERSAL)
        x86_prefix = os.path.join(self.tmp, Architecture.X86)
        x86_64_prefix = os.path.join(self.tmp, Architecture.X86_64)
        gen = OSXUniversalGenerator(uni_prefix)
        gen.merge_dirs([x86_prefix, x86_64_prefix])
        libfoo = os.path.join(self.tmp, Architecture.UNIVERSAL, 'lib', 'libfoo.so')
        libname = OSXRelocator.library_id_name(libfoo)
        check_prefix(libname)
        for p in OSXRelocator.list_shared_libraries(libfoo):
            check_prefix(p)
Esempio n. 8
0
    def merge(self):
        arch_inputs = {}
        for arch, recipe in self._recipes.items():
            # change the prefix temporarly to the arch prefix where files are
            # actually installed
            recipe.config.prefix = os.path.join(self.config.prefix, arch)
            arch_inputs[arch] = set(recipe.files_list())
            recipe.config.prefix = self._config.prefix

        # merge the common files
        inputs = reduce(lambda x, y: x & y, arch_inputs.values())
        output = self._config.prefix
        generator = OSXUniversalGenerator(output, logfile=self.logfile)
        dirs = [
            os.path.join(self._config.prefix, arch)
            for arch in self._recipes.keys()
        ]
        generator.merge_files(inputs, dirs)

        # Collect files that are only in one or more archs, but not all archs
        arch_files = {}
        for arch in self._recipes.keys():
            for f in list(inputs ^ arch_inputs[arch]):
                if f not in arch_files:
                    arch_files[f] = {arch}
                else:
                    arch_files[f].add(arch)
        # merge the architecture specific files
        for f, archs in arch_files.items():
            generator.merge_files(
                [f],
                [os.path.join(self._config.prefix, arch) for arch in archs])
Esempio n. 9
0
    def testMergedLibraryPaths(self):
        def check_prefix(path):
            if self.tmp not in path:
                return
            self.assertTrue(uni_prefix in path)
            self.assertTrue(x86_prefix not in path)
            self.assertTrue(x86_64_prefix not in path)

        self._compile(Architecture.X86)
        self._compile(Architecture.X86_64)
        self._check_compiled_files()
        uni_prefix = os.path.join(self.tmp, Architecture.UNIVERSAL)
        x86_prefix = os.path.join(self.tmp, Architecture.X86)
        x86_64_prefix = os.path.join(self.tmp, Architecture.X86_64)
        gen = OSXUniversalGenerator(uni_prefix)
        gen.merge_dirs([x86_prefix, x86_64_prefix])
        libfoo = os.path.join(self.tmp, Architecture.UNIVERSAL, 'lib',
                              'libfoo.so')
        libname = OSXRelocator.library_id_name(libfoo)
        check_prefix(libname)
        for p in OSXRelocator.list_shared_libraries(libfoo):
            check_prefix(p)
    def testMergeDirs(self):
        self._compile(Architecture.X86)
        self._compile(Architecture.X86_64)
        self._check_compiled_files()
        gen = OSXUniversalGenerator(
                os.path.join(self.tmp, Architecture.UNIVERSAL))
        gen.merge_dirs([
                os.path.join(self.tmp, Architecture.X86),
                os.path.join(self.tmp, Architecture.X86_64)])

        # bash-3.2$ file libfoo.so 
        # libfoo.so: Mach-O universal binary with 2 architectures
        # libfoo.so (for architecture i386):	Mach-O dynamically linked shared library i386
        # libfoo.so (for architecture x86_64):	Mach-O 64-bit dynamically linked shared library x86_64

        ftype = self._get_file_type(os.path.join(self.tmp,
            Architecture.UNIVERSAL, 'lib', 'libfoo.so'))
        for arch in [Architecture.X86, Architecture.X86_64]:
            self.assertTrue(SHARED_LIBRARY[arch] in ftype)
        ftype = self._get_file_type(os.path.join(self.tmp,
            Architecture.UNIVERSAL, 'bin', 'test_app'))
        for arch in [Architecture.X86, Architecture.X86_64]:
            self.assertTrue(EXECUTABLE[arch] in ftype)
Esempio n. 11
0
    def testMergeCopyAndLink(self):
        for arch in [Architecture.X86, Architecture.X86_64]:
            file1 = os.path.join(self.tmp, arch, 'share', 'test1')
            file2 = os.path.join(self.tmp, arch, 'share', 'test2')
            with open(file1, 'w') as f:
                f.write("test")
            os.symlink(file1, file2)

        gen = OSXUniversalGenerator(
            os.path.join(self.tmp, Architecture.UNIVERSAL))
        gen.merge_dirs([
            os.path.join(self.tmp, Architecture.X86),
            os.path.join(self.tmp, Architecture.X86_64)
        ])

        file1 = os.path.join(self.tmp, Architecture.UNIVERSAL, 'share',
                             'test1')
        file2 = os.path.join(self.tmp, Architecture.UNIVERSAL, 'share',
                             'test2')

        self.assertTrue(os.path.exists(file1))
        self.assertTrue(os.path.exists(file2))
        self.assertEquals(os.readlink(file2), file1)
Esempio n. 12
0
    def testMergeDirs(self):
        self._compile(Architecture.X86)
        self._compile(Architecture.X86_64)
        self._check_compiled_files()
        gen = OSXUniversalGenerator(
            os.path.join(self.tmp, Architecture.UNIVERSAL))
        gen.merge_dirs([
            os.path.join(self.tmp, Architecture.X86),
            os.path.join(self.tmp, Architecture.X86_64)
        ])

        # bash-3.2$ file libfoo.so
        # libfoo.so: Mach-O universal binary with 2 architectures
        # libfoo.so (for architecture i386):	Mach-O dynamically linked shared library i386
        # libfoo.so (for architecture x86_64):	Mach-O 64-bit dynamically linked shared library x86_64

        ftype = self._get_file_type(
            os.path.join(self.tmp, Architecture.UNIVERSAL, 'lib', 'libfoo.so'))
        for arch in [Architecture.X86, Architecture.X86_64]:
            self.assertTrue(SHARED_LIBRARY[arch] in ftype)
        ftype = self._get_file_type(
            os.path.join(self.tmp, Architecture.UNIVERSAL, 'bin', 'test_app'))
        for arch in [Architecture.X86, Architecture.X86_64]:
            self.assertTrue(EXECUTABLE[arch] in ftype)
Esempio n. 13
0
    async def merge(self):
        arch_inputs = {}
        for arch, recipe in self._recipes.items():
            arch_inputs[arch] = set(recipe.files_list())

        # merge the common files
        inputs = reduce(lambda x, y: x & y, arch_inputs.values())
        output = self._config.prefix
        generator = OSXUniversalGenerator(output, logfile=self.logfile)
        dirs = [recipe.config.prefix for arch, recipe in self._recipes.items()]
        await generator.merge_files(inputs, dirs)

        # Collect files that are only in one or more archs, but not all archs
        arch_files = {}
        for arch, recipe in self._recipes.items():
            for f in list(inputs ^ arch_inputs[arch]):
                if f not in arch_files:
                    arch_files[f] = {(arch, recipe)}
                else:
                    arch_files[f].add((arch, recipe))
        # merge the architecture specific files
        for f, archs in arch_files.items():
            await generator.merge_files([f], [recipe.config.prefix for arch, recipe in archs])
Esempio n. 14
0
    def merge(self):
        arch_inputs = {}
        for arch, recipe in self._recipes.items():
            # change the prefix temporarly to the arch prefix where files are
            # actually installed
            recipe.config.prefix = os.path.join(self.config.prefix, arch)
            arch_inputs[arch] = set(recipe.files_list())
            recipe.config.prefix = self._config.prefix

        # merge the common files
        inputs = reduce(lambda x, y: x & y, arch_inputs.values())
        output = self._config.prefix
        generator = OSXUniversalGenerator(output)
        dirs = [os.path.join(self._config.prefix, arch) for arch in self._recipes.keys()]
        generator.merge_files(inputs, dirs)

        # merge the architecture specific files
        for arch in self._recipes.keys():
            ainputs = list(inputs ^ arch_inputs[arch])
            output = self._config.prefix
            generator = OSXUniversalGenerator(output)
            generator.merge_files(ainputs,
                    [os.path.join(self._config.prefix, arch)])