forked from ariadne/pkgconf
libpkgconf: add basic support for cross-compile personality objects
parent
43e8c7b44d
commit
854490c5b9
|
@ -135,7 +135,8 @@ libpkgconf_la_SOURCES = \
|
||||||
libpkgconf/tuple.c \
|
libpkgconf/tuple.c \
|
||||||
libpkgconf/dependency.c \
|
libpkgconf/dependency.c \
|
||||||
libpkgconf/queue.c \
|
libpkgconf/queue.c \
|
||||||
libpkgconf/path.c
|
libpkgconf/path.c \
|
||||||
|
libpkgconf/personality.c
|
||||||
libpkgconf_la_LDFLAGS = -no-undefined -version-info 3:0:0 -export-symbols-regex '^pkgconf_'
|
libpkgconf_la_LDFLAGS = -no-undefined -version-info 3:0:0 -export-symbols-regex '^pkgconf_'
|
||||||
|
|
||||||
dist_man_MANS = \
|
dist_man_MANS = \
|
||||||
|
|
|
@ -789,7 +789,7 @@ main(int argc, char *argv[])
|
||||||
pkgconf_client_set_trace_handler(&pkg_client, error_handler, NULL);
|
pkgconf_client_set_trace_handler(&pkg_client, error_handler, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
pkgconf_client_init(&pkg_client, error_handler, NULL);
|
pkgconf_client_init(&pkg_client, error_handler, NULL, pkgconf_cross_personality_default());
|
||||||
|
|
||||||
while ((ret = pkg_getopt_long_only(argc, argv, "", options, NULL)) != -1)
|
while ((ret = pkg_getopt_long_only(argc, argv, "", options, NULL)) != -1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,6 +14,7 @@ ADD_LIBRARY(libpkgconf SHARED
|
||||||
fileio.c
|
fileio.c
|
||||||
fragment.c
|
fragment.c
|
||||||
path.c
|
path.c
|
||||||
|
personality.c
|
||||||
pkg.c
|
pkg.c
|
||||||
queue.c
|
queue.c
|
||||||
tuple.c
|
tuple.c
|
||||||
|
|
|
@ -48,17 +48,18 @@ trace_path_list(const pkgconf_client_t *client, const char *desc, pkgconf_list_t
|
||||||
/*
|
/*
|
||||||
* !doc
|
* !doc
|
||||||
*
|
*
|
||||||
* .. c:function:: void pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler)
|
* .. c:function:: void pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data, const pkgconf_cross_personality_t *personality)
|
||||||
*
|
*
|
||||||
* Initialise a pkgconf client object.
|
* Initialise a pkgconf client object.
|
||||||
*
|
*
|
||||||
* :param pkgconf_client_t* client: The client to initialise.
|
* :param pkgconf_client_t* client: The client to initialise.
|
||||||
* :param pkgconf_error_handler_func_t error_handler: An optional error handler to use for logging errors.
|
* :param pkgconf_error_handler_func_t error_handler: An optional error handler to use for logging errors.
|
||||||
* :param void* error_handler_data: user data passed to optional error handler
|
* :param void* error_handler_data: user data passed to optional error handler
|
||||||
|
* :param pkgconf_cross_personality_t* personality: the cross-compile personality to use for defaults
|
||||||
* :return: nothing
|
* :return: nothing
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data)
|
pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data, const pkgconf_cross_personality_t *personality)
|
||||||
{
|
{
|
||||||
client->error_handler_data = error_handler_data;
|
client->error_handler_data = error_handler_data;
|
||||||
client->error_handler = error_handler;
|
client->error_handler = error_handler;
|
||||||
|
@ -70,12 +71,15 @@ pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error
|
||||||
pkgconf_client_set_error_handler(client, error_handler, error_handler_data);
|
pkgconf_client_set_error_handler(client, error_handler, error_handler_data);
|
||||||
pkgconf_client_set_warn_handler(client, NULL, NULL);
|
pkgconf_client_set_warn_handler(client, NULL, NULL);
|
||||||
|
|
||||||
pkgconf_client_set_sysroot_dir(client, NULL);
|
pkgconf_client_set_sysroot_dir(client, personality->sysroot_dir);
|
||||||
pkgconf_client_set_buildroot_dir(client, NULL);
|
pkgconf_client_set_buildroot_dir(client, NULL);
|
||||||
pkgconf_client_set_prefix_varname(client, NULL);
|
pkgconf_client_set_prefix_varname(client, NULL);
|
||||||
|
|
||||||
pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_LIBRARY_PATH", SYSTEM_LIBDIR, &client->filter_libdirs, false);
|
pkgconf_path_copy_list(&client->filter_libdirs, &personality->filter_libdirs);
|
||||||
pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_INCLUDE_PATH", SYSTEM_INCLUDEDIR, &client->filter_includedirs, false);
|
pkgconf_path_copy_list(&client->filter_includedirs, &personality->filter_includedirs);
|
||||||
|
|
||||||
|
pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_LIBRARY_PATH", NULL, &client->filter_libdirs, false);
|
||||||
|
pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_INCLUDE_PATH", NULL, &client->filter_includedirs, false);
|
||||||
|
|
||||||
/* GCC uses these environment variables to define system include paths, so we should check them. */
|
/* GCC uses these environment variables to define system include paths, so we should check them. */
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
|
@ -102,20 +106,21 @@ pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error
|
||||||
/*
|
/*
|
||||||
* !doc
|
* !doc
|
||||||
*
|
*
|
||||||
* .. c:function:: pkgconf_client_t* pkgconf_client_new(pkgconf_error_handler_func_t error_handler)
|
* .. c:function:: pkgconf_client_t* pkgconf_client_new(pkgconf_error_handler_func_t error_handler, void *error_handler_data, const pkgconf_cross_personality_t *personality)
|
||||||
*
|
*
|
||||||
* Allocate and initialise a pkgconf client object.
|
* Allocate and initialise a pkgconf client object.
|
||||||
*
|
*
|
||||||
* :param pkgconf_error_handler_func_t error_handler: An optional error handler to use for logging errors.
|
* :param pkgconf_error_handler_func_t error_handler: An optional error handler to use for logging errors.
|
||||||
* :param void* error_handler_data: user data passed to optional error handler
|
* :param void* error_handler_data: user data passed to optional error handler
|
||||||
|
* :param pkgconf_cross_personality_t* personality: cross-compile personality to use
|
||||||
* :return: A pkgconf client object.
|
* :return: A pkgconf client object.
|
||||||
* :rtype: pkgconf_client_t*
|
* :rtype: pkgconf_client_t*
|
||||||
*/
|
*/
|
||||||
pkgconf_client_t *
|
pkgconf_client_t *
|
||||||
pkgconf_client_new(pkgconf_error_handler_func_t error_handler, void *error_handler_data)
|
pkgconf_client_new(pkgconf_error_handler_func_t error_handler, void *error_handler_data, const pkgconf_cross_personality_t *personality)
|
||||||
{
|
{
|
||||||
pkgconf_client_t *out = calloc(sizeof(pkgconf_client_t), 1);
|
pkgconf_client_t *out = calloc(sizeof(pkgconf_client_t), 1);
|
||||||
pkgconf_client_init(out, error_handler, error_handler_data);
|
pkgconf_client_init(out, error_handler, error_handler_data, personality);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ typedef struct pkgconf_tuple_ pkgconf_tuple_t;
|
||||||
typedef struct pkgconf_fragment_ pkgconf_fragment_t;
|
typedef struct pkgconf_fragment_ pkgconf_fragment_t;
|
||||||
typedef struct pkgconf_path_ pkgconf_path_t;
|
typedef struct pkgconf_path_ pkgconf_path_t;
|
||||||
typedef struct pkgconf_client_ pkgconf_client_t;
|
typedef struct pkgconf_client_ pkgconf_client_t;
|
||||||
|
typedef struct pkgconf_cross_personality_ pkgconf_cross_personality_t;
|
||||||
|
|
||||||
#define PKGCONF_ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
|
#define PKGCONF_ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
|
||||||
|
|
||||||
|
@ -179,9 +180,20 @@ struct pkgconf_client_ {
|
||||||
bool already_sent_notice;
|
bool already_sent_notice;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct pkgconf_cross_personality_ {
|
||||||
|
const char *name;
|
||||||
|
|
||||||
|
pkgconf_list_t dir_list;
|
||||||
|
|
||||||
|
pkgconf_list_t filter_libdirs;
|
||||||
|
pkgconf_list_t filter_includedirs;
|
||||||
|
|
||||||
|
char *sysroot_dir;
|
||||||
|
};
|
||||||
|
|
||||||
/* client.c */
|
/* client.c */
|
||||||
PKGCONF_API void pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data);
|
PKGCONF_API void pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data, const pkgconf_cross_personality_t *personality);
|
||||||
PKGCONF_API pkgconf_client_t * pkgconf_client_new(pkgconf_error_handler_func_t error_handler, void *error_handler_data);
|
PKGCONF_API pkgconf_client_t * pkgconf_client_new(pkgconf_error_handler_func_t error_handler, void *error_handler_data, const pkgconf_cross_personality_t *personality);
|
||||||
PKGCONF_API void pkgconf_client_deinit(pkgconf_client_t *client);
|
PKGCONF_API void pkgconf_client_deinit(pkgconf_client_t *client);
|
||||||
PKGCONF_API void pkgconf_client_free(pkgconf_client_t *client);
|
PKGCONF_API void pkgconf_client_free(pkgconf_client_t *client);
|
||||||
PKGCONF_API const char *pkgconf_client_get_sysroot_dir(const pkgconf_client_t *client);
|
PKGCONF_API const char *pkgconf_client_get_sysroot_dir(const pkgconf_client_t *client);
|
||||||
|
@ -199,6 +211,9 @@ PKGCONF_API void pkgconf_client_set_error_handler(pkgconf_client_t *client, pkgc
|
||||||
PKGCONF_API pkgconf_error_handler_func_t pkgconf_client_get_trace_handler(const pkgconf_client_t *client);
|
PKGCONF_API pkgconf_error_handler_func_t pkgconf_client_get_trace_handler(const pkgconf_client_t *client);
|
||||||
PKGCONF_API void pkgconf_client_set_trace_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t trace_handler, void *trace_handler_data);
|
PKGCONF_API void pkgconf_client_set_trace_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t trace_handler, void *trace_handler_data);
|
||||||
|
|
||||||
|
/* personality.c */
|
||||||
|
PKGCONF_API const pkgconf_cross_personality_t *pkgconf_cross_personality_default(void);
|
||||||
|
|
||||||
#define PKGCONF_IS_MODULE_SEPARATOR(c) ((c) == ',' || isspace ((unsigned int)(c)))
|
#define PKGCONF_IS_MODULE_SEPARATOR(c) ((c) == ',' || isspace ((unsigned int)(c)))
|
||||||
#define PKGCONF_IS_OPERATOR_CHAR(c) ((c) == '<' || (c) == '>' || (c) == '!' || (c) == '=')
|
#define PKGCONF_IS_OPERATOR_CHAR(c) ((c) == '<' || (c) == '>' || (c) == '!' || (c) == '=')
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* personality.c
|
||||||
|
* libpkgconf cross-compile personality database
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 pkgconf authors (see AUTHORS).
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* This software is provided 'as is' and without any warranty, express or
|
||||||
|
* implied. In no event shall the authors be liable for any damages arising
|
||||||
|
* from the use of this software.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <libpkgconf/stdinc.h>
|
||||||
|
#include <libpkgconf/libpkgconf.h>
|
||||||
|
#include <libpkgconf/config.h>
|
||||||
|
|
||||||
|
static bool default_personality_init = false;
|
||||||
|
static pkgconf_cross_personality_t default_personality = {
|
||||||
|
.name = "default",
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* !doc
|
||||||
|
*
|
||||||
|
* .. c:function:: const pkgconf_cross_personality_t *pkgconf_cross_personality_default(void)
|
||||||
|
*
|
||||||
|
* Returns the default cross-compile personality.
|
||||||
|
*
|
||||||
|
* :rtype: pkgconf_cross_personality_t*
|
||||||
|
* :return: the default cross-compile personality
|
||||||
|
*/
|
||||||
|
const pkgconf_cross_personality_t *
|
||||||
|
pkgconf_cross_personality_default(void)
|
||||||
|
{
|
||||||
|
if (default_personality_init)
|
||||||
|
return &default_personality;
|
||||||
|
|
||||||
|
pkgconf_path_split(SYSTEM_LIBDIR, &default_personality.filter_libdirs, true);
|
||||||
|
pkgconf_path_split(SYSTEM_INCLUDEDIR, &default_personality.filter_includedirs, true);
|
||||||
|
|
||||||
|
default_personality_init = true;
|
||||||
|
return &default_personality;
|
||||||
|
}
|
|
@ -67,6 +67,7 @@ libpkgconf = shared_library('pkgconf',
|
||||||
'libpkgconf/fileio.c',
|
'libpkgconf/fileio.c',
|
||||||
'libpkgconf/fragment.c',
|
'libpkgconf/fragment.c',
|
||||||
'libpkgconf/path.c',
|
'libpkgconf/path.c',
|
||||||
|
'libpkgconf/personality.c',
|
||||||
'libpkgconf/pkg.c',
|
'libpkgconf/pkg.c',
|
||||||
'libpkgconf/queue.c',
|
'libpkgconf/queue.c',
|
||||||
'libpkgconf/tuple.c',
|
'libpkgconf/tuple.c',
|
||||||
|
|
Loading…
Reference in New Issue