%bcond_with bootstrap
%bcond_with test
%bcond_with newrpm
%bcond_with miri
%bcond_without clang
%bcond_without bundled_libgit2
%bcond_without bundled_libssh2

# Some sub-packages are versioned independently of the rust compiler and runtime itself.
# Also beware that if any of these are not changed in a version bump, then the release
# number should still increase, not be reset to 1!
%global rustc_version 1.80.0
%global cargo_version %{rustc_version}
%global rustfmt_version %{rustc_version}
%global rls_version %{rustc_version}
%global clippy_version %{rustc_version}

# The channel can be stable, beta, or nightly
%{!?channel: %global channel stable}

# Only x86_64 and i686 are Tier 1 platforms at this time.
# https://forge.rust-lang.org/platform-support.html
%global rust_arches x86_64 i686

# To bootstrap from scratch, set the channel and date from src/stage0.txt
# e.g. 1.10.0 wants rustc: 1.9.0-2016-05-24
# or nightly wants some beta-YYYY-MM-DD
%global bootstrap_rust 1.79.0
%global bootstrap_cargo 1.79.0
%global bootstrap_channel %{bootstrap_rust}

# Only the specified arches will use bootstrap binaries.
%if %{with bootstrap}
%global bootstrap_arches %%{rust_arches}
%endif

# We generally don't want llvm-static present at all, since llvm-config will
# make us link statically.  But we can opt in, e.g. to aid LLVM rebases.
# FIXME: LLVM 3.9 prefers shared linking now! Which is good, but next time we
# *want* static we'll have to force it with "llvm-config --link-static".
# See also https://github.com/rust-lang/rust/issues/36854
# The new rustbuild accepts `--enable-llvm-link-shared`, else links static.
%bcond_with llvm_static

# We can also choose to just use Rust's bundled LLVM, in case the system LLVM
# is insufficient.  Rust currently requires LLVM 3.7+.
%bcond_with bundled_llvm

# LLDB only works on some architectures
%ifarch %{arm} aarch64 %{ix86} x86_64
# LLDB isn't available everywhere...
%bcond_without lldb
%else
%bcond_with lldb
%endif

Summary:        The Rust Programming Language
Name:           rust
Version:        %{rustc_version}
Release:        1%{?_dist_release}
Group:          programming
Vendor:         Project Vine
Distribution:   Vine Linux

License:        (ASL 2.0 or MIT) and (BSD and ISC and MIT)
# ^ written as: (rust itself) and (bundled libraries)
URL:            https://www.rust-lang.org

ExclusiveArch:  %{rust_arches}

%if "%{channel}" == "stable"
%global rustc_package rustc-%{version}-src
%else
%global rustc_package rustc-%{channel}-src
%endif
Source0:        https://static.rust-lang.org/dist/%{rustc_package}.tar.gz

# Get the Rust triple for any arch.
%{lua: function rust_triple(arch)
  local abi = "gnu"
  if arch == "armv7hl" then
    arch = "armv7"
    abi = "gnueabihf"
  elseif arch == "ppc64" then
    arch = "powerpc64"
  elseif arch == "ppc64le" then
    arch = "powerpc64le"
  end
  return arch.."-unknown-linux-"..abi
end}

%global rust_triple %{lua: print(rust_triple(rpm.expand("%{_target_cpu}")))}

%if %defined bootstrap_arches
# For each bootstrap arch, add an additional binary Source.
# Also define bootstrap_source just for the current target.
%{lua: do
  local bootstrap_arches = {}
  for arch in string.gmatch(rpm.expand("%{bootstrap_arches}"), "%S+") do
    table.insert(bootstrap_arches, arch)
  end
  local base = rpm.expand("https://static.rust-lang.org/dist"
                          .."/rust-%{bootstrap_channel}")
  local target_arch = rpm.expand("%{_target_cpu}")
  for i, arch in ipairs(bootstrap_arches) do
    print(string.format("Source%d: %s-%s.tar.gz\n",
                        i, base, rust_triple(arch)))
    if arch == target_arch then
      rpm.define("bootstrap_source "..i)
    end
  end
end}
%endif

%ifarch %{bootstrap_arches}
%global bootstrap_root rust-%{bootstrap_channel}-%{rust_triple}
%global local_rust_root %{_builddir}/%{bootstrap_root}/usr
Provides:       bundled(%{name}-bootstrap) = %{bootstrap_rust}
%else
BuildRequires:  cargo >= %{bootstrap_cargo}
BuildRequires:  %{name} >= %{bootstrap_rust}
BuildConflicts: %{name} > %{version}
%global local_rust_root %{_prefix}
%endif

