Skip to content

deprecated build tag

André edited this page Feb 14, 2020 · 1 revision

Using deprecated features

By default, deprecated GTK features are not included in the build.

By specifying the e.g. build tag gtk_3_20, any feature deprecated in GTK 3.20 or earlier will NOT be available. To enable deprecated features in the build, add the tag gtk_deprecated. Example:

$ go build -tags "gtk_3_10 gtk_deprecated" example.go
// Package main is an example-user of gotk3
package main

import "github.com/gotk3/gotk3/gtk"

func main() {
	gtk.dep_since_3_20()
	gtk.since_3_16()
}
// Filename: *_deprecated_since_3_20.go
// This file is compiled for all GTK versions below 3.20, and optionally with gtk_deprecated
// +build gtk_3_6 gtk_3_8 gtk_3_10 gtk_3_12 gtk_3_14 gtk_3_16 gtk_3_18 gtk_deprecated

package gtk

func dep_since_3_20() {
	println("< 3.20")
}
// Filename: *_since_3_16_deprecated_since_3_20.go
// This file is normally only compiled for GTK 3.16 and 3.18.
// Adding gtk_deprecated MUST NOT compile this file for GTK<=3.14,
// which requires a combined constraint "!gtk_3_6,!gtk_3_8,!gtk_3_10,!gtk_3_12,!gtk_3_14,gtk_deprecated"
// to specifically exclude all versions of GTK where this was NOT available.
// Do not add spaces in that constraint, only commas!
// +build !gtk_3_6,!gtk_3_8,!gtk_3_10,!gtk_3_12,!gtk_3_14,gtk_deprecated gtk_3_16 gtk_3_18

package main

func since_3_16() {
	println(">= 3.16, < 3_20")
}

Result:

go build -tags "gtk_3_22 gtk_deprecated"

will compile both files, but

go build -tags "gtk_3_14 gtk_deprecated"

will only compile the first.