[Cython] GCC Pxd

Philip Herron redbrain at gcc.gnu.org
Fri May 9 17:09:50 CEST 2014


Just small update i think i have got most of C code working now, but
working on C++ generation again its all shaping up to look pretty
usable. I wonder by the off chance is there a python library that can
parse the C preprocessor if anyone knows or not i am looking at
https://code.google.com/p/pypreprocessor/ to try and parse cpp as this
information is lost at the Middle-end level in GCC where the plugin
runs.

On 1 May 2014 14:01, Stefan Behnel <stefan_ml at behnel.de> wrote:
> [forwarding Philip's mail to the Cython users mailing list]
>
> Hey all,
>
> Some of you may remember a project i worked on for GSoC 2012, i wasn't
> really happy with the project over all for a long time it basicaly
> required at the time people to be running GCC from latest SVN/GIT for
> it to work correctly.
>
> Now gcc >= 4.7 is becoming more normal, so i went back into it and
> rewrote it from scratch now and its shaping up to look fairly decent
> and usable now.
>
> https://github.com/redbrain/cython/tree/master/Tools/gccpxd
>
> So the idea for this project is that you write a small configuration
> file and it will integrate with your C/C++ build system for example
> you could do:
>
> ./configure CC=cygcc ...
> make
> ...
>
> And you will get a project.pxd file after the build of your software.
> the cygcc is simply a wrapper over GCC that shoves in the fplugin
> arguments so you can run:
>
> cygcc -g -O2 -Wall -c test.c -o test.o
>
> So build systems wont really notice anything different it should just
> think its gcc. The configuration file example in the folder .cygcc:
>
> $ cat .cygcc
> header = 'test.h'             # the header to get declaratiosn for
> inputs = ['test.h', 'test.c'] # any locations of declarations that
> would be involved
> output = 'test.pxd'          # the output
>
> The cygcc compiler looks for this in the current director or looks up
> at the parent directory untill it finds it or it will fail with an
> error message.
>
> It will only ouput once if the test.pxd file exists in the current
> working directory it wont do anything.
>
> $ cat test.pxd
> cdef extern from "test.h":
>   int test (int, int)
>   int global_variable
>   int static_variable # this is a bug but hey...
>   struct bla:
>     int a
>     float b
>
> So far for the example code in there its working pretty well the gcc
> python plugin has stabalized alot and so has some of gcc's bits a
> bobs. I will try and keep you all updated i think the plugin is doing
> alot more work now so this doesnt have to do so much.
>
> Thanks to Robert Bradshaw for baring with me in the whole thing
> because i probably wasn't the easiest to work with ;) lol.
>
> Thanks everyone cython is awesome.
>
> --Phil
>


More information about the cython-devel mailing list