BuildRequires:  cmake
BuildRequires:  make
%if %{with clang}
BuildRequires:  clang
BuildRequires:  lld
%else
BuildRequires:  gcc
BuildRequires:  gcc-c++
%endif
%if %{without bundled_libgit2}
BuildRequires:  libgit2-devel
%endif
%if %{without bundled_libssh2}
BuildRequires:  libssh2-devel
%endif
BuildRequires:  ncurses-devel
BuildRequires:  openssl-devel
BuildRequires:  zlib-ng-compat-devel
BuildRequires:  python3
BuildRequires:  python3-rpm-macros
BuildRequires:  curl
BuildRequires:  curl-devel
BuildRequires:  xz-devel

%if %{with bundled_llvm}
BuildRequires:  cmake
BuildRequires:  git
Provides:       bundled(llvm) = 6.0
%else
BuildRequires:  cmake
%if %defined llvm
%global llvm_root %{_libdir}/%{llvm}
%else
%global llvm llvm
%global llvm_root %{_prefix}
%global llvm_has_filecheck 1
%endif
BuildRequires:  %{llvm}-devel >= 11.0.0
%if %{with llvm_static}
BuildRequires:  %{llvm}-static
BuildRequires:  libffi-devel
%else
BuildConflicts: %{llvm}-static
%endif
%endif

# make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
BuildRequires:  procps

# debuginfo-gdb tests need gdb
BuildRequires:  gdb

# TODO: work on unbundling these!
Provides:       bundled(jquery) = 2.1.4
Provides:       bundled(miniz) = 1.14

# Virtual provides for folks who attempt "dnf install rustc"
Provides:       rustc = %{version}-%{release}
Provides:       rustc%{?_isa} = %{version}-%{release}

Obsoletes:      rust-rls < %{version}-%{release}
Obsoletes:      rust-analysis < %{version}-%{release}

%if ! %{with miri}
Obsoletes:      rust-miri < %{version}-%{release}
%endif

# Always require our exact standard library
Requires:       %{name}-std-static%{?_isa} = %{version}-%{release}

# The C compiler is needed at runtime just for linking.  Someday rustc might
# invoke the linker directly, and then we'll only need binutils.
# https://github.com/rust-lang/rust/issues/11937
Requires:       /usr/bin/cc

# ALL Rust libraries are private, because they don't keep an ABI.
%global _privatelibs lib(.*-[[:xdigit:]]{16}*|rustc.*)[.]so.*
%global __provides_exclude ^(%{_privatelibs})$
%global __requires_exclude ^(%{_privatelibs})$
%global __provides_exclude_from ^(%{_docdir}|%{rustlibdir}/src)/.*$
%global __requires_exclude_from ^(%{_docdir}|%{rustlibdir}/src)/.*$

%if !%{with newrpm}
# eu-strip is very eager by default, so we have to limit it to -g, only debugging symbols.
%global _find_debuginfo_opts -g
%undefine _include_minidebuginfo
%else
# Newer find-debuginfo.sh supports --keep-section, which is preferable. rhbz1465997
%global _find_debuginfo_opts --keep-section .rustc
%endif

%if !%{with newrpm}
Obsoletes: rust-debuginfo < %{version}-%{release}
%else
%ifnarch x86_64
Obsoletes: rust-debuginfo < %{version}-%{release}
%endif
%endif

# Use hardening ldflags.
%global rustflags -Clink-arg=-Wl,-z,relro,-z,now

%if %{without bundled_llvm} && "%{llvm_root}" != "%{_prefix}"
# https://github.com/rust-lang/rust/issues/40717
%global library_path $(%{llvm_root}/bin/llvm-config --libdir)
%endif

%description
Rust is a systems programming language that runs blazingly fast, prevents
segfaults, and guarantees thread safety.

This package includes the Rust compiler and documentation generator.


%package std-static
Summary:        Standard library for Rust
Group:          programming

%description std-static
This package includes the standard libraries for building applications
written in Rust.


%package debugger-common
Summary:        Common debugger pretty printers for Rust
Group:          programming
BuildArch:      noarch

%description debugger-common
This package includes the common functionality for %{name}-gdb and %{name}-lldb.


%package gdb
Summary:        GDB pretty printers for Rust
Group:          programming
BuildArch:      noarch
Requires:       gdb
Requires:       %{name}-debugger-common = %{version}-%{release}

