Skip to content

Commit

Permalink
Conditionally include gio network header for 2.36 or later.
Browse files Browse the repository at this point in the history
  • Loading branch information
pekim committed Dec 30, 2018
1 parent a75ce7d commit 256761b
Show file tree
Hide file tree
Showing 44 changed files with 59 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gobbi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e
set -u

exampleDir=example
tags="gobject_2.10 glib_2.48 gdk_3.4 gdkpixbuf_2.32 gio_2.32 gtk_3.18"
tags="gobject_2.10 glib_2.48 gdk_3.4 gdkpixbuf_2.32 gio_2.36 gtk_3.18"

usage () {
echo "Usage:"
Expand Down
9 changes: 6 additions & 3 deletions internal/generate/cincludes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import (
)

type CInclude struct {
Name string `xml:"name,attr"`
Name string `xml:"name,attr"`
Version string `xml:"version,attr"`
}

type CIncludes []*CInclude

func (cc CIncludes) generate(f *jen.File) {
func (cc CIncludes) generate(f *jen.File, version Version) {
for _, cInclude := range cc {
f.CgoPreamble(fmt.Sprintf("#include <%s>", cInclude.Name))
if cInclude.Version == "" || version.GTE(VersionNew(cInclude.Version)) {
f.CgoPreamble(fmt.Sprintf("#include <%s>", cInclude.Name))
}
}
}
8 changes: 4 additions & 4 deletions internal/generate/namespace-file-generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (ns *Namespace) generatePackageFile() {

func (ns *Namespace) generateBooleanFile() {
ns.generateFile("boolean", func(f *jen.File) {
ns.cgoPreambleHeaders(f)
ns.cgoPreambleHeaders(f, Version{})

f.
Func().
Expand All @@ -62,7 +62,7 @@ func (ns *Namespace) generateBooleanFile() {
})
}

func (ns *Namespace) cgoPreambleHeaders(file *jen.File) {
func (ns *Namespace) cgoPreambleHeaders(file *jen.File, version Version) {
/*
* Suppress C compiler warnings about deprecated functions.
*
Expand All @@ -77,7 +77,7 @@ func (ns *Namespace) cgoPreambleHeaders(file *jen.File) {
file.CgoPreamble("#cgo CFLAGS: -Wno-format-security")
file.CgoPreamble("#cgo CFLAGS: -Wno-incompatible-pointer-types")

ns.repo.CIncludes.generate(file)
ns.repo.CIncludes.generate(file, version)

file.CgoPreamble("#include <stdlib.h>")
}
Expand All @@ -98,7 +98,7 @@ func (ns *Namespace) generateGeneratables(typeName string, generatables Generata
func (ns *Namespace) generateEntityVersionedFile(filename string, version Version, generatables Generatables) {
ns.generateFile(filename, func(f *jen.File) {
ns.buildConstraintsForVersion(f, version)
ns.cgoPreambleHeaders(f)
ns.cgoPreambleHeaders(f, version)
ns.generateVersionDebugFunction(f, version.value)

for _, entity := range generatables.entities() {
Expand Down
3 changes: 3 additions & 0 deletions internal/gir-files/Gio-2.0-addenda.gir
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
xmlns:c="http://www.gtk.org/introspection/c/1.0"
xmlns:glib="http://www.gtk.org/introspection/glib/1.0"
>
<!-- required header files -->
<c:include name="gio/gnetworking.h" version="2.36"/>

<namespace>
<constant blacklist="true" name="FILE_ATTRIBUTE_FILESYSTEM_REMOTE"/>
<constant blacklist="true" name="SETTINGS_BACKEND_EXTENSION_POINT_NAME"/>
Expand Down
6 changes: 6 additions & 0 deletions internal/test/gio/gio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ func TestCleanBuild(t *testing.T) {
gio.APPLICATION_FLAGS_NONE)
assert.NotNil(t, app)
}

// g_networking_init is defined in a header file that is not included
// in the gio gir repo file.
func TestAddendaCInclude(t *testing.T) {
gio.NetworkingInit()
}
1 change: 1 addition & 0 deletions lib/gio/bitfield-2.38.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gio
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/bitfield-2.40.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gio
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/class-2.36.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
/*
Expand Down
1 change: 1 addition & 0 deletions lib/gio/class-2.38.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/class-2.40.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
/*
Expand Down
1 change: 1 addition & 0 deletions lib/gio/class-2.42.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/class-2.44.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/class-2.46.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/class-2.48.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gio
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/class-2.50.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import "unsafe"
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/class-2.56.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/constant-2.36.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gio
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/constant-2.38.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gio
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/constant-2.40.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gio
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/constant-2.46.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gio
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/constant-2.52.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gio
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/enum-2.40.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gio
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/enum-2.42.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gio
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/enum-2.44.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gio
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/enum-2.46.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gio
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/function-2.36.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import "unsafe"
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/function-2.38.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ package gio
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"
1 change: 1 addition & 0 deletions lib/gio/function-2.48.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ package gio
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"
1 change: 1 addition & 0 deletions lib/gio/function-2.50.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gio
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/function-2.52.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import "unsafe"
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/function-2.54.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import "unsafe"
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/function-2.56.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import "unsafe"
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/interface-2.38.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/interface-2.40.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gio
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/interface-2.44.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
/*
Expand Down
1 change: 1 addition & 0 deletions lib/gio/interface-2.46.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gio
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/interface-2.48.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/interface-2.50.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/interface-2.56.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/record-2.40.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/record-2.44.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import "unsafe"
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/record-2.46.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gio
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/record-2.48.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import "unsafe"
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down
1 change: 1 addition & 0 deletions lib/gio/record-2.54.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import "unsafe"
// #include <gio/gunixmounts.h>
// #include <gio/gunixoutputstream.h>
// #include <gio/gunixsocketaddress.h>
// #include <gio/gnetworking.h>
// #include <stdlib.h>
import "C"

Expand Down

0 comments on commit 256761b

Please sign in to comment.