summaryrefslogtreecommitdiff
path: root/giscanner
Commit message (Collapse)AuthorAgeFilesLines
* giscanner/ccompiler.py: Fix macro defines with quotes on MSVCgnome-3-34Chun-wei Fan2019-11-091-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.
* 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!
* 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
|