%description gdb
This package includes the rust-gdb script, which allows easier debugging of Rust
programs.


%if %{with lldb}

%package lldb
Summary:        LLDB pretty printers for Rust
Group:          programming

# It could be noarch, but lldb has limited availability
#BuildArch:      noarch

Requires:       lldb
Requires:       python3-lldb
Requires:       %{name}-debugger-common = %{version}-%{release}

%description lldb
This package includes the rust-lldb script, which allows easier debugging of Rust
programs.

%endif


%package doc
Summary:        Documentation for Rust
Group:          documentation
# NOT BuildArch:      noarch
# Note, while docs are mostly noarch, some things do vary by target_arch.
# Koji will fail the build in rpmdiff if two architectures build a noarch
# subpackage differently, so instead we have to keep its arch.

%description doc
This package includes HTML documentation for the Rust programming language and
its standard library.


%package -n cargo
Summary:        Rust's package manager and build tool
Version:        %{cargo_version}
Group:          programming
# For tests:
BuildRequires:  git
# Cargo is not much use without Rust
Requires:       rust

%description -n cargo
Cargo is a tool that allows Rust projects to declare their various dependencies
and ensure that you'll always get a repeatable build.


%package -n cargo-doc
Summary:        Documentation for Cargo
Version:        %{cargo_version}
Group:          programming
BuildArch:      noarch
# Cargo no longer builds its own documentation
# https://github.com/rust-lang/cargo/pull/4904
Requires:       rust-doc = %{rustc_version}-%{release}

%description -n cargo-doc
This package includes HTML documentation for Cargo.


%package -n rustfmt
Summary:        Tool to find and fix Rust formatting issues
Version:        %{rustfmt_version}
Group:          programming
Requires:       cargo
Obsoletes:      rustfmt-preview < 1.0.0

%description -n rustfmt
A tool for formatting Rust code according to style guidelines.


%package -n clippy
Summary:        Lints to catch common mistakes and improve your Rust code
Version:        %{clippy_version}
Group:          programming
License:        MPLv2.0
Requires:       cargo
# /usr/bin/clippy-driver is dynamically linked against internal rustc libs
Requires:       %{name} = %{rustc_version}-%{release}
Obsoletes:      clippy-preview < 1.0.0

%description -n clippy
A collection of lints to catch common mistakes and improve your Rust code.


%package src
Summary:        Sources for the Rust standard library
Group:          programming
BuildArch:      noarch

%description src
This package includes source files for the Rust standard library.  It may be
useful as a reference for code completion tools in various editors.


%if %{with miri}
%package miri
Summary:        An interpreter for Rust's mid-level intermediate representation
Group:          programming
Requires:       rust = %{rustc_version}-%{release}

%description miri
An experimental interpreter for Rust's mid-level intermediate representation
(MIR). It can run binaries and test suites of cargo projects and detect certain
classes of undefined behavior.
%endif


%package analyzer
Summary:        A modular compiler frontend for the Rust language
Group:          programming
Requires:       rust = %{rustc_version}-%{release}

%description analyzer
rust-analyzer is a modular compiler frontend for the Rust language.


%if %{with newrpm}
# debuginfo is available on x86_64 only
%ifarch x86_64
%debug_package
%else
%global _build_id_links none
%global __debug_install_post %{nil}
%global debug_package %{nil}
%endif
%else
%global _build_id_links none
%global __debug_install_post %{nil}
%global debug_package %{nil}
%endif


%prep
%ifarch %{bootstrap_arches}
%setup -q -n %{bootstrap_root} -T -b %{bootstrap_source}
./install.sh --components=cargo,rustc,rust-std-%{rust_triple} \
  --prefix=%{local_rust_root} --disable-ldconfig
test -f '%{local_rust_root}/bin/cargo'
test -f '%{local_rust_root}/bin/rustc'
%endif

%setup -q -n %{rustc_package}
%autopatch -p1

sed -i.try-py3 -e '/try python2.7/i try python3 "$@"' ./configure

%if %without bundled_llvm
rm -rf src/llvm-project/
mkdir -p src/llvm-project/libunwind/
%endif

# We never enable emscripten.
rm -rf src/llvm-emscripten/

# Remove other unused vendored libraries
rm -rf vendor/curl-sys/curl/
rm -rf vendor/*jemalloc-sys*/jemalloc/
rm -rf vendor/libmimalloc-sys/c_src/mimalloc/
rm -rf vendor/libz-sys/src/zlib/
rm -rf vendor/libz-sys/src/zlib-ng/
rm -rf vendor/lzma-sys/xz-*/
rm -rf vendor/openssl-src/openssl/
%if %{without bundled_libgit2}
rm -rf vendor/libgit2-sys/libgit2/
%endif
%if %{without bundled_libssh2}
rm -rf vendor/libssh2-sys/libssh2/
%endif

