in project_future.py [0:0]
def dispatch(root_path, repo, action, swiftc, swift_version,
sandbox_profile_xcodebuild, sandbox_profile_package,
added_swift_flags, added_xcodebuild_flags,
build_config, should_strip_resource_phases=False,
stdout=sys.stdout, stderr=sys.stderr,
incremental=False, time_reporter = None, override_swift_exec=None):
"""Call functions corresponding to actions."""
substitutions = action.copy()
substitutions.update(repo)
if added_swift_flags:
# Support added swift flags specific to the current repository and
# action by passing their fields as keyword arguments to format, e.g.
# so that {path} in '-index-store-path /tmp/index/{path}' is replaced
# with the value of repo's path field.
added_swift_flags = added_swift_flags.format(**substitutions)
if added_xcodebuild_flags:
added_xcodebuild_flags = \
shlex.split(added_xcodebuild_flags.format(**substitutions))
else:
added_xcodebuild_flags = []
if action['action'] == 'BuildSwiftPackage':
if not build_config:
build_config = action['configuration']
return build_swift_package(os.path.join(root_path, repo['path']),
swiftc, swift_version,
build_config,
sandbox_profile_package,
stdout=stdout, stderr=stderr,
added_swift_flags=added_swift_flags,
incremental=incremental,
override_swift_exec=override_swift_exec)
elif action['action'] == 'TestSwiftPackage':
return test_swift_package(os.path.join(root_path, repo['path']),
swiftc,
sandbox_profile_package,
stdout=stdout, stderr=stderr,
added_swift_flags=added_swift_flags,
incremental=incremental,
override_swift_exec=override_swift_exec)
elif re.match(r'^(Build|Test)Xcode(Workspace|Project)(Scheme|Target)$',
action['action']):
match = re.match(
r'^(Build|Test)Xcode(Workspace|Project)(Scheme|Target)$',
action['action']
)
initial_xcodebuild_flags = ['SWIFT_EXEC=%s' % (override_swift_exec or swiftc),
'-IDEPackageSupportDisableManifestSandbox=YES']
if build_config == 'debug':
initial_xcodebuild_flags += ['-configuration', 'Debug']
elif build_config == 'release':
initial_xcodebuild_flags += ['-configuration', 'Release']
elif 'configuration' in action:
initial_xcodebuild_flags += ['-configuration',
action['configuration']]
build_env = {}
if 'environment' in action:
build_env = action['environment']
pretargets = []
if 'pretargets' in action:
pretargets = action['pretargets']
other_swift_flags = []
if swift_version:
if '.' not in swift_version:
swift_version += '.0'
major, minor = swift_version.split('.', 1)
# Need to use float for minor version parsing
# because it's possible that it would be specified
# as e.g. `4.0.3`
if int(major) == 4 and float(minor) == 2.0:
other_swift_flags += ['-swift-version', swift_version]
initial_xcodebuild_flags += ['SWIFT_VERSION=%s' % swift_version]
else:
other_swift_flags += ['-swift-version', major]
initial_xcodebuild_flags += ['SWIFT_VERSION=%s' % major]
if added_swift_flags:
other_swift_flags.append(added_swift_flags)
if other_swift_flags:
other_swift_flags = ['$(OTHER_SWIFT_FLAGS)'] + other_swift_flags
initial_xcodebuild_flags += ['OTHER_SWIFT_FLAGS=%s' % ' '.join(other_swift_flags)]
is_workspace = match.group(2).lower() == 'workspace'
project_path = os.path.join(root_path, repo['path'],
action[match.group(2).lower()])
has_scheme = match.group(3).lower() == 'scheme'
clean_build = True
if 'clean_build' in action:
clean_build = action['clean_build']
xcode_target = \
XcodeTarget(swiftc,
project_path,
action[match.group(3).lower()],
action['destination'],
pretargets,
build_env,
initial_xcodebuild_flags + added_xcodebuild_flags,
is_workspace,
has_scheme,
clean_build)
if should_strip_resource_phases:
strip_resource_phases(os.path.join(root_path, repo['path']),
stdout=stdout, stderr=stderr)
if match.group(1) == 'Build':
return xcode_target.build(sandbox_profile_xcodebuild,
stdout=stdout, stderr=stderr,
incremental=incremental,
time_reporter=time_reporter)
else:
return xcode_target.test(sandbox_profile_xcodebuild,
stdout=stdout, stderr=stderr,
incremental=incremental)
else:
raise common.Unimplemented("Unknown action: %s" % action['action'])