(msvc *context.MSVC)
| 343 | } |
| 344 | |
| 345 | func (w *WindowsKit) Detect(msvc *context.MSVC) error { |
| 346 | // Check if installed. |
| 347 | key, err := registry.OpenKey(registry.LOCAL_MACHINE, |
| 348 | `SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\Windows\v10.0`, |
| 349 | registry.QUERY_VALUE, |
| 350 | ) |
| 351 | if err != nil { |
| 352 | return fmt.Errorf("microsoft sdk v10.0 not found, make sure you have installed it") |
| 353 | } |
| 354 | defer key.Close() |
| 355 | |
| 356 | // Read installed dir. |
| 357 | w.InstalledDir, _, err = key.GetStringValue("InstallationFolder") |
| 358 | if err != nil { |
| 359 | return fmt.Errorf("microsoft sdk v10.0 not found, make sure you have installed it") |
| 360 | } |
| 361 | |
| 362 | // Read current version. |
| 363 | version, _, err := key.GetStringValue("ProductVersion") |
| 364 | if err != nil { |
| 365 | return fmt.Errorf("cannot read current verson of microsoft sdk v10.0") |
| 366 | } |
| 367 | w.Version = w.normalizeVersion(version) |
| 368 | |
| 369 | // Append includes. |
| 370 | msvc.Includes = append(msvc.Includes, filepath.Join(w.InstalledDir, "include", w.Version, "um")) |
| 371 | msvc.Includes = append(msvc.Includes, filepath.Join(w.InstalledDir, "include", w.Version, "shared")) |
| 372 | msvc.Includes = append(msvc.Includes, filepath.Join(w.InstalledDir, "include", w.Version, "ucrt")) |
| 373 | |
| 374 | // Append libs. |
| 375 | msvc.Libs = append(msvc.Libs, filepath.Join(w.InstalledDir, "lib", w.Version, "um")) |
| 376 | msvc.Libs = append(msvc.Libs, filepath.Join(w.InstalledDir, "lib", w.Version, "ucrt")) |
| 377 | |
| 378 | // Append bin files. |
| 379 | binDir := filepath.Join(w.InstalledDir, "bin", w.Version, "x64") |
| 380 | msvc.MT = filepath.Join(binDir, "mt.exe") |
| 381 | msvc.RC = filepath.Join(binDir, "rc.exe") |
| 382 | |
| 383 | // Append path. |
| 384 | os.Setenv("PATH", env.JoinPaths("PATH", |
| 385 | filepath.Join(w.InstalledDir, "bin", w.Version, "x64"), |
| 386 | filepath.Join(w.InstalledDir, "bin", "x64"), |
| 387 | filepath.Join(w.InstalledDir, "Windows Performance Toolkit"), |
| 388 | )) |
| 389 | |
| 390 | return nil |
| 391 | } |
| 392 | |
| 393 | // append ".0" as suffix. |
| 394 | func (w WindowsKit) normalizeVersion(version string) string { |
nothing calls this directly
no test coverage detected