# This only affects the transient rust-installer, but let it use our dynamic xz-libs
sed -i.lzma -e '/LZMA_API_STATIC/d' src/bootstrap/src/core/build_steps/tool.rs

# rename bundled license for packaging
if [ -e vendor/backtrace-sys/src/libbacktrace/LICENSE ]; then
  cp -a vendor/backtrace-sys/src/libbacktrace/LICENSE{,-libbacktrace}
fi

%if %{with bundled_llvm} && 0%{?epel}
mkdir -p cmake-bin
ln -s /usr/bin/cmake cmake-bin/cmake
%global cmake_path $PWD/cmake-bin
%endif

%if %{without bundled_llvm} && %{with llvm_static}
# Static linking to distro LLVM needs to add -lffi
# https://github.com/rust-lang/rust/issues/34486
sed -i.ffi -e '$a #[link(name = "ffi")] extern {}' \
  src/librustc_llvm/lib.rs
%endif

# The configure macro will modify some autoconf-related files, which upsets
# cargo when it tries to verify checksums in those files.  If we just truncate
# that file list, cargo won't have anything to complain about.
find vendor -name .cargo-checksum.json \
  -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'


%build
%if %{without bundled_libgit2}
export LIBGIT2_SYS_USE_PKG_CONFIG=1
%endif
%if %{without bundled_libssh2}
export LIBSSH2_SYS_USE_PKG_CONFIG=1
%endif

%{?cmake_path:export PATH=%{cmake_path}:$PATH}
%{?library_path:export LIBRARY_PATH="%{library_path}"}
%{?rustflags:export RUSTFLAGS="%{rustflags}"}

# We're going to override --libdir when configuring to get rustlib into a
# common path, but we'll fix the shared libraries during install.
%global common_libdir %{_prefix}/lib
%global rustlibdir %{common_libdir}/rustlib

%ifarch x86_64
%if %{with newrpm}
%define enable_debuginfo --debuginfo-level=0 --debuginfo-level-std=2
%else
%define enable_debuginfo --debuginfo-level=0
%global debug_package %{nil}
%endif
%else
%define enable_debuginfo --debuginfo-level=0
%global debug_package %{nil}
%endif

# Some builders have relatively little memory for their CPU count.
# At least 2GB per CPU is a good rule of thumb for building rustc.
ncpus=$(/usr/bin/getconf _NPROCESSORS_ONLN)
max_cpus=$(( ($(LANG=C free -g | awk '/^Mem:/{print $2}') + 1) / 2 ))
if [ "$max_cpus" -ge 1 -a "$max_cpus" -lt "$ncpus" ]; then
  ncpus="$max_cpus"
fi

%if %{with clang}
export CC=clang
export CXX=clang++
export LDFLAGS="$LDFLAGS -fuse-ld=lld"
export RUSTFLAGS="$RUSTFLAGS -C linker=clang -C link-arg=-fuse-ld=lld"
%endif

# workaround for https://github.com/rust-lang/rust/issues/69953
#  --set rust.deny-warnings=false

%configure \
  --disable-option-checking \
  --docdir=%{_pkgdocdir} \
  --libdir=%{common_libdir} \
  --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \
  --enable-local-rust --local-rust-root=%{local_rust_root} \
  --set build.build-stage=2 \
  --set build.doc-stage=2 \
  --set build.install-stage=2 \
  --set build.test-stage=2 \
  --set build.optimized-compiler-builtins=false \
  --set build.rustfmt=/bin/true \
  %{!?with_bundled_llvm: --llvm-root=%{llvm_root} \
    %{!?llvm_has_filecheck: --disable-codegen-tests} \
    %{!?with_llvm_static: --enable-llvm-link-shared } } \
  --disable-llvm-static-stdcpp \
  --disable-rpath \
  %{enable_debuginfo} \
  --set rust.codegen-units-std=1 \
  --enable-extended \
  --tools=cargo,clippy,rustfmt,rust-analyzer,src \
  --enable-vendor \
  --enable-verbose-tests \
  --release-channel=%{channel} \
  --dist-compression-formats=gz \
  --release-description="Vine Linux %{version}-%{release}" \
  %{nil}

%{__python3} ./x.py build -j "$ncpus"
%{__python3} ./x.py doc


