diff --git a/utils/build-script b/utils/build-script index 7271993e9d665..600f274809a11 100755 --- a/utils/build-script +++ b/utils/build-script @@ -138,6 +138,7 @@ class BuildScriptInvocation(object): targets_needing_toolchain = [ 'build_indexstoredb', + 'build_pythonkit', 'build_sourcekitlsp', 'build_toolchainbenchmarks', 'tsan_libdispatch_test', @@ -188,7 +189,8 @@ class BuildScriptInvocation(object): # Infer if ninja is required ninja_required = ( args.cmake_generator == 'Ninja' or args.build_foundation or - args.build_sourcekitlsp or args.build_indexstoredb) + args.build_pythonkit or args.build_sourcekitlsp or + args.build_indexstoredb) if ninja_required and toolchain.ninja is None: args.build_ninja = True @@ -770,6 +772,8 @@ class BuildScriptInvocation(object): product_classes.append(products.SwiftEvolve) if self.args.build_indexstoredb: product_classes.append(products.IndexStoreDB) + if self.args.build_pythonkit: + product_classes.append(products.PythonKit) if self.args.build_sourcekitlsp: product_classes.append(products.SourceKitLSP) if self.args.build_toolchainbenchmarks: diff --git a/utils/build_swift/build_swift/driver_arguments.py b/utils/build_swift/build_swift/driver_arguments.py index 47dcf1f8f5eed..3abbbf7ce530e 100644 --- a/utils/build_swift/build_swift/driver_arguments.py +++ b/utils/build_swift/build_swift/driver_arguments.py @@ -153,6 +153,7 @@ def _apply_default_arguments(args): args.build_libdispatch = False args.build_libicu = False args.build_playgroundsupport = False + args.build_pythonkit = False # --skip-{ios,tvos,watchos} or --skip-build-{ios,tvos,watchos} are # merely shorthands for --skip-build-{**os}-{device,simulator} @@ -611,6 +612,8 @@ def create_argument_parser(): toggle_true('swiftsyntax_verify_generated_files'), help='set to verify that the generated files in the source tree ' 'match the ones that would be generated from current master') + option(['--install-pythonkit'], toggle_true('install_pythonkit'), + help='install PythonKit') option(['--install-sourcekit-lsp'], toggle_true('install_sourcekitlsp'), help='install SourceKitLSP') option(['--install-skstresstester'], toggle_true('install_skstresstester'), @@ -637,6 +640,9 @@ def create_argument_parser(): option('--playgroundsupport', store_true('build_playgroundsupport'), help='build PlaygroundSupport') + option('--pythonkit', store_true('build_pythonkit'), + help='build PythonKit') + option('--build-ninja', toggle_true, help='build the Ninja tool') @@ -886,6 +892,9 @@ def create_argument_parser(): option('--skip-test-cygwin', toggle_false('test_cygwin'), help='skip testing Swift stdlibs for Cygwin') + option('--test-pythonkit', toggle_true('test_pythonkit'), + help='skip testing PythonKit') + # ------------------------------------------------------------------------- in_group('Run build') diff --git a/utils/build_swift/tests/expected_options.py b/utils/build_swift/tests/expected_options.py index f91a9c21a13da..38276cfe9c782 100644 --- a/utils/build_swift/tests/expected_options.py +++ b/utils/build_swift/tests/expected_options.py @@ -76,6 +76,7 @@ 'build_ninja': False, 'build_osx': True, 'build_playgroundsupport': False, + 'build_pythonkit': False, 'build_runtime_with_host_compiler': False, 'build_stdlib_deployment_targets': ['all'], 'build_subdir': None, @@ -94,6 +95,7 @@ 'install_swiftpm': False, 'install_swiftsyntax': False, 'swiftsyntax_verify_generated_files': False, + 'install_pythonkit': False, 'install_sourcekitlsp': False, 'install_skstresstester': False, 'install_swiftevolve': False, @@ -207,6 +209,7 @@ 'test_optimized': None, 'test_osx': False, 'test_paths': [], + 'test_pythonkit': False, 'test_tvos': False, 'test_tvos_host': False, 'test_tvos_simulator': False, @@ -446,6 +449,9 @@ class BuildScriptImplOption(_BaseOption): SetTrueOption('--maccatalyst', dest='maccatalyst'), SetTrueOption('--maccatalyst-ios-tests', dest='maccatalyst_ios_tests'), SetTrueOption('--playgroundsupport', dest='build_playgroundsupport'), + SetTrueOption('--pythonkit', dest='build_pythonkit'), + SetTrueOption('--install-pythonkit', dest='install_pythonkit'), + SetTrueOption('--test-pythonkit', dest='test_pythonkit'), SetTrueOption('--skip-build'), SetTrueOption('--swiftpm', dest='build_swiftpm'), SetTrueOption('--swiftsyntax', dest='build_swiftsyntax'), diff --git a/utils/swift_build_support/swift_build_support/products/__init__.py b/utils/swift_build_support/swift_build_support/products/__init__.py index 526ccb22959d3..3bc1e7d6ec857 100644 --- a/utils/swift_build_support/swift_build_support/products/__init__.py +++ b/utils/swift_build_support/swift_build_support/products/__init__.py @@ -21,6 +21,7 @@ from .lldb import LLDB from .llvm import LLVM from .ninja import Ninja +from .pythonkit import PythonKit from .skstresstester import SKStressTester from .sourcekitlsp import SourceKitLSP from .swift import Swift @@ -41,6 +42,7 @@ 'LLDB', 'LLVM', 'Ninja', + 'PythonKit', 'Swift', 'SwiftPM', 'XCTest', diff --git a/utils/swift_build_support/swift_build_support/products/pythonkit.py b/utils/swift_build_support/swift_build_support/products/pythonkit.py new file mode 100644 index 0000000000000..7b2d4667d8f11 --- /dev/null +++ b/utils/swift_build_support/swift_build_support/products/pythonkit.py @@ -0,0 +1,60 @@ +# swift_build_support/products/pythonkit.py ---------------------*- python -*- +# +# This source file is part of the Swift.org open source project +# +# Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors +# Licensed under Apache License v2.0 with Runtime Library Exception +# +# See https://swift.org/LICENSE.txt for license information +# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +# +# ---------------------------------------------------------------------------- + +from . import product +from .. import shell + + +class PythonKit(product.Product): + @classmethod + def product_source_name(cls): + return "PythonKit" + + @classmethod + def is_build_script_impl_product(cls): + return False + + def should_build(self, host_target): + return True + + def build(self, host_target): + shell.call([ + self.toolchain.cmake, + '-G', 'Ninja', + '-D', 'BUILD_SHARED_LIBS=YES', + '-D', 'CMAKE_INSTALL_PREFIX={}/usr'.format( + self.args.install_destdir), + '-D', 'CMAKE_MAKE_PROGRAM={}'.format(self.toolchain.ninja), + '-D', 'CMAKE_Swift_COMPILER={}'.format(self.toolchain.swiftc), + '-B', self.build_dir, + '-S', self.source_dir, + ]) + shell.call([ + self.toolchain.cmake, + '--build', self.build_dir, + ]) + + def should_test(self, host_target): + return self.args.test_pythonkit + + def test(self, host_target): + pass + + def should_install(self, host_target): + return self.args.install_pythonkit + + def install(self, host_target): + shell.call([ + self.toolchain.cmake, + '--build', self.build_dir, + '--target', 'install', + ]) diff --git a/utils/swift_build_support/swift_build_support/toolchain.py b/utils/swift_build_support/swift_build_support/toolchain.py index 8f63759ee352c..1395397a80332 100644 --- a/utils/swift_build_support/swift_build_support/toolchain.py +++ b/utils/swift_build_support/swift_build_support/toolchain.py @@ -62,6 +62,7 @@ def _getter(self): _register("llvm_cov", "llvm-cov") _register("lipo", "lipo") _register("libtool", "libtool") +_register("swiftc", "swiftc") class Darwin(Toolchain): diff --git a/utils/update_checkout/update-checkout-config.json b/utils/update_checkout/update-checkout-config.json index 9c10c92c79b34..c035636764d78 100644 --- a/utils/update_checkout/update-checkout-config.json +++ b/utils/update_checkout/update-checkout-config.json @@ -35,6 +35,9 @@ "remote": { "id": "KitWare/CMake" }, "platforms": [ "Linux" ] }, + "pythonkit": { + "remote": { "id": "pvieito/PythonKit" } + }, "indexstore-db": { "remote": { "id": "apple/indexstore-db" } }, "sourcekit-lsp": { @@ -90,7 +93,8 @@ "cmake": "v3.15.1", "indexstore-db": "master", "sourcekit-lsp": "master", - "swift-format": "master" + "swift-format": "master", + "pythonkit": "master" } }, "next" : {