Skip to content

Build SwiftSyntax and the stress tester using a unified build #28005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions utils/build-script
Original file line number Diff line number Diff line change
Expand Up @@ -808,12 +808,17 @@ class BuildScriptInvocation(object):
continue
product_source = product_class.product_source_name()
product_name = product_class.product_name()
if product_class.is_swiftpm_unified_build_product():
build_dir = self.workspace.swiftpm_unified_build_dir(
host_target)
else:
build_dir = self.workspace.build_dir(
host_target, product_name)
product = product_class(
args=self.args,
toolchain=self.toolchain,
source_dir=self.workspace.source_dir(product_source),
build_dir=self.workspace.build_dir(
host_target, product_name))
build_dir=build_dir)
if product.should_build(host_target):
print("--- Building %s ---" % product_name)
product.build(host_target)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/xcuserdata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# swift_build_support/multiroot_data_file.py - Unified build -----*- python -*-
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2014 - 2019 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
#
# ----------------------------------------------------------------------------

import os


def path():
"""product_source_name() -> str

The path to the Xcode workspace to use for a unified build of multiple
SwiftPM projects.
"""
return os.path.join(os.path.dirname(__file__), '..',
'SwiftPM-Unified-Build.xcworkspace')
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ def is_build_script_impl_product(cls):
"""
return True

@classmethod
def is_swiftpm_unified_build_product(cls):
"""is_swiftpm_unified_build_product -> bool

Whether this product should be build in the unified build of SwiftPM
products.
"""
return False

def should_build(self, host_target):
"""should_build() -> Bool

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# swift_build_support/products/skstresstester.py -----------------*- python -*-
#
# This source file is part of the Swift.org open source project
Expand All @@ -14,6 +15,7 @@
import platform

from . import product
from .. import multiroot_data_file
from .. import shell


Expand All @@ -26,6 +28,14 @@ def product_source_name(cls):
"""
return "swift-stress-tester"

@classmethod
def is_build_script_impl_product(cls):
return False

@classmethod
def is_swiftpm_unified_build_product(cls):
return True

def package_name(self):
return 'SourceKitStressTester'

Expand All @@ -42,17 +52,18 @@ def run_build_script_helper(self, action, additional_params=[]):
'--toolchain', self.install_toolchain_path(),
'--config', configuration,
'--build-dir', self.build_dir,
'--multiroot-data-file', multiroot_data_file.path(),
# There might have been a Package.resolved created by other builds
# or by the package being opened using Xcode. Discard that and
# reset the dependencies to be local.
'--update'
]
if self.args.verbose_build:
helper_cmd.append('--verbose')
helper_cmd.extend(additional_params)

shell.call(helper_cmd)

@classmethod
def is_build_script_impl_product(cls):
return False

def should_build(self, host_target):
return True

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
#
# ----------------------------------------------------------------------------

import os

from . import skstresstester
from .. import shell


class SwiftEvolve(skstresstester.SKStressTester):
Expand All @@ -22,9 +25,39 @@ def product_source_name(cls):
"""
return "swift-stress-tester"

@classmethod
def is_swiftpm_unified_build_product(cls):
return False

def package_name(self):
return 'SwiftEvolve'

# Copy of the build-script-helper invocation without the multiroot data
# file. Remove again once SwiftEvolve also builds in the unified build.
def run_build_script_helper(self, action, additional_params=[]):
script_path = os.path.join(
self.source_dir, 'build-script-helper.py')

configuration = 'release' if self.is_release() else 'debug'

helper_cmd = [
script_path,
action,
'--package-dir', self.package_name(),
'--toolchain', self.install_toolchain_path(),
'--config', configuration,
'--build-dir', self.build_dir,
# There might have been a Package.resolved created by other builds
# or by the package being opened using Xcode. Discard that and
# reset the dependencies to be local.
'--update'
]
if self.args.verbose_build:
helper_cmd.append('--verbose')
helper_cmd.extend(additional_params)

shell.call(helper_cmd)

# Inherit the entire build configuration from the SourceKit stress tester

def should_build(self, host_target):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import os

from . import product
from .. import multiroot_data_file
from .. import shell
from .. import targets

Expand All @@ -26,6 +27,14 @@ def product_source_name(cls):
"""
return "swift-syntax"

@classmethod
def is_build_script_impl_product(cls):
return False

@classmethod
def is_swiftpm_unified_build_product(cls):
return True

def run_swiftsyntax_build_script(self, target, additional_params=[]):
llvm_build_dir = os.path.join(self.build_dir, '..', 'llvm-' + target)
llvm_build_dir = os.path.realpath(llvm_build_dir)
Expand All @@ -35,6 +44,7 @@ def run_swiftsyntax_build_script(self, target, additional_params=[]):
build_cmd = [
script_path,
'--build-dir', self.build_dir,
'--multiroot-data-file', multiroot_data_file.path(),
'--toolchain', self.install_toolchain_path(),
'--filecheck-exec', os.path.join(llvm_build_dir, 'bin',
'FileCheck'),
Expand All @@ -53,10 +63,6 @@ def run_swiftsyntax_build_script(self, target, additional_params=[]):

shell.call(build_cmd)

@classmethod
def is_build_script_impl_product(cls):
return False

def should_build(self, host_target):
return True

Expand Down
9 changes: 9 additions & 0 deletions utils/swift_build_support/swift_build_support/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ def build_dir(self, deployment_target, product):
return os.path.join(self.build_root,
'%s-%s' % (product, deployment_target))

def swiftpm_unified_build_dir(self, deployment_target):
""" swiftpm_unified_build_dir() -> str

Build directory that all SwiftPM unified build products share.
"""
return os.path.join(self.build_root,
'unified-swiftpm-build-%s' %
deployment_target)


def compute_build_subdir(args):
# Create a name for the build directory.
Expand Down