%install
rm -rf %{buildroot}

%{?cmake_path:export PATH=%{cmake_path}:$PATH}
%{?library_path:export LIBRARY_PATH="%{library_path}"}
%{?rustflags:export RUSTFLAGS="%{rustflags}"}
%if %{with clang}
export CC=clang
export CXX=clang++
export RUSTFLAGS="$RUSTFLAGS -C linker=clang -C link-arg=-fuse-ld=lld"
%endif

DESTDIR=%{buildroot} ./x.py install
#DESTDIR=%{buildroot} ./x.py install src


# Make sure the shared libraries are in the proper libdir
%if "%{_libdir}" != "%{common_libdir}"
mkdir -p %{buildroot}%{_libdir}
find %{buildroot}%{common_libdir} -maxdepth 1 -type f -name '*.so' \
  -exec mv -v -t %{buildroot}%{_libdir} '{}' '+'
%endif

# The shared libraries should be executable for debuginfo extraction.
find %{buildroot}%{_libdir} -maxdepth 1 -type f -name '*.so' \
  -exec chmod -v +x '{}' '+'

# The libdir libraries are identical to those under rustlib/.  It's easier on
# library loading if we keep them in libdir, but we do need them in rustlib/
# to support dynamic linking for compiler plugins, so we'll symlink.
(cd "%{buildroot}%{rustlibdir}/%{rust_triple}/lib" &&
 find ../../../../%{_lib} -maxdepth 1 -name '*.so' |
 while read lib; do
   if [ -f "${lib##*/}" ]; then
     # make sure they're actually identical!
     cmp "$lib" "${lib##*/}"
     ln -v -f -s -t . "$lib"
   fi
 done)
 
# Remove installer artifacts (manifests, uninstall scripts, etc.)
find %{buildroot}%{rustlibdir} -maxdepth 1 -type f -exec rm -v '{}' '+'

# Remove backup files from %%configure munging
find %{buildroot}%{rustlibdir} -type f -name '*.orig' -exec rm -v '{}' '+'

# https://fedoraproject.org/wiki/Changes/Make_ambiguous_python_shebangs_error
# We don't actually need to ship any of those python scripts in rust-src anyway.

find %{buildroot}%{rustlibdir}/src -type f -name '*.py' -exec rm -v '{}' '+'

# FIXME: __os_install_post will strip the rlibs
# -- should we find a way to preserve debuginfo?

