-
Notifications
You must be signed in to change notification settings - Fork 44
How gtk fortran is generated
When we want to make a release of gtk-fortran with new GTK libraries versions, we use the src/cfwrapper/cfwrapper.py
script to parse all the GTK .h
header files in /usr/include/
and automatically generate the src/*-auto.f90
files containing interfaces to the C functions. It also writes the list of all those functions with informations on the required files and the C prototypes in the src/gtk-fortran-index.csv
file.
The most important option of the Python script is -g
to choose the GTK major version to use:
$ ./cfwrapper.py --help
usage: cfwrapper.py [-h] -g 2|3|4 [-b] [-d]
Generate gtk-fortran files
optional arguments:
-h, --help show this help message and exit
-g 2|3|4, --gtk 2|3|4
GTK major version
-b, --build Build gtk-fortran libraries and examples
-d, --deprecated Remove deprecated functions
GPLv3 license, https://github.com/vmagnin/gtk-fortran
Let's for example generate a new gtk-fortran version with GTK 4:
$ ./cfwrapper.py -g 4
Pass 1: looking for enumerators, funptr and derived types...
Pass 2: looking for C functions...
/usr/include/cairo => cairo-auto.f90 135832 bytes
/usr/include/gdk-pixbuf-2.0 => gdk-pixbuf-auto.f90 49475 bytes
/usr/include/glib-2.0 => glib-auto.f90 1374088 bytes
/usr/include/gtk-4.0/gdk => gdk-auto.f90 176391 bytes
/usr/include/gtk-4.0/gsk => gsk-auto.f90 69526 bytes
/usr/include/gtk-4.0/gtk => gtk-auto.f90 1060054 bytes
/usr/include/gtk-4.0/unix-print => unix-print-auto.f90 26023 bytes
/usr/include/graphene-1.0 => graphene-auto.f90 125855 bytes
/usr/include/pango-1.0 => pango-auto.f90 185172 bytes
Extracting GDK events for gtk-4-fortran
=== Statistics (ready to paste in the Status wiki page) ===
## GTK 4.2.0, GLib 2.68.0, Fedora 34 x86_64, Python 3.9.2
osboxes, Sun, 04 Apr 2021 13:05:12 +0000
* nb_files scanned = 706
* nb_generated_interfaces = 9736
* nb_deprecated_functions = 332
* nb_type_errors = 219
* nb_errors (others) = 302
* nb_lines treated = 32242
* nb_variadic functions = 136
* nb_enumerators = 350
* nb_win32_utf8 = 4
* Number of types = 78
* Computing time: 12.47 s
* SHA1: f5e8212b53bb254220d63ab2286f52ddcca5ec6e
Used types: ['c_ptr', 'c_int', 'c_char', 'c_double', 'c_funptr', 'c_long', 'c_int32_t', 'c_float', 'c_size_t', 'c_int8_t', 'c_int64_t', 'c_int16_t', '?', 'c_long_double']
The statistics are archived on the Status page. Note that the process is fast: only 12 seconds, and in a Fedora virtual machine.
Now, when building the project, two things can happen:
- The build process runs flawlessly :-) The new gtk-fortran release can be pushed!
- The build fails because some
*-auto.f90
files contain weird things. It occurs when some new coding conventions are introduced in some.h
file of a GTK library, or when some new C preprocessor constants appear is some files (for example https://github.com/vmagnin/gtk-fortran/issues/234). In that case, one or more regex must be updated or added in the wrapper scripts. That's why you should not usecfwrapper.py
except if you know what you do.
See the Known issues and limits page to know more about what the wrapper limits.
- Installation
- My first gtk-fortran application
- Drawing an image in a PNG file (without GUI)
- A program also usable without GUI
- Using Glade3 and gtkf-sketcher (GTK 3)
- Using gtk-fortran as a fpm dependency
- Debugging with GtkInspector
- Learning from examples
- Video tutorials
- How to start my own project from a gtk-fortran example
- git basics
- CMake basics
- Alternatives to CMake
- How to migrate to GTK 4
- How to contribute to gtk-fortran
- How to hack the cfwrapper