Skip to content

Commit

Permalink
attempt fix of parent resource acquisition
Browse files Browse the repository at this point in the history
Re-ordered dependency resolution resource gathering to skip resources for the root/parent node of the tree. This change aims to only mark resources for download on dependencies that are below the root node of the dependency tree. This fixes an issue where a `package run` of a package that supplies plugin binaries can run locally without attempting to pull its own binaries from GitHub - this means plugin packages can define their own in-development copies of plugin binaries for proper local testing.
  • Loading branch information
Southclaws committed Dec 26, 2018
1 parent 2d33ac6 commit 9510408
Showing 1 changed file with 34 additions and 35 deletions.
69 changes: 34 additions & 35 deletions rook/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,59 +77,58 @@ func (pcx *PackageContext) EnsureDependenciesCached() (errOuter error) {
print.Verb(prefix, currentMeta, "is not a package:", errInner)
return
}
}

// some resources may not be plugins
isPlugin := false
// Run through resources for the target platform and grab all the
// include paths that will be used for includes from resource archives.
for _, res := range currentPackage.Resources {
if res.Platform != pcx.Platform {
print.Verb(prefix, "ignoring platform mismatch", res.Platform)
continue
}

// Run through resources for the target platform and grab all the
// include paths that will be used for includes from resource archives.
for _, res := range currentPackage.Resources {
if res.Platform != pcx.Platform {
print.Verb(prefix, "ignoring platform mismatch", res.Platform)
continue
if len(res.Includes) > 0 {
targetPath := filepath.Join(pcx.Package.Vendor, res.Path(currentPackage))
pcx.AllIncludePaths = append(pcx.AllIncludePaths, targetPath)
print.Verb(prefix, "added target path for resource includes:", targetPath)
}
}

// some resources may not be plugins
isPlugin := false

for _, resource := range currentPackage.Resources {
if resource.Archive {
if len(resource.Plugins) > 0 {
isPlugin = true
}
} else {
if strings.Contains(resource.Name, "dll") || strings.Contains(resource.Name, "so") {
isPlugin = true
}
}
}

if len(res.Includes) > 0 {
targetPath := filepath.Join(pcx.Package.Vendor, res.Path(currentPackage))
pcx.AllIncludePaths = append(pcx.AllIncludePaths, targetPath)
print.Verb(prefix, "added target path for resource includes:", targetPath)
if isPlugin {
pcx.AllPlugins = append(pcx.AllPlugins, currentMeta)
print.Verb(prefix, currentMeta, "is a plugin")
}
}

// mark the repo as visited so we don't hit it again in case it appears
// multiple times within the dependency tree.
visited[currentMeta.Repo] = true

var subPackageDepStrings []versioning.DependencyString
// first iteration has finished, mark it false and next iterations will
// operate on dependencies
firstIter = false

var subPackageDepStrings []versioning.DependencyString
if currentPackage.Parent {
subPackageDepStrings = currentPackage.GetAllDependencies()
} else {
subPackageDepStrings = currentPackage.Dependencies
}

for _, resource := range currentPackage.Resources {
if resource.Archive {
if len(resource.Plugins) > 0 {
isPlugin = true
}
} else {
if strings.Contains(resource.Name, "dll") || strings.Contains(resource.Name, "so") {
isPlugin = true
}
}
}

if isPlugin {
pcx.AllPlugins = append(pcx.AllPlugins, currentMeta)
print.Verb(prefix, currentMeta, "is a plugin")
}

// first iteration has finished, mark it false and next iterations will
// operate on dependencies
firstIter = false

print.Verb(prefix, "iterating", len(subPackageDepStrings), "dependencies of", currentPackage)
var subPackageDepMeta versioning.DependencyMeta
for _, subPackageDepString := range subPackageDepStrings {
Expand Down

0 comments on commit 9510408

Please sign in to comment.