Skip to content

Commit e26b216

Browse files
authored
Merge pull request swiftlang#29366 from compnerd/optional-pythonkit-support
build: add support for optionally building PythonKit
2 parents 23e2b70 + cad0c7a commit e26b216

File tree

7 files changed

+88
-2
lines changed

7 files changed

+88
-2
lines changed

utils/build-script

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class BuildScriptInvocation(object):
124124

125125
targets_needing_toolchain = [
126126
'build_indexstoredb',
127+
'build_pythonkit',
127128
'build_sourcekitlsp',
128129
'build_toolchainbenchmarks',
129130
'tsan_libdispatch_test',
@@ -174,7 +175,8 @@ class BuildScriptInvocation(object):
174175
# Infer if ninja is required
175176
ninja_required = (
176177
args.cmake_generator == 'Ninja' or args.build_foundation or
177-
args.build_sourcekitlsp or args.build_indexstoredb)
178+
args.build_pythonkit or args.build_sourcekitlsp or
179+
args.build_indexstoredb)
178180
if ninja_required and toolchain.ninja is None:
179181
args.build_ninja = True
180182

@@ -737,6 +739,8 @@ class BuildScriptInvocation(object):
737739
product_classes.append(products.SwiftEvolve)
738740
if self.args.build_indexstoredb:
739741
product_classes.append(products.IndexStoreDB)
742+
if self.args.build_pythonkit:
743+
product_classes.append(products.PythonKit)
740744
if self.args.build_sourcekitlsp:
741745
product_classes.append(products.SourceKitLSP)
742746
if self.args.build_toolchainbenchmarks:

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def _apply_default_arguments(args):
152152
args.build_libdispatch = False
153153
args.build_libicu = False
154154
args.build_playgroundsupport = False
155+
args.build_pythonkit = False
155156