# Remove unwanted documentation files (we already package them)
# Remove unwanted documentation files (we already package them)
rm -f %{buildroot}%{_docdir}/%{name}/README.md
rm -f %{buildroot}%{_docdir}/%{name}/COPYRIGHT
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-APACHE
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-MIT
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-THIRD-PARTY
rm -f %{buildroot}%{_docdir}/%{name}/*.old

# Sanitize the HTML documentation
find %{buildroot}%{_docdir}/%{name}/html -empty -delete
find %{buildroot}%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'

# Create the path for crate-devel packages
mkdir -p %{buildroot}%{_datadir}/cargo/registry

# Cargo no longer builds its own documentation
# https://github.com/rust-lang/cargo/pull/4904
mkdir -p %{buildroot}%{_docdir}/cargo
ln -sT ../rust/html/cargo/ %{buildroot}%{_docdir}/cargo/html

rm -f %{buildroot}%{_bindir}/*.old

%if %{without lldb}
rm -f %{buildroot}%{_bindir}/rust-lldb
rm -f %{buildroot}%{rustlibdir}/etc/lldb_*.py*
rm -f %{buildroot}%{rustlibdir}/etc/lldb_commands
%endif

%if %{with bundled_llvm}
rm -rf %{buildroot}/home
%endif

# We don't want Rust copies of LLVM tools (rust-lld, rust-llvm-dwp)
rm -f %{buildroot}%{rustlibdir}/%{rust_triple}/bin/rust-ll*


%check
%if %{with test}
%{?cmake_path:export PATH=%{cmake_path}:$PATH}
%{?library_path:export LIBRARY_PATH="%{library_path}"}
%{?rustflags:export RUSTFLAGS="%{rustflags}"}
%if %{with clang}
export CC=clang
export CXX=clang++
export LD=ld.lld
export RUSTFLAGS="$RUSTFLAGS -C linker=ld.lld -C link-arg=-fuse-ld=lld"
%endif

# The results are not stable on koji, so mask errors and just log it.
%{__python3} ./x.py test --no-fail-fast || :
%{__python3} ./x.py test --no-fail-fast cargo || :
%{__python3} ./x.py test --no-fail-fast clippy || :
%{__python3} ./x.py test --no-fail-fast rustfmt || :
%endif


%files
%license COPYRIGHT LICENSE-APACHE LICENSE-MIT
#license src/libbacktrace/LICENSE-libbacktrace
%doc README.md
%{_bindir}/rustc
%{_bindir}/rustdoc
%{_libdir}/*.so
%{_mandir}/man1/rustc.1*
%{_mandir}/man1/rustdoc.1*
%dir %{rustlibdir}
%dir %{rustlibdir}/%{rust_triple}
%dir %{rustlibdir}/%{rust_triple}/lib
%{rustlibdir}/%{rust_triple}/lib/*.so

%files std-static
%dir %{rustlibdir}
%dir %{rustlibdir}/%{rust_triple}
%dir %{rustlibdir}/%{rust_triple}/lib
%{rustlibdir}/%{rust_triple}/lib/*.rlib

%files debugger-common
%dir %{rustlibdir}
%dir %{rustlibdir}/etc
%{rustlibdir}/etc/rust_types.py*

%files gdb
%{_bindir}/rust-gdb
%{rustlibdir}/etc/gdb_*.py*
%exclude %{_bindir}/rust-gdbgui

%if %with lldb
%files lldb
%{_bindir}/rust-lldb
%{rustlibdir}/etc/lldb_*.py*
%{rustlibdir}/etc/lldb_commands
%endif

%files doc
%docdir %{_docdir}/%{name}
%dir %{_docdir}/%{name}
%dir %{_docdir}/%{name}/html
%{_docdir}/%{name}/html/*/
%{_docdir}/%{name}/html/*.html
%{_docdir}/%{name}/html/*.css
%{_docdir}/%{name}/html/*.js
%{_docdir}/%{name}/html/robots.txt
%{_docdir}/%{name}/html/releases.md

%files -n cargo
%license src/tools/cargo/LICENSE-APACHE src/tools/cargo/LICENSE-MIT src/tools/cargo/LICENSE-THIRD-PARTY
%doc src/tools/cargo/README.md
%{_bindir}/cargo
%{_mandir}/man1/cargo*.1*
%dir %{_sysconfdir}/bash_completion.d
%{_sysconfdir}/bash_completion.d/cargo
%dir %{_datadir}/zsh
%dir %{_datadir}/zsh/site-functions
%{_datadir}/zsh/site-functions/_cargo
%dir %{_datadir}/cargo
%dir %{_datadir}/cargo/registry

%files -n cargo-doc
%docdir %{_docdir}/cargo
%dir %{_docdir}/cargo
%{_docdir}/cargo/html

%files -n rustfmt
%{_bindir}/rustfmt
%{_bindir}/cargo-fmt
%doc src/tools/rustfmt/{README,CHANGELOG,Configurations}.md
%license src/tools/rustfmt/LICENSE-{APACHE,MIT}

%files -n clippy
%{_bindir}/cargo-clippy
%{_bindir}/clippy-driver
%doc src/tools/clippy/{README.md,CHANGELOG.md}
%license src/tools/clippy/LICENSE*

%files src
%dir %{rustlibdir}
%{rustlibdir}/src

%files analyzer
%{_bindir}/rust-analyzer
%{_libexecdir}/rust-analyzer-proc-macro-srv

%if %{with miri}
%files miri
%{_bindir}/miri
%{_bindir}/cargo-miri
%endif


%changelog
* Sat Jul 27 2024 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.80.0-1
- new upstream release.

* Thu Jun 13 2024 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.79.0-1
- new upstream release.

* Mon May 06 2024 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.78.0-1
- new upstream release.

* Thu Mar 28 2024 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.77.0-1
- new upstream release.

* Fri Feb 09 2024 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.76.0-1
- new upstream release.

* Fri Dec 29 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.75.0-1
- new upstream release.

* Tue Dec 19 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.74.1-1
- new upstream release.

* Fri Nov 17 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.74.0-1
- new upstream release.

* Fri Oct 06 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.73.0-1
- new upstream release.

* Sun Oct 01 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.72.1-1
- new upstream release.

* Fri Aug 25 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.72.0-1
- new upstream release.

* Fri Jul 14 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.71.0-1
- new upstream release.

* Sun Jun 04 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.70.0-1
- new upstream release.

* Thu Apr 20 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.69.0-1
- new upstream release.
- dropped rust-analysis.

* Wed Mar 29 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.68.2-1
- new upstream release.

* Tue Mar 28 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.68.1-1
- new upstream release.

* Fri Mar 10 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.68.0-1
- new upstream release.

* Fri Feb 10 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.67.1-1
- new upstream release.

* Fri Jan 27 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.67.0-1
- new upstream release.

* Wed Jan 11 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.66.1-1
- new upstream release.

* Fri Dec 16 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.66.0-1
- new upstream release.

* Fri Nov 04 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.65.0-1
- new upstream release.

* Fri Sep 23 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.64.0-1
- new upstream release.

* Fri Aug 12 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.63.0-1
- new upstream release.

* Wed Jul 20 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.62.1-1
- new upstream release.

* Fri Jul 01 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.62.0-1
- new upstream release.

* Sat May 21 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.61.0-1
- new upstream release.

* Fri Apr 22 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.60.0-1
- new upstream release.

* Fri Feb 25 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.59.0-1
- new upstream release.

* Fri Jan 21 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.58.1-1
- new upstream release.

* Fri Jan 14 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.58.0-1
- new upstream release.

* Fri Dec 03 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.57.0-1
- new upstream release.

* Tue Nov 02 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.56.1-1
- new upstream release.

* Fri Oct 22 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.56.0-1
- new upstream release.

* Wed Sep 15 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.55.0-1
- new upstream release.

* Wed Aug 11 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.54.0-2
- rebuilt with current toolchain.

* Fri Jul 30 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.54.0-1
- new upstream release.

* Mon Jun 21 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.53.0-1
- new upstream release.
- dropped a package: rust-miri.

* Sun Jun 13 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.52.1-1
- new upstream release.

* Mon May 10 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.52.0-1
- new upstream release.
- dropped Patch0 and 1: merged to upstream.

* Sun Apr 18 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.51.0-2
- rebuilt with llvm-12.

* Tue Mar 30 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.51.0-1
- new upstream release.

* Sun Feb 21 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.50.0-1
- new upstream release.

* Wed Jan 27 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.49.0-1
- new upstream release.

* Sat Dec 12 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.48.0-1
- new upstream release.

* Fri Oct 16 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.47.0-1
- new upstream release.

* Thu Sep 24 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.46.0-1
- new upstream release.

* Thu Mar 26 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.42.0-1
- new upstream release.
- separated debuginfo.

* Sun Dec 22 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.40.0-1
- new upstream release.

* Sat Sep 28 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.38.0-1
- new upstream release.
- erased "-preview" from the name of subpackages.

* Wed Dec 05 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.30.1-1
- new upstream release.
- dropped Patch1.
- added subpackages cargo, cargo-doc, rustformat-preview, rls-preview, clippy-preview and rust-analysis.

* Fri Jan 05 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.23.0-1
- Update to 1.23.0 (stable).

* Tue Jan 02 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.23.0-0.beta1
- initial build for Vine Linux.
- Update to 1.23.0-beta.
- built a bootstrap rpm.

* Thu Nov 23 2017 Josh Stone <jistone@redhat.com> - 1.22.1-1
- Update to 1.22.1.

* Thu Oct 12 2017 Josh Stone <jistone@redhat.com> - 1.21.0-1
- Update to 1.21.0.

* Mon Sep 11 2017 Josh Stone <jistone@redhat.com> - 1.20.0-2
- ABI fixes for ppc64 and s390x.

* Thu Aug 31 2017 Josh Stone <jistone@redhat.com> - 1.20.0-1
- Update to 1.20.0.
- Add a rust-src subpackage.

* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.19.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild

* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.19.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Mon Jul 24 2017 Josh Stone <jistone@redhat.com> - 1.19.0-2
- Use find-debuginfo.sh --keep-section .rustc

* Thu Jul 20 2017 Josh Stone <jistone@redhat.com> - 1.19.0-1
- Update to 1.19.0.

* Thu Jun 08 2017 Josh Stone <jistone@redhat.com> - 1.18.0-1
- Update to 1.18.0.

* Mon May 08 2017 Josh Stone <jistone@redhat.com> - 1.17.0-2
- Move shared libraries back to libdir and symlink in rustlib

* Thu Apr 27 2017 Josh Stone <jistone@redhat.com> - 1.17.0-1
- Update to 1.17.0.

* Mon Mar 20 2017 Josh Stone <jistone@redhat.com> - 1.16.0-3
- Make rust-lldb arch-specific to deal with lldb deps

* Fri Mar 17 2017 Josh Stone <jistone@redhat.com> - 1.16.0-2
- Limit rust-lldb arches

* Thu Mar 16 2017 Josh Stone <jistone@redhat.com> - 1.16.0-1
- Update to 1.16.0.
- Use rustbuild instead of the old makefiles.
- Update bootstrapping to include rust-std and cargo.
- Add a rust-lldb subpackage.

* Thu Feb 09 2017 Josh Stone <jistone@redhat.com> - 1.15.1-1
- Update to 1.15.1.
- Require rust-rpm-macros for new crate packaging.
- Keep shared libraries under rustlib/, only debug-stripped.
- Merge and clean up conditionals for epel7.

* Fri Dec 23 2016 Josh Stone <jistone@redhat.com> - 1.14.0-2
- Rebuild without bootstrap binaries.

* Thu Dec 22 2016 Josh Stone <jistone@redhat.com> - 1.14.0-1
- Update to 1.14.0.
- Rewrite bootstrap logic to target specific arches.
- Bootstrap ppc64, ppc64le, s390x. (thanks to Sinny Kumari for testing!)

* Thu Nov 10 2016 Josh Stone <jistone@redhat.com> - 1.13.0-1
- Update to 1.13.0.
- Use hardening flags for linking.
- Split the standard library into its own package
- Centralize rustlib/ under /usr/lib/ for multilib integration.

* Thu Oct 20 2016 Josh Stone <jistone@redhat.com> - 1.12.1-1
- Update to 1.12.1.

* Fri Oct 14 2016 Josh Stone <jistone@redhat.com> - 1.12.0-7
- Rebuild with LLVM 3.9.
- Add ncurses-devel for llvm-config's -ltinfo.

* Thu Oct 13 2016 Josh Stone <jistone@redhat.com> - 1.12.0-6
- Rebuild with llvm-static, preparing for 3.9

* Fri Oct 07 2016 Josh Stone <jistone@redhat.com> - 1.12.0-5
- Rebuild with fixed eu-strip (rhbz1380961)

* Fri Oct 07 2016 Josh Stone <jistone@redhat.com> - 1.12.0-4
- Rebuild without bootstrap binaries.

* Thu Oct 06 2016 Josh Stone <jistone@redhat.com> - 1.12.0-3
- Bootstrap aarch64.
- Use jemalloc's MALLOC_CONF to work around #36944.
- Apply pr36933 to really disable armv7hl NEON.

* Sat Oct 01 2016 Josh Stone <jistone@redhat.com> - 1.12.0-2
- Protect .rustc from rpm stripping.

* Fri Sep 30 2016 Josh Stone <jistone@redhat.com> - 1.12.0-1
- Update to 1.12.0.
- Always use --local-rust-root, even for bootstrap binaries.
- Remove the rebuild conditional - the build system now figures it out.
- Let minidebuginfo do its thing, since metadata is no longer a note.
- Let rust build its own compiler-rt builtins again.

* Sat Sep 03 2016 Josh Stone <jistone@redhat.com> - 1.11.0-3
- Rebuild without bootstrap binaries.

* Fri Sep 02 2016 Josh Stone <jistone@redhat.com> - 1.11.0-2
- Bootstrap armv7hl, with backported no-neon patch.

* Wed Aug 24 2016 Josh Stone <jistone@redhat.com> - 1.11.0-1
- Update to 1.11.0.
- Drop the backported patches.
- Patch get-stage0.py to trust existing bootstrap binaries.
- Use libclang_rt.builtins from compiler-rt, dodging llvm-static issues.
- Use --local-rust-root to make sure the right bootstrap is used.

* Sat Aug 13 2016 Josh Stone <jistone@redhat.com> 1.10.0-4
- Rebuild without bootstrap binaries.

* Fri Aug 12 2016 Josh Stone <jistone@redhat.com> - 1.10.0-3
- Initial import into Fedora (#1356907), bootstrapped
- Format license text as suggested in review.
- Note how the tests already run in parallel.
- Undefine _include_minidebuginfo, because it duplicates ".note.rustc".
- Don't let checks fail the whole build.
- Note that -doc can't be noarch, as rpmdiff doesn't allow variations.

* Tue Jul 26 2016 Josh Stone <jistone@redhat.com> - 1.10.0-2
- Update -doc directory ownership, and mark its licenses.
- Package and declare licenses for libbacktrace and hoedown.
- Set bootstrap_base as a global.
- Explicitly require python2.

* Thu Jul 14 2016 Josh Stone <jistone@fedoraproject.org> - 1.10.0-1
- Initial package, bootstrapped
