%global debug_package %{nil}
%global swifttag 4.2-DEVELOPMENT-SNAPSHOT-2018-07-20-a
%global swiftgithash 18650bc
%global swiftgitdate 20180720
%global swiftbuild swift-source
%global __provides_exclude ^/usr/lib/swift-lldb/.*\\.so.*
Name: swift-lang
Version: 4.2
Release: 0.37.%{swiftgitdate}git%{swiftgithash}%{?dist}
Summary: Apple's Swift programming language
License: ASL 2.0
URL: https://swift.org
Source0: https://github.com/apple/swift/archive/swift-%{swifttag}.tar.gz#/swift.tar.gz
Source1: https://github.com/apple/swift-compiler-rt/archive/swift-%{swifttag}.tar.gz#/swift-compiler-rt.tar.gz
Source2: https://github.com/apple/swift-corelibs-libdispatch/archive/swift-%{swifttag}.tar.gz#/corelibs-libdispatch.tar.gz
Source3: https://github.com/apple/swift-corelibs-foundation/archive/swift-%{swifttag}.tar.gz#/corelibs-foundation.tar.gz
Source4: https://github.com/apple/swift-integration-tests/archive/swift-%{swifttag}.tar.gz#/swift-integration-tests.tar.gz
Source5: https://github.com/apple/swift-corelibs-xctest/archive/swift-%{swifttag}.tar.gz#/corelibs-xctest.tar.gz
Source6: https://github.com/apple/swift-clang/archive/swift-%{swifttag}.tar.gz#/clang.tar.gz
Source7: https://github.com/apple/swift-package-manager/archive/swift-%{swifttag}.tar.gz#/package-manager.tar.gz
Source8: https://github.com/apple/swift-lldb/archive/swift-%{swifttag}.tar.gz#/lldb.tar.gz
Source9: https://github.com/apple/swift-llvm/archive/swift-%{swifttag}.tar.gz#/llvm.tar.gz
Source10: https://github.com/apple/swift-llbuild/archive/swift-%{swifttag}.tar.gz#/llbuild.tar.gz
Source11: https://github.com/apple/swift-cmark/archive/swift-%{swifttag}.tar.gz#/cmark.tar.gz
Source12: https://github.com/apple/swift-xcode-playground-support/archive/swift-%{swifttag}.tar.gz#/swift-xcode-playground-support.tar.gz
Source13: swift-lang.conf
Source14: swift-lang-runtime.conf
Patch0: %{name}-%{version}-change-lldb-location.patch
Patch1: compiler-rt-no-ustat.patch
Patch2: no-ninja-build.patch
Patch3: lldb-paths-1.patch
Patch4: lldb-paths-2.patch
BuildRequires: clang
BuildRequires: cmake
BuildRequires: swig
BuildRequires: pkgconfig
BuildRequires: perl-podlators
BuildRequires: rsync
%if 0%{?fedora} > 28
BuildRequires: python-unversioned-command
%endif
BuildRequires: python2
BuildRequires: python2-devel
BuildRequires: libbsd-devel
BuildRequires: libxml2-devel
BuildRequires: libsqlite3x-devel
BuildRequires: libblocksruntime-static
BuildRequires: libatomic-static
BuildRequires: libcurl-devel
BuildRequires: libuuid-devel
BuildRequires: libedit-devel
BuildRequires: libicu-devel
BuildRequires: python2-sphinx
BuildRequires: ninja-build
Requires: glibc-devel
Requires: clang
Requires: %{name}-runtime = %{version}-%{release}
ExclusiveArch: x86_64
%description
Swift is a general-purpose programming language built using
a modern approach to safety, performance, and software design
patterns.
The goal of the Swift project is to create the best available
language for uses ranging from systems programming, to mobile
and desktop apps, scaling up to cloud services. Most
importantly, Swift is designed to make writing and maintaining
correct programs easier for the developer.
%package runtime
Summary: Runtime files for Swift
%description runtime
Runtime libraries for Swift programs
%prep
%setup -q -c -n %{swiftbuild} -a 0 -a 1 -a 2 -a 3 -a 4 -a 5 -a 6 -a 7 -a 8 -a 9 -a 10 -a 11 -a 12
# The Swift build script requires directories to be named
# in a specific way so renaming the source directories is
# necessary
mv swift-clang-swift-%{swifttag} clang
mv swift-cmark-swift-%{swifttag} cmark
mv swift-compiler-rt-swift-%{swifttag} compiler-rt
mv swift-corelibs-foundation-swift-%{swifttag} swift-corelibs-foundation
mv swift-corelibs-libdispatch-swift-%{swifttag} swift-corelibs-libdispatch
mv swift-corelibs-xctest-swift-%{swifttag} swift-corelibs-xctest
mv swift-integration-tests-swift-%{swifttag} swift-integration-tests
mv swift-llbuild-swift-%{swifttag} llbuild
mv swift-lldb-swift-%{swifttag} lldb
mv swift-llvm-swift-%{swifttag} llvm
mv swift-package-manager-swift-%{swifttag} swiftpm
mv swift-swift-%{swifttag} swift
mv swift-xcode-playground-support-swift-%{swifttag} swift-xcode-playground-support
# This patch tells the Swift executable to look for its Swift-specific
# lldb executable in /usr/libexec/swift-lldb, not in the same directory
# as the swift executable (i.e. /usr/bin).
%patch0 -p0
# sys/ustat.h was removed from glibc (per https://sourceware.org/git/?p=glibc.git;a=commit;h=cf2478d53ad7071e84c724a986b56fe17f4f4ca7)
# A patch has been submitted to resolve this upstream (https://github.com/apple/swift-compiler-rt/pull/20) but until
# it is merged this patch is necessary to build Swift on Fedora with the latest glibc.
%patch1 -p0
# Since we require ninja for building, there's no sense to rebuild it just for Swift
%patch2 -p0
# Per https://forums.swift.org/t/swift-force-load-swiftglibc-error-since-2018-07-03-build/14418
%patch3 -p0
%patch4 -p0
%build
export VERBOSE=1
export PYTHON_DISALLOW_AMBIGUOUS_VERSION=0
swift/utils/build-script --preset=buildbot_linux,no_test install_destdir=%{_builddir} installable_package=%{_builddir}/swift-%{version}-fedora.tar.gz
%install
export PYTHON_DISALLOW_AMBIGUOUS_VERSION=0
mkdir -p %{buildroot}%{_libexecdir}/swift-lldb
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}/usr/lib
install -m 0755 %{_builddir}/usr/bin/swift %{buildroot}%{_bindir}
install -m 0755 %{_builddir}/usr/bin/swift-build %{buildroot}%{_bindir}
install -m 0755 %{_builddir}/usr/bin/swift-build-tool %{buildroot}%{_bindir}
install -m 0755 %{_builddir}/usr/bin/swift-demangle %{buildroot}%{_bindir}
install -m 0755 %{_builddir}/usr/bin/swift-package %{buildroot}%{_bindir}
install -m 0755 %{_builddir}/usr/bin/swift-run %{buildroot}%{_bindir}
install -m 0755 %{_builddir}/usr/bin/swift-test %{buildroot}%{_bindir}
ln -fs swift %{buildroot}/usr/bin/swift-autolink-extract
ln -fs swift %{buildroot}/usr/bin/swiftc
ln -fs swift %{buildroot}/usr/bin/swift-format
install -m 0755 %{_builddir}/usr/bin/lldb* %{buildroot}%{_libexecdir}/swift-lldb
install -m 0755 %{_builddir}/usr/bin/repl_swift %{buildroot}%{_libexecdir}/swift-lldb
# Why /usr/lib instead of %{_libdir}?
# The Swift toolchain is *extermely* sensitive to locations of its files
# (for example, the need for the patch above in the prep section) and
# has "lib" hardcoded in many, many places throughout all the projects that
# make up the Swift toolchain. Since we use subdirectories for the
# libraries, no actual .so files are dumped in /usr/lib.
mkdir -p %{buildroot}/usr/lib/swift-lldb
cp %{_builddir}/usr/lib/liblldb.so.6.0.0 %{buildroot}/usr/lib/swift-lldb
ln -fs liblldb.so.6.0.0 %{buildroot}/usr/lib/swift-lldb/liblldb.so.6
ln -fs liblldb.so.6 %{buildroot}/usr/lib/swift-lldb/liblldb.so
cp %{_builddir}/usr/lib/libsourcekitdInProc.so %{buildroot}/usr/lib/swift-lldb
cp %{_builddir}/usr/lib/libswiftDemangle.so %{buildroot}/usr/lib/swift-lldb
cp %{_builddir}/usr/lib/liblldbIntelFeatures.so.6.0.0 %{buildroot}/usr/lib/swift-lldb
ln -fs liblldbIntelFeatures.so.6.0.0 %{buildroot}/usr/lib/swift-lldb/liblldbIntelFeatures.so.6
ln -fs liblldbIntelFeatures.so.6 %{buildroot}/usr/lib/swift-lldb/liblldbIntelFeatures.so
ln -fs %{_bindir}/swift %{buildroot}%{_libexecdir}/swift-lldb/swift
mkdir -p %{buildroot}/usr/lib/swift
cp -r %{_builddir}/usr/lib/swift/* %{buildroot}/usr/lib/swift
ln -fs /usr/lib/swift %{buildroot}/usr/lib/swift-lldb/swift
mkdir -p %{buildroot}/usr/lib/swift_static
cp -r %{_builddir}/usr/lib/swift_static/* %{buildroot}/usr/lib/swift_static
mkdir -p %{buildroot}/%{_sysconfdir}/ld.so.conf.d/
install -m 0644 %{SOURCE13} %{buildroot}/%{_sysconfdir}/ld.so.conf.d/swift-lang.conf
install -m 0644 %{SOURCE14} %{buildroot}/%{_sysconfdir}/ld.so.conf.d/swift-lang-runtime.conf
mkdir -p %{buildroot}%{_mandir}/man1
install -m 0644 %{_builddir}/usr/share/man/man1/swift.1 %{buildroot}%{_mandir}/man1
%files
%license swift/LICENSE.txt
%{_bindir}/swift*
%{_mandir}/man1/*
/usr/lib/swift/
/usr/lib/swift-lldb/
/usr/lib/swift/Block/
/usr/lib/swift/CoreFoundation/
/usr/lib/swift/clang/
/usr/lib/swift/dispatch/
/usr/lib/swift/migrator/
/usr/lib/swift/os/
/usr/lib/swift/pm/
/usr/lib/swift/shims/
/usr/lib/swift/linux/x86_64/
/usr/lib/swift_static/
%{_libexecdir}/swift-lldb/
%{_sysconfdir}/ld.so.conf.d/swift-lang.conf
%files runtime
/usr/lib/swift/
/usr/lib/swift/linux/
%{_sysconfdir}/ld.so.conf.d/swift-lang-runtime.conf
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%changelog
* Sat Jul 21 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.37.20180720git18650bc
- Added patches for lldb to fix relative path issue (see URL by patches) until
it's merged into the 4.2 branch
* Sat Jul 21 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.37.20180720git18650bc
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-07-20-a
* Fri Jul 20 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.36.20180719git9277281
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-07-19-a
* Thu Jul 19 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.35.20180718gite325e32
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-07-18-a
* Tue Jul 17 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.34.20180716gitaaf545a
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-07-16-a
* Sun Jul 15 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.33.20180703git107e307
- Switched from __provides_exclude_from to __provides_exclude to inhibit
lldb being included as a dependency
* Thu Jul 12 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.32.20180703git107e307
- Reverted to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-07-03-a as loading modules
in the REPL seems to have been broken as of the 2018-07-04 builds.
2018-07-03 is currently the best version until the issue is resolved.
* Thu Jul 12 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.31.20180711git104c96a
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-07-11-a
* Wed Jul 11 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.30.20180709gitd9561d9
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-07-09-a and added a check to
include python-unversioned-command for verisons greated than 28 while
working on making patches/pull requests upstream to be explicit about
which version of Python to use. Also removed patch for time struct issue
as the fix has been handled upstream. Also switched to ExclusiveArch
instead of ExcludeArch per suggestion from Dan HorĂ¡k.
* Thu Jul 05 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.29.20180705git1e2dc99
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-07-05-a
* Thu Jul 05 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.28.20180704gitf56a941
- Removed explicit requirement on libatomic and libbsd, modifed files section
of the runtime package so it can own the directory
* Thu Jul 05 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.27.20180704gitf56a941
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-07-04-a
* Tue Jul 03 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.26.20180703git107e307
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-07-03-a, added a
filter for excluding lldb libraries from public view, and broke out the
runtime libraries into their own -runtime package.
* Mon Jul 02 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.25.20180702gitc2e1567
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-07-02-a
* Mon Jul 02 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.24.20180701git6079032
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-07-01-a, removed unnecessary
lldb headers
* Sat Jun 30 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.23.20180630gitb3408e8
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-06-30-a
* Fri Jun 29 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.22.20180629gitdab0d8e
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-06-29-a, removed unnecessary
files and links
* Fri Jun 29 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.21.20180628git9f8f2a1
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-06-28-a
* Thu Jun 28 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.20.20180626gitbe3b9a7
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-06-26-a
* Wed Jun 13 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.19.20180612gitbb9532c
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-06-12-a and removed
gcc-c++ as a build requirement
* Tue Jun 12 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.18.20180611gitd99cd32
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-06-10-a and removed
separate ninja build (will now use the repo-based one)
* Mon Jun 11 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.17.20180610git7a35ad0
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-06-10-a
* Fri Jun 08 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.16.20180607git78e9497
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-06-07-a
* Thu Jun 07 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.15.20180606git4e2064e
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-06-06-a
* Tue Jun 05 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.14.20180604git9e274fc
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-06-04-a
* Sun Jun 03 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.13.20180602gitadad0f5
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-06-02-a
* Wed May 30 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.12.20180529git4160301
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-29-a
* Wed May 23 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.11.20180522git58f7399
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-22-a
* Mon May 21 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.10.20180520gitbb77484
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-20-a and added
patch for removing sys/ustat.h references
* Tue May 15 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.9.20180514gitf58f528
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-14-a
* Wed May 09 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.8.20180508git0e6d867
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-08-a
* Wed May 02 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.7.20180502gitb08fb12
- Updated to swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-02-a
* Mon Apr 23 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.6.20180422git5030d38
- Updated to swift-DEVELOPMENT-SNAPSHOT-2018-04-22-a
* Thu Apr 19 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.5.20180418gitac06163
- Updated to swift-DEVELOPMENT-SNAPSHOT-2018-04-18-a
* Mon Apr 16 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.4.20180415git22530b9
- Updated to swift-DEVELOPMENT-SNAPSHOT-2018-04-15-a
* Thu Apr 12 2018 Ron Olson <tachoknight@gmail.com> 4.2-0.3.20180411git537a846
- Updated to swift-DEVELOPMENT-SNAPSHOT-2018-04-11-a
* Wed Feb 28 2018 Ron Olson <tachoknight@gmail.com> 4.1-0.2.20180227git5f2f440
- Updated to swift-DEVELOPMENT-SNAPSHOT-2018-02-27-a
* Wed Feb 14 2018 Ron Olson <tachoknight@gmail.com> 4.1-0.1.20180214git5a1a34b
- Initial package for Fedora