%global pkgvers 4
%global scdate0 20220704
%global schash0 c985b4648e66414b250261c1ba4cbe45a2971b1c
%global branch0 main
%global source0 https://github.com/chipsalliance/fpga-interchange-schema.git

%global sshort0 %{expand:%%{lua:print(('%{schash0}'):sub(1,8))}}

Summary:        FPGA interchange schema definitions
Name:           fpga-interchange-schema
Version:        0.0
Release:        %{scdate0}.%{pkgvers}.git%{sshort0}%{?dist}
License:        MIT

URL:            https://github.com/chipsalliance/fpga-interchange-schema

BuildRequires:  git gcc-c++ cmake wget
BuildRequires:  capnproto capnproto-devel

%global __cmake_in_source_build 1

%description
FPGA interchange schema definitions


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

%description devel
This package contains the data files and libraries for %{name}


%prep
%setup -T -c -n %{name}
git clone --depth 1 -n -b %{branch0} %{source0} .
git fetch --depth 1 origin %{schash0}
git reset --hard %{schash0}
git log --format=fuller


%build
sed -i 's|STATIC|SHARED|' cmake/cxx_static/CMakeLists.txt
sed -i 's|CAPNPC_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/../../interchange|CAPNPC_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/../interchange|' cmake/cxx_static/CMakeLists.txt
mkdir build
pushd build
%cmake -Wno-dev \
       ../cmake/cxx_static \
       -DCMAKE_VERBOSE=OFF \
       -DCMAKE_VERBOSE_MAKEFILE=OFF \
       -DCMAKE_SKIP_RPATH=ON \
       -DCMAKE_BUILD_TYPE=RelWithDebInfo
make V=0 %{?_smp_mflags}


%install
rm -rf %{buildroot}
mkdir -p %{buildroot}%{_libdir}
mkdir -p %{buildroot}%{_includedir}/capnp/
mkdir -p %{buildroot}%{_includedir}/interchange/
install -p -m 0755 build/lib*.so %{buildroot}%{_libdir}/
install -p -m 0644 interchange/*.{capnp,h} %{buildroot}%{_includedir}/interchange/
install -p -m 0644 build/schema/capnp/* %{buildroot}%{_includedir}/capnp/


%ldconfig_scriptlets


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

%files devel
%{_includedir}/*


%changelog
* Sun Dec 05 2021 Cristian Balint <cristian.balint@gmail.com>
- update github releases