-
Notifications
You must be signed in to change notification settings - Fork 46
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 -v VERSION [-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
-v VERSION, --version VERSION
gtk-fortran semantic versioning
-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 4.0.0 version with GTK 4:
$ ./cfwrapper.py -g 4 -v 4.0.0
Pass 1: looking for enumerators, funptr and derived types...
Pass 2: looking for C functions...
/usr/include/cairo => cairo-auto.f90 142123 bytes
/usr/include/gdk-pixbuf-2.0 => gdk-pixbuf-auto.f90 51216 bytes
/usr/include/glib-2.0 => glib-auto.f90 1429477 bytes
/usr/include/gtk-4.0/gdk => gdk-auto.f90 184124 bytes
/usr/include/gtk-4.0/gsk => gsk-auto.f90 72555 bytes
/usr/include/gtk-4.0/gtk => gtk-auto.f90 1107518 bytes
/usr/include/gtk-4.0/unix-print => unix-print-auto.f90 27204 bytes
/usr/include/graphene-1.0 => graphene-auto.f90 131446 bytes
/usr/include/pango-1.0 => pango-auto.f90 193297 bytes
Extracting GDK events for gtk-4-fortran
=== Statistics (ready to paste in the Status wiki page) ===
## gtk-fortran 4.0.0, GTK 4.2.1, GLib 2.68.1, Fedora 34 x86_64, Python 3.9.4
osboxes, Thu, 13 May 2021 19:16:01 +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: 11.88 s
* SHA1: 3ade30b56249f31050eaf82840c55076097c1f6f
>>>>>> SHA 1 HAS BEEN MODIFIED ! It was fe23b33301d15241851b34b730393ab293b97601 <<<<<<
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 with other C libraries