forked from ariadne/pkgconf
fragment, pkg: handle --static correctly in some more esoteric scenarios
parent
fa665a40a5
commit
1cc0ae62a9
32
fragment.c
32
fragment.c
|
@ -86,7 +86,7 @@ pkg_fragment_lookup(pkg_list_t *list, pkg_fragment_t *base)
|
||||||
{
|
{
|
||||||
pkg_node_t *node;
|
pkg_node_t *node;
|
||||||
|
|
||||||
PKG_FOREACH_LIST_ENTRY(list->head, node)
|
PKG_FOREACH_LIST_ENTRY_REVERSE(list->tail, node)
|
||||||
{
|
{
|
||||||
pkg_fragment_t *frag = node->data;
|
pkg_fragment_t *frag = node->data;
|
||||||
|
|
||||||
|
@ -101,10 +101,17 @@ pkg_fragment_lookup(pkg_list_t *list, pkg_fragment_t *base)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
pkg_fragment_can_merge_back(pkg_fragment_t *base, unsigned int flags)
|
pkg_fragment_can_merge_back(pkg_fragment_t *base, unsigned int flags, bool is_private)
|
||||||
{
|
{
|
||||||
if ((flags & PKGF_MERGE_PRIVATE_FRAGMENTS) && base->type == 'l')
|
(void) flags;
|
||||||
return false;
|
|
||||||
|
if (base->type == 'l')
|
||||||
|
{
|
||||||
|
if (is_private)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (base->type == 'F')
|
if (base->type == 'F')
|
||||||
return false;
|
return false;
|
||||||
|
@ -113,10 +120,13 @@ pkg_fragment_can_merge_back(pkg_fragment_t *base, unsigned int flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
pkg_fragment_can_merge(pkg_fragment_t *base, unsigned int flags)
|
pkg_fragment_can_merge(pkg_fragment_t *base, unsigned int flags, bool is_private)
|
||||||
{
|
{
|
||||||
(void) flags;
|
(void) flags;
|
||||||
|
|
||||||
|
if (is_private)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!strncmp(base->data, "-framework", 10))
|
if (!strncmp(base->data, "-framework", 10))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -124,25 +134,25 @@ pkg_fragment_can_merge(pkg_fragment_t *base, unsigned int flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline pkg_fragment_t *
|
static inline pkg_fragment_t *
|
||||||
pkg_fragment_exists(pkg_list_t *list, pkg_fragment_t *base, unsigned int flags)
|
pkg_fragment_exists(pkg_list_t *list, pkg_fragment_t *base, unsigned int flags, bool is_private)
|
||||||
{
|
{
|
||||||
if (!pkg_fragment_can_merge_back(base, flags))
|
if (!pkg_fragment_can_merge_back(base, flags, is_private))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!pkg_fragment_can_merge(base, flags))
|
if (!pkg_fragment_can_merge(base, flags, is_private))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return pkg_fragment_lookup(list, base);
|
return pkg_fragment_lookup(list, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pkg_fragment_copy(pkg_list_t *list, pkg_fragment_t *base, unsigned int flags)
|
pkg_fragment_copy(pkg_list_t *list, pkg_fragment_t *base, unsigned int flags, bool is_private)
|
||||||
{
|
{
|
||||||
pkg_fragment_t *frag;
|
pkg_fragment_t *frag;
|
||||||
|
|
||||||
if ((frag = pkg_fragment_exists(list, base, flags)) != NULL)
|
if ((frag = pkg_fragment_exists(list, base, flags, is_private)) != NULL)
|
||||||
pkg_fragment_delete(list, frag);
|
pkg_fragment_delete(list, frag);
|
||||||
else if (!pkg_fragment_can_merge_back(base, flags) && (pkg_fragment_lookup(list, base) != NULL))
|
else if (!is_private && !pkg_fragment_can_merge_back(base, flags, is_private) && (pkg_fragment_lookup(list, base) != NULL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
frag = calloc(sizeof(pkg_fragment_t), 1);
|
frag = calloc(sizeof(pkg_fragment_t), 1);
|
||||||
|
|
11
pkg.c
11
pkg.c
|
@ -972,7 +972,7 @@ pkg_traverse(pkg_t *root,
|
||||||
|
|
||||||
if (flags & PKGF_SEARCH_PRIVATE)
|
if (flags & PKGF_SEARCH_PRIVATE)
|
||||||
{
|
{
|
||||||
eflags = pkg_walk_list(root, &root->requires_private, func, data, maxdepth, rflags);
|
eflags = pkg_walk_list(root, &root->requires_private, func, data, maxdepth, rflags | PKGF_ITER_PKG_IS_PRIVATE);
|
||||||
if (eflags != PKG_ERRF_OK)
|
if (eflags != PKG_ERRF_OK)
|
||||||
return eflags;
|
return eflags;
|
||||||
}
|
}
|
||||||
|
@ -990,8 +990,7 @@ pkg_cflags_collect(pkg_t *pkg, void *data, unsigned int flags)
|
||||||
PKG_FOREACH_LIST_ENTRY(pkg->cflags.head, node)
|
PKG_FOREACH_LIST_ENTRY(pkg->cflags.head, node)
|
||||||
{
|
{
|
||||||
pkg_fragment_t *frag = node->data;
|
pkg_fragment_t *frag = node->data;
|
||||||
|
pkg_fragment_copy(list, frag, flags, false);
|
||||||
pkg_fragment_copy(list, frag, flags);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1006,7 +1005,7 @@ pkg_cflags_private_collect(pkg_t *pkg, void *data, unsigned int flags)
|
||||||
{
|
{
|
||||||
pkg_fragment_t *frag = node->data;
|
pkg_fragment_t *frag = node->data;
|
||||||
|
|
||||||
pkg_fragment_copy(list, frag, flags);
|
pkg_fragment_copy(list, frag, flags, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1039,7 +1038,7 @@ pkg_libs_collect(pkg_t *pkg, void *data, unsigned int flags)
|
||||||
PKG_FOREACH_LIST_ENTRY(pkg->libs.head, node)
|
PKG_FOREACH_LIST_ENTRY(pkg->libs.head, node)
|
||||||
{
|
{
|
||||||
pkg_fragment_t *frag = node->data;
|
pkg_fragment_t *frag = node->data;
|
||||||
pkg_fragment_copy(list, frag, flags);
|
pkg_fragment_copy(list, frag, flags, (flags & PKGF_ITER_PKG_IS_PRIVATE) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & PKGF_MERGE_PRIVATE_FRAGMENTS)
|
if (flags & PKGF_MERGE_PRIVATE_FRAGMENTS)
|
||||||
|
@ -1047,7 +1046,7 @@ pkg_libs_collect(pkg_t *pkg, void *data, unsigned int flags)
|
||||||
PKG_FOREACH_LIST_ENTRY(pkg->libs_private.head, node)
|
PKG_FOREACH_LIST_ENTRY(pkg->libs_private.head, node)
|
||||||
{
|
{
|
||||||
pkg_fragment_t *frag = node->data;
|
pkg_fragment_t *frag = node->data;
|
||||||
pkg_fragment_copy(list, frag, flags);
|
pkg_fragment_copy(list, frag, flags, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
6
pkg.h
6
pkg.h
|
@ -48,6 +48,9 @@ typedef struct pkg_fragment_ pkg_fragment_t;
|
||||||
#define PKG_FOREACH_LIST_ENTRY_SAFE(head, nextiter, value) \
|
#define PKG_FOREACH_LIST_ENTRY_SAFE(head, nextiter, value) \
|
||||||
for ((value) = (head), (nextiter) = (head) != NULL ? (head)->next : NULL; (value) != NULL; (value) = (nextiter), (nextiter) = (nextiter) != NULL ? (nextiter)->next : NULL)
|
for ((value) = (head), (nextiter) = (head) != NULL ? (head)->next : NULL; (value) != NULL; (value) = (nextiter), (nextiter) = (nextiter) != NULL ? (nextiter)->next : NULL)
|
||||||
|
|
||||||
|
#define PKG_FOREACH_LIST_ENTRY_REVERSE(tail, value) \
|
||||||
|
for ((value) = (tail); (value) != NULL; (value) = (value)->prev)
|
||||||
|
|
||||||
#define PKG_MIN(a,b) (((a) < (b)) ? (a) : (b))
|
#define PKG_MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||||
#define PKG_MAX(a,b) (((a) > (b)) ? (a) : (b))
|
#define PKG_MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||||
|
|
||||||
|
@ -119,6 +122,7 @@ struct pkg_ {
|
||||||
#define PKGF_NO_CACHE 0x040
|
#define PKGF_NO_CACHE 0x040
|
||||||
#define PKGF_MUNGE_SYSROOT_PREFIX 0x080
|
#define PKGF_MUNGE_SYSROOT_PREFIX 0x080
|
||||||
#define PKGF_SKIP_ERRORS 0x100
|
#define PKGF_SKIP_ERRORS 0x100
|
||||||
|
#define PKGF_ITER_PKG_IS_PRIVATE 0x200
|
||||||
|
|
||||||
#define PKG_ERRF_OK 0x0
|
#define PKG_ERRF_OK 0x0
|
||||||
#define PKG_ERRF_PACKAGE_NOT_FOUND 0x1
|
#define PKG_ERRF_PACKAGE_NOT_FOUND 0x1
|
||||||
|
@ -159,7 +163,7 @@ void pkg_argv_free(char **argv);
|
||||||
/* fragment.c */
|
/* fragment.c */
|
||||||
void pkg_fragment_parse(pkg_list_t *list, pkg_list_t *vars, const char *value, unsigned int flags);
|
void pkg_fragment_parse(pkg_list_t *list, pkg_list_t *vars, const char *value, unsigned int flags);
|
||||||
void pkg_fragment_add(pkg_list_t *list, const char *string, unsigned int flags);
|
void pkg_fragment_add(pkg_list_t *list, const char *string, unsigned int flags);
|
||||||
void pkg_fragment_copy(pkg_list_t *list, pkg_fragment_t *base, unsigned int flags);
|
void pkg_fragment_copy(pkg_list_t *list, pkg_fragment_t *base, unsigned int flags, bool is_private);
|
||||||
void pkg_fragment_delete(pkg_list_t *list, pkg_fragment_t *node);
|
void pkg_fragment_delete(pkg_list_t *list, pkg_fragment_t *node);
|
||||||
void pkg_fragment_free(pkg_list_t *list);
|
void pkg_fragment_free(pkg_list_t *list);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue