Commit 844fdf97 authored by Drew's avatar Drew

Recursively parse sources

parent 3e5f5122
......@@ -5,3 +5,8 @@ tasks:
helloworld:
tool: "shell"
script: "echo \"Hello world\""
default:
tool: "atllbuild"
source: ["src/**.swift"]
bootstrap: true
......@@ -16,5 +16,6 @@ final class Task {
print("Running task \(name)...")
let tool = try toolByName(self.tool)
try tool.run(yaml)
print("Completed task \(name).")
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@ protocol Tool {
func run(args: [Yaml: Yaml]) throws
}
let tools = ["shell":Shell()]
let tools : [String: Tool] = ["shell":Shell(),"atllbuild":ATllbuild()]
func toolByName(name: String) throws -> Tool {
guard let tool = tools[name] else { throw AnarchyBuildError.CantParseYaml("Unknown build tool \(name)") }
......
import Foundation
final class ATllbuild : Tool {
func collectSources(sourceDescriptions: [String]) -> [String] {
var sources : [String] = []
for description in sourceDescriptions {
if description.hasSuffix("**.swift") {
let basepath = String(Array(description.characters)[0..<description.characters.count - 9])
let manager = NSFileManager.defaultManager()
let enumerator = manager.enumeratorAtPath(basepath)!
while let source = enumerator.nextObject() as? String {
if source.hasSuffix("swift") {
sources.append(source)
}
}
}
else {
sources.append(description)
}
}
return sources
}
func run(args: [Yaml : Yaml]) throws {
guard let sourceDescriptions = args["source"]?.array?.flatMap({$0.string}) else { throw AnarchyBuildError.CantParseYaml("Can't find sources for atllbuild.") }
let sources = collectSources(sourceDescriptions)
print("\(sources)")
}
}
\ No newline at end of file
//
// errors.swift
// AnarchyToolsXcode
//
// Created by Drew Crawford on 1/13/16.
// Copyright © 2016 Drew Crawford. All rights reserved.
//
import Foundation
enum AnarchyBuildError : ErrorType {
......
......@@ -19,3 +19,5 @@ if Process.arguments.count > 1 {
else {
runtask("default")
}
print("Built package \(name).")
\ No newline at end of file
......@@ -18,6 +18,7 @@
3AED49931C4679E800AC56A8 /* Task.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AED49921C4679E800AC56A8 /* Task.swift */; };
3AED49951C467C2300AC56A8 /* Tools.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AED49941C467C2300AC56A8 /* Tools.swift */; };
3AED49971C467C4400AC56A8 /* Shell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AED49961C467C4400AC56A8 /* Shell.swift */; };
3AED49991C4681F600AC56A8 /* atllbuild.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AED49981C4681F600AC56A8 /* atllbuild.swift */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -45,6 +46,7 @@
3AED49921C4679E800AC56A8 /* Task.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Task.swift; path = ../src/Task.swift; sourceTree = SOURCE_ROOT; };
3AED49941C467C2300AC56A8 /* Tools.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Tools.swift; path = ../src/Tools.swift; sourceTree = SOURCE_ROOT; };
3AED49961C467C4400AC56A8 /* Shell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Shell.swift; path = ../src/Shell.swift; sourceTree = SOURCE_ROOT; };
3AED49981C4681F600AC56A8 /* atllbuild.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = atllbuild.swift; path = ../src/atllbuild.swift; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -83,6 +85,7 @@
3AED49921C4679E800AC56A8 /* Task.swift */,
3AED49941C467C2300AC56A8 /* Tools.swift */,
3AED49961C467C4400AC56A8 /* Shell.swift */,
3AED49981C4681F600AC56A8 /* atllbuild.swift */,
);
path = AnarchyToolsXcode;
sourceTree = "<group>";
......@@ -165,6 +168,7 @@
3AED498A1C466DFD00AC56A8 /* Regex.swift in Sources */,
3AED49911C466EC200AC56A8 /* errors.swift in Sources */,
3AED49881C466DFD00AC56A8 /* Operators.swift in Sources */,
3AED49991C4681F600AC56A8 /* atllbuild.swift in Sources */,
3AED49971C467C4400AC56A8 /* Shell.swift in Sources */,
3AED49891C466DFD00AC56A8 /* Parser.swift in Sources */,
3AED49931C4679E800AC56A8 /* Task.swift in Sources */,
......
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../src/main.swift"
timestampString = "474378408.886193"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "4"
endingLineNumber = "4">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../src/main.swift"
timestampString = "474378408.886193"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "3"
endingLineNumber = "3">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../src/main.swift"
timestampString = "474378408.886193"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "1"
endingLineNumber = "1">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../src/Shell.swift"
timestampString = "474382081.524901"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "4"
endingLineNumber = "4"
landmarkName = "run(_:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3AE6850F1C466CDE00444852"
BuildableName = "AnarchyToolsXcode"
BlueprintName = "AnarchyToolsXcode"
ReferencedContainer = "container:AnarchyToolsXcode.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3AE6850F1C466CDE00444852"
BuildableName = "AnarchyToolsXcode"
BlueprintName = "AnarchyToolsXcode"
ReferencedContainer = "container:AnarchyToolsXcode.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "YES"
customWorkingDirectory = "/Users/drew/Code/AnarchyTools/atbuild"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3AE6850F1C466CDE00444852"
BuildableName = "AnarchyToolsXcode"
BlueprintName = "AnarchyToolsXcode"
ReferencedContainer = "container:AnarchyToolsXcode.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "helloworld"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3AE6850F1C466CDE00444852"
BuildableName = "AnarchyToolsXcode"
BlueprintName = "AnarchyToolsXcode"
ReferencedContainer = "container:AnarchyToolsXcode.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>AnarchyToolsXcode.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>3AE6850F1C466CDE00444852</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment