File mingw64-vulkan-loader.spec of Package mingw64-vulkan-loader

#
# spec file for package mingw64-vulkan-loader
#
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#

%define flavor @BUILD_FLAVOR@%nil

# Prefer to go with just /^sdk-.*/ tags
%define lname	libvulkan1
%define _name   vulkan-loader
Name:           mingw64-%{_name}
Version:        1.3.250.0
Release:        0
Summary:        Reference ICD loader for Vulkan
License:        Apache-2.0
Group:          Development/Libraries/C and C++
URL:            https://github.com/KhronosGroup/Vulkan-Loader
Source:         https://github.com/KhronosGroup/Vulkan-Loader/archive/refs/tags/sdk-%version.tar.gz
#PATCH_FIX_UPSTREAM
Patch0:         v1.3.235-fix-asm_offset.patch
#PATCH_FIX_UPSTREAM
Patch1:         v1.3.250-loader-fix-settings-of-cflags.patch
#PATCH_FIX_UPSTREAM
Patch2:         0001-Run-cross-compiled-asm_offset-to-generate-asm-define.patch 
#PATCH_FIX_UPSTREAM
Patch3:         0001-Revert-Fix-the-pkg-config-import-library-name-with-m.patch
BuildRequires:  JWasm
BuildRequires:  mingw64-cross-cmake 
BuildRequires:  mingw64-cross-gcc-c++
BuildRequires:  mingw64-vulkan-headers >= %version
BuildRequires:  python3-xml
# for building asm_offset
%if "%flavor" != "cross"
BuildRequires: wine
%_mingw64_package_header_debug
BuildArch:      noarch
#!BuildIgnore: post-build-checks
%endif

%description
Vulkan is a 3D graphics and compute API providing cross-platform
access to modern GPUs with low overhead and targeting realtime
graphics applications such as games and interactive media.

This package contains the reference ICD loader for Vulkan.

%if "%flavor" != "cross"
%package -n mingw64-%lname
Summary:        The Vulkan 3D graphics and compute API
Group:          System/Libraries

%description -n mingw64-%lname
Vulkan is a 3D graphics and compute API providing cross-platform
access to modern GPUs with low overhead and targeting realtime
graphics applications such as games and interactive media.

%package -n mingw64-vulkan-devel
Summary:        Vulkan development package
Group:          Development/Libraries/C and C++
Requires:       mingw64-%lname = %version-%release
Requires:       mingw64-vulkan-headers >= %version

%description -n mingw64-vulkan-devel
Vulkan is a 3D graphics and compute API providing cross-platform
access to modern GPUs with low overhead and targeting realtime
graphics applications such as games and interactive media.

This subpackage contains the development headers for packages wanting
to make use of Vulkan.

%_mingw64_debug_package

%else

%package -n mingw64-cross-%_name
Summary:        Native tools for vulkan development package
Group:          Development/Libraries/C and C++
Requires:       JWasm

%description -n mingw64-cross-%_name
Vulkan is a 3D graphics and compute API providing cross-platform
access to modern GPUs with low overhead and targeting realtime
graphics applications such as games and interactive media.

This subpackage contains the native tools required to build the 
development package
%endif

%prep
%autosetup -p1 -n Vulkan-Loader-sdk-%version

%build
P=$(pwd)
# create wrapper for converting the not supported command line options by jwasm
# TODO move 
cat <<EOF > $P/jwasm
#!/bin/sh
params=\$(echo "\$*" | sed 's, /c , -c ,g;s, /Fo , -Fo ,g')
/usr/bin/jwasm \$params
EOF
chmod a+x $P/jwasm

%if "%flavor" != "cross"
MINGW64_LFLAGS="-Wl,--enable-stdcall-fixup -Wl,--kill-at %_mingw64_ldflags"
%_mingw64_cmake \
	-DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/wine \
	-DENABLE_WERROR=OFF \
	-DLIB_SUFFIX:STRING="" \
	-DJWASM_FOUND="$P/jwasm" \
	-DVulkanHeaders_INCLUDE_DIR:PATH="%_mingw64_includedir" \
	-DVulkanRegistry_DIR:PATH="%_mingw64_datadir/vulkan/registry"

%_mingw64_cmake_build
%endif

%install
%if "%flavor" != "cross"
%_mingw64_cmake_install
# fix building libqt5-qtbase
# Checking for Vulkan... 
# Trying source 0 (type pkgConfig) of library vulkan ...
# + i686-w64-mingw64-pkgconf --exists --silence-errors vulkan
# + i686-w64-mingw64-pkgconf --modversion vulkan
# > 1.3.239
# + i686-w64-mingw64-pkgconf --libs-only-L vulkan
# > -L/usr/i686-w64-mingw64/sys-root/mingw/Lib
# + i686-w64-mingw64-pkgconf --libs-only-l vulkan
# > -lvulkan-1 
# Library path /usr/i686-w64-mingw64/sys-root/mingw/Lib is invalid.
sed -i 's,Lib,lib,g' %buildroot%_mingw64_libdir/pkgconfig/vulkan.pc

# https://sourceware.org/bugzilla/show_bug.cgi?id=28363
cp %buildroot%_mingw64_bindir/vulkan-1.dll %buildroot%_mingw64_libdir/libvulkan-1.dll.a
%else
# install cross tools
mkdir -p %buildroot/%_bindir
cp jwasm %buildroot/%_bindir/%{_mingw64_target}-jwasm
%endif

%if "%flavor" != "cross"
%files -n mingw64-%lname
%license LICENSE.txt
%_mingw64_bindir/vulkan*.dll

%files -n mingw64-vulkan-devel
%_mingw64_libdir/libvulkan*.dll.a
%_mingw64_libdir/pkgconfig/vulkan.pc

%else

%files -n mingw64-cross-%_name
%{_bindir}/%{_mingw64_target}-jwasm

%endif
%changelog
openSUSE Build Service is sponsored by