Skip to content
Open
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ playground.xcworkspace
# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
Packages/
.build/
Package.resolved

# CocoaPods
#
Expand Down
4 changes: 0 additions & 4 deletions Cartfile

This file was deleted.

6 changes: 0 additions & 6 deletions Cartfile.resolved

This file was deleted.

21 changes: 6 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
PREFIX?=/usr/local
TEMPORARY_FOLDER=/tmp/RomeBuild.dst
BUILD_TOOL=xcodebuild

XCODEFLAGS=DSTROOT=$(TEMPORARY_FOLDER)

ROME_EXECUTABLE=$(TEMPORARY_FOLDER)/Applications/RomeBuild.app/Contents/MacOS/RomeBuild
FRAMEWORKS_BUNDLE=$(TEMPORARY_FOLDER)/Applications/RomeBuild.app/Contents/Frameworks/

BUILD_TOOL=swift build
BUILD_TOOL_FLAGS=-c release --build-path "$(TEMPORARY_FOLDER)"
BINARIES_FOLDER=$(PREFIX)/bin
FRAMEWORKS_FOLDER=$(PREFIX)/Frameworks/RomeBuild

ROME_EXECUTABLE=$(shell $(BUILD_TOOL) $(BUILD_TOOL_FLAGS) --show-bin-path)/romebuild

clean:
rm -rf "$(TEMPORARY_FOLDER)"
$(BUILD_TOOL) $(XCODEFLAGS) clean

install:
carthage bootstrap --platform OSX
$(BUILD_TOOL) $(XCODEFLAGS) install
mkdir -p "$(TEMPORARY_FOLDER)"
$(BUILD_TOOL) $(BUILD_TOOL_FLAGS)
mkdir -p "$(BINARIES_FOLDER)"
mkdir -p "$(FRAMEWORKS_FOLDER)"
cp -R "$(FRAMEWORKS_BUNDLE)" "$(FRAMEWORKS_FOLDER)"
cp "$(ROME_EXECUTABLE)" "$(BINARIES_FOLDER)/romebuild"
install_name_tool -add_rpath "$(FRAMEWORKS_FOLDER)" "$(BINARIES_FOLDER)/romebuild"

uninstall:
rm -rf "$(FRAMEWORKS_FOLDER)"
rm "$(BINARIES_FOLDER)/romebuild"
26 changes: 26 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// swift-tools-version:4.0
//
// Package.swift
// RomeBuild
//
// Created by Yehor Popovych on 22/09/2017.
// Copyright © 2017 Yehor Popovych. All rights reserved.
//

import PackageDescription

let package = Package(
name: "RomeBuild",
products: [
.executable(name: "romebuild", targets: ["RomeBuild"]),
],
dependencies: [
.package(url: "https://github.com/ypopovych/RomeKit.git", from: "0.4.0"),
.package(url: "https://github.com/jatoben/CommandLine.git", .branch("master")),
.package(url: "https://github.com/sharplet/Regex.git", from: "1.1.0"),
.package(url: "https://github.com/jkandzi/Progress.swift.git", from: "0.2.0")
],
targets: [
.target(name: "RomeBuild", dependencies: ["RomeKit", "CommandLine", "Regex", "Progress"])
]
)
388 changes: 0 additions & 388 deletions RomeBuild.xcodeproj/project.pbxproj

This file was deleted.

This file was deleted.

31 changes: 0 additions & 31 deletions RomeBuild/Carthage/Carthage.swift

This file was deleted.

31 changes: 0 additions & 31 deletions RomeBuild/Commands/UploadSelfCommand.swift

This file was deleted.

39 changes: 0 additions & 39 deletions RomeBuild/Info.plist

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ struct Cartfile {
return false
}

return NSFileManager.defaultManager().fileExistsAtPath(filePath)
return FileManager.default.fileExists(atPath: filePath)
}

