shana / bindinator

A C# binding generator for Gnome libraries
MIT License
15 stars 17 forks source link

Barfs on Freetype 2 #2

Open directhex opened 12 years ago

directhex commented 12 years ago

directhex@dream:/tmp$ bindinate freetype2-2.0 freetype2-2.0 Processing freetype2-2.0 Must specify package names on the command line Package freetype2-2.0 was not found in the pkg-config search path. Perhaps you should add the directory containing `freetype2-2.0.pc' to the PKG_CONFIG_PATH environment variable No package 'freetype2-2.0' found PACKAGE: freetype2-2.0 LIBS: LIB: freetype2-2.0 SOLIB: Mono StrongName - version 2.10.8.1 StrongName utility for signing assemblies Copyright 2002, 2003 Motus Technologies. Copyright 2004-2008 Novell. BSD licensed.

A new 1024 bits strong name keypair has been generated in file 'freetype2-2.0//freetype2-sharp.snk'. Processing /usr/share/gir-1.0//freetype2-2.0.gir and outputting freetype2-2.0//freetype2-sharp-api.raw directhex@dream:/tmp$ cd freetype2-2.0/

directhex@dream:/tmp/freetype2-2.0$ ./autogen.sh configure.ac:4: error: AC_INIT should be called with package and version arguments /usr/share/aclocal-1.11/init.m4:26: AM_INIT_AUTOMAKE is expanded from... configure.ac:4: the top level autom4te: /usr/bin/m4 failed with exit status: 1 aclocal: /usr/bin/autom4te failed with exit status: 1 autoreconf: aclocal failed with exit status: 1 ./autogen.sh: 4: ./autogen.sh: ./configure: not found

directhex commented 12 years ago

A bunch of gir files cause this failure, e.g. libxml and xrandr

riccioclista commented 10 years ago

I can't reproduce this with freetype 2 on Ubuntu 14.04. Maybe it has been fixed by this commit: 7cc2a6a49a91b05ea6e4e049f29b5c86340f5923.

HinTak commented 8 years ago

The initial reporter's command line was incorrect. However, doing this:

bindinate --gir=freetype2-2.0 --package=freetype2

resulted in:

Making all in sources
make[1]: Entering directory '/tmp/freetype2-2.0/sources'
cp ./freetype2-sharp-api.raw ./freetype2-sharp-api.xml
chmod u+w ./freetype2-sharp-api.xml
/usr/bin/gapi3-fixup --api=./freetype2-sharp-api.xml --metadata=./freetype2-sharp.metadata
make[1]: Leaving directory '/tmp/freetype2-2.0/sources'
Making all in sources/glue
make[1]: Entering directory '/tmp/freetype2-2.0/sources/glue'
make[1]: *** No rule to make target 'generated.c', needed by 'generated.lo'.  Stop.
make[1]: Leaving directory '/tmp/freetype2-2.0/sources/glue'
Makefile:471: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

Anyway,

$ rpm -qf /usr/share/gir-1.0/freetype2-2.0.gir
gobject-introspection-devel-1.46.0-1.fc23.x86_64
$ rpm -qf /usr/lib64/pkgconfig/freetype2.pc
freetype-devel-2.6.3-1.fc23.x86_64

and the content of

$ cat sources/freetype2-sharp-api.raw 
<?xml version="1.0" encoding="UTF-8"?>
<api parser_version="3">
  <namespace name="freetype2" library="">
    <struct name="Bitmap" cname="FT_Bitmap" opaque="false" hidden="false"/>
    <struct name="Face" cname="FT_Face" opaque="false" hidden="false"/>
    <struct name="Library" cname="FT_Library" opaque="false" hidden="false"/>
    <object name="Global" cname="freetype2Global" opaque="true">
      <method name="LibraryVersion" cname="FT_Library_Version" shared="true">
        <return-type type="void"/>
        <parameters/>
      </method>
    </object>
    <object name="Constants" cname="freetype2Constants" opaque="true"/>
  </namespace>
</api>
shana commented 8 years ago

Weird. Does it create a generated.c file? Feels like that's missing from the generation, for some reason.

HinTak commented 8 years ago

Fresh run:

$ bin/bindinate --gir=freetype2-2.0 --package=freetype2
Processing freetype2-2.0
PACKAGE: freetype2
LIBS: 
LIBVERSIONS:  
BUILDLIBVERSIONS:  
LIB: freetype2
SOLIB: 
GLUELIB: libfreetype2sharpglue-18.3.12.so
Mono StrongName - version 4.2.2.0
StrongName utility for signing assemblies
Copyright 2002, 2003 Motus Technologies. Copyright 2004-2008 Novell. BSD licensed.

A new 1024 bits strong name keypair has been generated in file 'freetype2-2.0//sources/freetype2-sharp.snk'.
Processing /usr/share/gir-1.0//freetype2-2.0.gir and outputting freetype2-2.0//sources/freetype2-sharp-api.raw
$ find freetype2-2.0/ -type f
freetype2-2.0/freetype2-sharp.sln
freetype2-2.0/freetype2-sharp-2.0.pc.in
freetype2-2.0/COPYING
freetype2-2.0/ChangeLog
freetype2-2.0/AUTHORS
freetype2-2.0/README
freetype2-2.0/NEWS
freetype2-2.0/autogen.sh
freetype2-2.0/Makefile.am
freetype2-2.0/configure.ac
freetype2-2.0/doc/Makefile.am
freetype2-2.0/sources/csproj.xslt
freetype2-2.0/sources/freetype2-sharp-api.raw
freetype2-2.0/sources/freetype2-sharp.snk
freetype2-2.0/sources/freetype2-sharp.metadata
freetype2-2.0/sources/custom.sources
freetype2-2.0/sources/AssemblyInfo.cs.in
freetype2-2.0/sources/Makefile.am
freetype2-2.0/sources/freetype2-sharp.dll.config
freetype2-2.0/sources/glue/Makefile.am

No, there isn't a generated.c

HinTak commented 8 years ago

@directhex : BTW, SharpFont (a C# binding for freetype, done mostly by hand) works quite well.

My interests in this is because I'd be making some enhancement to freetype in the near future and need to expose that to C# quickly. While enhancing SharpFont is possible for small api changes and I have done that before, quite recently, the sort of additions to freetype I am planning to do is a bit large for hand-editing/additons of C# api's.

shana commented 8 years ago

If it isn't generating a generated.c file, it's most likely because something is wrong with the detection of the library, which is empty in the raw file. Can you paste or gist the contents of the freetype2-2.0.gir file that it's trying to parse?

HinTak commented 8 years ago
$ cat /usr/share/gir-1.0/freetype2-2.0.gir
<?xml version="1.0"?>
<repository version="1.2"
            xmlns="http://www.gtk.org/introspection/core/1.0"
            xmlns:c="http://www.gtk.org/introspection/c/1.0">
  <namespace name="freetype2" version="2.0"
         c:identifier-prefixes="FT"
         c:symbol-prefixes="FT">
    <record name="Bitmap" c:type="FT_Bitmap"/>
    <record name="Face" c:type="FT_Face"/>
    <record name="Library" c:type="FT_Library"/>
    <alias name="Int32" c:type="FT_Int32">
      <type name="int32"/>
    </alias>
    <function name="library_version" c:identifier="FT_Library_Version">
      <return-value transfer-ownership="none">
        <type name="none" c:type="void"/>
      </return-value>
      <parameters>
      </parameters>
    </function>
  </namespace>
</repository>
$ ls -l /usr/share/gir-1.0/freetype2-2.0.gir
-rw-r--r--. 1 root root 768 Sep 22  2015 /usr/share/gir-1.0/freetype2-2.0.gir

It is quite tiny.

sundermann commented 8 years ago

It doesn't make sense to generate bindings for .gir files like this. These libraries are not native GObject and thus these files only exist to make g-i able to resolve these external types. These .gir files are not even generated by g-i but are just handmade (see https://github.com/GNOME/gobject-introspection/blob/master/gir/freetype2-2.0.gir) The same applies to the cairo .gir and lots of other non native GObject libs.

For these libraries custom bindings have to be made by either using some kind of parser or just plain C# code. Integration with these custom bindings could be provided by mapping the types of the external library using tags though.

shana commented 8 years ago

@stsundermann Thanks for the input 😄 I wasn't really thinking about the library, only the error.

@HinTak There are a number of bindings for Freetype that you can try, including SharpFont, those might be useful to you.

HinTak commented 8 years ago

Fair enough - I guess bindinator should detect such and simply refuse to process these bare gir's.