Skip to content

Commit

Permalink
Remove output script files
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlokhorst committed Sep 30, 2021
1 parent 97ec699 commit 57761d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 26 deletions.
22 changes: 0 additions & 22 deletions Sources/RswiftCore/EnvironmentValidation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ public func validateRswiftEnvironment(
outputURL: URL,
uiTestOutputURL: URL?,
sourceRootPath: String,
scriptOutputFiles: [String],
podsRoot: String?,
podsTargetSrcroot: String?,
commandLineArguments: [String]) -> [String]
{
var errors: [String] = []

// Check regular output file
var outputFileForError = outputURL.path
if outputURL.pathExtension != "swift" {

var error = "Output path must specify a file, it should not be a directory."
Expand All @@ -35,24 +33,13 @@ public func validateRswiftEnvironment(
.map { $0.contains(" ") ? "\"\($0)\"" : $0 }

error += "\nExample: " + commandParts.joined(separator: " ")

outputFileForError = rswiftGeneratedFile
}

errors.append(error)
}

let scriptOutputPaths = scriptOutputFiles.map { URL(fileURLWithPath: $0).standardized.path }
if !scriptOutputPaths.contains(outputURL.standardized.path) && !scriptOutputPaths.contains(outputFileForError) {
let path = outputFileForError
.replacingOccurrences(of: podsTargetSrcroot ?? "", with: "$PODS_TARGET_SRCROOT")
.replacingOccurrences(of: sourceRootPath, with: "$SOURCE_ROOT")
errors.append("Build phase Output Files do not contain '\(path)'.")
}

// Check UITest output file
if let uiTestOutputURL = uiTestOutputURL {
var uiTestOutputFileForError = uiTestOutputURL.path
if uiTestOutputURL.pathExtension != "swift" {

var error = "Output path for UI test file must specify a file, it should not be a directory."
Expand All @@ -67,19 +54,10 @@ public func validateRswiftEnvironment(
.map { $0.contains(" ") ? "\"\($0)\"" : $0 }

error += "\nExample: " + commandParts.joined(separator: " ")

uiTestOutputFileForError = rswiftGeneratedFile
}

errors.append(error)
}

if !scriptOutputPaths.contains(uiTestOutputURL.standardized.path) && !scriptOutputPaths.contains(uiTestOutputFileForError) {
let path = uiTestOutputFileForError
.replacingOccurrences(of: podsTargetSrcroot ?? "", with: "$PODS_TARGET_SRCROOT")
.replacingOccurrences(of: sourceRootPath, with: "$SOURCE_ROOT")
errors.append("Build phase Output Files do not contain '\(path)'.")
}
}

return errors
Expand Down
10 changes: 6 additions & 4 deletions Sources/rswift/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ let generate = command(

let processInfo = ProcessInfo()

if let scriptInputFile = try? processInfo.environmentVariable(name: EnvironmentKeys.scriptInputFile(number: 0)),
scriptInputFile.hasSuffix("/rswift-lastrun")
{
warn("For updating to R.swift 6.0, read our migration guide: https://github.com/mac-cain13/R.swift/blob/master/Documentation/Migration.md")
}

let xcodeprojPath = try xcodeprojOption ?? processInfo.environmentVariable(name: EnvironmentKeys.xcodeproj)
let targetName = try targetOption ?? processInfo.environmentVariable(name: EnvironmentKeys.target)
let bundleIdentifier = try bundleIdentifierOption ?? processInfo.environmentVariable(name: EnvironmentKeys.bundleIdentifier)
Expand All @@ -227,13 +233,10 @@ let generate = command(

if inputOutputFilesValidation {

let scriptOutputFiles = try processInfo.scriptOutputFiles()

let errors = validateRswiftEnvironment(
outputURL: outputURL,
uiTestOutputURL: uiTestOutputURL,
sourceRootPath: sourceRootPath,
scriptOutputFiles: scriptOutputFiles,
podsRoot: processInfo.environment["PODS_ROOT"],
podsTargetSrcroot: processInfo.environment["PODS_TARGET_SRCROOT"],
commandLineArguments: CommandLine.arguments)
Expand All @@ -242,7 +245,6 @@ let generate = command(
for error in errors {
fail(error)
}
warn("For updating to R.swift 5.0, read our migration guide: https://github.com/mac-cain13/R.swift/blob/master/Documentation/Migration.md")
exit(EXIT_FAILURE)
}
}
Expand Down

0 comments on commit 57761d7

Please sign in to comment.