Created
September 4, 2018 08:59
-
-
Save segabor/cd08eae2ce8717a1e4f8476687d98221 to your computer and use it in GitHub Desktop.
Build Swift 4.2-dev on Arch Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Build Swift on Arch Linux | |
# Original post I followed https://akrabat.com/compiling-swift-on-linux/. | |
# [1] Checking out repo | |
mkdir swift-dev | |
cd swift-dev/ | |
git clone [email protected]:apple/swift.git | |
cd swift | |
git checkout -b 4.2-dev origin/swift-4.2-branch | |
cd .. | |
# [2] Update the whole source stuff | |
./swift/utils/update-checkout --clone-with-ssh | |
# [3] Fix python usage | |
# Use python2 where appropriate | |
srcdir="." | |
find "$srcdir" -type f -print0 | \ | |
xargs -0 sed -i 's|/usr/bin/env python$|&2|;s|/usr/bin/python$|&2|' | |
find "$srcdir/lldb" -name Makefile -print0 | \ | |
xargs -0 sed -i 's|python-config|python2-config|g' | |
sed -i '/^cmake_minimum_required/a set(Python_ADDITIONAL_VERSIONS 2.7)' \ | |
"$srcdir/swift/CMakeLists.txt" | |
sed -i '/^cmake_minimum_required/a set(Python_ADDITIONAL_VERSIONS 2.7)' \ | |
"$srcdir/lldb/CMakeLists.txt" | |
sed -i 's/\<python\>/&2/' \ | |
"$srcdir/swift/utils/build-script-impl" \ | |
"$srcdir/swift/test/sil-passpipeline-dump/basic.test-sh" | |
# [4] Build the whole stuff | |
./swift/utils/build-script --preset=buildbot_linux,no_test installable_package=~/swift.tar.gz install_destdir=~/.swiftenv/versions/4.2-dev | |
# [5] Deploy Swift package under Swiftenv | |
cd ~/.swiftenv/versions | |
mkdir 4.2-dev | |
cd 4.2-dev | |
tar xvzf ~/swift.tar.gz |
For 4.2 release use this command
git fetch --tags
git checkout -b swift-4.2-RELEASE tags/swift-4.2-RELEASE
To avoid python search replaces you can make a python2.7 virtualenv and then reference the correct FindPythonLibs references for the make. To add '--extra-cmake-options=-DPYTHON_EXECUTABLE=/usr/bin/python2.7 -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/libpython2.7.so -DPYTHON_RELEASE_LIB=/usr/lib/libpython2.7.so'
you cannot use a preset but can extract the current preset using the --expand-build-script-invocation
toggle and then adding the cmake options ie:
virtualenv -p python2.7 swiftpy
. swiftpy/bin/activate
swift/utils/build-script --expand-build-script-invocation --preset=buildbot_linux,no_test installable_package=~/swift-4.2.tar.gz install_destdir=~/.swiftenv/versions/4.2
swift/utils/build-script: note: using preset "buildbot_linux,no_test", which expands to
swift/utils/build-script --assertions --no-swift-stdlib-assertions --swift-enable-ast-verifier=0 --llbuild --swiftpm --xctest --build-ninja --install-swift --install-lldb --install-llbuild --install-swiftpm --install-xctest --install-prefix=/usr '--swift-install-components=autolink-driver;compiler;clang-builtin-headers;stdlib;swift-remote-mirror;sdk-overlay;license;sourcekit-inproc' '--llvm-install-components=llvm-cov;llvm-profdata;IndexStore' --build-swift-static-stdlib --build-swift-static-sdk-overlay --build-swift-stdlib-unittest-extra --test-installable-package --install-destdir=/home/jlawson/.swiftenv/versions/4.2 --installable-package=/home/jlawson/swift-4.2.tar.gz --build-subdir=buildbot_linux --lldb --release --test --validation-test --long-test --stress-test --test-optimized --foundation --libdispatch --lit-args=-v --lldb-test-swift-only --install-foundation --install-libdispatch --reconfigure --skip-test-cmark --skip-test-lldb --skip-test-swift --skip-test-llbuild --skip-test-swiftpm --skip-test-xctest --skip-test-foundation --skip-test-libdispatch --skip-test-playgroundsupport --skip-test-libicu
swift/utils/build-script --assertions --no-swift-stdlib-assertions --swift-enable-ast-verifier=0 --llbuild --swiftpm --xctest --build-ninja --install-swift --install-lldb --install-llbuild --install-swiftpm --install-xctest --install-prefix=/usr '--swift-install-components=autolink-driver;compiler;clang-builtin-headers;stdlib;swift-remote-mirror;sdk-overlay;license;sourcekit-inproc' '--llvm-install-components=llvm-cov;llvm-profdata;IndexStore' --build-swift-static-stdlib --build-swift-static-sdk-overlay --build-swift-stdlib-unittest-extra --test-installable-package --install-destdir=/home/jlawson/.swiftenv/versions/4.2 --installable-package=/home/jlawson/swift-4.2.tar.gz --build-subdir=buildbot_linux --lldb --release --test --validation-test --long-test --stress-test --test-optimized --foundation --libdispatch --lit-args=-v --lldb-test-swift-only --install-foundation --install-libdispatch --reconfigure --skip-test-cmark --skip-test-lldb --skip-test-swift --skip-test-llbuild --skip-test-swiftpm --skip-test-xctest --skip-test-foundation --skip-test-libdispatch --skip-test-playgroundsupport --skip-test-libicu \
\
'--extra-cmake-options=-DPYTHON_EXECUTABLE=/usr/bin/python2.7 -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/libpython2.7.so -DPYTHON_RELEASE_LIB=/usr/lib/libpython2.7.so'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script requires python2 !!