Skip to content

Commit c221dd6

Browse files
benlangmuirhyp
authored andcommitted
[libcxx] Simplify the conditions for building libcxx
Now we build libcxx if and only if --libcxx is passed, like with other optional products. This loses the intended "build if sources are checked out" behaviour, but behaves more predictably. (cherry picked from commit e180006) Revert "Revert "[build-script] Add Product for libc++"" add libcxx-cmake-options
1 parent 76e66e9 commit c221dd6

File tree

8 files changed

+39
-6
lines changed

8 files changed

+39
-6
lines changed

utils/build-presets.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ llbuild
717717
swiftpm
718718
xctest
719719
libicu
720+
libcxx
720721

721722
dash-dash
722723

@@ -730,6 +731,7 @@ install-libicu
730731
install-prefix=/usr
731732
swift-install-components=autolink-driver;compiler;clang-resource-dir-symlink;stdlib;swift-remote-mirror;sdk-overlay;license;sourcekit-inproc
732733
llvm-install-components=llvm-cov;llvm-profdata;IndexStore;clang;clang-headers;compiler-rt
734+
install-libcxx
733735
build-swift-static-stdlib
734736
build-swift-static-sdk-overlay
735737
build-swift-stdlib-unittest-extra

utils/build-script

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,8 @@ class BuildScriptInvocation(object):
586586
impl_args += ["--skip-build-lldb"]
587587
if not args.build_llbuild:
588588
impl_args += ["--skip-build-llbuild"]
589+
if not args.build_libcxx:
590+
impl_args += ["--skip-build-libcxx"]
589591
if not args.build_libdispatch:
590592
impl_args += ["--skip-build-libdispatch"]
591593
if not args.build_libicu:
@@ -823,6 +825,8 @@ class BuildScriptInvocation(object):
823825
product_classes = []
824826
product_classes.append(products.CMark)
825827
product_classes.append(products.LLVM)
828+
if self.args.build_libcxx:
829+
product_classes.append(products.LibCXX)
826830
if self.args.build_libicu:
827831
product_classes.append(products.LibICU)
828832
product_classes.append(products.Swift)

