()
| 1028 | } |
| 1029 | |
| 1030 | func (b BuildConfig) readMSVCEnvs() (map[string]string, error) { |
| 1031 | toolchain := b.Ctx.Platform().GetToolchain() |
| 1032 | |
| 1033 | // Read MSVC environment variables. |
| 1034 | // TODO: the `x64` may be different depending on the platform. |
| 1035 | command := fmt.Sprintf(`call "%s" x64 && set`, toolchain.GetMSVC().VCVars) |
| 1036 | title := fmt.Sprintf("[read msvc envs: %s]", b.PortConfig.nameVersion()) |
| 1037 | executor := cmd.NewExecutor(title, command) |
| 1038 | output, err := executor.ExecuteOutput() |
| 1039 | if err != nil { |
| 1040 | return nil, err |
| 1041 | } |
| 1042 | |
| 1043 | // Parse environment variables from output. |
| 1044 | var msvcEnvs = make(map[string]string) |
| 1045 | lines := strings.SplitSeq(output, "\n") |
| 1046 | for line := range lines { |
| 1047 | line = strings.TrimSpace(line) |
| 1048 | if line != "" && strings.Contains(line, "=") { |
| 1049 | parts := strings.Split(line, "=") |
| 1050 | |
| 1051 | // Unify "Path" to "PATH". |
| 1052 | if parts[0] == "Path" { |
| 1053 | parts[0] = "PATH" |
| 1054 | } |
| 1055 | msvcEnvs[parts[0]] = parts[1] |
| 1056 | color.Printf(color.Hint, "-- %s=%s\n", parts[0], parts[1]) |
| 1057 | } |
| 1058 | } |
| 1059 | |
| 1060 | return msvcEnvs, nil |
| 1061 | } |
| 1062 | |
| 1063 | // removeLaFiles remove la files generated by libtool. |
| 1064 | func (b BuildConfig) removeLaFiles(root string) error { |
no test coverage detected