Skip to content

Commit 6527ca5

Browse files
internal/discover: use explicit driver version for matching libraries
1 parent 2251776 commit 6527ca5

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

internal/discover/graphics.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,20 @@ func newVulkanConfigsDiscover(logger logger.Interface, driver *root.Driver) Disc
109109

110110
type graphicsDriverLibraries struct {
111111
Discover
112-
logger logger.Interface
113-
hookCreator HookCreator
112+
// driverVersion is the version of the driver that is being used.
113+
driverVersion string
114114
}
115115

116116
var _ Discover = (*graphicsDriverLibraries)(nil)
117117

118118
func newGraphicsLibrariesDiscoverer(logger logger.Interface, driver *root.Driver, hookCreator HookCreator) (Discover, error) {
119-
cudaVersionPattern, err := driver.Version()
119+
driverVersion, err := driver.Version()
120120
if err != nil {
121121
return nil, fmt.Errorf("failed to get driver version: %w", err)
122122
}
123+
// We use the driver version as a pattern for matching libraries.
124+
// This pattern is used to identify libraries that are part of the driver.
125+
cudaVersionPattern := driverVersion
123126
cudaLibRoot, err := driver.GetDriverLibDirectory()
124127
if err != nil {
125128
return nil, fmt.Errorf("failed to get libcuda.so parent directory: %w", err)
@@ -161,9 +164,10 @@ func newGraphicsLibrariesDiscoverer(logger logger.Interface, driver *root.Driver
161164
)
162165

163166
return &graphicsDriverLibraries{
164-
Discover: Merge(libraries, xorgLibraries),
165-
logger: logger,
166-
hookCreator: hookCreator,
167+
Discover: Merge(libraries, xorgLibraries),
168+
logger: logger,
169+
hookCreator: hookCreator,
170+
driverVersion: driverVersion,
167171
}, nil
168172
}
169173

@@ -231,8 +235,7 @@ func (d graphicsDriverLibraries) Hooks() ([]Hook, error) {
231235

232236
// isDriverLibrary checks whether the specified filename is a specific driver library.
233237
func (d graphicsDriverLibraries) isDriverLibrary(filename string, libraryName string) bool {
234-
// TODO: Instead of `.*.*` we could use the driver version.
235-
pattern := strings.TrimSuffix(libraryName, ".") + ".*.*"
238+
pattern := strings.TrimSuffix(libraryName, ".") + "." + d.driverVersion
236239
match, _ := filepath.Match(pattern, filename)
237240
return match
238241
}

0 commit comments

Comments
 (0)