Skip to content

Commit

Permalink
Added glue code generation
Browse files Browse the repository at this point in the history
  • Loading branch information
sundermann committed Jul 17, 2013
1 parent f045b3c commit ad47a8c
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
18 changes: 18 additions & 0 deletions bindinate/Makefile-glue.am.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
lib_LTLIBRARIES = #GLUENAME#-#MODVERSION#.la

#GLUENAME#_#VERSION#_la_SOURCES =

nodist_#GLUENAME#_#VERSION#_la_SOURCES = generated.c

#GLUENAME#_#VERSION#_la_LDFLAGS = -module -avoid-version -no-undefined

#GLUENAME#_#VERSION#_la_LIBADD = $(#PREFIX#_LIBS)

INCLUDES = $(#PREFIX#_CFLAGS) -I$(top_srcdir)

#GLUENAME#.dll: $(#GLUENAME#_#VERSION#_la_OBJECTS) #GLUENAME#.rc #GLUENAME#.def
./build-dll #GLUENAME# $(VERSION)

CLEANFILES = lib*.a lib*.dll

EXTRA_DIST =
2 changes: 1 addition & 1 deletion bindinate/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
bin_SCRIPTS = bindinate
bindinatedir = $(libdir)/bindinator
bindinate_DATA = gir2gapi.xslt preprocess.xslt configure.ac.template Makefile.am.template AssemblyInfo.cs.in autogen.sh metadata.template pc.template Makefile-docs.am.template
bindinate_DATA = gir2gapi.xslt preprocess.xslt configure.ac.template Makefile.am.template AssemblyInfo.cs.in autogen.sh metadata.template pc.template Makefile-docs.am.template Makefile-glue.am.template
3 changes: 3 additions & 0 deletions bindinate/Makefile.am.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ API = $(ASSEMBLY_NAME)-api.xml
METADATA = $(ASSEMBLY_NAME).metadata
DLL = $(top_srcdir)/out/$(ASSEMBLY_NAME).dll
DLLMAP = $(top_srcdir)/out/$(ASSEMBLY_NAME).dll.config
GLUEDIR = $(srcdir)/glue

sources =

Expand Down Expand Up @@ -31,6 +32,8 @@ $(API): $(srcdir)/$(RAW_API) $(srcdir)/$(METADATA)
generated-stamp: $(API)
$(GAPI_CODEGEN) --generate $(srcdir)/$(API) $(GTK_SHARP_CFLAGS) \
--outdir=generated \
--glue-filename=$(GLUEDIR)/generated.c --gluelib-name=#GLUELIBNAME# \
--glue-includes=#GLUEINCLUDES# \
--assembly-name=$(ASSEMBLY_NAME) && touch generated-stamp

$(DLL): $(build_sources) generated-stamp
Expand Down
24 changes: 21 additions & 3 deletions bindinate/bindinate.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ fi
if [ ! -d $OUTDIR/sources ]; then
mkdir -p $OUTDIR/sources
fi
if [ ! -d $OUTDIR/sources/glue ]; then
mkdir -p $OUTDIR/sources/glue
fi
if [ ! -d $OUTDIR/out ]; then
mkdir -p $OUTDIR/out
fi
Expand All @@ -46,6 +49,7 @@ ORIGINAL=$PACKAGE
LIBS=`@XSLTPROC@ --stringparam type libs @prefix@/lib/bindinator/preprocess.xslt @GIRDIR@/$1.gir|sed 's/,/ /'`
NS=`@XSLTPROC@ --stringparam type namespace @prefix@/lib/bindinator/preprocess.xslt @GIRDIR@/$1.gir`
VERSION=`@XSLTPROC@ --stringparam type version @prefix@/lib/bindinator/preprocess.xslt @GIRDIR@/$1.gir`
INCLUDES=`@XSLTPROC@ --stringparam type include @prefix@/lib/bindinator/preprocess.xslt @GIRDIR@/$1.gir`
GAPI=`@XSLTPROC@ --stringparam type gapi @prefix@/lib/bindinator/preprocess.xslt @GIRDIR@/$1.gir`

echo "PACKAGE: $PACKAGE"
Expand All @@ -63,11 +67,14 @@ fi
MODVERSION=$(@PKG_CONFIG@ --modversion $PACKAGE)
NAME=$(echo $NS|tr '[:upper:]' '[:lower:]')
UNAME=$(echo $NS|tr '[:lower:]' '[:upper:]')
GLUEVERSION=$(echo $MODVERSION|tr '.' '_')
LIB=$PACKAGE
SOLIB=

DLLMAP=$NAME-sharp.dll.config
CONFIGURE=configure.ac
GLUELIB="lib"$NAME"sharpglue-"$MODVERSION".so"
GLUENAME="lib"$NAME"sharpglue"

for lib in $LIBS; do
case "$lib" in
Expand All @@ -82,6 +89,7 @@ done

echo "LIB: $LIB"
echo "SOLIB: $SOLIB"
echo "GLUELIB: $GLUELIB"

cat >$OUTDIR/out/$DLLMAP <<EOF
<configuration>
Expand All @@ -96,6 +104,7 @@ AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE
AM_MAINTAINER_MODE
AC_PROG_INSTALL
LT_INIT
dnl Package settings
ASSEMBLY_COMPANY=""
Expand All @@ -112,12 +121,16 @@ EOF
sed "s/#GAPI#/$GAPI/g" @prefix@/lib/bindinator/configure.ac.template >>$OUTDIR/$CONFIGURE

PR=$NAME"_prefix"
PLIBS=$UNAME"_LIBS"
PCFLAGS=$UNAME"_CFLAGS"

cat >>$OUTDIR/$CONFIGURE <<EOF
dnl Check for $NS
PKG_CHECK_MODULES($UNAME, $PACKAGE)
$PR=`pkg-config --variable=prefix $PACKAGE`
AC_SUBST($PR)
AC_SUBST($PLIBS)
AC_SUBST($PCFLAGS)
EOF

Expand All @@ -137,6 +150,7 @@ cat >>$OUTDIR/$CONFIGURE <<EOF
AC_CONFIG_FILES([
Makefile
sources/Makefile
sources/glue/Makefile
sources/AssemblyInfo.cs
$NAME-sharp-$VERSION.pc
doc/Makefile
Expand Down Expand Up @@ -165,8 +179,12 @@ DISTCLEANFILES = $NAME-sharp-$VERSION.pc
EOF

sed "s/#REFERENCES#/$REF/g" @prefix@/lib/bindinator/Makefile.am.template>$OUTDIR/sources/Makefile.am
#cp @prefix@/lib/bindinator/Makefile.am.template $OUTDIR/Makefile.am
sed "s,#REFERENCES#,$REF,g" @prefix@/lib/bindinator/Makefile.am.template|sed "s,#GLUELIBNAME#,$GLUELIB,g"| \
sed "s,#GLUEINCLUDES#,$INCLUDES,g">$OUTDIR/sources/Makefile.am

sed "s,#GLUENAME#,$GLUENAME,g" @prefix@/lib/bindinator/Makefile-glue.am.template|sed "s,#GLUELIBNAME#,$GLUELIB,g"| \
sed "s,#VERSION#,$GLUEVERSION,g"|sed "s,#LTVERSION#,$MODVERSION,g"|sed "s,#PREFIX#,$UNAME,g">$OUTDIR/sources/glue/Makefile.am

cp @prefix@/lib/bindinator/AssemblyInfo.cs.in $OUTDIR/sources/.
cp @prefix@/lib/bindinator/autogen.sh $OUTDIR/.
chmod +x $OUTDIR/autogen.sh
Expand All @@ -175,7 +193,7 @@ mkdir -p $OUTDIR/m4
if [ ! -e $OUTDIR/sources/$NAME-sharp.metadata ]; then
cp @prefix@/lib/bindinator/metadata.template $OUTDIR/sources/$NAME-sharp.metadata
fi

#LT
if [ ! -e "$OUTDIR/NEWS" ]; then touch $OUTDIR/NEWS; fi
if [ ! -e "$OUTDIR/README" ]; then touch $OUTDIR/README; fi
if [ ! -e "$OUTDIR/AUTHORS" ]; then touch $OUTDIR/AUTHORS; fi
Expand Down
3 changes: 3 additions & 0 deletions bindinate/preprocess.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ exclude-result-prefixes="xsl exsl gir c glib"
<xsl:when test="$type='version'">
<xsl:value-of select="gir:repository/gir:namespace/@version" />
</xsl:when>
<xsl:when test="$type='include'">
<xsl:value-of select="gir:repository/c:include/@name" />
</xsl:when>
<xsl:when test="$type='gapi'">
<xsl:choose>
<xsl:when test="gir:repository/gir:include[@name='Gdk']/@version='2.0'">2</xsl:when>
Expand Down

0 comments on commit ad47a8c

Please sign in to comment.