156157
# --skip-{ios,tvos,watchos} or --skip-build-{ios,tvos,watchos} are
157158
# merely shorthands for --skip-build-{**os}-{device,simulator}
@@ -595,6 +596,8 @@ def create_argument_parser():
595596
toggle_true('swiftsyntax_verify_generated_files'),
596597
help='set to verify that the generated files in the source tree '
597598
'match the ones that would be generated from current master')
599+
option(['--install-pythonkit'], toggle_true('install_pythonkit'),
600+
help='install PythonKit')
598601
option(['--install-sourcekit-lsp'], toggle_true('install_sourcekitlsp'),
599602
help='install SourceKitLSP')
600603
option(['--install-skstresstester'], toggle_true('install_skstresstester'),
@@ -621,6 +624,9 @@ def create_argument_parser():
621624
option('--playgroundsupport', store_true('build_playgroundsupport'),
622625
help='build PlaygroundSupport')
623626

627+
option('--pythonkit', store_true('build_pythonkit'),
628+
help='build PythonKit')
629+
624630
option('--build-ninja', toggle_true,
625631
help='build the Ninja tool')
626632

@@ -870,6 +876,9 @@ def create_argument_parser():
870876
option('--skip-test-cygwin', toggle_false('test_cygwin'),
871877
help='skip testing Swift stdlibs for Cygwin')
872878

879+
option('--test-pythonkit', toggle_true('test_pythonkit'),
880+
help='skip testing PythonKit')
881+
873882
# -------------------------------------------------------------------------
874883
in_group('Run build')
875884

utils/build_swift/tests/expected_options.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
'build_ninja': False,
7777
'build_osx': True,
7878
'build_playgroundsupport': False,
79+
'build_pythonkit': False,
7980
'build_runtime_with_host_compiler': False,
8081
'build_stdlib_deployment_targets': ['all'],
8182
'build_subdir': None,
@@ -94,6 +95,7 @@
9495
'install_swiftpm': False,
9596
'install_swiftsyntax': False,
9697
'swiftsyntax_verify_generated_files': False,
98+
'install_pythonkit': False,
9799
'install_sourcekitlsp': False,
98100
'install_skstresstester': False,
99101
'install_swiftevolve': False,
@@ -207,6 +209,7 @@
207209
'test_optimized': None,
208210
'test_osx': False,
209211
'test_paths': [],
212+
'test_pythonkit': False,
210213
'test_tvos': False,
211214
'test_tvos_host': False,
212215
'test_tvos_simulator': False,
@@ -446,6 +449,9 @@ class BuildScriptImplOption(_BaseOption):
446449
SetTrueOption('--maccatalyst', dest='maccatalyst'),
447450
SetTrueOption('--maccatalyst-ios-tests', dest='maccatalyst_ios_tests'),
448451
SetTrueOption('--playgroundsupport', dest='build_playgroundsupport'),
452+
SetTrueOption('--pythonkit', dest='build_pythonkit'),
453+
SetTrueOption('--install-pythonkit', dest='install_pythonkit'),
454+
SetTrueOption('--test-pythonkit', dest='test_pythonkit'),
449455
SetTrueOption('--skip-build'),
450456
SetTrueOption('--swiftpm', dest='build_swiftpm'),
451457
SetTrueOption('--swiftsyntax', dest='build_swiftsyntax'),

utils/swift_build_support/swift_build_support/products/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from .lldb import LLDB
2222
from .llvm import LLVM
2323
from .ninja import Ninja
24+
from .pythonkit import PythonKit
2425
from .skstresstester import SKStressTester
2526
from .sourcekitlsp import SourceKitLSP
2627
from .swift import Swift
@@ -41,6 +42,7 @@
4142
'LLDB',
4243
'LLVM',
4344
'Ninja',
45+
'PythonKit',
4446
'Swift',
4547
'SwiftPM',
4648
'XCTest',
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# swift_build_support/products/pythonkit.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+
from .. import shell
15+
16+
17+
class PythonKit(product.Product):
18+
@classmethod
19+
def product_source_name(cls):
20+
return "PythonKit"
21+
22+
@classmethod
23+
def is_build_script_impl_product(cls):
24+
return False
25+
26+
def should_build(self, host_target):
27+
return True
28+
29+
def build(self, host_target):
30+
shell.call([
31+
self.toolchain.cmake,
32+
'-G', 'Ninja',
33+
'-D', 'BUILD_SHARED_LIBS=YES',
34+
'-D', 'CMAKE_INSTALL_PREFIX={}/usr'.format(
35+
self.args.install_destdir),
36+
'-D', 'CMAKE_MAKE_PROGRAM={}'.format(self.toolchain.ninja),
37+
'-D', 'CMAKE_Swift_COMPILER={}'.format(self.toolchain.swiftc),
38+
'-B', self.build_dir,
39+
'-S', self.source_dir,
40+
])
41+
shell.call([
42+
self.toolchain.cmake,
43+
'--build', self.build_dir,
44+
])
45+
46+
def should_test(self, host_target):
47+
return self.args.test_pythonkit
48+
49+
def test(self, host_target):
50+
pass
51+
52+
def should_install(self, host_target):
53+
return self.args.install_pythonkit
54+
55+
def install(self, host_target):
56+
shell.call([
57+
self.toolchain.cmake,
58+
'--build', self.build_dir,
59+
'--target', 'install',
60+
])

utils/swift_build_support/swift_build_support/toolchain.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def _getter(self):
6262
_register("llvm_cov", "llvm-cov")
6363
_register("lipo", "lipo")
6464
_register("libtool", "libtool")
65+
_register("swiftc", "swiftc")
6566

6667

6768
class Darwin(Toolchain):

utils/update_checkout/update-checkout-config.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
"remote": { "id": "KitWare/CMake" },
3737
"platforms": [ "Linux" ]
3838
},
39+
"pythonkit": {
40+
"remote": { "id": "pvieito/PythonKit" }
41+
},
3942
"indexstore-db": {
4043
"remote": { "id": "apple/indexstore-db" } },
4144
"sourcekit-lsp": {
@@ -68,7 +71,8 @@
6871
"cmake": "v3.15.1",
6972
"indexstore-db": "master",
7073
"sourcekit-lsp": "master",
71-
"swift-format": "master"
74+
"swift-format": "master",
75+
"pythonkit": "master"
7276
}
7377
},
7478
"next" : {

0 commit comments

Comments
 (0)