summaryrefslogtreecommitdiffstats
path: root/swift-lang.spec
blob: caa41557bd0784decda0e117597cec508bdb7bdd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
%global debug_package %{nil}
%global swifttag 4.2-DEVELOPMENT-SNAPSHOT-2018-07-01-a
%global swiftgithash 6079032
%global swiftgitdate 20180701
%global swiftbuild swift-source
Name:           swift-lang
Version:        4.2
Release:        0.24.%{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


Patch0:         %{name}-%{version}-change-lldb-location.patch
Patch1:		compiler-rt-no-ustat.patch
Patch2:		no-ninja-build.patch
Patch3:		time-struct-redefined.patch


BuildRequires:  which
BuildRequires:  clang
BuildRequires:  cmake
BuildRequires:  swig
BuildRequires:  pkgconfig
BuildRequires:  perl-podlators
BuildRequires:  rsync
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:       libatomic
Requires:       libbsd

ExcludeArch:    s390x i686 armv7hl ppc64le aarch64 ppc64 

%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. 


%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

# Fixes an error in compiler-rt where the timespec struct is redefined
%patch3 -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

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-lldb/
/usr/lib/swift/
/usr/lib/swift_static/
%{_libexecdir}/swift-lldb/
%{_sysconfdir}/ld.so.conf.d/swift-lang.conf

%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%changelog
* 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