Commit db99ea43 authored by Drew's avatar Drew

[atpm] `if-including` and `--include`

See https://github.com/AnarchyTools/atpm/issues/12

Parse the `if-including` directive in ExternalDepency
Reference a package in ExternalDependency, this is used for namespacing
parent 80558124
Pipeline #2426 passed with stage
in 1 minute and 6 seconds
......@@ -43,6 +43,12 @@ final public class ExternalDependency {
///In practice, this is used to hold lock information for atpm
public var _applicationInfo: Any? = nil
///If non-nil, the dependency should only be loaded if the user specifies one of the strings in the array
public var ifIncluding: [String]? = nil
///The reference to the containing package
public var package: Package
///The name of the dependency.
///Note that if the dependency points to a manifest, the name is not known.
public var name: String? {
......@@ -60,7 +66,8 @@ final public class ExternalDependency {
}
}
private init?(url: String, versionMethod: VersioningMethod, channels: [String]?) {
private init?(url: String, versionMethod: VersioningMethod, channels: [String]?, package: Package) {
self.package = package
self.url = url
self.version = versionMethod
self.channels = channels
......@@ -68,21 +75,20 @@ final public class ExternalDependency {
self.dependencyType = .Manifest
}
else { self.dependencyType = .Git }
print("dependency type \(self.dependencyType)")
}
convenience init?(url: String, version: [String], channels: [String]?) {
self.init(url: url, versionMethod: .Version(version), channels: channels)
convenience init?(url: String, version: [String], channels: [String]?, package: Package) {
self.init(url: url, versionMethod: .Version(version), channels: channels, package: package)
}
convenience init?(url: String, commit: String, channels: [String]?) {
self.init(url: url, versionMethod: .Commit(commit), channels: channels)
convenience init?(url: String, commit: String, channels: [String]?, package: Package) {
self.init(url: url, versionMethod: .Commit(commit), channels: channels, package: package)
}
convenience init?(url: String, branch: String, channels: [String]?) {
self.init(url: url, versionMethod: .Branch(branch), channels: channels)
convenience init?(url: String, branch: String, channels: [String]?, package: Package) {
self.init(url: url, versionMethod: .Branch(branch), channels: channels, package: package)
}
convenience init?(url: String, tag: String, channels: [String]?) {
self.init(url: url, versionMethod: .Tag(tag), channels: channels)
convenience init?(url: String, tag: String, channels: [String]?, package: Package) {
self.init(url: url, versionMethod: .Tag(tag), channels: channels, package: package)
}
}
\ No newline at end of file
......@@ -256,15 +256,29 @@ final public class Package {
fatalError("Could not parse external dependency version declaration for \(url)")
}
}
externalDep = ExternalDependency(url: url, version: versionDecl, channels: channels)
externalDep = ExternalDependency(url: url, version: versionDecl, channels: channels, package: self)
} else if let branch = d["branch"]?.string {
externalDep = ExternalDependency(url: url, branch: branch, channels: channels)
externalDep = ExternalDependency(url: url, branch: branch, channels: channels, package: self)
} else if let commit = d["commit"]?.string {
externalDep = ExternalDependency(url: url, commit: commit, channels: channels)
externalDep = ExternalDependency(url: url, commit: commit, channels: channels, package: self)
} else if let tag = d["tag"]?.string {
externalDep = ExternalDependency(url: url, tag: tag, channels: channels)
externalDep = ExternalDependency(url: url, tag: tag, channels: channels, package: self)
}
if let externalDep = externalDep {
if let iiv = d["if-including"] {
guard case .Vector(let ii) = iiv else {
fatalError("Non-vector if-including directive \(iiv)")
}
externalDep.ifIncluding = []
for iss in ii {
guard case .StringLiteral(let s) = iss else {
fatalError("Non-string if-including directive \(iss)")
}
externalDep.ifIncluding!.append(s)
}
}
// add to external deps
self.externals.append(externalDep)
......
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