%global commit 2742e959347ae2fac58acd0d022c92a0ff1f24bf
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global commit_date 20220202
%global gitrel .%{commit_date}.git%{shortcommit}

Name:           glslang
Version:        11.9.0
Release:        1
Summary:        OpenGL and OpenGL ES shader front end and validator

License:        BSD and GPLv3+ and ASL 2.0
URL:            https://github.com/KhronosGroup
Source0:        %{url}/%{name}/archive/%{commit}/%{name}-%{commit}.tar.gz
Patch1:         glslang-default-resource-limits_staticlib.patch
# Patch to build against system spirv-tools (rebased locally)
#Patch3:         https://patch-diff.githubusercontent.com/raw/KhronosGroup/glslang/pull/1722.patch#/0001-pkg-config-compatibility.patch
Patch3:         0001-pkg-config-compatibility.patch

BuildRequires:  cmake3
BuildRequires:  gcc-c++
BuildRequires:  ninja-build
BuildRequires:  spirv-tools-devel

%description
%{name} is the official reference compiler front end for the OpenGL
ES and OpenGL shading languages. It implements a strict
interpretation of the specifications for these languages.

%package        devel
Summary:        Development files for %{name}
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description    devel
%{name} is the official reference compiler front end for the OpenGL
ES and OpenGL shading languages. It implements a strict
interpretation of the specifications for these languages.

%prep
%autosetup -p1 -n %{name}-%{commit}
# Fix rpmlint warning on debuginfo
find . -name '*.h' -or -name '*.cpp' -or -name '*.hpp'| xargs chmod a-x

%build
%__mkdir_p %_target_platform
pushd %{_vpath_builddir}
%cmake3 -DBUILD_SHARED_LIBS=OFF ..
popd
%__cmake --build %{_vpath_builddir} %{?_smp_mflags} --verbose

%install
DESTDIR="%{buildroot}" %__cmake --install %{_vpath_builddir}

# we don't want them in here
rm -rf %{buildroot}%{_includedir}/SPIRV

%ifnarch s390x ppc64
%check
pushd Test
./runtests localResults ../%{_vpath_builddir}/StandAlone/glslangValidator ../%{_vpath_builddir}/StandAlone/spirv-remap
popd
%endif

# Install libglslang-default-resource-limits.a
install -pm 0644 %{_vpath_builddir}/StandAlone/libglslang-default-resource-limits.a %{buildroot}%{_libdir}/

%files
%doc README.md README-spirv-remap.txt
%{_bindir}/glslangValidator
%{_bindir}/spirv-remap

%files devel
%{_includedir}/glslang/
%{_libdir}/libHLSL.a
%{_libdir}/libOGLCompiler.a
%{_libdir}/libOSDependent.a
%{_libdir}/libSPIRV.a
%{_libdir}/libSPVRemapper.a
%{_libdir}/libglslang.a
%{_libdir}/libGenericCodeGen.a
%{_libdir}/libMachineIndependent.a
%{_libdir}/libglslang-default-resource-limits.a
%{_libdir}/pkgconfig/glslang.pc
%{_libdir}/pkgconfig/spirv.pc
%{_libdir}/cmake/*

%changelog
* Wed Jul 27 2022 liweiganga <liweiganga@uniontech.com> - 11.9.0-1
- Initial build
