mirror of
https://gitlab.freedesktop.org/pkg-config/pkg-config.git
synced 2026-02-04 17:40:29 +01:00
Respect sysroot for -isystem and -idirafter
Treat -isystem and -idirafter as -I Cflags since they control the compiler search path. Adjust the sysroot handling so that the arguments to these options have the sysroot prefixed. However, leave them out of the system Cflags handling since these directives are explicitly trying to adjust the compiler's system header search behavior. The special-flags test case output needs adjustment since all the flags are now considered -I flags and come out in the order specified in the pc file. https://bugs.freedesktop.org/show_bug.cgi?id=97337
This commit is contained in:
parent
7707d2ff33
commit
d5d8074893
4 changed files with 26 additions and 9 deletions
|
|
@ -4,7 +4,7 @@ set -e
|
|||
|
||||
. ${srcdir}/common
|
||||
|
||||
RESULT="-g -isystem /system1 -idirafter /after1 -ffoo -idirafter /after2 -isystem /system2 -I/foo -I/bar"
|
||||
RESULT="-g -ffoo -I/foo -isystem /system1 -idirafter /after1 -I/bar -idirafter /after2 -isystem /system2"
|
||||
run_test --cflags special-flags
|
||||
|
||||
RESULT="-L/foo -L/bar -framework Foo -lsimple -framework Bar -Wl,-framework -Wl,Baz"
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ run_test --cflags public-dep
|
|||
RESULT="-L$root/sysroot/public-dep/lib -lpublic-dep"
|
||||
run_test --libs public-dep
|
||||
|
||||
RESULT="-g -isystem /system1 -idirafter /after1 -ffoo -idirafter /after2 -isystem /system2 -I$root/sysroot/foo -I$root/sysroot/bar"
|
||||
RESULT="-g -ffoo -I$root/sysroot/foo -isystem $root/sysroot/system1 -idirafter $root/sysroot/after1 -I$root/sysroot/bar -idirafter $root/sysroot/after2 -isystem $root/sysroot/system2"
|
||||
run_test --cflags special-flags
|
||||
|
||||
RESULT="-L$root/sysroot/foo -L$root/sysroot/bar -framework Foo -lsimple -framework Bar -Wl,-framework -Wl,Baz"
|
||||
|
|
|
|||
4
parse.c
4
parse.c
|
|
@ -861,7 +861,9 @@ parse_cflags (Package *pkg, const char *str, const char *path)
|
|||
|
||||
tmp = trim_string (argv[i+1]);
|
||||
option = strdup_escape_shell (tmp);
|
||||
flag->type = CFLAGS_OTHER;
|
||||
|
||||
/* These are -I flags since they control the search path */
|
||||
flag->type = CFLAGS_I;
|
||||
flag->arg = g_strconcat (arg, " ", option, NULL);
|
||||
pkg->cflags = g_list_prepend (pkg->cflags, flag);
|
||||
i++;
|
||||
|
|
|
|||
27
pkg.c
27
pkg.c
|
|
@ -434,10 +434,21 @@ flag_list_to_string (GList *list)
|
|||
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);
|
||||
g_string_append (str, tmpstr+2);
|
||||
/* Handle non-I Cflags like -isystem */
|
||||
if (flag->type & CFLAGS_I && strncmp (tmpstr, "-I", 2) != 0) {
|
||||
char *space = strchr (tmpstr, ' ');
|
||||
|
||||
/* Ensure this has a separate arg */
|
||||
g_assert (space != NULL && space[1] != '\0');
|
||||
g_string_append_len (str, tmpstr, space - tmpstr + 1);
|
||||
g_string_append (str, pcsysrootdir);
|
||||
g_string_append (str, space + 1);
|
||||
} else {
|
||||
g_string_append_c (str, '-');
|
||||
g_string_append_c (str, tmpstr[1]);
|
||||
g_string_append (str, pcsysrootdir);
|
||||
g_string_append (str, tmpstr+2);
|
||||
}
|
||||
} else {
|
||||
g_string_append (str, tmpstr);
|
||||
}
|
||||
|
|
@ -772,8 +783,12 @@ verify_package (Package *pkg)
|
|||
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
|
||||
/* Handle the system cflags. 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.
|
||||
*
|
||||
* Note that the -i* flags are left out of this handling since
|
||||
* they're intended to adjust the system cflags behavior.
|
||||
*/
|
||||
if (((strncmp (flag->arg, "-I", 2) == 0) && (offset = 2))||
|
||||
((strncmp (flag->arg, "-I ", 3) == 0) && (offset = 3)))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue