mirror of
https://gitlab.freedesktop.org/pkg-config/pkg-config.git
synced 2026-05-05 14:38:04 +02:00
Merge branch 'flag-order-fixes'
This commit is contained in:
commit
1694230365
9 changed files with 199 additions and 266 deletions
|
|
@ -4,11 +4,12 @@ set -e
|
|||
|
||||
. ${srcdir}/common
|
||||
|
||||
RESULT="-DPATH2 -DFOO -DPATH1 -I/path/include"
|
||||
RESULT="-DPATH2 -DFOO -DPATH1 -DFOO -I/path/include"
|
||||
run_test --cflags flag-dup-1 flag-dup-2
|
||||
run_test --cflags flag-dup-2 flag-dup-1
|
||||
|
||||
RESULT="-Wl,--whole-archive --Wl,--no-whole-archive -Xlinker -R /path/lib \
|
||||
-L/path/lib -lpath2 -lpath1 -lm"
|
||||
RESULT="-L/path/lib -lpath2 -Wl,--whole-archive -lm --Wl,--no-whole-archive \
|
||||
-Xlinker -R -Xlinker /path/lib -lpath1 -Wl,--whole-archive -lm \
|
||||
--Wl,--no-whole-archive -Xlinker -R -Xlinker /path/lib"
|
||||
run_test --libs flag-dup-1 flag-dup-2
|
||||
run_test --libs flag-dup-2 flag-dup-1
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ PKG_CONFIG_LIBDIR=${srcdir}/gtk
|
|||
RESULT="-DGSEAL_ENABLE -pthread -I/gtk/include/gtk-3.0 \
|
||||
-I/gtk/include/pango-1.0 -I/gtk/include/atk-1.0 -I/gtk/include/cairo \
|
||||
-I/gtk/include/pixman-1 -I/gtk/include -I/gtk/include/gdk-pixbuf-2.0 \
|
||||
-I/gtk/include/glib-2.0 -I/gtk/lib/glib-2.0/include -I/gtk/include/freetype2"
|
||||
-I/gtk/include -I/gtk/include/pango-1.0 -I/gtk/include/glib-2.0 \
|
||||
-I/gtk/lib/glib-2.0/include -I/gtk/include/freetype2 -I/gtk/include"
|
||||
run_test --cflags gtk+-3.0
|
||||
run_test --cflags --static gtk+-3.0
|
||||
|
||||
|
|
@ -26,10 +27,10 @@ run_test --cflags --static gtk+-3.0
|
|||
# -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lcairo -lpango-1.0 \
|
||||
# -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt \
|
||||
# -lglib-2.0
|
||||
RESULT="-pthread -L/gtk/lib -lgtk-3 -lgdk-3 -lpangocairo-1.0 -latk-1.0 \
|
||||
-lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 \
|
||||
-lpango-1.0 -lgobject-2.0 -lgthread-2.0 -lgmodule-2.0 -lrt -lglib-2.0 \
|
||||
-lfreetype -lfontconfig"
|
||||
RESULT="-L/gtk/lib -lgtk-3 -lgdk-3 -lpangocairo-1.0 -latk-1.0 -lcairo-gobject \
|
||||
-lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 \
|
||||
-lgthread-2.0 -pthread -lrt -lgmodule-2.0 -pthread -lrt -lglib-2.0 -lfreetype \
|
||||
-lfontconfig"
|
||||
if [ "$list_indirect_deps" = no ]; then
|
||||
run_test --libs gtk+-3.0
|
||||
fi
|
||||
|
|
@ -47,11 +48,11 @@ fi
|
|||
# -lpixman-1 -lXrender -lX11 -lpthread -lxcb -lXau -lpng12 -lz -lm \
|
||||
# -lpango-1.0 -lfontconfig -lexpat -lfreetype -lgobject-2.0 -lffi \
|
||||
# -lgmodule-2.0 -ldl -lgthread-2.0 -lglib-2.0 -lrt
|
||||
RESULT="-pthread -L/gtk/lib -lgtk-3 -lgdk-3 -lpangocairo-1.0 -latk-1.0 \
|
||||
-lcairo-gobject -lcairo -lpixman-1 -lXrender -lX11 -lpthread -lxcb -lXau \
|
||||
-lgdk_pixbuf-2.0 -lpng12 -lm -lgio-2.0 -lz -lresolv -lpangoft2-1.0 \
|
||||
-lpango-1.0 -lgobject-2.0 -lffi -lgthread-2.0 -lgmodule-2.0 -ldl -lglib-2.0 \
|
||||
-lrt -lfontconfig -lexpat -lfreetype"
|
||||
RESULT="-L/gtk/lib -lgtk-3 -lgdk-3 -lpangocairo-1.0 -latk-1.0 -lcairo-gobject \
|
||||
-lcairo -lz -lpixman-1 -lpng12 -lz -lm -lXrender -lX11 -lpthread -lxcb -lXau \
|
||||
-lgdk_pixbuf-2.0 -lm -lpng12 -lz -lm -lgio-2.0 -lz -lresolv -lpangoft2-1.0 \
|
||||
-lpango-1.0 -lgobject-2.0 -lffi -lgthread-2.0 -pthread -lrt -lgmodule-2.0 \
|
||||
-pthread -lrt -ldl -lglib-2.0 -lrt -lfreetype -lfontconfig -lexpat -lfreetype"
|
||||
if [ "$list_indirect_deps" = yes ]; then
|
||||
run_test --libs gtk+-3.0
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ run_test --libs --static simple
|
|||
RESULT=""
|
||||
run_test --libs fields-blank
|
||||
|
||||
RESULT="-Wl,--as-needed -L/other/lib -lother"
|
||||
RESULT="-L/other/lib -Wl,--as-needed -lother"
|
||||
run_test --libs other
|
||||
|
||||
RESULT="-lother"
|
||||
|
|
@ -39,11 +39,11 @@ RESULT="-Wl,--as-needed -lother"
|
|||
run_test --libs-only-l --libs-only-other other
|
||||
run_test --libs-only-other --libs-only-l other
|
||||
|
||||
RESULT="-Wl,--as-needed -L/other/lib"
|
||||
RESULT="-L/other/lib -Wl,--as-needed"
|
||||
run_test --libs-only-L --libs-only-other other
|
||||
run_test --libs-only-other --libs-only-L other
|
||||
|
||||
RESULT="-Wl,--as-needed -L/other/lib -lother"
|
||||
RESULT="-L/other/lib -Wl,--as-needed -lother"
|
||||
run_test --libs-only-l --libs-only-L --libs-only-other other
|
||||
run_test --libs --libs-only-l --libs-only-L --libs-only-other other
|
||||
run_test --libs --libs-only-l other
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ set -e
|
|||
|
||||
. ${srcdir}/common
|
||||
|
||||
RESULT="-DOTHER -I/other/include -Wl,--as-needed -L/other/lib -lother"
|
||||
RESULT="-DOTHER -I/other/include -L/other/lib -Wl,--as-needed -lother"
|
||||
run_test --cflags --libs other
|
||||
run_test --libs --cflags other
|
||||
run_test --cflags-only-I --cflags-only-other --libs-only-l --libs-only-L \
|
||||
|
|
@ -50,11 +50,11 @@ RESULT="-DOTHER -Wl,--as-needed -lother"
|
|||
run_test --cflags-only-other --libs-only-other --libs-only-l other
|
||||
run_test --libs-only-l --libs-only-other --cflags-only-other other
|
||||
|
||||
RESULT="-I/other/include -Wl,--as-needed -L/other/lib"
|
||||
RESULT="-I/other/include -L/other/lib -Wl,--as-needed"
|
||||
run_test --cflags-only-I --libs-only-other --libs-only-L other
|
||||
run_test --libs-only-L --libs-only-other --cflags-only-I other
|
||||
|
||||
RESULT="-DOTHER -Wl,--as-needed -L/other/lib"
|
||||
RESULT="-DOTHER -L/other/lib -Wl,--as-needed"
|
||||
run_test --cflags-only-other --libs-only-other --libs-only-L other
|
||||
run_test --libs-only-L --libs-only-other --cflags-only-other other
|
||||
|
||||
|
|
@ -70,10 +70,10 @@ RESULT="-DOTHER -I/other/include -Wl,--as-needed"
|
|||
run_test --cflags --libs-only-other other
|
||||
run_test --cflags-only-I --cflags-only-other --libs-only-other other
|
||||
|
||||
RESULT="-I/other/include -Wl,--as-needed -L/other/lib -lother"
|
||||
RESULT="-I/other/include -L/other/lib -Wl,--as-needed -lother"
|
||||
run_test --cflags-only-I --libs other
|
||||
run_test --cflags-only-I --libs-only-l --libs-only-L --libs-only-other other
|
||||
|
||||
RESULT="-DOTHER -Wl,--as-needed -L/other/lib -lother"
|
||||
RESULT="-DOTHER -L/other/lib -Wl,--as-needed -lother"
|
||||
run_test --cflags-only-other --libs other
|
||||
run_test --cflags-only-other --libs-only-l --libs-only-L --libs-only-other other
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ run_test --cflags sort-order-2-1 sort-order-1-1 sort-order-3-1
|
|||
run_test --cflags sort-order-1-1 sort-order-3-1 sort-order-2-1
|
||||
run_test --cflags sort-order-1-1 sort-order-2-1 sort-order-3-1
|
||||
|
||||
RESULT="-Wl,-O3 -Wl,-O2 -Wl,-O1 -L/path3/lib -L/path2/lib -L/path1/lib \
|
||||
-lpath3 -lpath2 -lpath1"
|
||||
RESULT="-L/path3/lib -L/path2/lib -L/path1/lib -Wl,-O3 -lpath3 -Wl,-O2 \
|
||||
-lpath2 -Wl,-O1 -lpath1"
|
||||
run_test --libs sort-order-3-1
|
||||
run_test --libs sort-order-3-1 sort-order-2-1
|
||||
run_test --libs sort-order-2-1 sort-order-3-1
|
||||
|
|
@ -78,8 +78,8 @@ run_test --cflags sort-order-2-2 sort-order-1-2 sort-order-3-2
|
|||
run_test --cflags sort-order-1-2 sort-order-3-2 sort-order-2-2
|
||||
run_test --cflags sort-order-1-2 sort-order-2-2 sort-order-3-2
|
||||
|
||||
RESULT="-Wl,-O3 -Wl,-O2 -Wl,-O1 -L/path3/lib -L/path2/lib -L/path1/lib \
|
||||
-lpath3 -lpath2 -lpath1"
|
||||
RESULT="-L/path3/lib -L/path2/lib -L/path1/lib -Wl,-O3 -lpath3 -Wl,-O2 \
|
||||
-lpath2 -Wl,-O1 -lpath1"
|
||||
run_test --libs sort-order-3-2
|
||||
run_test --libs sort-order-3-2 sort-order-2-2
|
||||
run_test --libs sort-order-2-2 sort-order-3-2
|
||||
|
|
@ -91,7 +91,7 @@ run_test --libs sort-order-1-2 sort-order-3-2 sort-order-2-2
|
|||
run_test --libs sort-order-1-2 sort-order-2-2 sort-order-3-2
|
||||
|
||||
# Check package set -3
|
||||
RESULT="-DPATH3 -DPATH2 -DPATH1 -I/path3/include -I/path2/include \
|
||||
RESULT="-DPATH1 -DPATH2 -DPATH3 -I/path3/include -I/path2/include \
|
||||
-I/path1/include"
|
||||
run_test --cflags sort-order-1-3
|
||||
run_test --cflags sort-order-1-3 sort-order-2-3
|
||||
|
|
@ -103,8 +103,8 @@ run_test --cflags sort-order-2-3 sort-order-1-3 sort-order-3-3
|
|||
run_test --cflags sort-order-1-3 sort-order-3-3 sort-order-2-3
|
||||
run_test --cflags sort-order-1-3 sort-order-2-3 sort-order-3-3
|
||||
|
||||
RESULT="-Wl,-O3 -Wl,-O2 -Wl,-O1 -L/path3/lib -L/path2/lib -L/path1/lib \
|
||||
-lpath1 -lpath2 -lpath3"
|
||||
RESULT="-L/path3/lib -L/path2/lib -L/path1/lib -Wl,-O1 -lpath1 -Wl,-O2 \
|
||||
-lpath2 -Wl,-O3 -lpath3"
|
||||
run_test --libs sort-order-1-3
|
||||
run_test --libs sort-order-1-3 sort-order-2-3
|
||||
run_test --libs sort-order-2-3 sort-order-1-3
|
||||
|
|
@ -119,7 +119,7 @@ run_test --libs sort-order-1-3 sort-order-2-3 sort-order-3-3
|
|||
PKG_CONFIG_PATH="$order2"
|
||||
|
||||
# Check package set -1
|
||||
RESULT="-DPATH2 -DPATH3 -DPATH1 -I/path2/include -I/path3/include \
|
||||
RESULT="-DPATH3 -DPATH2 -DPATH1 -I/path2/include -I/path3/include \
|
||||
-I/path1/include"
|
||||
run_test --cflags sort-order-3-1
|
||||
run_test --cflags sort-order-3-1 sort-order-2-1
|
||||
|
|
@ -131,8 +131,8 @@ run_test --cflags sort-order-2-1 sort-order-1-1 sort-order-3-1
|
|||
run_test --cflags sort-order-1-1 sort-order-3-1 sort-order-2-1
|
||||
run_test --cflags sort-order-1-1 sort-order-2-1 sort-order-3-1
|
||||
|
||||
RESULT="-Wl,-O2 -Wl,-O3 -Wl,-O1 -L/path2/lib -L/path3/lib -L/path1/lib \
|
||||
-lpath3 -lpath2 -lpath1"
|
||||
RESULT="-L/path2/lib -L/path3/lib -L/path1/lib -Wl,-O3 -lpath3 -Wl,-O2 \
|
||||
-lpath2 -Wl,-O1 -lpath1"
|
||||
run_test --libs sort-order-3-1
|
||||
run_test --libs sort-order-3-1 sort-order-2-1
|
||||
run_test --libs sort-order-2-1 sort-order-3-1
|
||||
|
|
@ -144,7 +144,7 @@ run_test --libs sort-order-1-1 sort-order-3-1 sort-order-2-1
|
|||
run_test --libs sort-order-1-1 sort-order-2-1 sort-order-3-1
|
||||
|
||||
# Check package set -2
|
||||
RESULT="-DPATH2 -DPATH3 -DPATH1 -I/path2/include -I/path3/include \
|
||||
RESULT="-DPATH3 -DPATH2 -DPATH1 -I/path2/include -I/path3/include \
|
||||
-I/path1/include"
|
||||
run_test --cflags sort-order-3-2
|
||||
run_test --cflags sort-order-3-2 sort-order-2-2
|
||||
|
|
@ -156,8 +156,8 @@ run_test --cflags sort-order-2-2 sort-order-1-2 sort-order-3-2
|
|||
run_test --cflags sort-order-1-2 sort-order-3-2 sort-order-2-2
|
||||
run_test --cflags sort-order-1-2 sort-order-2-2 sort-order-3-2
|
||||
|
||||
RESULT="-Wl,-O2 -Wl,-O3 -Wl,-O1 -L/path2/lib -L/path3/lib -L/path1/lib \
|
||||
-lpath3 -lpath2 -lpath1"
|
||||
RESULT="-L/path2/lib -L/path3/lib -L/path1/lib -Wl,-O3 -lpath3 -Wl,-O2 \
|
||||
-lpath2 -Wl,-O1 -lpath1"
|
||||
run_test --libs sort-order-3-2
|
||||
run_test --libs sort-order-3-2 sort-order-2-2
|
||||
run_test --libs sort-order-2-2 sort-order-3-2
|
||||
|
|
@ -169,7 +169,7 @@ run_test --libs sort-order-1-2 sort-order-3-2 sort-order-2-2
|
|||
run_test --libs sort-order-1-2 sort-order-2-2 sort-order-3-2
|
||||
|
||||
# Check package set -3
|
||||
RESULT="-DPATH2 -DPATH3 -DPATH1 -I/path2/include -I/path3/include \
|
||||
RESULT="-DPATH1 -DPATH2 -DPATH3 -I/path2/include -I/path3/include \
|
||||
-I/path1/include"
|
||||
run_test --cflags sort-order-1-3
|
||||
run_test --cflags sort-order-1-3 sort-order-2-3
|
||||
|
|
@ -181,8 +181,8 @@ run_test --cflags sort-order-2-3 sort-order-1-3 sort-order-3-3
|
|||
run_test --cflags sort-order-1-3 sort-order-3-3 sort-order-2-3
|
||||
run_test --cflags sort-order-1-3 sort-order-2-3 sort-order-3-3
|
||||
|
||||
RESULT="-Wl,-O2 -Wl,-O3 -Wl,-O1 -L/path2/lib -L/path3/lib -L/path1/lib \
|
||||
-lpath1 -lpath2 -lpath3"
|
||||
RESULT="-L/path2/lib -L/path3/lib -L/path1/lib -Wl,-O1 -lpath1 -Wl,-O2 \
|
||||
-lpath2 -Wl,-O3 -lpath3"
|
||||
run_test --libs sort-order-1-3
|
||||
run_test --libs sort-order-1-3 sort-order-2-3
|
||||
run_test --libs sort-order-2-3 sort-order-1-3
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@ RESULT='-Dlala=misc -I/usr/white\ space/include -I$(top_builddir) -Iinclude\ dir
|
|||
run_test --cflags whitespace
|
||||
|
||||
# expect libs from whitespace
|
||||
RESULT="-r:foo -L/usr/white\\ space/lib -lfoo\\ bar -lbar\\ baz"
|
||||
RESULT="-L/usr/white\\ space/lib -lfoo\\ bar -lbar\\ baz -r:foo"
|
||||
run_test --libs whitespace
|
||||
|
|
|
|||
88
parse.c
88
parse.c
|
|
@ -616,6 +616,7 @@ static void _do_parse_libs (Package *pkg, int argc, char **argv)
|
|||
i = 0;
|
||||
while (i < argc)
|
||||
{
|
||||
Flag *flag = g_new (Flag, 1);
|
||||
char *tmp = trim_string (argv[i]);
|
||||
char *arg = strdup_escape_shell(tmp);
|
||||
char *p;
|
||||
|
|
@ -632,9 +633,9 @@ static void _do_parse_libs (Package *pkg, int argc, char **argv)
|
|||
while (*p && isspace ((guchar)*p))
|
||||
++p;
|
||||
|
||||
pkg->l_libs = g_list_prepend (pkg->l_libs,
|
||||
g_strconcat (l_flag, p, lib_suffix, NULL));
|
||||
|
||||
flag->type = LIBS_l;
|
||||
flag->arg = g_strconcat (l_flag, p, lib_suffix, NULL);
|
||||
pkg->libs = g_list_prepend (pkg->libs, flag);
|
||||
}
|
||||
else if (p[0] == '-' &&
|
||||
p[1] == 'L')
|
||||
|
|
@ -642,8 +643,10 @@ static void _do_parse_libs (Package *pkg, int argc, char **argv)
|
|||
p += 2;
|
||||
while (*p && isspace ((guchar)*p))
|
||||
++p;
|
||||
pkg->L_libs = g_list_prepend (pkg->L_libs,
|
||||
g_strconcat (L_flag, p, NULL));
|
||||
|
||||
flag->type = LIBS_L;
|
||||
flag->arg = g_strconcat (L_flag, p, lib_suffix, NULL);
|
||||
pkg->libs = g_list_prepend (pkg->libs, flag);
|
||||
}
|
||||
else if (strcmp("-framework",p) == 0 && i+1 < argc)
|
||||
{
|
||||
|
|
@ -654,19 +657,23 @@ static void _do_parse_libs (Package *pkg, int argc, char **argv)
|
|||
*/
|
||||
gchar *framework, *tmp = trim_string (argv[i+1]);
|
||||
|
||||
framework = strdup_escape_shell(tmp);
|
||||
pkg->other_libs = g_list_prepend (pkg->other_libs,
|
||||
g_strconcat(arg, " ", framework, NULL));
|
||||
framework = strdup_escape_shell(tmp);
|
||||
flag->type = LIBS_OTHER;
|
||||
flag->arg = g_strconcat (arg, " ", framework, NULL);
|
||||
pkg->libs = g_list_prepend (pkg->libs, flag);
|
||||
i++;
|
||||
g_free(framework);
|
||||
g_free(tmp);
|
||||
g_free (framework);
|
||||
g_free (tmp);
|
||||
}
|
||||
else if (*arg != '\0')
|
||||
{
|
||||
flag->type = LIBS_OTHER;
|
||||
flag->arg = g_strdup (arg);
|
||||
pkg->libs = g_list_prepend (pkg->libs, flag);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*arg != '\0')
|
||||
pkg->other_libs = g_list_prepend (pkg->other_libs,
|
||||
g_strdup (arg));
|
||||
}
|
||||
/* flag wasn't used */
|
||||
g_free (flag);
|
||||
|
||||
g_free (arg);
|
||||
|
||||
|
|
@ -766,7 +773,7 @@ parse_cflags (Package *pkg, const char *str, const char *path)
|
|||
GError *error = NULL;
|
||||
int i;
|
||||
|
||||
if (pkg->I_cflags || pkg->other_cflags)
|
||||
if (pkg->cflags)
|
||||
{
|
||||
verbose_error ("Cflags field occurs twice in '%s'\n", path);
|
||||
|
||||
|
|
@ -786,6 +793,7 @@ parse_cflags (Package *pkg, const char *str, const char *path)
|
|||
i = 0;
|
||||
while (i < argc)
|
||||
{
|
||||
Flag *flag = g_new (Flag, 1);
|
||||
char *tmp = trim_string (argv[i]);
|
||||
char *arg = strdup_escape_shell(tmp);
|
||||
char *p = arg;
|
||||
|
|
@ -798,22 +806,32 @@ parse_cflags (Package *pkg, const char *str, const char *path)
|
|||
while (*p && isspace ((guchar)*p))
|
||||
++p;
|
||||
|
||||
pkg->I_cflags = g_list_prepend (pkg->I_cflags,
|
||||
g_strconcat ("-I", p, NULL));
|
||||
flag->type = CFLAGS_I;
|
||||
flag->arg = g_strconcat ("-I", p, NULL);
|
||||
pkg->cflags = g_list_prepend (pkg->cflags, flag);
|
||||
}
|
||||
else if (strcmp("-idirafter", arg) == 0 && i+1 < argc)
|
||||
{
|
||||
char *dirafter, *tmp;
|
||||
|
||||
} else {
|
||||
if (*arg != '\0')
|
||||
pkg->other_cflags = g_list_prepend (pkg->other_cflags,
|
||||
g_strdup (arg));
|
||||
if (strcmp("-idirafter", arg) == 0) {
|
||||
char *n;
|
||||
|
||||
tmp = trim_string(argv[++i]);
|
||||
n = strdup_escape_shell(tmp);
|
||||
pkg->other_cflags = g_list_prepend (pkg->other_cflags, n);
|
||||
g_free(tmp);
|
||||
}
|
||||
}
|
||||
tmp = trim_string (argv[i+1]);
|
||||
dirafter = strdup_escape_shell (tmp);
|
||||
flag->type = CFLAGS_OTHER;
|
||||
flag->arg = g_strconcat (arg, " ", dirafter, NULL);
|
||||
pkg->cflags = g_list_prepend (pkg->cflags, flag);
|
||||
i++;
|
||||
g_free (dirafter);
|
||||
g_free (tmp);
|
||||
}
|
||||
else if (*arg != '\0')
|
||||
{
|
||||
flag->type = CFLAGS_OTHER;
|
||||
flag->arg = g_strdup (arg);
|
||||
pkg->cflags = g_list_prepend (pkg->cflags, flag);
|
||||
}
|
||||
else
|
||||
/* flag wasn't used */
|
||||
g_free (flag);
|
||||
|
||||
g_free (arg);
|
||||
|
||||
|
|
@ -1093,12 +1111,8 @@ parse_package_file (const char *path, gboolean ignore_requires,
|
|||
g_string_free (str, TRUE);
|
||||
fclose(f);
|
||||
|
||||
pkg->I_cflags = g_list_reverse (pkg->I_cflags);
|
||||
pkg->other_cflags = g_list_reverse (pkg->other_cflags);
|
||||
|
||||
pkg->l_libs = g_list_reverse (pkg->l_libs);
|
||||
pkg->L_libs = g_list_reverse (pkg->L_libs);
|
||||
pkg->other_libs = g_list_reverse (pkg->other_libs);
|
||||
pkg->cflags = g_list_reverse (pkg->cflags);
|
||||
pkg->libs = g_list_reverse (pkg->libs);
|
||||
|
||||
return pkg;
|
||||
}
|
||||
|
|
|
|||
285
pkg.c
285
pkg.c
|
|
@ -424,66 +424,36 @@ get_package_quiet (const char *name)
|
|||
return internal_get_package (name, FALSE);
|
||||
}
|
||||
|
||||
/* Strip consecutive duplicate arguments in the flag list. */
|
||||
static GList *
|
||||
string_list_strip_duplicates (GList *list)
|
||||
flag_list_strip_duplicates (GList *list)
|
||||
{
|
||||
GHashTable *table;
|
||||
GList *tmp;
|
||||
|
||||
table = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
for (tmp = list; tmp != NULL; tmp = g_list_next (tmp))
|
||||
/* Start at the 2nd element of the list so we don't have to check for an
|
||||
* existing previous element. */
|
||||
for (tmp = g_list_next (list); tmp != NULL; tmp = g_list_next (tmp))
|
||||
{
|
||||
if (!g_hash_table_lookup_extended (table, tmp->data, NULL, NULL))
|
||||
{
|
||||
/* Unique string. Track it and and move to the next. */
|
||||
g_hash_table_replace (table, tmp->data, tmp->data);
|
||||
}
|
||||
else
|
||||
Flag *cur = tmp->data;
|
||||
Flag *prev = tmp->prev->data;
|
||||
|
||||
if (cur->type == prev->type && g_strcmp0 (cur->arg, prev->arg) == 0)
|
||||
{
|
||||
/* Remove the duplicate flag from the list and move to the last
|
||||
* element to prepare for the next iteration. */
|
||||
GList *dup = tmp;
|
||||
|
||||
/* Remove the duplicate string from the list. */
|
||||
debug_spew (" removing duplicate \"%s\"\n", tmp->data);
|
||||
tmp = tmp->prev;
|
||||
debug_spew (" removing duplicate \"%s\"\n", cur->arg);
|
||||
tmp = g_list_previous (tmp);
|
||||
list = g_list_remove_link (list, dup);
|
||||
}
|
||||
}
|
||||
g_hash_table_destroy (table);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static GList *
|
||||
string_list_strip_duplicates_from_back (GList *list)
|
||||
{
|
||||
GHashTable *table;
|
||||
GList *tmp;
|
||||
|
||||
table = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
for (tmp = g_list_last (list); tmp != NULL; tmp = g_list_previous (tmp))
|
||||
{
|
||||
if (!g_hash_table_lookup_extended (table, tmp->data, NULL, NULL))
|
||||
{
|
||||
/* Unique string. Track it and and move to the next. */
|
||||
g_hash_table_replace (table, tmp->data, tmp->data);
|
||||
}
|
||||
else
|
||||
{
|
||||
GList *dup = tmp;
|
||||
|
||||
/* Remove the duplicate string from the list. */
|
||||
debug_spew (" removing duplicate (from back) \"%s\"\n", tmp->data);
|
||||
tmp = tmp->next;
|
||||
list = g_list_remove_link (list, dup);
|
||||
}
|
||||
}
|
||||
g_hash_table_destroy (table);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static char *
|
||||
string_list_to_string (GList *list)
|
||||
flag_list_to_string (GList *list)
|
||||
{
|
||||
GList *tmp;
|
||||
GString *str = g_string_new ("");
|
||||
|
|
@ -491,11 +461,10 @@ string_list_to_string (GList *list)
|
|||
|
||||
tmp = list;
|
||||
while (tmp != NULL) {
|
||||
char *tmpstr = (char*) tmp->data;
|
||||
if (pcsysrootdir != NULL &&
|
||||
tmpstr[0] == '-' &&
|
||||
(tmpstr[1] == 'I' ||
|
||||
tmpstr[1] == 'L')) {
|
||||
Flag *flag = tmp->data;
|
||||
char *tmpstr = flag->arg;
|
||||
|
||||
if (pcsysrootdir != NULL && flag->type & (CFLAGS_I | LIBS_L)) {
|
||||
g_string_append_c (str, '-');
|
||||
g_string_append_c (str, tmpstr[1]);
|
||||
g_string_append (str, pcsysrootdir);
|
||||
|
|
@ -513,56 +482,6 @@ string_list_to_string (GList *list)
|
|||
return retval;
|
||||
}
|
||||
|
||||
typedef GList *(* GetListFunc) (Package *pkg);
|
||||
|
||||
static GList *
|
||||
get_l_libs (Package *pkg)
|
||||
{
|
||||
return pkg->l_libs;
|
||||
}
|
||||
|
||||
static GList *
|
||||
get_L_libs (Package *pkg)
|
||||
{
|
||||
return pkg->L_libs;
|
||||
}
|
||||
|
||||
static GList *
|
||||
get_other_libs (Package *pkg)
|
||||
{
|
||||
return pkg->other_libs;
|
||||
}
|
||||
|
||||
static GList *
|
||||
get_I_cflags (Package *pkg)
|
||||
{
|
||||
return pkg->I_cflags;
|
||||
}
|
||||
|
||||
static GList *
|
||||
get_other_cflags (Package *pkg)
|
||||
{
|
||||
return pkg->other_cflags;
|
||||
}
|
||||
|
||||
static GList *
|
||||
get_conflicts (Package *pkg)
|
||||
{
|
||||
return pkg->conflicts;
|
||||
}
|
||||
|
||||
static GList *
|
||||
get_requires (Package *pkg)
|
||||
{
|
||||
return pkg->requires;
|
||||
}
|
||||
|
||||
static GList *
|
||||
get_requires_private (Package *pkg)
|
||||
{
|
||||
return pkg->requires_private;
|
||||
}
|
||||
|
||||
static int
|
||||
pathposcmp (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
|
|
@ -603,16 +522,10 @@ packages_sort_by_path_position (GList *list)
|
|||
}
|
||||
|
||||
static void
|
||||
recursive_fill_list (Package *pkg, GetListFunc func, GList **listp)
|
||||
recursive_fill_list (Package *pkg, gboolean include_private, GList **listp)
|
||||
{
|
||||
GList *tmp;
|
||||
|
||||
/*
|
||||
* This function should only be called to resolve Requires or
|
||||
* Requires.private.
|
||||
*/
|
||||
g_assert (func == get_requires || func == get_requires_private);
|
||||
|
||||
/*
|
||||
* If the package is one of the parents, we can skip it. This allows
|
||||
* circular requires loops to be broken.
|
||||
|
|
@ -629,9 +542,9 @@ recursive_fill_list (Package *pkg, GetListFunc func, GList **listp)
|
|||
|
||||
/* Start from the end of the required package list to maintain order since
|
||||
* the recursive list is built by prepending. */
|
||||
for (tmp = g_list_last ((*func) (pkg)); tmp != NULL;
|
||||
tmp = g_list_previous (tmp))
|
||||
recursive_fill_list (tmp->data, func, listp);
|
||||
tmp = include_private ? pkg->requires_private : pkg->requires;
|
||||
for (tmp = g_list_last (tmp); tmp != NULL; tmp = g_list_previous (tmp))
|
||||
recursive_fill_list (tmp->data, include_private, listp);
|
||||
|
||||
*listp = g_list_prepend (*listp, pkg);
|
||||
|
||||
|
|
@ -640,27 +553,37 @@ recursive_fill_list (Package *pkg, GetListFunc func, GList **listp)
|
|||
}
|
||||
|
||||
/* merge the flags from the individual packages */
|
||||
static void
|
||||
merge_flag_lists (GList *packages, GetListFunc func, GList **listp)
|
||||
static GList *
|
||||
merge_flag_lists (GList *packages, FlagType type)
|
||||
{
|
||||
GList *pkg;
|
||||
GList *last = NULL;
|
||||
GList *flags;
|
||||
GList *merged = NULL;
|
||||
|
||||
/* keep track of the last element to avoid traversing the whole list */
|
||||
for (pkg = packages; pkg != NULL; pkg = pkg->next)
|
||||
for (; packages != NULL; packages = g_list_next (packages))
|
||||
{
|
||||
for (flags = (*func) (pkg->data); flags != NULL; flags = flags->next)
|
||||
Package *pkg = packages->data;
|
||||
GList *flags = (type & LIBS_ANY) ? pkg->libs : pkg->cflags;
|
||||
|
||||
/* manually copy the elements so we can keep track of the end */
|
||||
for (; flags != NULL; flags = g_list_next (flags))
|
||||
{
|
||||
if (last == NULL)
|
||||
Flag *flag = flags->data;
|
||||
|
||||
if (flag->type & type)
|
||||
{
|
||||
*listp = g_list_prepend (NULL, flags->data);
|
||||
last = *listp;
|
||||
if (last == NULL)
|
||||
{
|
||||
merged = g_list_prepend (NULL, flags->data);
|
||||
last = merged;
|
||||
}
|
||||
else
|
||||
last = g_list_next (g_list_append (last, flags->data));
|
||||
}
|
||||
else
|
||||
last = g_list_next (g_list_append (last, flags->data));
|
||||
}
|
||||
}
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
/* Work backwards from the end of the package list to remove duplicate
|
||||
|
|
@ -700,19 +623,18 @@ package_list_strip_duplicates (GList *packages)
|
|||
return packages;
|
||||
}
|
||||
|
||||
static void
|
||||
fill_list (GList *packages, GetListFunc func,
|
||||
GList **listp, gboolean in_path_order, gboolean include_private)
|
||||
static GList *
|
||||
fill_list (GList *packages, FlagType type,
|
||||
gboolean in_path_order, gboolean include_private)
|
||||
{
|
||||
GList *tmp;
|
||||
GList *expanded = NULL;
|
||||
GList *flags;
|
||||
|
||||
/* Start from the end of the requested package list to maintain order since
|
||||
* the recursive list is built by prepending. */
|
||||
for (tmp = g_list_last (packages); tmp != NULL; tmp = g_list_previous (tmp))
|
||||
recursive_fill_list (tmp->data,
|
||||
include_private ? get_requires_private : get_requires,
|
||||
&expanded);
|
||||
recursive_fill_list (tmp->data, include_private, &expanded);
|
||||
|
||||
/* Remove duplicate packages from the recursive list. This should provide a
|
||||
* serialized package list where all interdependencies are resolved
|
||||
|
|
@ -728,9 +650,10 @@ fill_list (GList *packages, GetListFunc func,
|
|||
spew_package_list (" sorted", expanded);
|
||||
}
|
||||
|
||||
merge_flag_lists (expanded, func, listp);
|
||||
|
||||
flags = merge_flag_lists (expanded, type);
|
||||
g_list_free (expanded);
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
static GList *
|
||||
|
|
@ -829,8 +752,8 @@ verify_package (Package *pkg)
|
|||
/* Make sure we didn't drag in any conflicts via Requires
|
||||
* (inefficient algorithm, who cares)
|
||||
*/
|
||||
recursive_fill_list (pkg, get_requires_private, &requires);
|
||||
conflicts = get_conflicts (pkg);
|
||||
recursive_fill_list (pkg, TRUE, &requires);
|
||||
conflicts = pkg->conflicts;
|
||||
|
||||
requires_iter = requires;
|
||||
while (requires_iter != NULL)
|
||||
|
|
@ -894,15 +817,19 @@ verify_package (Package *pkg)
|
|||
}
|
||||
|
||||
count = 0;
|
||||
iter = pkg->I_cflags;
|
||||
while (iter != NULL)
|
||||
for (iter = pkg->cflags; iter != NULL; iter = g_list_next (iter))
|
||||
{
|
||||
gint offset = 0;
|
||||
Flag *flag = iter->data;
|
||||
|
||||
if (!(flag->type & CFLAGS_I))
|
||||
continue;
|
||||
|
||||
/* we put things in canonical -I/usr/include (vs. -I /usr/include) format,
|
||||
* but if someone changes it later we may as well be robust
|
||||
*/
|
||||
if (((strncmp (iter->data, "-I", 2) == 0) && (offset = 2))||
|
||||
((strncmp (iter->data, "-I ", 3) == 0) && (offset = 3)))
|
||||
if (((strncmp (flag->arg, "-I", 2) == 0) && (offset = 2))||
|
||||
((strncmp (flag->arg, "-I ", 3) == 0) && (offset = 3)))
|
||||
{
|
||||
if (offset == 0)
|
||||
{
|
||||
|
|
@ -914,29 +841,28 @@ verify_package (Package *pkg)
|
|||
while (system_dir_iter != NULL)
|
||||
{
|
||||
if (strcmp (system_dir_iter->data,
|
||||
((char*)iter->data) + offset) == 0)
|
||||
((char*)flag->arg) + offset) == 0)
|
||||
{
|
||||
debug_spew ("Package %s has %s in Cflags\n",
|
||||
pkg->key, (gchar *)iter->data);
|
||||
debug_spew ("Package %s has %s in Cflags\n",
|
||||
pkg->key, (gchar *)flag->arg);
|
||||
if (g_getenv ("PKG_CONFIG_ALLOW_SYSTEM_CFLAGS") == NULL)
|
||||
{
|
||||
debug_spew ("Removing %s from cflags for %s\n", iter->data, pkg->key);
|
||||
debug_spew ("Removing %s from cflags for %s\n",
|
||||
flag->arg, pkg->key);
|
||||
++count;
|
||||
iter->data = NULL;
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
system_dir_iter = system_dir_iter->next;
|
||||
}
|
||||
}
|
||||
|
||||
iter = iter->next;
|
||||
}
|
||||
|
||||
while (count)
|
||||
{
|
||||
pkg->I_cflags = g_list_remove (pkg->I_cflags, NULL);
|
||||
pkg->cflags = g_list_remove (pkg->cflags, NULL);
|
||||
--count;
|
||||
}
|
||||
|
||||
|
|
@ -955,15 +881,18 @@ verify_package (Package *pkg)
|
|||
system_directories = add_env_variable_to_list (system_directories, search_path);
|
||||
|
||||
count = 0;
|
||||
iter = pkg->L_libs;
|
||||
while (iter != NULL)
|
||||
for (iter = pkg->libs; iter != NULL; iter = g_list_next (iter))
|
||||
{
|
||||
GList *system_dir_iter = system_directories;
|
||||
Flag *flag = iter->data;
|
||||
|
||||
if (!(flag->type & LIBS_L))
|
||||
continue;
|
||||
|
||||
while (system_dir_iter != NULL)
|
||||
{
|
||||
gboolean is_system = FALSE;
|
||||
const char *linker_arg = iter->data;
|
||||
const char *linker_arg = flag->arg;
|
||||
const char *system_libpath = system_dir_iter->data;
|
||||
|
||||
if (strncmp (linker_arg, "-L ", 3) == 0 &&
|
||||
|
|
@ -980,7 +909,8 @@ verify_package (Package *pkg)
|
|||
{
|
||||
iter->data = NULL;
|
||||
++count;
|
||||
debug_spew ("Removing -L %s from libs for %s\n", system_libpath, pkg->key);
|
||||
debug_spew ("Removing -L %s from libs for %s\n",
|
||||
system_libpath, pkg->key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -992,36 +922,28 @@ verify_package (Package *pkg)
|
|||
|
||||
while (count)
|
||||
{
|
||||
pkg->L_libs = g_list_remove (pkg->L_libs, NULL);
|
||||
pkg->libs = g_list_remove (pkg->libs, NULL);
|
||||
--count;
|
||||
}
|
||||
}
|
||||
|
||||
static char*
|
||||
get_multi_merged (GList *pkgs, GetListFunc func, gboolean in_path_order,
|
||||
gboolean include_private)
|
||||
/* Create a merged list of required packages and retrieve the flags from them.
|
||||
* Strip the duplicates from the flags list. The sorting and stripping can be
|
||||
* done in one of two ways: packages sorted by position in the pkg-config path
|
||||
* and stripping done from the beginning of the list, or packages sorted from
|
||||
* most dependent to least dependent and stripping from the end of the list.
|
||||
* The former is done for -I/-L flags, and the latter for all others.
|
||||
*/
|
||||
static char *
|
||||
get_multi_merged (GList *pkgs, FlagType type, gboolean in_path_order,
|
||||
gboolean include_private)
|
||||
{
|
||||
GList *list = NULL;
|
||||
GList *list;
|
||||
char *retval;
|
||||
|
||||
fill_list (pkgs, func, &list, in_path_order, include_private);
|
||||
list = string_list_strip_duplicates (list);
|
||||
retval = string_list_to_string (list);
|
||||
g_list_free (list);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static char*
|
||||
get_multi_merged_from_back (GList *pkgs, GetListFunc func,
|
||||
gboolean in_path_order, gboolean include_private)
|
||||
{
|
||||
GList *list = NULL;
|
||||
char *retval;
|
||||
|
||||
fill_list (pkgs, func, &list, in_path_order, include_private);
|
||||
list = string_list_strip_duplicates_from_back (list);
|
||||
retval = string_list_to_string (list);
|
||||
list = fill_list (pkgs, type, in_path_order, include_private);
|
||||
list = flag_list_strip_duplicates (list);
|
||||
retval = flag_list_to_string (list);
|
||||
g_list_free (list);
|
||||
|
||||
return retval;
|
||||
|
|
@ -1035,42 +957,33 @@ packages_get_flags (GList *pkgs, FlagType flags)
|
|||
|
||||
str = g_string_new (NULL);
|
||||
|
||||
|
||||
/* sort flags from beginning and in forward direction except for -l */
|
||||
/* sort packages in path order for -L/-I, dependency order otherwise */
|
||||
if (flags & CFLAGS_OTHER)
|
||||
{
|
||||
cur = get_multi_merged (pkgs, get_other_cflags, TRUE, TRUE);
|
||||
cur = get_multi_merged (pkgs, CFLAGS_OTHER, FALSE, TRUE);
|
||||
debug_spew ("adding CFLAGS_OTHER string \"%s\"\n", cur);
|
||||
g_string_append (str, cur);
|
||||
g_free (cur);
|
||||
}
|
||||
if (flags & CFLAGS_I)
|
||||
{
|
||||
cur = get_multi_merged (pkgs, get_I_cflags, TRUE, TRUE);
|
||||
cur = get_multi_merged (pkgs, CFLAGS_I, TRUE, TRUE);
|
||||
debug_spew ("adding CFLAGS_I string \"%s\"\n", cur);
|
||||
g_string_append (str, cur);
|
||||
g_free (cur);
|
||||
}
|
||||
if (flags & LIBS_OTHER)
|
||||
{
|
||||
cur = get_multi_merged (pkgs, get_other_libs, TRUE,
|
||||
!ignore_private_libs);
|
||||
debug_spew ("adding LIBS_OTHER string \"%s\"\n", cur);
|
||||
g_string_append (str, cur);
|
||||
g_free (cur);
|
||||
}
|
||||
if (flags & LIBS_L)
|
||||
{
|
||||
cur = get_multi_merged (pkgs, get_L_libs, TRUE, !ignore_private_libs);
|
||||
cur = get_multi_merged (pkgs, LIBS_L, TRUE, !ignore_private_libs);
|
||||
debug_spew ("adding LIBS_L string \"%s\"\n", cur);
|
||||
g_string_append (str, cur);
|
||||
g_free (cur);
|
||||
}
|
||||
if (flags & LIBS_l)
|
||||
if (flags & (LIBS_OTHER | LIBS_l))
|
||||
{
|
||||
cur = get_multi_merged_from_back (pkgs, get_l_libs, FALSE,
|
||||
!ignore_private_libs);
|
||||
debug_spew ("adding LIBS_l string \"%s\"\n", cur);
|
||||
cur = get_multi_merged (pkgs, flags & (LIBS_OTHER | LIBS_l), FALSE,
|
||||
!ignore_private_libs);
|
||||
debug_spew ("adding LIBS_OTHER | LIBS_l string \"%s\"\n", cur);
|
||||
g_string_append (str, cur);
|
||||
g_free (cur);
|
||||
}
|
||||
|
|
|
|||
14
pkg.h
14
pkg.h
|
|
@ -45,9 +45,16 @@ typedef enum
|
|||
ALWAYS_MATCH
|
||||
} ComparisonType;
|
||||
|
||||
typedef struct _Flag Flag;
|
||||
typedef struct _Package Package;
|
||||
typedef struct _RequiredVersion RequiredVersion;
|
||||
|
||||
struct _Flag
|
||||
{
|
||||
FlagType type;
|
||||
char *arg;
|
||||
};
|
||||
|
||||
struct _RequiredVersion
|
||||
{
|
||||
char *name;
|
||||
|
|
@ -68,11 +75,8 @@ struct _Package
|
|||
GList *requires;
|
||||
GList *requires_private_entries;
|
||||
GList *requires_private;
|
||||
GList *l_libs;
|
||||
GList *L_libs;
|
||||
GList *other_libs;
|
||||
GList *I_cflags;
|
||||
GList *other_cflags;
|
||||
GList *libs;
|
||||
GList *cflags;
|
||||
GHashTable *vars;
|
||||
GHashTable *required_versions; /* hash from name to RequiredVersion */
|
||||
GList *conflicts; /* list of RequiredVersion */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue