summaryrefslogtreecommitdiff
path: root/giscanner
Commit message (Collapse)AuthorAgeFilesLines
* 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!
* get_source_root_dirs: handle empty file list case. Fixes #257Christoph Reiter2019-01-081-0/+3
| | | | | | While scannermain checks that at least one filename is given, it filters them based on the file extension after that, so we still need to handle an empty file list laster on.
* scanner: Flatten multi-dimensional arrays fieldsTomasz Miąsko2019-01-071-10/+17
| | | | | | | | | | | | | Provide partial support for multi-dimensional arrays by representing them as flattened one dimensional array with size that is equal to product of sizes in each dimension. Previously only the first dimension would be actually used. This should be sufficient to ensure that those fields have layout compatible with C, without using nested array types that are currently unsupported by vapigen Issue #255.
* scanner: Remove incorrect c:type generated for array of synthesized unionsTomasz Miąsko2019-01-061-4/+2
| | | | | | | | This also reverts workaround introduced to support this use case in f77cfc4275b1fba4f9fedea6e40b00e0ebbe142c, since it is no longer necessary. Fixes issue #141.
* scanner: Remove incorrect c:type from fields with array typeTomasz Miąsko2019-01-061-12/+1
| | | | | | | | | | Neither `_create_source_type` nor `_create_complete_source_type` actually support fixed size arrays, so previously generated C types were incorrect. Remove C types from array fields instead of producing incorrect ones. Fixes issue #145.
* scanner: rework source root guessing codeChristoph Reiter2019-01-061-3/+24
| | | | | | | | | | | | commonprefix doesn't work on relative paths and doesn't return directories so so for the g-i build case it returned an empty string resulting in paths relative to the working directory, making the build not reproducible. To somehwat improve this make sure the paths are absolute, use commonpath and if no common dir can be found just fall back to passing all directories so we only write the basenames. I guess we should look into passing --sources-top-dirs in the g-i build.
* scanner: Merge specifiers and qualifiers when merging basic types.Tomasz Miąsko2019-01-051-0/+5
|
* scanner: Merge basic types in `specifier_qualifier_list` production.Tomasz Miąsko2019-01-051-10/+11
| | | | | | | | | | | This is necessary to parse types like `unsigned char` or `long double`, and is already done when parsing `declarations_specifiers`. Examples that are fixed by this change include: * `GLib.TestLogMsg.nums` previously parsed as `long` but should be `long double`. * `GMime.Encoding.uubuf` previously parsed as `unsigned` but should be `unsigned char`.
* meson: port doctool testsChristoph Reiter2019-01-031-0/+12
|
* ci: enable -Werror for msys2+mesonChristoph Reiter2019-01-011-6/+9
|
* customize_compiler: also replace the linker command if CC is setChristoph Reiter2018-12-301-1/+4
| | | | | | | | Otherwise when you set CC=clang then distuils will still use gcc for linking. While it seems we don't invoke the link command atm this shouldn't hurt. The upstream customize_compiler() does the same thing on macOS and there is a bug for enabling it everywhere: https://bugs.python.org/issue24935
* Do not bail out when parsing GIR files without doc positionsEmmanuele Bassi2018-12-291-2/+2
| | | | | | | The position attributes on a <doc> element are not mandatory, so we should have some fallback value if they are missing. Fixes: #252
* ccompiler: don't use Python compiler flags. Fixes #150Christoph Reiter2018-12-291-6/+8
| | | | | | | Only use flags provided by env vars from the user and never from the Python sysconfig. The sysconfig values depend on the way Python was built, might conflict when using g-i with a different compiler and can't be controlled by the g-i user.
* ccompiler: include a version of customize_compiler() from CPythonChristoph Reiter2018-12-291-1/+50
| | | | | | | | So we have more control over it. This also removes all macOS specific bits from it because I'm not sure if they are needed and they depend in internal API. This means this change can cause functional changes. Please report if you hit any!
* Test commands executed by unix C compiler.Tomasz Miąsko2018-12-291-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | No functional changes intended. Tests check that: * Compiler is obtained from CC. * cc is used as the default compiler. Currently not true as a Python build time compiler is used as the default. * Preprocessor is obtained from CC when CPP is unspecified by adding -E. * Preprocessor is obtained from CPP. * cpp is used as the default preprocessor. Currently not true as Python build time preprocessor is used as the default. * Shell word splitting rules are used to split CC. * Shell word splitting rules are used to split CPP. * Deprecation warnings are disabled during compilation. * Preprocessing step includes CPPFLAGS. * Compilation step includes both CFLAGS and CPPFLAGS, in that order. * Macros from CFLAGS are defined only once. Currently not true as they are defined twice. * Flags that would retain macros after preprocessing step are filtered out. Currently only partially true as they aren't filtered out from CPPFLAGS. * Preprocessing step includes flag that preserves comments. * Preprocessing step includes current working directory. * Complete preprocessing command doesn't contain anything unexpected. Currently not true as Python build time CPPFLAGS are included as well. * Complete build command doesn't contain anything unexpected. Currently not true as Python build time CFLAGS and CPPFLAGS are included as well.
* scanner: make using bool without stdbool include work again. Fixes #247Christoph Reiter2018-12-212-1/+2
| | | | | | | | | With !45 special casing of bool in the lexer was removed which previously allowed the usage of bool without including stdbool.h. This breaks scanning of graphene headers which guarded the stdbool include with __GI_SCANNER__ (I haven't figured out why). Add back the special handling for bool in the lexer and also map it to gboolean like _Bool as if stdbool.h was included.
* docwriter: Support markdown 3.x. Fixes #250Christoph Reiter2018-12-201-3/+14
| | | | | The headerid extension no longer exists in 3.x. Use the toc extension instead. The toc_depth option was only added in 3.x so still try headerid first.
* meson: add default compiler warning flags and enable -Werror on CIChristoph Reiter2018-12-181-2/+6
| | | | | | | | This enables various compiler warnings project wide and disables the triggered ones for each library/executable. This should give us roughly the same behaviour as with autotools. Tested with gcc8 and clang7.
* meson: only link against libpython on WindowsChristoph Reiter2018-12-171-1/+8
| | | | | Like we currently do with autotools. See https://github.com/mesonbuild/meson/issues/4117
* meson: install everything.c/h like with autotoolsChristoph Reiter2018-12-171-1/+4
| | | | | | This requires a code change in codegen.py to support the case whre output files are not installed in the working directory. Instead of using the output path for the header include use the relative path to the output source file.
* meson: build/install mdextensions.py; and add a simple testChristoph Reiter2018-12-171-0/+1
| | | | | Add a simple test using the docwriter so we trigger the docwriter related Python imports.
* Save preprocessor input and output files with save-tempsTomasz Miąsko2018-12-171-2/+5
| | | | | | | | | | When using `GI_SCANNER_DEBUG=save-temps`, the temporary input file to be preprocessed and temporary output file that is result of this preprocessing are retained for debugging purposes. Use together with `-v` option to actually determine names of those temporary files. This should make it easier to determine the source of parsing errors, like those described in the #247.
* Merge branch 'sourcescanner-empty-delcs' into 'master'Christoph Reiter2018-12-091-0/+4
|\ | | | | | | | | | | | | sourcescanner: Allow empty declarations. Fixes #216 Closes #216 See merge request GNOME/gobject-introspection!89
| * sourcescanner: Allow empty declarations. Fixes #216Christoph Reiter2018-12-091-0/+4
| | | | | | | | | | As far as I see these are not valid C and only allowed in C++11. But they do occur in the wild (mingw headers) so let's try to handle them.
* | Replace linked lists with arrays in source scannerTomasz Miąsko2018-12-095-62/+53
|/ | | | Reduce total number of memory allocations and increase data locality.
* Ignore __pragma keyword used by MSVCTomasz Miąsko2018-12-081-0/+1
|
* Merge branch 'drop-py-compat-code' into 'master'Christoph Reiter2018-12-0825-184/+7
|\ | | | | | | | | Drop all Python 2 compat code See merge request GNOME/gobject-introspection!85
| * Drop all Python 2 compat codeChristoph Reiter2018-12-0825-184/+7
| | | | | | | | We only support 3.4+ now.
* | sourcescanner: collect error messages and expose themChristoph Reiter2018-12-087-8/+56
| | | | | | | | | | | | | | | | | | | | | | It just printed errors to stderr and always returns success even if parsing fails. This prevents us to write any tests for it. As a first step collect all lexing/parsing error messages and print them to stderr after the scanner is done. This allows us to add some regression tests for !78. In the future we probably want to raise an exception with those errors if parsing fails.
* | cachestore: don't try to catch nonexisting pickle.BadPickleGet. Fixes #159Christoph Reiter2018-12-081-1/+1
|/ | | | | pickle.loads() can pretty much throw any kind of exception and we can't handle it besides ignoring it, so just catch all.
* Merge branch 'scan-file-use-filename' into 'master'Christoph Reiter2018-12-074-117/+27
|\ | | | | | | | | gi_source_scanner_parse_file: use a filename instead of a FILE struct See merge request GNOME/gobject-introspection!79
| * gi_source_scanner_parse_file: use a filename instead of a FILE structChristoph Reiter2018-12-064-117/+27
| | | | | | | | | | | | This allows us to get rid of the msvc hacks which are needed in case Python is built with a different msvc than g-i. By passing a filename the FILE struct never passes over library boundaries.
* | Merge branch 'typeof' into 'master'Christoph Reiter 🐍2018-12-061-2/+2
|\ \ | |/ |/| | | | | scanner: Replace use of typeof with void token See merge request GNOME/gobject-introspection!78
| * scanner: Replace use of typeof with void tokenTomasz Miąsko2018-12-041-2/+2
| | | | | | | | | | | | This makes it possible to parse inputs where typeof is used as part of cast expression, e.g., in g_object_ref macro expansion. Selection of VOID is arbitrary since there is no actual implementation of typeof.
* | giscanner/girwriter.py: Fix running on WindowsChun-wei Fan2018-12-061-1/+8
|/ | | | | | | ... When we are building in a drive that is different from the drive that we are acquiring the depedencies from. For example, os.path.relpath() does not like it when we we are building G-I on D:\foo while the GLib headers are found are C:\glib.
* writer: Include documentation and symbol position in source filesThibault Saunier2018-11-288-11/+84
| | | | | | | | | | | Some documentation tool (as hotdoc[0]) need to have information about symbol declaration and documentation positions in the source files to be able to do smart indexing (automatically build the documenation index). [0] https://hotdoc.github.io/ Fixes #175