File skia.spec of Package skia

#
# spec file for package skia
#
# Copyright (c) 2024 mantarimay
#
# 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 mod_ver 0.gitmodule
%define _major 99
%define _minor 9
%define _release 0
Name:           skia
Version:        20231106~git.ced64f6f9
Release:        0
Summary:        A complete 2D graphic library for drawing Text, Geometries, and Images (Mis012 fork)
License:        BSD-3-Clause
URL:            https://github.com/Mis012/skia/tree/with-patches-applied
Source0:        skia-%{version}.tar.zst
Source1:        brotli-%{mod_ver}.tar.zst
Source2:        abseil-cpp-%{mod_ver}.tar.zst
Source3:        dng_sdk-%{mod_ver}.tar.zst
Source4:        egl-registry-%{mod_ver}.tar.zst
Source5:        highway-%{mod_ver}.tar.zst
Source6:        imgui-%{mod_ver}.tar.zst
Source7:        libavif-%{mod_ver}.tar.zst
Source8:        libgav1-%{mod_ver}.tar.zst
Source9:        libyuv-%{mod_ver}.tar.zst
Source10:       libmicrohttpd-%{mod_ver}.tar.zst
Source11:       oboe-%{mod_ver}.tar.zst
Source12:       opengl-registry-%{mod_ver}.tar.zst
Source13:       perfetto-%{mod_ver}.tar.zst
Source14:       piex-%{mod_ver}.tar.zst
Source15:       vulkanmemoryallocator-%{mod_ver}.tar.zst
Source16:       vulkan-deps-%{mod_ver}.tar.zst
Source17:       spirv-cross-%{mod_ver}.tar.zst
Source18:       spirv-headers-%{mod_ver}.tar.zst
Source19:       spirv-tools-%{mod_ver}.tar.zst
Source20:       vello-%{mod_ver}.tar.zst
Source21:       vulkan-headers-%{mod_ver}.tar.zst
Source22:       vulkan-tools-%{mod_ver}.tar.zst
Source23:       wuffs-mirror-release-c-%{mod_ver}.tar.zst
Source24:       harfbuzz-%{mod_ver}.tar.zst
Source25:       zlib-%{mod_ver}.tar.zst
Source26:       jpeg-xl-%{mod_ver}.tar.zst
BuildRequires:  clang
BuildRequires:  gn
BuildRequires:  ninja
BuildRequires:  python3
BuildRequires:  harfbuzz-devel
BuildRequires:  zlib-devel
BuildRequires:  libexpat-devel
BuildRequires:  fontconfig-devel
BuildRequires:  freetype2-devel
BuildRequires:  libpng-devel
BuildRequires:  libwebp-devel
BuildRequires:  pkgconfig(libjpeg)

%description
%summary.

%package devel
Summary:        Development files for skia
Requires:       %{name} = %{version}

%description devel
This subpackage contains libraries and header files for developing
applications that want to make use of the skia library.

%prep
%autosetup -p1

mkdir -p third_party/externals/{dng_sdk,libgav1,libyuv,microhttpd,perfetto,piex,vulkan-deps,harfbuzz,zlib,brotli,abseil-cpp,egl-registry,highway,imgui,libavif,oboe,opengl-registry,vulkanmemoryallocator,spirv-cross,spirv-headers,spirv-tools,vello,vulkan-headers,vulkan-tools,wuffs,libjxl}


tar -xf %{SOURCE3} -C third_party/externals/dng_sdk
tar -xf %{SOURCE8} -C third_party/externals/libgav1
tar -xf %{SOURCE9} -C third_party/externals/libyuv
tar -xf %{SOURCE10} -C third_party/externals/microhttpd
tar -xf %{SOURCE13} -C third_party/externals/perfetto
tar -xf %{SOURCE14} -C third_party/externals/piex
tar -xf %{SOURCE16} -C third_party/externals/vulkan-deps
tar -xf %{SOURCE24} -C third_party/externals/harfbuzz
tar -xf %{SOURCE25} -C third_party/externals/zlib

tar -xf %{SOURCE1} -C third_party/externals/brotli
tar -xf %{SOURCE2} -C third_party/externals/abseil-cpp
tar -xf %{SOURCE4} -C third_party/externals/egl-registry
tar -xf %{SOURCE5} -C third_party/externals/highway
tar -xf %{SOURCE6} -C third_party/externals/imgui
tar -xf %{SOURCE7} -C third_party/externals/libavif
tar -xf %{SOURCE11} -C third_party/externals/oboe
tar -xf %{SOURCE12} -C third_party/externals/opengl-registry
tar -xf %{SOURCE15} -C third_party/externals/vulkanmemoryallocator
tar -xf %{SOURCE17} -C third_party/externals/spirv-cross
tar -xf %{SOURCE18} -C third_party/externals/spirv-headers
tar -xf %{SOURCE19} -C third_party/externals/spirv-tools
tar -xf %{SOURCE20} -C third_party/externals/vello
tar -xf %{SOURCE21} -C third_party/externals/vulkan-headers
tar -xf %{SOURCE22} -C third_party/externals/vulkan-tools
tar -xf %{SOURCE23} -C third_party/externals/wuffs
tar -xf %{SOURCE26} -C third_party/externals/libjxl

%build
CFLAGS="${CFLAGS} \
    -DSKIA_C_DLL"

extra_cflags=""
for cflag in ${CFLAGS}; do
    extra_cflags+="\"${cflag}\","
done
extra_ldflags=""
for ldflag in ${LDFLAGS}; do
    extra_ldflags+="\"${ldflag}\","
done

gn gen out \
    --args="\
      target_os=\"linux\" \
      target_cpu=\"x64\" \
      cc=\"clang\" \
      cxx=\"clang++\" \
      extra_cflags=[${extra_cflags}] \
      extra_ldflags=[${extra_ldflags}] \
      skia_enable_gpu=true \
      skia_enable_tools=false \
      skia_use_dng_sdk=true \
      skia_use_icu=false \
      skia_use_piex=true \
      skia_use_sfntly=false \
      skia_use_system_harfbuzz=false \
      skia_use_system_expat=true \
      skia_use_system_freetype2=true \
      skia_use_system_libjpeg_turbo=true \
      skia_use_system_libpng=true \
      skia_use_system_libwebp=true \
      skia_use_system_zlib=true \
      is_component_build=false \
      is_debug=false \
      is_official_build=true \
      linux_soname_version=\"%{_major}.%{_minor}.%{_release}\""
ninja -C out

%install
install -Dm755 out/libSkiaSharp.so.%{_major}.%{_minor}.%{_release} -t \
      %{buildroot}%{_libdir}
ln -s libSkiaSharp.so.%{_major}.%{_minor}.%{_release} %{buildroot}%{_libdir}/libSkiaSharp.so.%{_major}.%{_minor}
ln -s libSkiaSharp.so.%{_major}.%{_minor}.%{_release} %{buildroot}%{_libdir}/libSkiaSharp.so.%{_major}
ln -s libSkiaSharp.so.%{_major}.%{_minor}.%{_release} %{buildroot}%{_libdir}/libSkiaSharp.so

%files
%license LICENSE
%doc README
%{_libdir}/libSkiaSharp.so.*

%files devel
%{_libdir}/libSkiaSharp.so

%changelog
openSUSE Build Service is sponsored by