def get_swiftpm_options()

in Utilities/build-script-helper.py [0:0]


def get_swiftpm_options(args):
  swiftpm_args = [
    '--package-path', args.package_path,
    '--build-path', args.build_path,
    '--configuration', args.configuration,
  ]

  if args.verbose:
    swiftpm_args += ['--verbose']

  if args.sanitize:
    for san in args.sanitize:
      swiftpm_args += ['--sanitize=%s' % san]

  if platform.system() == 'Darwin':
    swiftpm_args += [
      # Relative library rpath for swift; will only be used when /usr/lib/swift
      # is not available.
      '-Xlinker', '-rpath', '-Xlinker', '@executable_path/../lib/swift/macosx',
    ]
  else:
    swiftpm_args += [
      # Dispatch headers
      '-Xcxx', '-I', '-Xcxx',
      os.path.join(args.toolchain, 'lib', 'swift'),
      # For <Block.h>
      '-Xcxx', '-I', '-Xcxx',
      os.path.join(args.toolchain, 'lib', 'swift', 'Block'),
    ]

  if 'ANDROID_DATA' in os.environ or (args.cross_compile_host and re.match(
    'android-', args.cross_compile_host)):
    swiftpm_args += [
      '-Xlinker', '-rpath', '-Xlinker', '$ORIGIN/../lib/swift/android',
      # SwiftPM will otherwise try to compile against GNU strerror_r on
      # Android and fail.
      '-Xswiftc', '-Xcc', '-Xswiftc', '-U_GNU_SOURCE',
    ]
  elif platform.system() == 'Linux':
    # Library rpath for swift, dispatch, Foundation, etc. when installing
    swiftpm_args += [
      '-Xlinker', '-rpath', '-Xlinker', '$ORIGIN/../lib/swift/linux',
    ]

  if args.cross_compile_host:
    swiftpm_args += ['--destination', args.cross_compile_config]

  return swiftpm_args