func load() -> [String:String] {
var dependencies = [String:String]()

if let filePath = cartfilePath(), cartfileContents = try? String.init(contentsOfFile: filePath) {
dependencies = parseFile(cartfileContents)
if let filePath = cartfilePath(), let cartfileContents = try? String.init(contentsOfFile: filePath) {
dependencies = parseFile(contents: cartfileContents)
}

return dependencies
Expand All @@ -36,17 +36,16 @@ struct Cartfile {

let fvRegex = Regex("\"\\s*(.*?)\\s*\"")

let matches = fvRegex.allMatches(line)
if let framework = matches[0].captures.first!, version = matches[1].captures.first! {
if let frameworkName = framework.componentsSeparatedByString("/").last {
let cleanedFramework = frameworkName.stringByReplacingOccurrencesOfString(".git", withString: "")
let matches = fvRegex.allMatches(in: line)
if let framework = matches[0].captures.first!, let version = matches[1].captures.first! {
if let frameworkName = framework.components(separatedBy: "/").last {
let cleanedFramework = frameworkName.replacingOccurrences(of: ".git", with: "")
dependencies[cleanedFramework] = version
}
}

}

return dependencies
}

}
}
113 changes: 113 additions & 0 deletions Sources/RomeBuild/Carthage/Carthage.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import Foundation
import Regex


private let carthageArguments: Dictionary<String, Dictionary<String, Bool>> = [
"archive": [
"--output": true,
"--project-directory": true,
"--color": true
],
"bootstrap": [
"--no-checkout": false,
"--no-build": false,
"--verbose": false,
"--configuration": true,
"--platform": true,
"--toolchain": true,
"--derived-data": true,
"--use-ssh": false,
"--use-submodules": false,
"--no-use-binaries": false,
"--color": true,
"--project-directory": true
],
"build": [
"--configuration": true,
"--platform": true,
"--toolchain": true,
"--derived-data": true,
"--no-skip-current": false,
"--color": true,
"--verbose": false,
"--project-directory": true
],
"checkout": [
"--use-ssh": false,
"--use-submodules": false,
"--no-use-binaries": false,
"--color": true,
"--project-directory": true
],
"fetch": ["--color": true],
"outdated": [
"--use-ssh": false,
"--verbose": false,
"--color": true,
"--project-directory": true
],
"update": [
"--no-checkout": false,
"--no-build": false,
"--verbose": false,
"--configuration": true,
"--platform": true,
"--toolchain": true,
"--derived-data": true,
"--use-ssh": false,
"--use-submodules": false,
"--no-use-binaries": false,
"--color": true,
"--project-directory": true
]
]

@discardableResult
func Carthage(_ args: [String], path: String? = nil) -> TaskStatus {
let task = Process()
let standardOutputPipe = Pipe()
task.launchPath = "/usr/local/bin/carthage"
if let path = path {
task.currentDirectoryPath = path
}
task.arguments = args
task.standardOutput = standardOutputPipe
task.launch()
task.waitUntilExit()

let readHandle = standardOutputPipe.fileHandleForReading
let data = readHandle.readDataToEndOfFile()
if let standardOutput = String.init(data: data, encoding: .utf8) {
let lines = standardOutput.characters.split { $0 == "\n" || $0 == "\r\n" }.map(String.init)
return TaskStatus(status: task.terminationStatus, standardOutput: lines)
} else {
return TaskStatus(status: task.terminationStatus, standardOutput: nil)
}
}

func filterAdditionalArgs(task: String, args: [String]) -> [String] {
var additionalArgs = args
let allowedArgs = carthageArguments[task]
if let allowedArgs = allowedArgs {
var index = additionalArgs.startIndex
while index < additionalArgs.endIndex {
let arg = allowedArgs[additionalArgs[index]]
if let arg = arg {
if arg {
index += 1
}
index += 1
} else {
additionalArgs.remove(at: index)
}
}
}
return additionalArgs
}

func getFrameworkPath(taskStatus: TaskStatus) -> String? {
if let lastLineOfOutput = taskStatus.standardOutput?.last {
return Regex("Created (.*framework.zip)$").firstMatch(in: lastLineOfOutput)?.captures[0]
}
return nil
}
Loading