File crystal1.18.spec of Package crystal1.18

#
# spec file for package crystal1.18
#
# Copyright (c) 2024 SUSE LLC
#
# 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/
#


%bcond_without test
%bcond_without bundled_crystal

%global version_suffix   1.18
%global version_current  1.18.2
%global version_previous 1.17.1

Name:           crystal%{version_suffix}
Version:        %{version_current}
Release:        0
License:        Apache-2.0
Summary:        A programming language for humans and computers
URL:            https://github.com/crystal-lang/crystal
Source0:        https://github.com/crystal-lang/crystal/archive/refs/tags/%{version}.tar.gz#/crystal-%{version}.tar.gz
Patch0:         skip_test_requiring_network.patch
ExclusiveArch:  x86_64
# To build the Crystal compiler, a Crystal compiler is required. If no package exists yet, a precompiled binary has to be used.
%if 0%{with bundled_crystal}
Source1:        https://github.com/crystal-lang/crystal/releases/download/%{version_previous}/crystal-%{version_previous}-1-linux-x86_64.tar.gz
%else
BuildRequires:  crystal = %{version_previous}
%endif
%if 0%{?sle_version} == 150600
BuildRequires:  gcc13
BuildRequires:  gcc13-c++
%else
%if 0%{?suse_version} == 1600
BuildRequires:  gcc15
BuildRequires:  gcc15-c++
%else
BuildRequires:  gcc
BuildRequires:  gcc-c++
%endif
%endif
BuildRequires:  llvm-devel
BuildRequires:  lld
BuildRequires:  make
BuildRequires:  fdupes
BuildRequires:  findutils
BuildRequires:  pkgconfig(libpcre2-8)
BuildRequires:  pkgconfig(libffi)
BuildRequires:  pkgconfig(zlib)
BuildRequires:  pkgconfig(libssl)
BuildRequires:  gmp-devel
BuildRequires:  pkgconfig(bdw-gc)
BuildRequires:  pkgconfig(libxml-2.0)
BuildRequires:  pkgconfig(yaml-0.1)
%if %{with test}
BuildRequires:  git
BuildRequires:  hostname
%endif
Requires:       pkg-config
Requires:       pkgconfig(libpcre2-8)
Requires:       pkgconfig(libffi)
Requires:       pkgconfig(zlib)
Requires:       pkgconfig(libssl)
Requires:       gmp-devel
Requires:       pkgconfig(bdw-gc)
Requires:       pkgconfig(libxml-2.0)
Requires:       pkgconfig(yaml-0.1)
Provides:       crystal = %{version}
Conflicts:      crystal < %{version}

%description
Crystal is a general-purpose, object-oriented programming language.
With syntax inspired by Ruby, it is a compiled language with static type-checking,
serving both, humans and computers.

%package docs
Summary:        Documentation for the Crystal Programming Language
BuildArch:      noarch
Version:        %{version}

%description docs
Documentation for the %{name}.

%package        zsh-completion
Summary:        Zsh Completion for %{name}
Group:          System/Shells
Supplements:    (%{name} and zsh)
Requires:       zsh
BuildArch:      noarch
Provides:       crystal-zsh-completion = %{version}
Conflicts:      crystal-zsh-completion < %{version}
Obsoletes:      crystal-zsh-completion < %{version}

%description    zsh-completion
Zsh command-line completion support for %{name}.

%package        bash-completion
Summary:        Bash Completion for %{name}
Group:          System/Shells
Supplements:    (%{name} and bash-completion)
Requires:       bash-completion
BuildArch:      noarch
Provides:       crystal-bash-completion = %{version}
Conflicts:      crystal-bash-completion < %{version}
Obsoletes:      crystal-bash-completion < %{version}

%description    bash-completion
Bash command-line completion support for %{name}.

%package        fish-completion
Summary:        Fish Completion for %{name}
Group:          System/Shells
Supplements:    (%{name} and fish)
Requires:       fish
BuildArch:      noarch
Provides:       crystal-fish-completion = %{version}
Conflicts:      crystal-fish-completion < %{version}
Obsoletes:      crystal-fish-completion < %{version}

%description    fish-completion
Fish command-line completion support for %{name}.

%prep
%if %{with bundled_crystal}
%autosetup -a1 -p1 -n crystal-%{version}
%else
%autosetup -p1 -n crystal-%{version}
%endif

%build
%if 0%{with bundled_crystal}
export PATH="$PATH:%{_builddir}/crystal-%{version}/crystal-%{version_previous}-1/bin"
%endif

%if 0%{?sle_version} == 150600
export CC="gcc-13"
export CXX="g++-13"
%else
%if 0%{?suse_version} == 1600
export CC="gcc-15"
export CXX="g++-15"
%endif
%endif

make progress=1 threads="$(nproc)" verbose=1 stats=1 release=1 interpreter=1 \
  CRYSTAL_CONFIG_PATH="./lib:%{_datadir}/crystal/src" \
  %if 0%{with bundled_crystal}
  CRYSTAL_CONFIG_LIBRARY_PATH="%{_libdir}/crystal" \
  %endif

make docs

%install
%make_install PREFIX="%{_prefix}"

# "make install" installs the license to the wrong directory.
rm -r "%{buildroot}%{_datadir}/licenses/crystal"

mkdir -p "%{buildroot}%{_libdir}"
cp -a src "%{buildroot}%{_libdir}/crystal"

mkdir -p "%{buildroot}%{_datadir}/doc/crystal/"
cp -a docs "%{buildroot}%{_datadir}/doc/crystal/api"

%fdupes -s %{buildroot}

%if %{with test}
%check
%if 0%{?sle_version} == 150600
export CC="gcc-13"
export CXX="g++-13"
%else
%if 0%{?suse_version} == 1600
export CC="gcc-15"
export CXX="g++-15"
%endif
%endif

make primitives_spec compiler_spec std_spec
%endif

%files
%doc *.md
%license LICENSE
%{_bindir}/crystal
%dir %{_libdir}/crystal
%{_libdir}/crystal/*
%{_mandir}/man1/*
%dir %{_datadir}/crystal
%dir %{_datadir}/crystal/*
%{_datadir}/crystal/src/*

%files docs
%dir %{_datadir}/doc/crystal/
%dir %{_datadir}/doc/crystal/api
%{_datadir}/doc/crystal/api/*

%files bash-completion
%dir %{_datadir}/bash-completion
%dir %{_datadir}/bash-completion/completions
%{_datadir}/bash-completion/completions/crystal

%files zsh-completion
%dir %{_datadir}/zsh
%dir %{_datadir}/zsh/site-functions
%{_datadir}/zsh/site-functions/_crystal

%files fish-completion
%dir %{_datadir}/fish
%dir %{_datadir}/fish/vendor_completions.d
%{_datadir}/fish/vendor_completions.d/crystal.fish

%changelog
openSUSE Build Service is sponsored by