-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from toshi0383/include-existing-option
Introduce --include-existing option
- Loading branch information
Showing
15 changed files
with
346 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// FileReference.swift | ||
// xcconfig-extractor | ||
// | ||
// Created by Toshihiro Suzuki on 2017/04/30. | ||
// Copyright © 2017 Toshihiro Suzuki. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum FileType: String { | ||
case xcconfig = "text.xcconfig" | ||
} | ||
|
||
public struct FileReference: IsaObject { | ||
public let key: String | ||
public let rawObject: [String : Any] | ||
public let lastKnownFileType: FileType | ||
public let path: String | ||
public let sourceTree: String | ||
|
||
// custom property | ||
public let fullPath: String | ||
|
||
public init?(key: String, value o: [String : Any], objects: [String : Any]) { | ||
guard IsaType(object: o) == .PBXFileReference else { | ||
return nil | ||
} | ||
self.key = key | ||
self.rawObject = o | ||
self.lastKnownFileType = FileType(rawValue: o["lastKnownFileType"] as! String)! | ||
self.path = o["path"] as! String | ||
let fullPath = findPaths(to: key, objects: objects) + [self.path] | ||
self.fullPath = fullPath.joined(separator: "/") | ||
self.sourceTree = o["sourceTree"] as! String | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// Functions.swift | ||
// xcconfig-extractor | ||
// | ||
// Created by Toshihiro Suzuki on 2017/04/30. | ||
// Copyright © 2017 Toshihiro Suzuki. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
func findPaths(to id: String, objects: [String: Any]) -> [String] { | ||
for (k, v) in objects { | ||
if let o = v as? [String: Any], let group = Group(key: k, value: o, objects: objects) { | ||
if group.children.contains(id) { | ||
if let path = group.path { | ||
return findPaths(to: k, objects: objects) + [path] | ||
} else { | ||
return findPaths(to: k, objects: objects) | ||
} | ||
} | ||
} | ||
} | ||
return [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// Group.swift | ||
// xcconfig-extractor | ||
// | ||
// Created by Toshihiro Suzuki on 2017/04/30. | ||
// Copyright © 2017 Toshihiro Suzuki. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct Group: IsaObject { | ||
public let rawObject: [String : Any] | ||
public let key: String | ||
public let children: [String] | ||
public let path: String? | ||
public let name: String? | ||
public init?(key: String, value o: [String : Any], objects: [String : Any]) { | ||
guard IsaType(object: o) == .PBXGroup else { | ||
return nil | ||
} | ||
self.key = key | ||
self.rawObject = o | ||
self.children = o["children"] as! [String] | ||
self.path = o["path"] as? String | ||
self.name = o["name"] as? String | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// Config.swift | ||
// xcconfig-extractor | ||
// | ||
// Created by Toshihiro Suzuki on 2017/04/30. | ||
// Copyright © 2017 Toshihiro Suzuki. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
struct Config { | ||
static let version = "0.2.0" | ||
let isIncludeExisting: Bool | ||
init(isIncludeExisting: Bool) { | ||
self.isIncludeExisting = isIncludeExisting | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// ErrorReporter.swift | ||
// xcconfig-extractor | ||
// | ||
// Created by Toshihiro Suzuki on 2017/04/30. | ||
// Copyright © 2017 Toshihiro Suzuki. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
func printStdError(_ message: String) { | ||
fputs("\(ANSI.red)\(message)\(ANSI.reset)", stderr) | ||
} | ||
|
||
private enum ANSI : String, CustomStringConvertible { | ||
case red = "\u{001B}[0;31m" | ||
case green = "\u{001B}[0;32m" | ||
case yellow = "\u{001B}[0;33m" | ||
|
||
case bold = "\u{001B}[0;1m" | ||
case reset = "\u{001B}[0;0m" | ||
|
||
var description:String { | ||
if isatty(STDOUT_FILENO) > 0 { | ||
return rawValue | ||
} | ||
return "" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// ResultFormatter.swift | ||
// xcconfig-extractor | ||
// | ||
// Created by Toshihiro Suzuki on 2017/04/30. | ||
// Copyright © 2017 Toshihiro Suzuki. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
class ResultFormatter { | ||
let config: Config | ||
init(config: Config) { | ||
self.config = config | ||
} | ||
private var header: [String] { | ||
let signature = "// Generated using xcconfig-extractor \(Config.version) by Toshihiro Suzuki - https://github.com/toshi0383/xcconfig-extractor" | ||
return [signature] | ||
} | ||
private func addInclude(filePath: String) -> String { | ||
return "#include \"\(filePath)\"" | ||
} | ||
func format(result: ResultObject, includes: [String] = []) -> [String] { | ||
return header | ||
+ result.includes.map(addInclude) | ||
+ includes.map(addInclude) | ||
+ result.settings | ||
+ ["\n"] | ||
} | ||
} |
Oops, something went wrong.