| 151 | } |
| 152 | |
| 153 | func (b BuildConfig) setupPkgConfig() { |
| 154 | var ( |
| 155 | configPaths []string |
| 156 | configLibDirs []string |
| 157 | pathDivider string |
| 158 | sysrootDir string |
| 159 | ) |
| 160 | |
| 161 | rootfs := b.Ctx.Platform().GetRootFS() |
| 162 | tmpDepsDir := filepath.Join(dirs.TmpDepsDir, b.PortConfig.LibraryDir) |
| 163 | hostBuild := b.DevDep || b.HostDev |
| 164 | |
| 165 | switch runtime.GOOS { |
| 166 | case "windows": |
| 167 | if b.buildSystem.Name() == "meson" || b.buildSystem.Name() == "b2" { |
| 168 | // For meson in windows, we use windows version pkgconf, |
| 169 | // so we need to provider with windows format path. |
| 170 | configPaths = []string{ |
| 171 | filepath.Join(tmpDepsDir, "lib", "pkgconfig"), |
| 172 | filepath.Join(tmpDepsDir, "share", "pkgconfig"), |
| 173 | } |
| 174 | |
| 175 | sysrootDir = tmpDepsDir |
| 176 | pathDivider = ";" |
| 177 | } else { |
| 178 | configPaths = []string{ |
| 179 | fileio.ToCygpath(filepath.Join(tmpDepsDir, "lib", "pkgconfig")), |
| 180 | fileio.ToCygpath(filepath.Join(tmpDepsDir, "share", "pkgconfig")), |
| 181 | } |
| 182 | |
| 183 | sysrootDir = fileio.ToCygpath(tmpDepsDir) |
| 184 | pathDivider = ":" |
| 185 | } |
| 186 | |
| 187 | case "linux": |
| 188 | // Pkg config paths and sysroot dir. |
| 189 | if rootfs != nil && !hostBuild { |
| 190 | sysrootDir = rootfs.GetAbsDir() |
| 191 | |
| 192 | // PKG_CONFIG related. |
| 193 | for _, configPath := range rootfs.GetPkgConfigPath() { |
| 194 | configLibDirs = append(configLibDirs, filepath.Join(sysrootDir, configPath)) |
| 195 | } |
| 196 | |
| 197 | pathDivider = ":" |
| 198 | |
| 199 | // Use actual tmpDepsDir path (not sysroot symlink) for pkgconfig to ensure correct library paths |
| 200 | tmpDepsDir := filepath.Join(dirs.TmpDepsDir, b.PortConfig.LibraryDir) |
| 201 | |
| 202 | // Prepend pkgconfig with actual tmp/deps directory (not sysroot symlink) to prioritize it. |
| 203 | configPaths = append([]string{ |
| 204 | filepath.Join(tmpDepsDir, "lib", "pkgconfig"), |
| 205 | filepath.Join(tmpDepsDir, "share", "pkgconfig"), |
| 206 | }, configPaths...) |
| 207 | } else { |
| 208 | configPaths = []string{ |
| 209 | filepath.Join(tmpDepsDir, "lib", "pkgconfig"), |
| 210 | filepath.Join(tmpDepsDir, "share", "pkgconfig"), |