   compilerCommand.add("-filelist", swiftFileListPath.get().toString());
    } else {
      for (SourcePath sourcePath : srcs) {
        compilerCommand.add(resolver.getRelativePath(sourcePath).toString());
      }
    }

    ProjectFilesystem projectFilesystem = getProjectFilesystem();
    return new SwiftCompileStep(
        projectFilesystem.getRootPath(), ImmutableMap.of(), compilerCommand.build());
  }

  @VisibleForTesting
  static String validVersionString(String originalVersionString) {
    // Swiftc officially only accepts the major version, but it respects the minor
    // version if the version is 4.2.
    String[] versions = originalVersionString.split("\\.");
    if (versions.length > 2) {
      versions = Arrays.copyOfRange(versions, 0, 2);
    }
    if (versions.length == 2) {
      Integer majorVersion = Integer.parseInt(versions[0]);
      Integer minorVersion = Integer.parseInt(versions[1]);

      if (majorVersion > 4 || (majorVersion >= 4 && minorVersion >= 2)) {
        return String.format("%d.%d", majorVersion, minorVersion);
      } else {
        return originalVersionString.length() > 1
            ? originalVersionString.substring(0, 1)
            : originalVersionString;
      }
    } else {
      return originalVersionString.length() > 1
          ? originalVersionString.substring(0, 1)
          : originalVersionString;
    }
  }

  private SwiftCompileStep makeModulewrapStep(SourcePathResolverAdapter resolver) {
    ImmutableList.Builder<String> compilerCommand = ImmutableList.builder();
    ImmutableList<String> commandPrefix = swiftCompiler.getCommandPrefix(resolver);

    // The swift compiler path will be the first element of the command prefix
    compilerCommand.add(commandPrefix.get(0));
    compilerCommand.add("-modulewrap", modulePath.toString(), "-o", moduleObjectPath.toString());
    compilerCommand.add("-target", swiftTarget.getTriple());

    ProjectFilesystem projectFilesystem = getProjectFilesystem();
    return new SwiftCompileStep(
        projectFilesystem.getRoot