(toolchain *strings.Builder)
| 160 | } |
| 161 | |
| 162 | func (c *Celer) writePkgConfig(toolchain *strings.Builder) { |
| 163 | var ( |
| 164 | configPaths []string |
| 165 | configLibDirs []string |
| 166 | tmpDepDir string |
| 167 | tmpDepSysroot string |
| 168 | ) |
| 169 | |
| 170 | installedDir := filepath.Join("${WORKSPACE_ROOT}/installed", c.LibraryFolder()) |
| 171 | writePathList := func(indent, name string, paths []string) { |
| 172 | if len(paths) == 0 { |
| 173 | return |
| 174 | } |
| 175 | |
| 176 | fmt.Fprintf(toolchain, "%sset(%s\n", indent, name) |
| 177 | for _, path := range paths { |
| 178 | fmt.Fprintf(toolchain, "%s %q\n", indent, path) |
| 179 | } |
| 180 | fmt.Fprintf(toolchain, "%s)\n", indent) |
| 181 | fmt.Fprintf(toolchain, "%slist(JOIN %s %q %s_STR)\n", indent, name, string(os.PathListSeparator), name) |
| 182 | fmt.Fprintf(toolchain, "%sset(%s %q)\n", indent, "ENV{"+name+"}", "${"+name+"_STR}") |
| 183 | } |
| 184 | |
| 185 | switch runtime.GOOS { |
| 186 | case "windows": |
| 187 | configPaths = []string{ |
| 188 | filepath.ToSlash(filepath.Join(installedDir, "lib", "pkgconfig")), |
| 189 | filepath.ToSlash(filepath.Join(installedDir, "share", "pkgconfig")), |
| 190 | } |
| 191 | tmpDepDir = filepath.ToSlash("${TMP_DEP_DIR}") |
| 192 | tmpDepSysroot = tmpDepDir |
| 193 | |
| 194 | case "linux": |
| 195 | tmpDepDir = filepath.ToSlash("${TMP_DEP_DIR}") |
| 196 | |
| 197 | // Target directory. |
| 198 | if c.RootFS() != nil { |
| 199 | // tmp/deps is a symlink in rootfs. |
| 200 | tmpDepSysroot = "${CMAKE_SYSROOT}" |
| 201 | |
| 202 | // Add rootfs pkgconfig paths to both PKG_CONFIG_LIBDIR and PKG_CONFIG_PATH. |
| 203 | for _, configPath := range c.RootFS().GetPkgConfigPath() { |
| 204 | configLibDirs = append(configLibDirs, filepath.Join("${CMAKE_SYSROOT}", configPath)) |
| 205 | } |
| 206 | } else { |
| 207 | tmpDepSysroot = "${WORKSPACE_ROOT}" |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | fmt.Fprintf(toolchain, "\n# ============== PkgConfig search paths ============== #\n") |
| 212 | fmt.Fprintf(toolchain, "set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH FALSE)\n") |
| 213 | fmt.Fprintf(toolchain, "set(PKG_CONFIG_EXECUTABLE \"${INSTALLED_DEV_DIR}/bin/pkgconf\")\n") |
| 214 | |
| 215 | // PKG_CONFIG_LIBDIR |
| 216 | writePathList("", "PKG_CONFIG_LIBDIR", configLibDirs) |
| 217 | |
| 218 | tmpDepConfigPaths := []string{ |
| 219 | filepath.ToSlash(filepath.Join(tmpDepDir, "lib", "pkgconfig")), |
no test coverage detected