summaryrefslogtreecommitdiff
path: root/giscanner
Commit message (Collapse)AuthorAgeFilesLines
* gicsanner/message.py: Windows: Fix running on different drivesfix.win.cmd.3-38Chun-wei Fan2020-09-181-2/+8
| | | | | | | | | os.path.relpath() will throw a ValueError when the two paths that are fed to it are on different drives, at least when running under cmd.exe consoles. Fix this by falling back to the full path when this ValueError is thrown.
* giscanner: Fix section matching for documentationJames Westman2020-09-071-1/+6
| | | | | | | | | | | | | When writing documentation to the GIR files, GIR tries to match classes with their matching SECTION: comment in the source code. Some codebases use kebab-case or CamelCase for their section names, but GIR always expects them to be flatcase or the matching will fail. This commit converts all section names to flatcase (by removing "-" and converting to lowercase) while they are being parsed, so that they are matched properly later on. Fixes #350.
* giscanner: Add support for using clang-clChun-wei Fan2020-08-242-6/+30
| | | | | | | | | | | | | | | | | This adds quick support for using 'clang-cl' (CLang's emulation of the Visual Studio compiler) to run giscanner. This will still initialize things mostly in the MSVC fashion, except that it will also check whether both 'CC' and 'CXX' envvars are set to 'clang-cl [args]', as per the way that Meson supports using 'clang-cl'. Since we are using distutils to set up the compiler instance, when we enable 'clang-cl' support, we trick distutils that we have already initialized the MSVCCompiler parameters as needed. We just leave out the compiler flags as we don't really care about debug symbols nor optimization with the built dumper binary, as it is gone as soon as the .gir file is generated. This will build G-I successfully with all the tests passed.
* Merge branch 'standalone-doc-sections' into 'master'Mathieu Duponchelle2020-07-225-1/+35
|\ | | | | | | | | Add the notion of standalone doc sections. See merge request GNOME/gobject-introspection!226
| * Add the notion of standalone doc sections.Mathieu Duponchelle2020-07-125-1/+35
| | | | | | | | | | | | | | | | Up to now, section annotations had to match a class or interface name in order to be serialized in the gir. With this commit, they now get serialized as docsection nodes, for potential use by documentation tools.
* | giscanner: parse block comments for members and fieldsMathieu Duponchelle2020-07-123-19/+66
|/ | | | | | | | | | | | | | | | | | | | | | | | | | There was previously no mechanism for tagging enum members and struct fields with Since tags (or other, eg deprecation tags). While the customary place to add Since tags for these symbols is inline in the parent symbol's documentation eg: /** * Foo: * * @FOO_BAR: some bar. Since X.Y */ And variations on that theme, implementing parsing for that scheme would result in a pretty ambiguous grammar, especially if we also want support for multiple tags. Instead, the solution implemented here is to allow providing documentation for individual members and fields through their own separate block, as is done for virtual functions already. Inline comments are still used, with a lower precedence. Fixes #348
* dumper: Fix missing symbols in LTO case or with overridden symbol visibility ↵Christoph Reiter2020-05-151-2/+2
| | | | | | | | | | | | | | | | | | | | settings In case a user had a combination of -fvisibility=hidden, -Wl,--as-needed, -flto, -O2 in the CFLAGS the linker would sometimes detect that all the referenced gtype functions weren't actually used and throw them out with their providing libraries. Instead of hoping that the user's CFLAGS don't mess without our symbol visibility just use G_MODULE_EXPORT on the two symbols which reference all other gtype and gquark symbols. This fixes errors such as: Invalid GType function: 'gtk_accel_group_get_type' Failed to find symbol 'gtk_accel_group_get_type' during the g-ir-scanner execution. Fixes #280
* flake8: fix invalid placeholder in GtkDocAnnotatable repr format stringChristoph Reiter2020-05-141-1/+1
| | | | The newest flake8 has started to detect this.
* Update utils.pyneok2020-05-101-1/+1
|
* Revert "Add support for element-type to GListModel"Rico Tzschichholz2020-04-284-19/+7
| | | | | | Breaks vapigen and changes GListModel definition in Gio-2.0.gir This reverts commit a9f45431684e6be3623e272e54d481e4c5d9423d.
* Add support for element-type to GListModelEmmanuele Bassi2020-04-264-7/+19
| | | | | | | | GListModel is an interface for creating typed, list-like containers. The data stored is GObject instances, but it's useful to be able to annotate the actual type, for both documentation and code generation purposes. The annotation should be optional, to maintain backward compatibility.
* Revert "Add element-type support to GListModel"Emmanuele Bassi2020-04-262-4/+1
| | | | | | This reverts commit b4c058bba4d95ae10e1e4238f9417fe954f97795. See: #336
* Revert "Generate appropriate docs for ListModel with element-type"Emmanuele Bassi2020-04-261-13/+5
| | | | | | This reverts commit ffe3e435e0b7943a0872034223b5f6ea02258ffa. See: #336
* Generate appropriate docs for ListModel with element-typeEmmanuele Bassi2020-04-241-5/+13
| | | | | | We need to special case the ListModel container type in the documentation writer so that we don't fall back into array/list automatic conversion in the code snippets.
* Add element-type support to GListModelEmmanuele Bassi2020-04-242-1/+4
| | | | | | | | GListModel is an interface for creating typed, list-like containers. The data stored is GObject instances, but it's useful to be able to annotate the actual type, for both documentation and code generation purposes. Fixes: #328
* Support the gtk-doc action syntaxEmmanuele Bassi2020-04-241-6/+36
| | | | | | | | | | | | | | | | GTK4 allows adding widget-related actions to the documentation with the newly defined syntax: <class_name> '|' <action_name> ':' This means g-ir-scanner needs to detect this new format, to avoid emitting unnecessary warnings. Currently, we don't do anything with the actions; in the future we might want to add them to the documentation in the GIR, but for that we'd need a new element. See also: GNOME/gtk-doc!30
* Replace calls to deprecated xml.etree.cElementTreeStephen Gallagher2020-03-262-2/+2
| | | | | | | | | cElementTree was removed in Python 3.9 in favor of ElementTree, which has used a fast, native implementation since Python 3.3. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1817649 Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
* Windows: Fix building and running on Python 3.8+Chun-wei Fan2020-01-164-1/+53
| | | | | | | | | | | | | | | | | | | | | | | Python 3.8.x and later changed the way how dependent DLLs can be found for a given Python module that depends on the presence of external, non-system DLLs, for more fine-grained DLLs searching and loading, as well as for security purposes, which required the use of os.add_dll_directory(). Thus, the scripts in scanner/ must be updated such that: -We are able to find and load the GObject and GLib DLLs, at least, on initialization, via the use of 'pkg-config --variable bindir', as we already depend on the GLib DLLs. Note that since the gobject-2.0.pc file does not have a 'bindir' entry, we use gio-2.0.pc instead to discover the bindir of the GObject and GLib DLLs. Likewise, we use the same technique for pkg-config files that are dependent upon when using g-ir-scanner (or friends) on items that are higher up in the stack. -We are able to find any other DLLs (e.g. non-GNOME DLLs such as ZLib) that are dependent but are not found in the path(s) given by 'pkg-config --variable bindir' with the envvar GI_EXTRA_BASE_DLL_DIRS, as needed. Note that GI_EXTRA_BASE_DLL_DIRS can be multiple paths, and that the results from 'pkg-config --variable bindir' takes precendence, in a LIFO manner.
* Drop deprecated xml.etree.ElementTree.Element.getchildren() callsMiro Hrončok2020-01-061-6/+6
| | | | | | | | | The XML elements are implicitly iterable in all Python versions including at least 2.7 and 3.2+. The .getchildren() method is deprecated since 2.7 and 3.2, removed in 3.9. Fixes https://gitlab.gnome.org/GNOME/gobject-introspection/issues/325
* giscanner: add a --lib-dirs-envvar optionAlexander Kanavin2019-12-133-3/+7
| | | | | | | | | | By default LD_LIBRARY_PATH is set to the list of target library paths; this breaks down in cross-compilation environment, as we need to run a native emulation wrapper rather than the target binary itself. This patch allows exporting those paths to a different environment variable which can be picked up and used by the wrapper. Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
* giscanner: add a --use-ldd-wrapper optionAlexander Kanavin2019-12-132-1/+6
| | | | | | | This is useful in cross-compile environments where system's ldd command does not work on binaries built for a different architecture Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
* giscanner: add --use-binary-wrapper optionAlexander Kanavin2019-12-131-0/+14
| | | | | | | | | With this option, giscanner will use a wrapper executable to run binaries it's producing, instead of running them directly. This is useful when binaries are cross-compiled and cannot be run directly, but they can be run using for example QEMU emulation. Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
* Fix a bison deprecation warning for using %error-verboseChristoph Reiter2019-12-111-1/+1
| | | | warning: deprecated directive, use ‘%define parse.error verbose’
* giscanner/ccompiler.py: Fix macro defines with quotes on MSVCChun-wei Fan2019-11-011-0/+7
| | | | | | | | | | | | When we save the macros to pass to distutils to compile the dumper program, the quotes were not properly preserved for Visual Studio builds, causing items such as -DG_LOG_DOMAIN to fail as quotes are used in there. When we use quotes in macro definitions, we escape the escape character in ccompiler._set_cpp_options() when we are running g-ir-scanner with Visual Studio, so that distutils won't be too eager to drop those prematurely.
* Evaluate the filters when checking library types in resolve_shlibsAlistair Buxton2019-09-271-2/+2
| | | | | | | | | | In Python 3, filter() returns a filter object for lazy evaluation. This object is truthy, so casting it to bool will return True even if it would contain no objects. This thwarts the test at the beginning of _resolve_non_libtool. To fix this, immediately evaluate the filters with list(). Fixes #314.
* Support array arguments with static keywordEmmanuele Bassi2019-09-151-0/+11
| | | | | | | | | | | | | | | | | | | | | | | C99 allows defining an array argument with a fixed size as: void foo (int arr[static 10]) Compilers conforming to the C99 specification will be able to warn if the function is called with NULL or with an array smaller than the specified length, something that does not happen when using pre-C99 declarations like: void foo (int arr[10]) As the declaration above is identical to: void foo (int arr[]) Which is, in turn, identical to: void foo (int *arr) Fixes: #309
* Make meson.override_find_program working on more complex use casesThibault Saunier2019-08-151-2/+1
| | | | | | | Add some missing `meson.override_find_program` And make sure that the `.gir` we build are found when used uninstalled as a concequence of `meson.override_find_program`.
* ccompiler: use the distutils linker in the dumperChristoph Reiter2019-08-082-5/+10
| | | | | No need to hardcode things since distutils looks it up. Similar to !170 but for Windows.
* Use the defined compiler when invoking libtoolDavid Demelier2019-08-081-1/+1
| | | | Closes: https://gitlab.gnome.org/GNOME/gobject-introspection/issues/303
* meson: abort the build if the correct Python dependency isn't foundChristoph Reiter2019-07-261-0/+5
| | | | | | | For some reason there is no way to pass required to external meson deps. Check manually instead. See #297
* meson: don't pass "install" to configure_file() unless really neededChristoph Reiter2019-07-261-2/+0
| | | | | | | | | | In our case it was never needed because it defaults to true if install_dir is set, which it always is for all calls. This avoids a warning when running with newer meson where it complains that install is only available with 0.50+. Fixes #298
* transformer: only include function macros from headers. See #159Christoph Reiter2019-07-221-0/+4
| | | | | We already do the same thing for constants (see _create_const()). Otherwise macros in .c files which aren't namespaced will trigger a warning.
* scanner: parse and expose function macrosMathieu Duponchelle2019-07-198-5/+98
| | | | | This is useful for documentation tools, and other utilities that rely on full introspection of the C API of a given library.
* build: Force-include msvc_recommended_pragmas.h on Visual StudioChun-wei Fan2019-04-301-4/+8
| | | | | | | | | | By doing so, we essentially cover the various compiler flags that we want to use for non-Visual Studio builds to check for warnings that might cause real concern. This also skips the checks for the various GCC-isque CFlag checks that are scattered in the various build files on Visual Studio builds, since they are essentially meaningless on Visual Studio builds.
* giscanner/scannerlexer.l: Include io.h on WindowsChun-wei Fan2019-04-301-0/+2
| | | | | | | | This is to compensate the for the lack of unistd.h on Visual Studio builds, and to avoid the compiler warning about the implicit declaration of access() as a result. This is to also prepare for the next commit when we force-include msvc_recommended_pragmas.h from GLib on Visual Studio builds.
* scanner: Fix error on Windows in case source files are on different drivesChristoph Reiter2019-04-211-1/+6
| | | | | | | | | os.path.commonpath() raises ValueError if the paths given to it are on different drives. Handle that case by giving up and add a test. Reported here: https://github.com/msys2/MINGW-packages/pull/5258#issuecomment-485230864
* cachestore: handle cache getting deleted while loading it. Fixes #278Christoph Reiter2019-04-171-3/+7
| | | | | | | | In the unlucky event where the cache gets deleted after the os.path.exists() check but before we get its mtime things would error out. Instead of using os.path.exists() handle the exceptions of the operations which we expect to possibly fail.
* giscanner: Allow fields which are callbacksPhilip Chimento2019-04-071-1/+1
| | | | This is apparently used in Gee-0.8 and Folks-0.6.
* docwriter: Fix Exception message attributePhilip Chimento2019-04-071-1/+1
| | | | | This may have been a leftover from Python 2. Exception('message') does not automatically set a message attribute on the exception object.
* shlibs: fall back to basename on macOS for relative paths. Fixes #222Christoph Reiter2019-03-251-7/+18
| | | | | | | | | | | | | | | | | | | On macOS we ideally want to write the final absolute path of the library into the gir and typelib. Up until now we inferred the install path from the .la file in case we used libtool and through otool in case we weren't using libtool hoping that the install_name was matching the install path. meson currently sets the install_name of libraries to "@rpath/foo.dylib" and adds rpaths to the executables in the build dir. Only during install does it change the install_name to the absolute target path in all places. Since we get called during build time we only get the @rpath from otool, which then makes things fail at runtime since the executables don't have the matching rpath set. To make this somewhat work just fall back to the basename for relative paths, so we dlopen "foo.dylib" and depend on things being in /usr/local/lib or DYLD_FALLBACK_LIBRARY_PATH including the lib path (see man dlopen)
* ccompiler: restore customize_compiler() setup for macOS. See #268Christoph Reiter2019-03-021-0/+7
| | | | | | | | | The original customize_compiler() calls into _osx_support.customize_compiler() the first time it is used and I didn't copy it in !118 because it is private API. Issue #268 points out that the macOS build is broken now so I guess that was important in some way. Make sure the setup code is run by calling the original customize_compiler() with a dummy compiler instance.
* Revert "Restore original meaning of disguised attribute."Christoph Reiter2019-01-163-2/+16
| | | | | | This reverts commit f606183a010fbec4382acb728882cc0eddbaf7f7. See https://gitlab.gnome.org/GNOME/gobject-introspection/merge_requests/9#note_409979
* maintransformer: Don't warn on (optional) annotations on (inout)Guido Günther2019-01-131-2/+3
| | | | This makes the scanner consistent with the docs.
* Restore original meaning of disguised attribute.Tomasz Miąsko2019-01-103-16/+2
| | | | | | | | | | | | | | | | > Certain types like GIConv and GdkAtom are pointers internally but don't > look like pointers when referenced. They have the form. > > typedef struct _X *X; > > Parse these as structures/records but mark them in the gir with a 'disguised' > attribute so that we know that they need special handling. Additionally, stop relaying on disguised attribute when deciding whether to render a page. Check number of fields instead, so as to avoid introducing large regression in the docs. Fixes #101.
* message: handle fatal errors even if warnings are disabled. Fixes #229Christoph Reiter2019-01-101-1/+1
|
* maintransformer: when the namespace is empty use error() instead of fatal()Christoph Reiter2019-01-101-1/+1
| | | | | | | | | | | network-manager is calling things like this during configure: g-ir-scanner --namespace=test --library=c /dev/null --output /dev/null to test if the scanner is working. This results in a fatal error, but beause of #229 was ignored. Do keep this working after we fix #229 downgrade this to a simple recoverable error message. An empty namespace doesn't prevent the scanner from creating a .gir file so this should be fine.
* message: simplify handling of error levelsChristoph Reiter2019-01-102-10/+5
| | | | | | | | Instead of allowing each error level to be enabled just enable all of them through the enable_warnings() method. This matches what the code is currently doing (minus that one helper script) and simplifies things. Also remove the error count, it's not used.
* maintransformer: parse deprecation annotations for section blocks. Fixes #213Christoph Reiter2019-01-091-3/+1
| | | | | | | | | | The scanner matches gtk-doc sections which match the lower case type name to the type and uses that for the type documentation. The only problem is it only takes the docs and none of the other annotations like deprecation info etc. This changes things to also parse the annotations in that case and adds some tests while at it.
* Clean shebangs out of non-executable scripts and drop exec perm from ↵Dominique Leuenberger2019-01-095-4/+0
| | | | xmlwriter.py
* tests: add some tests for get_source_root_dirsChristoph Reiter2019-01-081-2/+2
| | | | | To make it easier to test make sure it always returns absolute paths. Also fix a typo, oops!