summaryrefslogtreecommitdiff
path: root/giscanner/sourcescanner.py
Commit message (Collapse)AuthorAgeFilesLines
* Add --compiler argument to g-ir-scannerEmmanuele Bassi2022-02-121-1/+5
| | | | | | | | | | | | We currently use the `CC` environment variable to find the C compiler to use internally in g-ir-scanner. Build systems might wish to store the compiler detected during the build configuration, and then pass that compiler to g-ir-scanner at the time of build, avoiding to put things into the environment. One possible solution is to have a command line argument that lets us specify the C compiler, with the same semantics as the `CC` environment variable.
* Remove LibtoolImporterChristoph Reiter2020-11-071-9/+8
| | | | | From what I can see this was used for importing the C ext in an uninstalled libtool build of g-i. We no longer use libtool, so this is no longer needed.
* Windows: Fix building and running on Python 3.8+Chun-wei Fan2020-01-161-1/+4
| | | | | | | | | | | | | | | | | | | | | | | 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.
* scanner: parse and expose function macrosMathieu Duponchelle2019-07-191-1/+3
| | | | | This is useful for documentation tools, and other utilities that rely on full introspection of the C API of a given library.
* 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 'drop-py-compat-code' into 'master'Christoph Reiter2018-12-081-6/+0
|\ | | | | | | | | Drop all Python 2 compat code See merge request GNOME/gobject-introspection!85
| * Drop all Python 2 compat codeChristoph Reiter2018-12-081-6/+0
| | | | | | | | We only support 3.4+ now.
* | sourcescanner: collect error messages and expose themChristoph Reiter2018-12-081-0/+3
|/ | | | | | | | | | | 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.
* gi_source_scanner_parse_file: use a filename instead of a FILE structChristoph Reiter2018-12-061-4/+1
| | | | | | 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.
* tests: depend on flake8 instead of including pep8/pyflakesChristoph Reiter2018-08-151-1/+0
| | | | | | | | | | | | | | | | 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.
* giscanner: Recognize _Thread_local as a storage class specifierTing-Wei Lan2018-01-091-0/+1
| | | | | | | | | _Thread_local is a C11 keyword, and thread_local is a macro to make it more confortable to read. As this keyword can only be used in variable declarations, not in function return values or parameters, it cannot be included in bindable APIs and we can safely ignore it. https://bugzilla.gnome.org/show_bug.cgi?id=756921
* giscanner: Update location of temp sources and objectsChun-wei Fan2017-05-011-1/+3
| | | | | | | | | | | | | | For preprocessing, when we create the temp file for preprocessing, make the temp file be stored in CWD instead of the system's temp directory; and when we compile the dumper program, set the output_dir to be the root directory (<drive letter>:\ on Windows and / otherwise). This is because distutils insists on using the full path from the root directory to compile sources, so that if we set the output_dir as we now do we will get $(abs_srcdir)/$(tmpdir)/<$(abs_srcdir)_minus_rootdir>/$(tmpdir)/<target_gir_file_name>.[o|obj]. https://bugzilla.gnome.org/show_bug.cgi?id=781525
* giscanner: Fix python2/3 compatibilityDamien Grassart2015-10-191-5/+5
| | | | | | | This allows building in both Python 2 and 3 by fixing a few text/binary ambiguities and using "as" in an except clause. https://bugzilla.gnome.org/show_bug.cgi?id=756763
* giscanner: Encode data passed to subprocess.stdin.writeSimon Feltman2015-09-291-3/+2
| | | | | | | ASCII encode bytes sent to subprocess.stdin.write to ensure Python 2 and 3 compatibility. 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-3/+3
| | | | | | | | | | | 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-2/+3
| | | | | | | 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
* sourcescanner.py: Use Distutils for PreprocessingChun-wei Fan2015-07-301-40/+6
| | | | | | | | | | | | | | | | | | Add a preprocess() function in ccompiler.py so that it will call the preprocess() method of the distutils.ccompiler class, and make use of it from sourcescanner.py. As we would need to set up the options (include paths, macros, undefs) to pass into the preprocessor (and later for the compiler), we have a new private function that translates what we have from the rest of giscanner so that it could be passed to distutils.ccompiler in a way that it understands. Also, as the MSVCCompiler classes in distutils do not provide a preprocess() implementation, we provide our own so that we can use it when preprocessing, via distutils, through subclassing MSVCCompiler. https://bugzilla.gnome.org/show_bug.cgi?id=728313
* giscanner/sourcescanner.py: Use Tempfiles For ParsingChun-wei Fan2015-07-301-31/+47
| | | | | | | | | | | | | As we attempt to move giscanner to use distutils for preprocessing and building the introspection dumper program, we need to update _parse(), where the preprocessor is called, to not use stdin and stdout for the preprocessor input and output, as distutils do not accept such usage. The added bonus for this change is that MSVC builds can be done without using MinGW/GCC as a helper, as the '-' flag for preprocessing from stdin was the hindrance to that. https://bugzilla.gnome.org/show_bug.cgi?id=728313
* tests: Update misc/pep8.py to 1.6.2Dieter Verfaillie2015-06-291-1/+1
| | | | | Updated from: https://raw.githubusercontent.com/jcrocholl/pep8/1.6.2/pep8.py
* scanner: don't pass certain debug level flags to cppMichael Catanzaro2015-02-131-0/+8
| | | | | | | These may cause cpp to output code that still has #defines in them, which the scanner does not expect. https://bugzilla.gnome.org/show_bug.cgi?id=720504
* Honour CPPFLAGS as we do CFLAGSRyan Lortie2013-12-211-0/+1
| | | | | | | In all of the places that we pass through the CFLAGS, we should be doing the same with the CPPFLAGS. https://bugzilla.gnome.org/show_bug.cgi?id=720063
* scanner: make sure we pass CFLAGS to cppRyan Lortie2013-12-081-0/+1
| | | | | | | | When doing the source scanning in giscanner, make sure we pass the user's CFLAGS environment variable to the compiler, as we do for the dumper. https://bugzilla.gnome.org/show_bug.cgi?id=720063
* scanner: Support boolean constantsFlorian Müllner2013-11-291-2/+6
| | | | | | | | Aliasing TRUE or FALSE is not very common, but done occasionally for extra clarity. Namely G_SOURCE_REMOVE / G_SOURCE_CONTINUE are self-explanatory, unlike the "raw" booleans. https://bugzilla.gnome.org/show_bug.cgi?id=719566
* giscanner: Make sure we use real paths in more placesCarlos Garcia Campos2013-11-151-2/+2
| | | | | | | | 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-4/+4
| | | | | | | | | | | 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
* tests: Update misc/pep8.py to 1.4.5Dieter Verfaillie2013-05-071-5/+3
| | | | | | | | | | | | | | | | | 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
* giscanner: small cpp_args cleanupDieter Verfaillie2013-05-071-11/+9
| | | | | | No need for two variables... https://bugzilla.gnome.org/show_bug.cgi?id=699533
* giscanner: Define source and header filename extensions only onceDieter Verfaillie2013-05-071-2/+5
| | | | | | | 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: use mkstemp() instead of mktemp()Dieter Verfaillie2013-04-091-3/+3
| | | | | | mktemp was deprecated in Python 2.3... https://bugzilla.gnome.org/show_bug.cgi?id=697624
* scanner: Allow CFLAGS to contain arbitrary preprocessor commands like -includeColin Walters2013-03-061-1/+2
| | | | | | | | | Newer spidermonkey .pc file contains a -include argument, which g-ir-scanner doesn't understand. Rather than us attempting to replicate all of cpp's options, use wrapper arguments in Makefile.introspection to pass them through. https://bugzilla.gnome.org/show_bug.cgi?id=695182
* Revert "gi-r-scanner: add support for raw CFLAGS flags option"Colin Walters2013-03-051-3/+1
| | | | | | Doesn't work with arguments that have shell quotes. This reverts commit 95b03cf87efbd4fea4b7d55601c9752cefd29bfc.
* gi-r-scanner: add support for raw CFLAGS flags optionTim Lunn2013-03-061-1/+3
| | | | | | | | gi-r-scanner chokes when gir_CFLAGS have an '-include <header>' since this is not a recognised option. This commit adds a new --cflags option that passes cflags directly to the spawned gcc. https://bugzilla.gnome.org/show_bug.cgi?id=695182
* giscanner/sourcescanner.py: Update for Visual C++ usageChun-wei Fan2012-10-271-1/+10
| | | | | | | | | | | Since the Visual C++ (cl.exe) preprocessor does not accept source input from stdin (the '-' preprocessor flag, we need to use the GCC preprocessor as a helper here. Note that the generated dumper program is still compiled and run by Visual C++. https://bugzilla.gnome.org/show_bug.cgi?id=681820
* Do the filename filtering in scannerlexerJohan Dahlin2012-04-051-4/+1
| | | | | This avoids a bit of python work and reduces the amount of allocations.
* Don't parse doc comments in dependenciesJohan Dahlin2012-04-051-2/+5
| | | | | Only parse doc comments for the files we pass in on the command line to g-ir-scanner, not the included dependencies.
* scanner: split CC environment variableNatanael Copa2011-10-101-1/+2
| | | | | | | | This fixes compilation where CC="ccache gcc" and similar. https://bugzilla.gnome.org/show_bug.cgi?id=660160 Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
* Let the user override the default compiler with the CC env variableAndoni Morales Alastruey2011-09-031-1/+1
|
* Switch to nonrecursive make for core (i.e. not tests/)Colin Walters2010-11-091-3/+7
| | | | | This is cleaner and faster, and prepares us better for an incoming import of CMPH.
* scanner: fail if cpp failsVincent Untz2010-09-271-0/+5
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=630101
* [scanner] Support private/public directivesJohan Dahlin2010-09-201-0/+4
| | | | Fixes https://bugzilla.gnome.org/show_bug.cgi?id=594125
* [scanner] Add a Position classJohan Dahlin2010-09-201-1/+6
| | | | | | Add a position class which will make it easier to send filename/line/column information to the message class.
* Major rewriteColin Walters2010-08-311-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One of the first big changes in this rewrite is changing the Type object to have separate target_fundamental and target_giname properties, rather than just being strings. Previously in the scanner, it was awful because we used heuristics around strings. The ast.py is refactored so that not everything is a Node - that was a rather useless abstraction. Now, only things which can have a GIName are Node. E.g. Type and Field are no longer Node. More things were merged from glibast.py into ast.py, since it isn't a very useful split. transformer.py gains more intelligence and will e.g. turn GLib.List into a List() object earlier. The namespace processing is a lot cleaner now; since we parse the included .girs, we know the C prefix for each namespace, and have functions to parse both C type names (GtkFooBar) and symbols gtk_foo_bar into their symbols cleanly. Type resolution is much, much saner because we know Type(target_giname=Gtk.Foo) maps to the namespace Gtk. glibtransformer.py now just handles the XML processing from the dump, and a few miscellaneous things. The major heavy lifting now lives in primarytransformer.py, which is a combination of most of annotationparser.py and half of glibtransformer.py. annotationparser.py now literally just parses annotations; it's no longer in the business of e.g. guessing transfer too. finaltransformer.py is a new file which does post-analysis for "introspectability" mainly. girparser.c is fixed for some introspectable=0 processing.
* [scanner] Also parse C++ filesGustavo Noronha Silva2010-08-171-1/+2
| | | | | | | | This is to support cases such as WebKitGTK+, that have C API implemented in C++ files. Do note this does not mean we support proper C++ parsing. https://bugzilla.gnome.org/show_bug.cgi?id=627152
* [scanner] Make it compatible with python 2.yJohan Dahlin2010-07-221-1/+1
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=618562
* Support introspectable=no attribute, add warnings frameworkColin Walters2010-06-171-0/+4
| | | | | | | | | | | | | | | | | | This work allows us to move closer to replacing gtk-doc, among other things. We add a generic attribute "introspectable", and inside the typelib compiler if we see "introspectable=no", we don't put it in the typelib. This replaces the hackish pre-filter for varargs with a much more generic mechanism. The varargs is now handled in the scanner, and we emit introspectable=no for them. Add generic metadata to Node with references to file/line/column, which currently comes from symbols. Add scanner options --warn-all and --warn-error. https://bugzilla.gnome.org/show_bug.cgi?id=621570
* Revert "Support introspectable=no attribute, add warnings framework"Johan Dahlin2010-06-171-4/+0
| | | | This reverts commit 074192b89c6afcdd7f062f03989972e44334b8bf.
* Support introspectable=no attribute, add warnings frameworkColin Walters2010-06-161-0/+4
| | | | | | | | | | | | | | | | This work allows us to move closer to replacing gtk-doc, among other things. We add a generic attribute "introspectable", and inside the typelib compiler if we see "introspectable=no", we don't put it in the typelib. This replaces the hackish pre-filter for varargs with a much more generic mechanism. The varargs is now handled in the scanner, and we emit introspectable=no for them. Add generic metadata to Node with references to file/line/column, which currently comes from symbols. Add scanner options --Wall and --Werror.