utils/build-script-impl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ KNOWN_SETTINGS=(
123123
skip-build-android "" "set to skip building Swift stdlibs for Android"
124124
skip-build-lldb "" "set to skip building LLDB"
125125
skip-build-llbuild "" "set to skip building llbuild"
126+
skip-build-libcxx "" "set to skip building libcxx"
126127
skip-build-swiftpm "" "set to skip building swiftpm"
127128
skip-build-swiftsyntax "" "set to skip building swiftSyntax"
128129
skip-build-skstresstester "" "set to skip building the SourceKit stress tester"
@@ -199,6 +200,7 @@ KNOWN_SETTINGS=(
199200
install-skstresstester "" "whether to install the SourceKit stress tester"
200201
install-xctest "" "whether to install xctest"
201202
install-foundation "" "whether to install foundation"
203+
install-libcxx "" "whether to install libc++"
202204
install-libdispatch "" "whether to install libdispatch"
203205
install-libicu "" "whether to install libicu"
204206
install-playgroundsupport "" "whether to install PlaygroundSupport"
@@ -255,6 +257,7 @@ KNOWN_SETTINGS=(
255257
swiftpm-cmake-options "" "CMake options used for all swiftpm targets"
256258
xctest-cmake-options "" "CMake options used for all xctest targets"
257259
playgroundsupport-cmake-options "" "CMake options used for all playgroundsupport targets"
260+
libcxx-cmake-options "" "CMake options used for all libcxx targets"
258261
# TODO: Remove this some time later.
259262
user-config-args "" "**Renamed to --extra-cmake-options**: User-supplied arguments to cmake when used to do configuration."
260263
only-execute "all" "Only execute the named action (see implementation)"
@@ -1180,6 +1183,7 @@ XCTEST_SOURCE_DIR="${WORKSPACE}/swift-corelibs-xctest"
11801183
FOUNDATION_SOURCE_DIR="${WORKSPACE}/swift-corelibs-foundation"
11811184
LIBDISPATCH_SOURCE_DIR="${WORKSPACE}/swift-corelibs-libdispatch"
11821185
LIBICU_SOURCE_DIR="${WORKSPACE}/icu"
1186+
LIBCXX_SOURCE_DIR="${WORKSPACE}/libcxx"
11831187
PLAYGROUNDSUPPORT_SOURCE_DIR="${WORKSPACE}/swift-xcode-playground-support"
11841188

11851189
if [[ ! "${SKIP_BUILD_PLAYGROUNDSUPPORT}" && ! -d ${PLAYGROUNDSUPPORT_SOURCE_DIR} ]]; then
@@ -1214,12 +1218,6 @@ if [ -e "${WORKSPACE}/compiler-rt" ] ; then
12141218
fi
12151219
fi
12161220

1217-
# Build libcxx, unless it doesn't exist.
1218-
LIBCXX_SOURCE_DIR="${WORKSPACE}/libcxx"
1219-
if [[ ! -e "${LIBCXX_SOURCE_DIR}" ]] ; then
1220-
SKIP_BUILD_LIBCXX=1
1221-
fi
1222-
12231221
PRODUCTS=(cmark llvm)
12241222
if [[ ! "${SKIP_BUILD_LIBCXX}" ]] ; then
12251223
PRODUCTS=("${PRODUCTS[@]}" libcxx)
@@ -3446,6 +3444,9 @@ for host in "${ALL_HOSTS[@]}"; do
34463444
INSTALL_TARGETS=install-$(echo ${LLVM_INSTALL_COMPONENTS} | sed -E 's/;/ install-/g')
34473445
;;
34483446
libcxx)
3447+
if [[ -z "${INSTALL_LIBCXX}" ]] ; then
3448+
continue
3449+
fi
34493450
INSTALL_TARGETS=install-cxx-headers
34503451
;;
34513452
swift)

utils/build_swift/driver_arguments.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ def _apply_default_arguments(args):
142142
args.build_external_benchmarks = False
143143
args.build_lldb = False
144144
args.build_llbuild = False
145+
args.build_libcxx = False
145146
args.build_swiftpm = False
146147
args.build_xctest = False
147148
args.build_foundation = False
@@ -512,6 +513,9 @@ def create_argument_parser():
512513
option(['-b', '--llbuild'], store_true('build_llbuild'),
513514
help='build llbuild')
514515

516+
option(['--libcxx'], store_true('build_libcxx'),
517+
help='build libcxx')
518+
515519
option(['-p', '--swiftpm'], store_true('build_swiftpm'),
516520
help='build swiftpm')
517521

utils/build_swift/tests/expected_options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
'build_linux': True,
6868
'build_llbuild': False,
6969
'build_lldb': False,
70+
'build_libcxx': False,
7071
'build_ninja': False,
7172
'build_osx': True,
7273
'build_playgroundsupport': False,
@@ -393,6 +394,7 @@ class IgnoreOption(_BaseOption):
393394
SetTrueOption('--ios'),
394395
SetTrueOption('--llbuild', dest='build_llbuild'),
395396
SetTrueOption('--lldb', dest='build_lldb'),
397+
SetTrueOption('--libcxx', dest='build_libcxx'),
396398
SetTrueOption('--playgroundsupport', dest='build_playgroundsupport'),
397399
SetTrueOption('--skip-build'),
398400
SetTrueOption('--swiftpm', dest='build_swiftpm'),

utils/build_swift/tests/test_driver_arguments.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ def test_implied_defaults_skip_build(self):
590590
self.assertFalse(namespace.build_libicu)
591591
self.assertFalse(namespace.build_lldb)
592592
self.assertFalse(namespace.build_llbuild)
593+
self.assertFalse(namespace.build_libcxx)
593594
self.assertFalse(namespace.build_playgroundsupport)
594595
self.assertFalse(namespace.build_swiftpm)
595596
self.assertFalse(namespace.build_xctest)

utils/swift_build_support/swift_build_support/products/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from .cmark import CMark
1414
from .foundation import Foundation
15+
from .libcxx import LibCXX
1516
from .libdispatch import LibDispatch
1617
from .libicu import LibICU
1718
from .llbuild import LLBuild
@@ -26,6 +27,7 @@
2627
'CMark',
2728
'Ninja',
2829
'Foundation',
30+
'LibCXX',
2931
'LibDispatch',
3032
'LibICU',
3133
'LLBuild',
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# swift_build_support/products/libcxx.py -------------------------*- python -*-
2+
#
3+
# This source file is part of the Swift.org open source project
4+
#
5+
# Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
# Licensed under Apache License v2.0 with Runtime Library Exception
7+
#
8+
# See https://swift.org/LICENSE.txt for license information
9+
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
#
11+
# ----------------------------------------------------------------------------
12+
13+
from . import product
14+
15+
16+
class LibCXX(product.Product):
17+
pass

0 commit comments

Comments
 (0)