diff options
author | Andoni Morales Alastruey <ylatuya@gmail.com> | 2020-11-25 16:52:44 +0000 |
---|---|---|
committer | GStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2021-01-21 02:46:34 +0000 |
commit | e5a020caad967b72f35b905ce533ee5c6e3a65b9 (patch) | |
tree | 23dcc32d5f3b534f0b75be2adf99746ffd24530f | |
parent | a4b4483884ad2b5f2815993e429c6d95d56d6dba (diff) |
macOS: add arm64 vulkan support for universal builds
Bump moltenvk to 1.2.162.1
Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/673>
-rw-r--r-- | recipes/build-tools/moltenvk-tools.recipe | 13 | ||||
-rw-r--r-- | recipes/gst-plugins-bad-1.0.recipe | 7 | ||||
-rw-r--r-- | recipes/moltenvk.recipe | 44 |
3 files changed, 37 insertions, 27 deletions
diff --git a/recipes/build-tools/moltenvk-tools.recipe b/recipes/build-tools/moltenvk-tools.recipe index 3f6a463a..4df8063d 100644 --- a/recipes/build-tools/moltenvk-tools.recipe +++ b/recipes/build-tools/moltenvk-tools.recipe @@ -4,14 +4,14 @@ from cerbero.utils import shell class Recipe(recipe.Recipe): name = 'moltenvk-tools' - version = '1.2.131.1' + version = '1.2.162.1' licenses = [License.Apachev2] stype = SourceType.TARBALL tarball_dirname = "vulkansdk-macos-%(version)s" # Mirrored because lunarg.com has an extremely small download limit - # url = 'https://sdk.lunarg.com/sdk/download/%(version)s/mac/' + tarball_dirname + '.tar.gz' - url = 'https://gstreamer.freedesktop.org/data/src/mirror/' + tarball_dirname + '.tar.gz' - tarball_checksum = 'fbc01a433d61d303dd3ceef19a12a99ba3431498de2d761679073f12b05a7870' + #url = 'https://sdk.lunarg.com/sdk/download/%(version)s/mac/' + tarball_dirname + '.dmg' + url = 'https://gstreamer.freedesktop.org/data/src/mirror/' + tarball_dirname + '.dmg' + tarball_checksum = '2781c334997598c2828d8a3368aef7b7c94a25204c90d5503396e40c7a03fd5c' btype = BuildType.CUSTOM files_bins = [ @@ -31,6 +31,11 @@ class Recipe(recipe.Recipe): def prepare(self): if self.config.target_platform not in (Platform.IOS, Platform.DARWIN): raise InvalidRecipeError(self, "Invalid platform") + # The binaries from the SDK are already signed and do not require relocation + if BuildSteps.RELOCATE_OSX_LIBRARIES in self._steps: + self._steps.remove(BuildSteps.RELOCATE_OSX_LIBRARIES) + if BuildSteps.CODE_SIGN in self._steps: + self._steps.remove(BuildSteps.CODE_SIGN) async def install(self): srcdir = self.config.moltenvk_prefix diff --git a/recipes/gst-plugins-bad-1.0.recipe b/recipes/gst-plugins-bad-1.0.recipe index bcf2ecec..19a2e28e 100644 --- a/recipes/gst-plugins-bad-1.0.recipe +++ b/recipes/gst-plugins-bad-1.0.recipe @@ -495,12 +495,7 @@ class Recipe(custom.GStreamer): if self.config.target_platform in (Platform.DARWIN, Platform.IOS): self.meson_options['applemedia'] = 'enabled' - # No Vulkan SDK for macOS ARM664 yet - if self.config.target_platform == Platform.DARWIN and \ - self.config.target_arch == Architecture.ARM64: - self.disable_plugin('vulkan', 'vulkan', library_name='vulkan') - else: - self.deps += ['moltenvk'] + self.deps += ['moltenvk'] if self.config.target_platform in (Platform.ANDROID): self.deps += ['vulkan-android'] diff --git a/recipes/moltenvk.recipe b/recipes/moltenvk.recipe index 5bee95df..fb96cfe0 100644 --- a/recipes/moltenvk.recipe +++ b/recipes/moltenvk.recipe @@ -6,7 +6,7 @@ from cerbero.tools.libtool import LibtoolLibrary class Recipe(recipe.Recipe): name = 'moltenvk' - version = '1.2.131.1' + version = '1.2.162.1' licenses = [License.Apachev2] stype = SourceType.CUSTOM btype = BuildType.CUSTOM @@ -33,7 +33,6 @@ class Recipe(recipe.Recipe): files_devel = [ 'include/vulkan', 'include/MoltenVK', - 'include/vulkan-portability' ] def prepare(self): @@ -46,14 +45,11 @@ class Recipe(recipe.Recipe): if self.config.target_platform == Platform.DARWIN: self.files_libs += ['libvulkan'] - self.files_devel += ['etc/vulkan'] # no libvulkan.a self.library_type = LibraryType.SHARED async def install(self): # only copy once for the only architecture supported by the libraries - if self.config.target_platform == Platform.DARWIN and self.config.target_arch != Architecture.X86_64: - return if self.config.target_platform == Platform.IOS and self.config.target_arch != Architecture.ARM64: return @@ -77,25 +73,28 @@ class Recipe(recipe.Recipe): os.path.join(prefix, 'include', d), True) ] + libmoltenvk_shared = os.path.join(libdir, 'libMoltenVK.dylib') + libmoltenvk_static = os.path.join(libdir, 'libMoltenVK.a') + libvulkan = os.path.join(libdir, 'libvulkan.dylib') + libvulkan1 = os.path.join(libdir, 'libvulkan.1.dylib') + if self.config.target_platform == Platform.DARWIN: to_copy += [ - (os.path.join(srcdir, 'macOS', 'etc', 'vulkan'), - os.path.join(prefix, 'etc', 'vulkan'), True), (os.path.join(srcdir, 'macOS', 'lib', 'libvulkan.dylib'), - os.path.join(libdir, 'libvulkan.dylib'), False), + libvulkan, False), (os.path.join(srcdir, 'macOS', 'lib', 'libvulkan.1.dylib'), - os.path.join(libdir, 'libvulkan.1.dylib'), False), - (os.path.join(srcdir, 'MoltenVK', 'macOS', 'dynamic', 'libMoltenVK.dylib'), - os.path.join(libdir, 'libMoltenVK.dylib'), False), - (os.path.join(srcdir, 'MoltenVK', 'macOS', 'static', 'libMoltenVK.a'), - os.path.join(libdir, 'libMoltenVK.a'), False) + libvulkan, False), + (os.path.join(srcdir, 'MoltenVK', 'dylib', 'macOS', 'libMoltenVK.dylib'), + libmoltenvk_shared, False), + (os.path.join(srcdir, 'MoltenVK', 'MoltenVK.xcframework', 'macos-arm64_x86_64', 'libMoltenVK.a'), + libmoltenvk_static, False) ] elif self.config.target_platform == Platform.IOS: to_copy += [ - (os.path.join(srcdir, 'MoltenVK', 'iOS', 'dynamic', 'libMoltenVK.dylib'), - os.path.join(libdir, 'libMoltenVK.dylib'), False), - (os.path.join(srcdir, 'MoltenVK', 'iOS', 'static', 'libMoltenVK.a'), - os.path.join(libdir, 'libMoltenVK.a'), False) + (os.path.join(srcdir, 'MoltenVK', 'dylib', 'iOS', 'libMoltenVK.dylib'), + libmoltenvk_shared, False), + (os.path.join(srcdir, 'MoltenVK', 'MoltenVK.xcframework', 'ios-arm64', 'libMoltenVK.a'), + libmoltenvk_static, False) ] for src, dest, is_dir in to_copy: @@ -106,6 +105,17 @@ class Recipe(recipe.Recipe): os.makedirs(os.path.dirname(dest)) shutil.copy(src, dest) + # The SDK provides universal binaries, we need to convert them into thin binaries so + # that the merge step can merge them back + if self.config.target_platform == Platform.DARWIN: + binaries = [os.path.join(bindir, x) for x in self.files_bins] + for f in binaries + [libvulkan, libmoltenvk_shared, libmoltenvk_static]: + await shell.async_call(['lipo', '-thin', self.config.target_arch, f, '-output', f], logfile=self.logfile) + # Because we are editing the binary, we need to the remove the signature. + # The process would crash otherwise as not being + await shell.async_call(['codesign', '--remove-signature', f], logfile=self.logfile) + + LibtoolLibrary('vulkan', None, None, None, libdir, self.config.target_platform).save() LibtoolLibrary('MoltenVK', None, None, None, libdir, |