[devel] cpp.req -- зависимости *.h файлов (телеграфом)
Alexey Tourbin
=?iso-8859-1?q?at_=CE=C1_altlinux=2Eru?=
Вт Мар 18 00:21:12 MSK 2008
On Mon, Mar 03, 2008 at 06:26:17PM +0300, Alexey Tourbin wrote:
> Вывод препроцессора позволяет построить стек включаемых файлов и,
> следовательно, определить top-level includes. Если первый флаг 1,
> то это push на стек, а если первый флаг 2 -- то это pop. Push на
> начальной глубине даёт непосредственные зависимости исследуемого хедера.
>
> $ cpp /usr/include/rpm/rpmlib.h |grep ^# |awk '$4==1{++I;if(I==1)print$3}$4==2{--I}'
> "/usr/include/rpm/rpmio.h"
> "/usr/include/rpm/rpmmessages.h"
> "/usr/include/rpm/rpmerr.h"
> "/usr/include/rpm/header.h"
> "/usr/include/popt.h"
> $ grep -w include /usr/include/rpm/rpmlib.h
> #include "rpmio.h"
> #include "rpmmessages.h"
> #include "rpmerr.h"
> #include "header.h"
> #include "popt.h"
> $
Предварительная релизация опубликована в моем репозитарии rpm.git.
Она ещё не совсем хорошо работает (на реальной сборке в хешере),
потому что по умолчанию используется "cpp -x c++", то есть пока
для работы требуется gcc4.1-c++.
Но можно уже смотреть, что получается.
Примеры:
а) Зависимости хедеров у пакета librpm-devel.
$ rpm -ql librpm-devel |file -NF$'\t' -f - |/usr/lib/rpm/cpp.req.files |/usr/lib/rpm/cpp.req -v |sort -u
cpp.req: /usr/include/rpm/header.h: /usr/include/stdio.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/header.h: /usr/include/rpm/rpmio.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/header.h: /usr/include/rpm/hdrinline.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/misc.h: /usr/include/string.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmbuild.h: /usr/include/rpm/rpmcli.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmbuild.h: /usr/include/rpm/stringbuf.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmbuild.h: /usr/include/rpm/misc.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmbuild.h: /usr/include/rpm/rpmspec.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmbuild.h: /usr/include/ctype.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmcli.h: /usr/include/rpm/rpmlib.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmcli.h: /usr/include/rpm/rpmurl.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmcli.h: /usr/include/rpm/rpmmacro.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmdb.h: /usr/include/rpm/rpmlib.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmerr.h: /usr/include/rpm/rpmlog.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmio.h: /usr/include/sys/types.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmio.h: /usr/include/sys/stat.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmio.h: /usr/include/dirent.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmio.h: /usr/include/glob.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmio.h: /usr/include/stdio.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmio.h: /usr/include/stdlib.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmio.h: /usr/include/unistd.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmlib.h: /usr/include/rpm/rpmio.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmlib.h: /usr/include/rpm/rpmmessages.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmlib.h: /usr/include/rpm/rpmerr.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmlib.h: /usr/include/rpm/header.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmlib.h: /usr/include/popt.h -> libpopt-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmlog.h: /usr/lib/gcc/i586-alt-linux/4.1.2/include/stdarg.h -> gcc4.1 (via rpmdb)
cpp.req: /usr/include/rpm/rpmmessages.h: /usr/include/rpm/rpmlog.h -> librpm-devel (via rpmdb)
cpp.req: /usr/include/rpm/rpmurl.h: /usr/include/assert.h -> glibc-devel (via rpmdb)
gcc4.1
glibc-devel
libpopt-devel
librpm-devel
$
Таким образом, у librpm-devel реальная зависимость это только
libpopt-devel. Тогда как вручную у него прописано гораздо больше
(лишних) зависимостей:
$ rpm -qR librpm-devel |grep -e -devel
bzlib-devel
libbeecrypt-devel
libdb4.4-devel
libpopt-devel
zlib-devel
$
б) Зависимости хедеров у пакета imlib-devel.
$ rpm -ql imlib-devel |file -NF$'\t' -f - |/usr/lib/rpm/cpp.req.files |/usr/lib/rpm/cpp.req -v |sort -u
cpp.req: /usr/include/Imlib.h: /usr/include/Imlib_types.h -> imlib-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/stdio.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/unistd.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/stdlib.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/math.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/ctype.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/time.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/netinet/in.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/sys/time.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/X11/Xlib.h -> libX11-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/X11/Xutil.h -> libX11-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/X11/Xatom.h -> xorg-x11-proto-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/X11/Xos.h -> xorg-x11-proto-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/X11/extensions/shape.h -> xorg-x11-proto-devel (via rpmdb)
cpp.req: /usr/include/Imlib_private.h: /usr/include/X11/cursorfont.h -> libX11-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/X11/Xlib.h -> libX11-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/X11/Xutil.h -> libX11-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/X11/Xatom.h -> xorg-x11-proto-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/X11/Xos.h -> xorg-x11-proto-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/X11/extensions/shape.h -> xorg-x11-proto-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/stdio.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/stdlib.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/math.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/ctype.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/Imlib_types.h: /usr/include/netinet/in.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib.h: /usr/include/gdk_imlib_types.h -> imlib-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/stdio.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/unistd.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/stdlib.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/math.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/ctype.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/time.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/netinet/in.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/sys/time.h -> glibc-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/X11/Xlib.h -> libX11-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/X11/Xutil.h -> libX11-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/X11/Xatom.h -> xorg-x11-proto-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/X11/Xos.h -> xorg-x11-proto-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/X11/extensions/shape.h -> xorg-x11-proto-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/X11/cursorfont.h -> libX11-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/gtk-1.2/gdk/gdkprivate.h -> gtk+-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_private.h: /usr/include/gtk-1.2/gdk/gdkx.h -> gtk+-devel (via rpmdb)
cpp.req: /usr/include/gdk_imlib_types.h: /usr/include/gtk-1.2/gdk/gdk.h -> gtk+-devel (via rpmdb)
glibc-devel
gtk+-devel
imlib-devel
libX11-devel
xorg-x11-proto-devel
$
Установим эти зависимости в чрут (кроме самого пакета imlib-devel).
$ hsh --init
$ hsh-install glibc-devel gtk+-devel libX11-devel xorg-x11-proto-devel
Preparing packages for installation...
libX11-locales-1.1.4-alt3
libXau-1.0.3-alt1
libXdmcp-1.0.2-alt1.0
libxcb-1.1-alt4
libxcb-devel-1.1-alt4
glib-1.2.10-alt13
glib-devel-1.2.10-alt13
libX11-1.1.4-alt3
libXext-1.0.4-alt1
libXi-1.1.3-alt2
gtk+-1.2.10-alt15
libICE-1.0.4-alt1
libSM-1.0.3-alt1
libXt-1.0.5-alt1
xorg-x11-proto-devel-7.3.0-alt12
libICE-devel-1.0.4-alt1
libSM-devel-1.0.3-alt1
libXdmcp-devel-1.0.2-alt1.0
libXau-devel-1.0.3-alt1
libX11-devel-1.1.4-alt3
libXt-devel-1.0.5-alt1
gtk+-devel-1.2.10-alt15
$
Теперь поставим в чрут сам пакет imlib-devel и посмотрим, какие лишние
лишние пакеты он вытягивает.
$ hsh-install imlib
Preparing packages for installation...
libjpeg-6b-alt8
libpng12-1.2.25-alt1
libtiff-3.8.2-alt1
libungif-4.1.4-alt1
imlib-1.9.15-alt1
$ hsh-install imlib-devel
Preparing packages for installation...
imlib-cfgeditor-1.9.15-alt1
libXext-devel-1.0.4-alt1
libjpeg-devel-6b-alt8
zlib-devel-1.2.3-alt4
libpng-devel-1.2.25-alt1
libtiff-devel-3.8.2-alt1
libungif-devel-4.1.4-alt1
imlib-devel-1.9.15-alt1
$
Шесть лишних *-devel пакетов.
В общем, вроде бы, идея жизнеспособна.
Встают следующие вопросы:
1) Как поточнее выбрать хедеры -- в Си+плюсе хедеры не обязаны иметь
конвенциональный суффикс *.h.
2) Как быть с "cpp -x c++" -- он запускает cc1plus, которого по
сборочным зависимостям может и не быть (и нежелательно его туда
вносить).
3) Как быть с зависимостями на glibc-devel и gcc4.1 (тж.
libstdc++4.1-devel).
----------- следующая часть -----------
Было удалено вложение не в текстовом формате...
Имя : =?iso-8859-1?q?=CF=D4=D3=D5=D4=D3=D4=D7=D5=C5=D4?=
Тип : application/pgp-signature
Размер : 197 байтов
Описание: =?iso-8859-1?q?=CF=D4=D3=D5=D4=D3=D4=D7=D5=C5=D4?=
Url : <http://lists.altlinux.org/pipermail/devel/attachments/20080318/3de1c4b9/attachment-0002.bin>
Подробная информация о списке рассылки Devel