File euneus.spec of Package euneus

%define bname euneus
Name: %bname
Version: 2.4.0
Release: 1
Summary: An flexible and performant JSON parser, generator and formatter in pure Erlang
License: Apache-2.0
Group: Development/Tools/Other
URL: https://github.com/williamthome/%bname
Source: %bname-%version.tar.xz
Patch0: %bname-%version-git.patch
BuildArch: noarch
Provides: erlang-%bname = %version-%release
Requires: erlang-otp-base >= 1:21.3.8.24-40

BuildRequires: rpm-macros-erlang rpm-build-erlang
BuildRequires: rebar >= 2.6.1-7
BuildRequires: erlang-otpbp-devel >= 6.9.2
# check
BuildRequires: erlang-otp-base >= 1:21.3.8.24-40
BuildRequires: erlang-jiffy
BuildRequires: erlang-otpbp >= 6.9.2

%description
An incredibly flexible and performant JSON parser, generator and formatter
in pure Erlang.
Euneus is built on the top of the new OTP json module.
Both encoder and decoder fully conform to RFC 8259
(https://datatracker.ietf.org/doc/html/rfc8259) and ECMA 404
(https://ecma-international.org/publications-and-standards/standards/ecma-404/)
standards and are tested using JSONTestSuite
(https://github.com/nst/JSONTestSuite).


%package doc
Summary: Documentation of %bname
Group: Documentation/HTML
Provides: erlang-%bname-doc = %version-%release

%description doc
An incredibly flexible and performant JSON parser, generator and formatter
in pure Erlang.
This package contains socumentation of %bname.


%prep
%setup -q -n %bname-%version
%patch -p1 -P0


%build
erl -noshell -eval '
{ok, L} = file:consult("rebar.config"),
C = lists:keystore(edoc_opts, 1, lists:keydelete(deps, 1, L), {edoc_opts, [preprocess]}),
file:write_file("%bname.rebar.config",
                lists:map(fun(E) -> [io_lib:print(E), ".\n"] end,
                          case lists:keyfind(erl_opts, 1, C) of
                              {_, [_|_] = O} ->
                                  lists:keyreplace(erl_opts, 1, C, {erl_opts, lists:delete(warn_missing_spec, O)});
                              _ -> C
                          end),
                [raw]),
init:stop().'
%if %_otp_release < 27
ERL_COMPILER_OPTIONS="[inline,verbose,{parse_transform,otpbp_pt}]" \
%else
ERL_COMPILER_OPTIONS="[inline,verbose]" \
%endif
rebar %{?_smp_mflags} -C %bname.rebar.config compile -v
rebar %{?_smp_mflags} -C %bname.rebar.config doc -v


%install
install -d -m 0755 %buildroot%_otplibdir/%bname-%version/ebin
install -p -m 0644 ebin/* %buildroot%_otplibdir/%bname-%version/ebin/
install -d -m 0755 %buildroot%_otplibdir/%bname-%version/doc
install -p -m 0644 doc/*.{css,html,png} %buildroot%_otplibdir/%bname-%version/doc/
install -d -m 0755 %buildroot%_docdir/%name
ln -sf %_otplibdir/%bname-%version/doc %buildroot%_docdir/%name/html
install -p -m 0644 *.md %buildroot%_docdir/%name/


%check
%if %_otp_release < 27
ERL_COMPILER_OPTIONS="[inline,verbose,{parse_transform,otpbp_pt}]" \
%else
ERL_COMPILER_OPTIONS="[inline,verbose]" \
%endif
rebar -C %bname.rebar.config ct -v


%files
%defattr(-,root,root)
%_otplibdir/*
%exclude %_otplibdir/%bname-*/doc


%files doc
%defattr(-,root,root)
%doc %_docdir/%name
%doc %dir %_otplibdir/%bname-*
%doc %_otplibdir/%bname-*/doc


%changelog
* Sun Apr 27 2025 Led <ledest@gmail.com> 2.4.0-1
- 2.4.0
- git 7e6c25b

* Sun Apr 27 2025 Led <ledest@gmail.com> 1.2.2-2
- Update Requires and BuildRequires

* Sun Apr 27 2025 Led <ledest@gmail.com> 1.2.2-2
- Update Requires and BuildRequires

* Sun Apr 27 2025 Led <ledest@gmail.com> 1.2.2-1
- 1.2.2
openSUSE Build Service is sponsored by