summaryrefslogtreecommitdiff
path: root/giscanner/scannermain.py
Commit message (Collapse)AuthorAgeFilesLines
* giscanner: add a --lib-dirs-envvar optionAlexander Kanavin2019-12-131-0/+3
| | | | | | | | | | 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-131-0/+3
| | | | | | | 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>
* 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
* message: simplify handling of error levelsChristoph Reiter2019-01-101-1/+1
| | | | | | | | 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.
* Clean shebangs out of non-executable scripts and drop exec perm from ↵Dominique Leuenberger2019-01-091-1/+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: 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.
* Merge branch 'drop-py-compat-code' into 'master'Christoph Reiter2018-12-081-5/+0
|\ | | | | | | | | Drop all Python 2 compat code See merge request GNOME/gobject-introspection!85
| * Drop all Python 2 compat codeChristoph Reiter2018-12-081-5/+0
| | | | | | | | We only support 3.4+ now.
* | sourcescanner: collect error messages and expose themChristoph Reiter2018-12-081-2/+6
|/ | | | | | | | | | | 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.
* writer: Include documentation and symbol position in source filesThibault Saunier2018-11-281-3/+10
| | | | | | | | | | | 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
* tests: depend on flake8 instead of including pep8/pyflakesChristoph Reiter2018-08-151-2/+1
| | | | | | | | | | | | | | | | g-i includes an old version of pep8 and pyflakes and uses that during "make check". It (1) doesn't catch all cases newer versions of pycodestyle/pyflakes catch and (2) doesn't test all Python files (3) doesn't work with meson. Instead of updating just remove them and depend on flake8 instead. To run the checks simply run flake8 in the root dir. This also makes it possible to run those checks when using meson and not autotools. To not get test suite failures on flake8 updates move the checks from "make check" to an extra "make check.quality" target.
* Factor out pkg-config functionality to a separate module.Tomasz Miąsko2018-07-281-15/+8
| | | | | | | | | | | | | | Functional changes: * Consistently check that return code from pkg-config is zero. * Use shell word splitting rules to process pkg-config output to match behaviour obtained by running `cc program.cc $(pkg-config --cflags ...)`. Fixes issue #171 . * Use user preferred encoding to process output from pkg-config on Python 3. Python 2 behaviour defaults to using ascii encoding as before. edit creiter: still ignore pkg-config errors by default for now as we depend on it when glib is a subproject.
* transformer: don't shell out for filter commands and make the tests work on ↵Christoph Reiter2018-07-251-2/+5
| | | | | | | | | | | | | Windows Instead of passing the filter commands to the shell, split them with the shlex module. This gives us more control and a more similar behaviour on unix/win32 systems. I could only find two users in Debian which just call python with some script, so this seems safe to me. Adjust the tests accordingly and use the running python executable to test the functionality as we can be sure that's available on all platforms. Also add a new test for the symbol filter commadn which wasn't tested before.
* Merge branch 'verbose-distutils' into 'master'Christoph Reiter2018-06-181-0/+3
|\ | | | | | | | | Show commands executed by distutils when being verbose. See merge request GNOME/gobject-introspection!13
| * Show commands executed by distutils when being verbose.Tomasz Miąsko2018-03-141-0/+3
| |
* | Add --version option to Python based tools.Tomasz Miąsko2018-04-261-1/+3
|/ | | | | | | | | | | | | Version file is generated at build time and stored as _version.py. To support running uninstalled tools, a fallback version is included as well. Example output of `--version` option: ``` $ for t in g-ir-{annotation-tool,scanner,doc-tool}; do $t --version; done g-ir-annotation-tool 1.57.1 g-ir-scanner 1.57.1 g-ir-doc-tool 1.57.1 ```
* Revert "giscanner: Fix options in the preprocessor group"Emmanuele Bassi2018-03-101-7/+4
| | | | | | | This reverts commit 17323d2b966146ad19af6285e4eea4cd76bd2c7e. This commit breaks the build of every module using g-ir-scanner with compiler flags that are not just -I directives.
* giscanner: Fix options in the preprocessor groupNirbheek Chauhan2018-03-101-4/+7
| | | | | | | | | | | | | The way we were parsing cflags was causing cpp_includes, cpp_defines, cpp_undefines to always be empty because we would consume all arguments with --cflags-begin's callback. Now, we make a copy of the 'remaining arguments' and parse those to populate the cflags independent of cpp_* flags that are used for building the scanner executable. This fixes the build when glib and friends aren't available in the system prefix.
* giscanner: don't print "suppressed N warnings" if --quiet was specifiedTim-Philipp Müller2018-02-081-1/+1
|
* scanner: Add a way to specify extra libraries to link againstThibault Saunier2016-12-101-0/+3
| | | | | | | | | | | | Currently the only way to get a library to link against the dumper program is through '--link' which implies that library will be defined in the 'libraries' field of the .gir. When using libtool, we link against dependencies of that library as the .la defines that, but when using --no-libtool that won't happen and the user needs to be able to define to what other libraries the program needs to be link against, and this is what the new --extra-library argument is about. https://bugzilla.gnome.org/show_bug.cgi?id=774625
* g-ir-scanner: Set sensible permissions on the output fileMikhail Zabaluev2015-11-011-0/+8
| | | | | | | | If the file is new, set the permissions to 0644. If the file with the name specified as --output exists, copy its metadata onto the temporary output file. https://bugzilla.gnome.org/show_bug.cgi?id=757442
* Don't lose output silently when overwrite of the output file is deniedMikhail Zabaluev2015-11-011-1/+0
| | | | | | | If the move resulted in EPERM, discard the temporary output file, but raise the error so that the tool exits with a nonzero status. https://bugzilla.gnome.org/show_bug.cgi?id=757442
* giscanner: Decode command output for Python 3 compatibilitySimon Feltman2015-09-291-0/+1
| | | | | | | Decode the output of various subprocess calls assuming ascii encoding. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Use StringIO instead of cStringIO in Python 2Simon Feltman2015-09-291-5/+6
| | | | | | | | | | | | Replace usage of the Python 2 cStringIO module with StringIO and conditionally use io.StringIO for Python 3. This is needed to build up a unicode version of the XML since cStringIO does not support unicode. Add XMLWriter.get_encoded_xml() which returns a utf-8 encoded bytes object of the XML data. Open files for reading/writing in binary mode since we explicitly encode and decode as utf-8. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Use unicode literals in all Python filesSimon Feltman2015-09-291-0/+1
| | | | | | | | | | | | Add unicode_literals future import which turns any string literal into a unicode string. Return unicode strings from the Python C extension module. Force writing of annotations (g-ir-annotation-tool) to output utf8 encoded data to stdout. This is an initial pass at following the "unicode sandwich" model of programming (http://nedbatchelder.com/text/unipain.html) needed for supporting Python 3. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Replace repr format usage with string formatterSimon Feltman2015-09-291-4/+4
| | | | | | | | | | | Replace occurances of "%r" (repr) in format strings where the intended behaviour is to output a quoted string "'foo'" with explicit usage of "'%s'". This is needed to move the codebase to unicode literals in order to upgrade to Python 3. Python 2 unicode strings are expanded with repr formatting prefixed with a "u" as in "u'foo'" which causes failures for various text formatting scenarios. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Use print as a function for Python 3 compatibilitySimon Feltman2015-09-291-4/+6
| | | | | | | Use future import "print_function" and update relevant uses of print as a function call. See: PEP 3105 https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Enable "true division" for all Python filesSimon Feltman2015-09-291-0/+1
| | | | | | | | | | Import Python 3 compatible "true division" from the future (PEP 238). This changes the Python 2 classic division which uses floor division on integers to true division. Verfied we don't actually use the division operator anywhere in the code base so this a safety for supporting both Python 2 and 3. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Use absolute_import for all Python filesSimon Feltman2015-09-291-0/+2
| | | | | | Use absolute_import to ensure Python 3 compatibility of the code base. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* scanner: use open() as os.fdopen as context managersDieter Verfaillie2015-08-211-8/+6
| | | | | | Ensures files are correctly and immediately closed. https://bugzilla.gnome.org/show_bug.cgi?id=751926
* scanner: disable cache in reparse validate modeDieter Verfaillie2015-06-241-1/+1
| | | | | | | | | | | | Only types are stored in the cache store, so disable the cache for reparse validate mode since it needs access to the whole serialized tree. This fixes a seemingly hard to debug build failure running 'make distcheck' on source trees configured with --enable-doctool. https://bugzilla.gnome.org/show_bug.cgi?id=751238
* scanner: Add --symbol-filter-cmdGarrett Regier2015-04-201-1/+7
| | | | | | | | | | Add the command line flag --symbol-filter-cmd to g-ir-scanner which allows running symbol names through a filtering shell command. The symbol is sent as stdin to the filter command and expects a filtered result written to stdout. https://bugzilla.gnome.org/show_bug.cgi?id=744534 Signed-off-by: Garrett Regier <garrett.regier@riftio.com>
* build: use the detected pkg-configSaleem Abdulrasool2015-03-241-1/+1
| | | | | | | | | | Rather than assuming that pkg-config is spelt pkg-config, use the environment variable $PKG_CONFIG which is the actual detected pkg-config spelling. This is particularly important when cross-compiling, where the pkg-config may be prefixed with the target and will actually provide a different result from the build pkg-config which may be available unprefixed. https://bugzilla.gnome.org/show_bug.cgi?id=746669
* giscanner: Add Optional Options for CodegenChun-wei Fan2014-09-041-3/+34
| | | | | | | | | | | | | | | | | This adds options to scannermain so that we can decorate functions with macros as needed, so that we can use compiler annotations for symbol export for example. Options are also added to include headers before or after the main include block at the top so that we can include headers as necessary in the generated sources and/or headers, so that we could for example grab definitions from those headers as needed, such as to grab definitions of macros used for symbol export. The testcodegen.py script has been updated as well to make use of this functionality, if needed. https://bugzilla.gnome.org/show_bug.cgi?id=732669
* Check for MINGW instead of MINGW32Ignacio Casal Quinteiro2014-08-061-1/+2
| | | | | | New versions of msys2 provide a MINGW64 env variable instead. https://bugzilla.gnome.org/show_bug.cgi?id=734163
* scanner: Add --identifier-filter-cmdSimon Feltman2014-06-031-1/+7
| | | | | | | | | Add the command line flag --identifier-filter-cmd to g-ir-scanner which allows running identifier names through a filtering shell command. The identifier is sent as stdin to the filter command and expects a filtered result written to stdout. https://bugzilla.gnome.org/show_bug.cgi?706898
* Fix errors parsing OSX 10.9 headersDavide Bertola2014-02-131-0/+4
| | | | | | Un-defining __BLOCKS__ disables blocks in system headers (like stdlib.h). This avoids errors while compiling.
* giscanner: Handle the case when there's a space between -I cpp flag and the pathCarlos Garcia Campos2013-11-161-0/+3
| | | | | | | | | | In this case we were considering -I and the path as two different command line options. This was not a problem in the past (or for other cpp flags) because they are passed directly to gcc that accepts it. Now that we are ensuring that the include paths are always real paths, we need to handle this case to identify include paths in the command line. https://bugzilla.gnome.org/show_bug.cgi?id=712211
* giscanner: Make sure we use real paths in more placesCarlos Garcia Campos2013-11-151-4/+10
| | | | | | | | Ensure we are using the real path also for cflags comming from pkg_config files and command line options. This fixes the generation of the gir files when include paths contain symlinks. https://bugzilla.gnome.org/show_bug.cgi?id=712211
* giscanner: remove g_realpathDieter Verfaillie2013-10-171-2/+2
| | | | | | | | | | | giscannermodule expects file names to be canonicalized and symlinks to be resolved (most likely to support users of symlinked /usr/local). Instead of computing absolute and real paths all over the place, we can do this once on entry in SourceScanner().parse_files() and SourceScanner().parse_macros() and clean the rest a bit... https://bugzilla.gnome.org/show_bug.cgi?id=710320
* giscanner: give message.ERROR a purposeDieter Verfaillie2013-10-081-1/+2
| | | | | | | | | | | | | | | | | | | It's not yet being used but will be in the future by annotationparser.py to signal the difference between message.WARNING: something is wrong but the comment block can still be parsed and serialized back into a comment block without information being lost message.ERROR: something is wrong and the comment block can *not* be parsed and serialized back into a comment block without information being lost Different tools can then act accordingly. Nothing will change for g-ir-scanner but this will be important for the GTK-Doc comment block rewriting tool to prevent extremely broken input leading to even more broken output...
* giscanner: rename the parse() method to parse_comment_blocks()Dieter Verfaillie2013-10-081-1/+1
| | | | | | We already have a parse_comment_block() method parsing a single GTK-Doc comment block so it only seems natural to have a plural parse_comment_blocks() to go along with that.
* giscanner: rename AnnotationParser() to GtkDocCommentBlockParser()Dieter Verfaillie2013-10-081-3/+3
| | | | | | Clarify the purpose of what up until now was know as the AnnotationParser() class, as it does more than just extracting annotations, it parses the complete GTK-Doc comment block.
* tests: Update misc/pep8.py to 1.4.5Dieter Verfaillie2013-05-071-7/+23
| | | | | | | | | | | | | | | | | Version in our tree is a wee bit outdated. For example, later work will introduce an utf8 encoded python source file which our old pep8.py does not yet understand (yeah, it really was *that* ancient)... Updated from: https://raw.github.com/jcrocholl/pep8/1.4.5/pep8.py Takes 552c1f1525e37a30376790151c1ba437776682c5, f941537d1c0a40f0906490ed160db6c79af572d3, 5a4afe2a77d0ff7d9fea13dd93c3304a6ca993de and a17f157e19bd6792c00321c8020dca5e5a281f45 into account... https://bugzilla.gnome.org/show_bug.cgi?id=699535
* transformer: Remove annotationsJasper St. Pierre2013-05-071-1/+0
| | | | | | | The transformer doesn't need the annotations, so why are we giving it to it? https://bugzilla.gnome.org/show_bug.cgi?id=699854
* giscanner: Define source and header filename extensions only onceDieter Verfaillie2013-05-071-5/+2
| | | | | | | Enables us to to use a more effecient list membership test instead of testing the end of some string multiple times. https://bugzilla.gnome.org/show_bug.cgi?id=699533
* giscanner: prefer "except X as e" over "except X, e"Dieter Verfaillie2013-04-091-3/+3
| | | | | | It's more readable and as an added bonus Python 3 compatible. https://bugzilla.gnome.org/show_bug.cgi?id=697616