summaryrefslogtreecommitdiff
path: root/giscanner
Commit message (Collapse)AuthorAgeFilesLines
* scanner: use open() as os.fdopen as context managersDieter Verfaillie2015-08-217-79/+68
| | | | | | Ensures files are correctly and immediately closed. https://bugzilla.gnome.org/show_bug.cgi?id=751926
* scanner: fix cachestore raceDieter Verfaillie2015-08-211-9/+8
| | | | | | | | Using tempfile.mkstemp should prevent the temp file from being cleaned while it might still be used by another process. https://bugzilla.gnome.org/show_bug.cgi?id=751926
* Revert "dumper.py: Use Distutils to Build Dumper Program"Chun-wei Fan2015-07-312-164/+157
| | | | | | | | | This reverts commit 7ce646db1cb0842db2089df671b17081f82f2b0a. Apparently this patch caused introspection build breakage for gnome-shell, as problems occurred during linking for libgnome-volume-control. Please see bug 728313 comment 105 for more details.
* dumper.py: Use Distutils to Build Dumper ProgramChun-wei Fan2015-07-302-157/+164
| | | | | | | | | | | | | | | | Add compiler() and link() functions in ccompiler.py to call distutil.ccompiler's compile() and link() functions, so that we can in turn call them from dumper.py to build the dumper program. As distutils don't get along well with libtool libraries (ie .la files), we can deduce the libraries to link from using the file name .la file and include $(builddir)/.libs in the linking stage. For MSVC builds, we need to ignore mt.exe failing to find a .exe.manifest file as Visual Studio 2010+ do not generate such files during linking, and it is done by distutils as Python 2.7.x is built with Visual Studio 2008, which do generate such manifest files during the build. https://bugzilla.gnome.org/show_bug.cgi?id=728313
* sourcescanner.py: Use Distutils for PreprocessingChun-wei Fan2015-07-303-41/+170
| | | | | | | | | | | | | | | | | | 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/ccompiler.py: Initiate Distutils Compiler InstanceChun-wei Fan2015-07-302-78/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | This updates the __init__ constructor method of CCompiler so that distutils can be used, with some environment or user-supplied options to create the compiler instance that is appropriate with the platform that the giscanner scripts are being run on, and sets some specific environment for the compilers as necessary. This also adds a check_is_msvc() method that will progressively replace calls in the other giscanner scripts that attempt to check for CC=cl (or so), where a part of which is done in this patch. This is done for dumper.py as well as it needs to be updated in this patch to use the updated ccompiler.py which uses distutils to initiate the compiler instance. Also, as we have been using the --library option on Windows to pass in the library (not DLL) to deduce the correct DLL to link to in the introspection files for some time, we no longer need to make a copy of the library (.lib) to introspect that matches the <namespace>-<namespace_version>.lib convention, but use the libraries that were passed in with --library directly, so that we can link the dumper program during the introspection build. Please note that this also partially reverts commit c9cfa2b as the distutils items are clearly needed for these to work. 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
* scanner: Fix stray comment in previous commitColin Walters2015-07-271-1/+0
| | | | Forgot to amend.
* scanner: Recognize __signedColin Walters2015-07-271-0/+2
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=752904
* tests: Update misc/pep8.py to 1.6.2Dieter Verfaillie2015-06-297-20/+14
| | | | | Updated from: https://raw.githubusercontent.com/jcrocholl/pep8/1.6.2/pep8.py
* scanner: remove unused importsDieter Verfaillie2015-06-292-7/+1
|
* scanner: remove unused param_namesDieter Verfaillie2015-06-291-2/+0
| | | | | | we haven't been emitting the warning for about six years (see 7dbbda9abea9882d2c98726f382a905fa8738706) so remove the leftovers...
* scanner: fix broken assert messageDieter Verfaillie2015-06-291-1/+1
| | | | | | | | 288b339edf262f1dba4e87a9faef46cc79749bd5 changed the signature from def _parse_type_second_pass(self, parent, node, typeval): to def _parse_type_array_length(self, siblings, node, typeval) but failed to change the assert statement accordingly.
* scanner: document LibtoolImporter.load_module()Dieter Verfaillie2015-06-291-9/+6
| | | | | | | | | | | | | | | | | | It was reported by HeBD on #introspection that Python modules use the .pyd extension on windows, not .dll. The simple fix would have been to just rename to .pyd, but we started investigating the possibility of acquiring the suffix tuple(s) via imp.get_suffixes() instead. Which led to the discovery that imp.load_module() simply ignores the first item of said tuple. Thus, there is no use in pretending it to be of any importance in this case so we set it to an empty string. imp_load_module() source for: Python 2.6.9 : https://hg.python.org/cpython/file/fcb3ec2842f9/Python/import.c#l3021 Python 2.7.10: https://hg.python.org/cpython/file/15c95b7d81dc/Python/import.c#l3148 and just to be future-proof: Python 3.4.3 : https://hg.python.org/cpython/file/b4cbecbc0781/Lib/imp.py#l220
* scanner: future-proof cachestore version hashingDieter Verfaillie2015-06-291-2/+1
| | | | | | | Python 3 does not write .pyc files like Python 2 used to do but instead put's them in a __pycache__ directory. Simply compute the version hash using the .py files instead.
* scanner: centralize caret error message handlingDieter Verfaillie2015-06-242-105/+77
| | | | | | | Not doing this manually all over the place makes the code slightly more readable. https://bugzilla.gnome.org/show_bug.cgi?id=689454
* tests: sync with GTK-Doc test suite @ ↵Dieter Verfaillie2015-06-241-5/+2
| | | | | | 02e545371e2132a97458888895cacf57b8c0f83a (2015-06-23) https://bugzilla.gnome.org/show_bug.cgi?id=725685
* 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 "XDG Base Directory" functionsDieter Verfaillie2015-06-203-48/+100
| | | | | | | | | | | | Extract cache and data dir lookup code into documented get_user_cache_dir() and get_system_data_dirs() functions. Note that previously, the data dirs code did not fall back to '/usr/local/share:/usr/share' when the XDG_DATA_DIRS environment variable was either not set or empty, as required by the XDG Base Directory Specification. https://bugzilla.gnome.org/show_bug.cgi?id=747770
* scanner: honor XDG_CACHE_HOMEDieter Verfaillie2015-06-201-0/+5
| | | | | | | | We already use XDG_DATA_DIRS for .gir files lookup so we might as well honor XDG_CACHE_HOME instead of hardcoding ~/.cache. https://bugzilla.gnome.org/show_bug.cgi?id=747770
* docmain: port to using argparse.Mathieu Duponchelle2015-06-171-17/+15
| | | | optparse is deprecated.
* scanner/girepository: remove GdkRectangle->CairoRectangleInt automatic ↵Lionel Landwerlin2015-05-111-6/+0
| | | | | | conversion https://bugzilla.gnome.org/show_bug.cgi?id=748832
* scanner: Add --symbol-filter-cmdGarrett Regier2015-04-202-2/+22
| | | | | | | | | | 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>
* scanner: remove stray debug spewDieter Verfaillie2015-04-191-1/+0
| | | | | remove stray debugging print statement introduced in db7ab0e797f755fb7ff273a2071d27fd62a2b7c7
* scanner: Don't fail when GI_SCANNER_DISABLE_CACHE is setGarrett Regier2015-04-191-2/+2
| | | | | | | | | It was assumed that cache store was always working, this also removes a round trip to the cache store. So performance should also get a small boost. https://bugzilla.gnome.org/show_bug.cgi?id=746231 Signed-off-by: Garrett Regier <garrett.regier@riftio.com>
* scanner: allow multiline annotationsDieter Verfaillie2015-04-181-50/+49
| | | | | | | Allow `identifier`, `parameter` and `tag` part `annotations` fields to span multiple lines https://bugzilla.gnome.org/show_bug.cgi?id=676133
* scanner: sync with upstream OrderedDictDieter Verfaillie2015-04-181-13/+26
| | | | Synced with https://github.com/zzzeek/sqlalchemy/commit/a4a826021fb6d77fadbdac0071616d7e5486e4d1
* scanner: fix a docstring typoDieter Verfaillie2015-04-181-1/+1
|
* 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: enable the --reparse-validate option for our test suiteDieter Verfaillie2015-03-041-1/+19
| | | | | | | | | | Doing so reveals GIRParser did not yet support: - the (skip) annotation on parameters and return values - the (attributes) annotation This patch fixes both issues an prevents further similar problems. https://bugzilla.gnome.org/show_bug.cgi?id=738171
* scanner: Support the C99 'bool' typeEmmanuele Bassi2015-03-042-0/+3
| | | | | | Otherwise API using it will badly break in weird ways. https://bugzilla.gnome.org/show_bug.cgi?id=745608
* scanner: allow (array zero-terminated) instead of (array zero-terminated=1)Dieter Verfaillie2015-03-032-4/+13
| | | | | | | | | | | | | | What we already had: - (array zero-terminated=1) > array which is NULL terminated - (array zero-terminated=0) > array which is not NULL terminated - (array) > array which is not NULL terminated - (array zero-terminated=X) > array which is not NULL terminated where X can be anything What this patch adds: - (array zero-terminated) > array which is NULL terminated https://bugzilla.gnome.org/show_bug.cgi?id=657754
* girepository: Document semantics of dependencies and includes betterPhilip Withnall2015-02-161-0/+1
| | | | | | | | Make it clear that both the dependencies field in the typelib, and the include elements in the GIR AST, are for immediate dependencies, not transitive ones. https://bugzilla.gnome.org/show_bug.cgi?id=743782
* 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
* scanner: Honor nested types on array declarations as wellColin Walters2014-09-051-1/+4
| | | | | | | | | We have special code to look at (type GLib.List(utf8)), but (type GLib.PtrArray(utf8)) didn't work. This allows NetworkManager to annotate the ActiveConnections property. https://bugzilla.gnome.org/show_bug.cgi?id=733879
* giscanner: Add Optional Options for CodegenChun-wei Fan2014-09-043-6/+82
| | | | | | | | | | | | | | | | | 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
* Fix windows buildIgnacio Casal Quinteiro2014-09-021-2/+2
|
* scannerlexer.l: Update to Support MSVC PreprocessorChun-wei Fan2014-08-151-5/+18
| | | | | | | | | | | | | | This updates giscanner/scannerlexer.l by ignoring the Visual C++-specific directives, so that the scanner will not bail out while trying to produce the introspection dumper program source code, and silence many of the warnings that are produced in the process. As the Visual C++ processor produces slightly different line markers, we need to handle this here as well, otherwise the sources/headers would not be processed to acquire the _get_type and _get_gtype symbols to put in the introspection dumper sources, producing bad results. https://bugzilla.gnome.org/show_bug.cgi?id=728313
* Revert "codegen.py: Update Generation of everything.[c|h]"Chun-wei Fan2014-08-151-10/+1
| | | | This reverts commit 7a82752734b496bb619fce62572c0c7f8578350a.
* codegen.py: Update Generation of everything.[c|h]Chun-wei Fan2014-08-151-1/+10
| | | | | | | | Update everything.h include the header used to decorate symbols with the macro for export and everything.c to include config.h first, and have the symbols decorated with the aforementioned macro. 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
* giscanner: Add New CCompiler ModuleChun-wei Fan2014-08-053-157/+221
| | | | | | | | | | | | | | | This adds a CCompiler module for the giscanner Python scripts so that items related to the run of the preprocessor, compiler and linker can be done in this module, and this marks the beginning of the move of building the introspection files using Python's distutils. This patch first moves _add_[internal|external]_link_flags() to ccompiler.py as get_[internal|external]_link_flags and also moves the Windows shlibs resolution (deducing the DLLs the introspection files should link to from the libraries passed in) in shlibs.py to resolve_windows_libs() in ccompiler.py https://bugzilla.gnome.org/show_bug.cgi?id=728313
* giscanner/cachestore.py: Clean up a bitChun-wei Fan2014-08-011-4/+1
| | | | | | | Use the special os.path.expanduser('~'), as it it more portable, instead of quering the HOME or HOMEPATH envvar. https://bugzilla.gnome.org/show_bug.cgi?id=732668
* giscanner: Make _get_cachedir() Always Work on WindowsChun-wei Fan2014-07-041-1/+4
| | | | | | | | | | On Windows, checking for $(HOME) will work in a MSYS shell but not in cmd.exe (i.e. Visual Studio command prompt), so we need to check for HOMEPATH when we are building under a Visual Studio command prompt to get the users's home directory correctly. This will enable g-ir-doc-tool to work on Windows when run from cmd.exe. https://bugzilla.gnome.org/show_bug.cgi?id=732668
* scanner: Add --identifier-filter-cmdSimon Feltman2014-06-032-2/+21
| | | | | | | | | 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
* annotationparser: more nullable fixesRyan Lortie2014-05-081-0/+2
| | | | | Add ANN_NULLABLE and ANN_OPTIONAL in the one (and only) other place that ANN_ALLOW_NONE is mentioned...
* giscanner: allow (nullable) and (optional)Ryan Lortie2014-05-071-2/+2
| | | | | | | Add (nullable) and (optional) as recognised annotations in the same places that (allow-none) is allowed. This should have been done in the previous commits but the tests were passing because the only ill effect was that a warning was issued.
* Revert "giscanner: don't accept (allow-none) on Returns:"Ryan Lortie2014-05-061-1/+1
| | | | | | | This reverts commit 0839e696e9fbc1942ac5c61054de3b47e9578152. This was accidentally picked up by my 'git bz apply' against the bug as I was getting ready to push the last set of changes.
* giscanner: fix a comparisonRyan Lortie2014-05-061-1/+1
| | | | | | | | In the case that a parameter has not been explicitly annotated, the value of node.direction will be None, not 'in'. Instead of comparing as == 'in' we should therefore check for being != 'out'. https://bugzilla.gnome.org/show_bug.cgi?id=660879
* giscanner: support nullable return types tooRyan Lortie2014-05-063-6/+9
| | | | | | | | | | Promote the 'nullable' field to the TypeContainer base class (which is shared by Return and Parameter types). Add .gir support for nullability on return values, both in the writer and in the (scanner's) parser. https://bugzilla.gnome.org/show_bug.cgi?id=660879