Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List all direct pkg-config dependencies #320

Merged
merged 2 commits into from Jan 8, 2019
Merged

List all direct pkg-config dependencies #320

merged 2 commits into from Jan 8, 2019

Conversation

orivej
Copy link
Contributor

@orivej orivej commented Jan 8, 2019

Fixes #318.

See details in commit descriptions.

This is allowed since all cgo pkg-config directives in a package are
concatenated and used for all C files in the package.

pkg-config directives are left in cairo/cairo.go, gdk/gdk.go, glib/glib.go,
gtk/gtk.go; and pango/pango.go is updated to include fontconfig from
pango/pango-font.go and pangocairo from pango/pangocairo.go
Based on this output:

     cairo.a needs -lcairo-gobject -lcairo -lgobject-2.0
     gdk.a needs -lglib-2.0 -lgobject-2.0 -lgdk-3
     glib.a needs -lgio-2.0 -lglib-2.0 -lgobject-2.0
     gtk.a needs -lgio-2.0 -lglib-2.0 -lgobject-2.0 -lgdk-3 -lgtk-3
     pango.a needs -lfontconfig -lgobject-2.0 -lpango-1.0 -lpangocairo-1.0

     -lcairo in cairo
     -lcairo-gobject in cairo-gobject
     -lfontconfig in fontconfig
     -lgdk-3 in gdk-3.0 gdk-wayland-3.0 gdk-x11-3.0
     -lgio-2.0 in gio-2.0
     -lglib-2.0 in glib-2.0
     -lgobject-2.0 in gobject-2.0
     -lgtk-3 in gtk+-3.0 gtk+-wayland-3.0 gtk+-x11-3.0
     -lpango-1.0 in pango
     -lpangocairo-1.0 in pangocairo

of the following Bash script (using Nixpkgs):

set -euo pipefail
shopt -s nullglob

go install -v github.com/gotk3/gotk3/...
cd $GOPATH/pkg/linux_amd64/github.com/gotk3/gotk3

pkgs='cairo fontconfig glib gtk3 pango'
args=$(for pkg in $pkgs; do echo "-A $pkg.all"; done)
roots=$(nix-build --no-out-link '<nixpkgs>' $args)
pcs=$(for d in $roots; do echo $d/lib/pkgconfig/*.pc; done)
libs=$(for d in $roots; do echo $d/lib/*.so; done)

allneeded=()
for f in *.a; do
    syms=$(nm -o -u "$f" 2>/dev/null | awk '{print $3}' | sort -u)
    needed=()
    for lib in $libs; do
        libsyms=$(nm -o -D --defined-only $lib | awk '{print $3}' | sort -u)
        commonsyms=$(comm -1 -2 <(echo "$syms") <(echo "$libsyms"))
        if [ "$commonsyms" ]; then
            lib=${lib##*/lib}
            lib=${lib%.so}
            needed+=("-l$lib")
        fi
    done
    echo $f needs ${needed[*]}
    allneeded+=(${needed[*]})
done

echo
for lib in $(printf "%s\n" ${allneeded[*]} | sort -u); do
    inpcs=$(grep -P -l -- "(:|\s)$lib(\s|\$)" $pcs)
    echo $lib in $(for pc in $inpcs; do basename $pc .pc; done)
done
@andre-hub andre-hub merged commit d09d58e into gotk3:master Jan 8, 2019
@orivej orivej deleted the pkg-config branch January 8, 2019 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants