Commit 9521092e authored by Drew's avatar Drew

Add CollectSources a function we use from xcode-emit and atllbuild

parent 35359b51
Pipeline #703 passed with stage
// Copyright (c) 2016 Anarchy Tools Contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import Foundation
/**
* This function resolves wildcards in source descriptions to complete values
* - parameter sourceDescriptions: a descriptions of sources such as ["src/**.swift"] */
* - returns: A list of resolved sources such as ["src/a.swift", "src/b.swift"]
*/
public 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(basepath + "/" + source)
}
}
}
else {
sources.append(description)
}
}
return sources
}
\ No newline at end of file
(package
:name "import_dst"
:version "0.1.0-dev"
:tasks {:build {:tool "lldb-build"
:name "json-swift"
:output-type "lib"
:source [ "src/**.swift" "lib/**.swift" ]
:dependencies ["import_dst.build"]
}}
)
; End of the sample.
\ No newline at end of file
;; A package that imports a remote file
(package
:name "import_src"
:version "0.1.0-dev"
:import ["import_dst.atpkg"]
:tasks {:build {:tool "lldb-build"
:name "json-swift"
:output-type "lib"
:source [ "src/**.swift" "lib/**.swift" ]
:dependencies ["import_dst.build"]
}}
)
; End of the sample.
\ No newline at end of file
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