Skip to content

Commit e7b9c66

Browse files
compute the incompatible version at commit time
1 parent 70f256b commit e7b9c66

File tree

2 files changed

+37
-34
lines changed

2 files changed

+37
-34
lines changed

Diff for: arduino/cores/packageindex/index.go

-34
Original file line numberDiff line numberDiff line change
@@ -147,40 +147,6 @@ func (index Index) MergeIntoPackages(outPackages cores.Packages) {
147147
for _, inPackage := range index.Packages {
148148
inPackage.extractPackageIn(outPackages, index.IsTrusted, index.isInstalledJSON)
149149
}
150-
151-
// calculates Incompatible PlatformRelease
152-
for _, op := range outPackages {
153-
for _, p := range op.Platforms {
154-
for _, pr := range p.Releases {
155-
platformHasIncompatibleTools := func() bool {
156-
for _, td := range pr.ToolDependencies {
157-
if td == nil {
158-
return true
159-
}
160-
161-
_, ok := outPackages[td.ToolPackager]
162-
if !ok {
163-
return true
164-
}
165-
tool := outPackages[td.ToolPackager].Tools[td.ToolName]
166-
if tool == nil {
167-
return true
168-
}
169-
tr := tool.Releases[td.ToolVersion.NormalizedString()]
170-
if tr == nil {
171-
return true
172-
}
173-
174-
if tr.GetCompatibleFlavour() == nil {
175-
return true
176-
}
177-
}
178-
return false
179-
}
180-
pr.Incompatible = platformHasIncompatibleTools()
181-
}
182-
}
183-
}
184150
}
185151

186152
// IndexFromPlatformRelease creates an Index that contains a single indexPackage

Diff for: arduino/cores/packagemanager/package_manager.go

+37
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,50 @@ func (pmb *Builder) Build() *PackageManager {
121121
}
122122
}
123123

124+
func (pmb *Builder) calculateIncompatibleVersions() {
125+
// calculates Incompatible PlatformRelease
126+
for _, op := range pmb.packages {
127+
for _, p := range op.Platforms {
128+
for _, pr := range p.Releases {
129+
platformHasIncompatibleTools := func() bool {
130+
for _, td := range pr.ToolDependencies {
131+
if td == nil {
132+
return true
133+
}
134+
135+
_, ok := pmb.packages[td.ToolPackager]
136+
if !ok {
137+
return true
138+
}
139+
tool := pmb.packages[td.ToolPackager].Tools[td.ToolName]
140+
if tool == nil {
141+
return true
142+
}
143+
tr := tool.Releases[td.ToolVersion.NormalizedString()]
144+
if tr == nil {
145+
return true
146+
}
147+
148+
if tr.GetCompatibleFlavour() == nil {
149+
return true
150+
}
151+
}
152+
return false
153+
}
154+
pr.Incompatible = platformHasIncompatibleTools()
155+
}
156+
}
157+
}
158+
}
159+
124160
// NewBuilder creates a Builder with the same configuration
125161
// of this PackageManager. A "commit" function callback is returned: calling
126162
// this function will make the builder write the new configuration into this
127163
// PackageManager.
128164
func (pm *PackageManager) NewBuilder() (builder *Builder, commit func()) {
129165
pmb := NewBuilder(pm.IndexDir, pm.PackagesDir, pm.DownloadDir, pm.tempDir, pm.userAgent)
130166
return pmb, func() {
167+
pmb.calculateIncompatibleVersions()
131168
pmb.BuildIntoExistingPackageManager(pm)
132169
}
133170
}

0 commit comments

Comments
 (0)