File spirv-headers.spec of Package spirv-headers
%define realname SPIRV-Headers
%define realver 1.3.283.0
%define srcext tar.gz
%bcond_without ninja
# Common info
Name: spirv-headers
Version: %{realver}
Release: wiz%{?extraver:0.}1%{?dist}
License: MIT
Group: Development/Languages/C and C++
URL: https://github.com/KhronosGroup/SPIRV-Headers
Summary: SPIRV-Headers
# Install-time parameters
Provides: %{realname} = %{version}-%{release}
Obsoletes: %{realname} < %{version}-%{release}
# Build-time parameters
BuildRequires: cmake >= 3.0
BuildRequires: pkg-config
BuildRequires: gcc-c++
%if %{with ninja}
BuildRequires: ninja
%endif
BuildRoot: %{_tmppath}/%{name}-root
BuildArch: noarch
Source0: https://github.com/KhronosGroup/SPIRV-Headers/archive/refs/tags/vulkan-sdk-%{realver}%{?extraver}.%{srcext}#/%{realname}-%{realver}%{?extraver}.%{srcext}
%description
This package contains machine-readable files for the SPIR-V Registry.
This includes:
* Header files for various languages.
* JSON files describing the grammar for the SPIR-V core instruction set and
the extended instruction sets.
* The XML registry file.
* A tool to build the headers from the JSON grammar.
# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-vulkan-sdk-%{realver}%{?extraver}
# Build step (compile/build binaries, documentation, etc)
%build
_CMAKE_ARGS=(
-DCMAKE_INSTALL_PREFIX=%{_prefix}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_C_FLAGS_RELEASE="$_CFLAGS"
-DCMAKE_CXX_FLAGS_RELEASE="$_CFLAGS"
-DCMAKE_EXE_LINKER_FLAGS_RELEASE="$_LDFLAGS"
-DCMAKE_MODULE_LINKER_FLAGS_RELEASE="$_LDFLAGS"
-DCMAKE_SHARED_LINKER_FLAGS_RELEASE="$_LDFLAGS"
-DCMAKE_VERBOSE_MAKEFILE=YES
)
mkdir tmp_build
cd tmp_build
cmake .. \
%if %{with ninja}
-G Ninja \
%endif
"${_CMAKE_ARGS[@]}" \
\
-DSPIRV_HEADERS_SKIP_EXAMPLES=YES
%if %{with ninja}
ninja -v %{?_smp_mflags}
%else
%{__make} %{?_smp_mflags}
%endif
# Install built stuff
%install
%if %{with ninja}
DESTDIR=%{buildroot} ninja -v -C tmp_build install
%else
%{__make} -C tmp_build install DESTDIR=%{buildroot}
%endif
# Cleanup
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
# Files list
%files
%defattr(-,root,root)
%license LICENSE
%doc README.md
%{_includedir}/spirv/
%{_datadir}/pkgconfig/%{realname}.pc
%dir %{_datadir}/cmake/SPIRV-Headers
%dir %{_datadir}/cmake
%{_datadir}/cmake/SPIRV-Headers/*.cmake
%changelog