libpkgconf: personality: add stub cross personality loader

pull/185/head
William Pitcock 2018-05-09 19:27:53 -05:00
parent 6b0e346c28
commit 9439b683ca
3 changed files with 63 additions and 1 deletions

View File

@ -5,10 +5,11 @@ includedir = @includedir@
system_includedir = @SYSTEM_INCLUDEDIR@
system_libdir = @SYSTEM_LIBDIR@
pkg_default_dir = @PKG_DEFAULT_PATH@
personality_dir = @PERSONALITY_PATH@
pkgconfigdir = $(libdir)/pkgconfig
nodist_pkgconfig_DATA = libpkgconf.pc
AM_CFLAGS = -DPKG_DEFAULT_PATH=\"$(pkg_default_dir)\" -DSYSTEM_INCLUDEDIR=\"$(system_includedir)\" -DSYSTEM_LIBDIR=\"$(system_libdir)\"
AM_CFLAGS = -DPERSONALITY_PATH=\"$(personality_dir)\" -DPKG_DEFAULT_PATH=\"$(pkg_default_dir)\" -DSYSTEM_INCLUDEDIR=\"$(system_includedir)\" -DSYSTEM_LIBDIR=\"$(system_libdir)\"
bin_PROGRAMS = pkgconf
lib_LTLIBRARIES = libpkgconf.la

View File

@ -30,6 +30,13 @@ LT_INIT
AC_SYS_LARGEFILE
AC_ARG_WITH([personality-dir],[AC_HELP_STRING([--with-personality-dir],[specify
the place where cross-compile personality files will be found])],
PERSONALITY_PATH="$withval",
PERSONALITY_PATH="${datadir}/pkgconfig/personality.d:${etcdir}/pkgconfig/personality.d")
AC_SUBST([PERSONALITY_PATH])
AC_ARG_WITH([pkg-config-dir],[AC_HELP_STRING([--with-pkg-config-dir],[specify
the place where pc files will be found])],PKG_DEFAULT_PATH="$withval",
PKG_DEFAULT_PATH="${libdir}/pkgconfig:${datadir}/pkgconfig")

View File

@ -94,3 +94,57 @@ pkgconf_cross_personality_default(void)
default_personality_init = true;
return &default_personality;
}
static bool
valid_triplet(const char *triplet)
{
const char *c = triplet;
for (; c != '\0'; c++)
if (!isalnum(*c) && *c != '-')
return false;
return true;
}
static pkgconf_cross_personality_t *
load_personality_with_path(const char *path, const char *triplet)
{
return NULL;
}
/*
* !doc
*
* .. c:function:: pkgconf_cross_personality_t *pkgconf_cross_personality_find(const char *triplet)
*
* Attempts to find a cross-compile personality given a triplet.
*
* :rtype: pkgconf_cross_personality_t*
* :return: the default cross-compile personality
*/
pkgconf_cross_personality_t *
pkgconf_cross_personality_find(const char *triplet)
{
pkgconf_list_t plist;
pkgconf_node_t *n;
pkgconf_cross_personality_t *out = NULL;
if (!valid_triplet(triplet))
return NULL;
pkgconf_path_split(PERSONALITY_PATH, &plist, true);
PKGCONF_FOREACH_LIST_ENTRY(plist.head, n)
{
pkgconf_path_t *pn = n->data;
out = load_personality_with_path(pn->path, triplet);
if (out != NULL)
goto finish;
}
finish:
pkgconf_path_free(&plist);
return out;
}