Build system change


26-07-2006 11:39:29

I'm getting tired of spending 5+ minutes each time I change something in PyOgre.

So I have decided to try to split it up into a few, smaller, parts while still retaining the ability to build a single monolithic .pyd/.so
However, I want this to be transparent to the library user. So from pyogre import ogre would still be the norm.
To make this easier I have decided to use SCons
I have created a basic build script that seems to work for PyOgre and PyCegui in Windows and Linux. But I still have to make
some changes to make the debug build work.

Before I commit this to the repository I would like those of you with compilers to install SCons and download this archive:
Extract the archive to the root of your repository, have a look at SUserOptions, and try to do a build (scons from the command line).
Let me know how it goes and if you see something that could be done better.

In windows the name of the default folder for the Ogre and Cegui headers will change from dependancies to dependencies,
but it's easy to change it by setting the OGRE_HEADERS, OGRE_LIBS, CEGUI_HEADERS and CEGUI_LIBS variables in SUserOptions


26-07-2006 13:41:09

I get

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: *** While building `['bin\\release\\cegui\\cegui.obj']': Don't know how to build a file with suffix `.i'.
scons: building terminated because of errors.

I have my SWIG_PATH = r'C:\Program\swig\swigwin-1.3.29' in SUserOptions.


26-07-2006 14:08:05

It seems that swig also needs to be on the system path.
Try adding C:\Program\swig\swigwin-1.3.29 to the PATH environment variable.

I'll need to look into this.

EDIT: I have fixed it, swig doesn't need to be in the PATH environmen variable


26-07-2006 15:26:10

Just tried out your scons files on linux. Not sure how this reduces compile times. Time taken to compile pyogre and pycegui are same as using The problems I encountered were:

1) The library names for cegui are wrong:

#env.AppendUnique(LIBS=['CEGUIBase', 'OPENGLGUIRenderer', 'OgreGUIRenderer'])
env.AppendUnique(LIBS=['OgreMain','CEGUIBase', 'CEGUIOpenGLRenderer', 'CEGUIOgreRenderer'])

You may also need to add CEGUIFalagardBase?.
Leaving out OgreMain gives import errors, OPENGLGUIRenderer/CEGUIOgreRenderer gives link errors:

import _cegui
ImportError: /usr/local/lib/ undefined symbol: _ZN4Ogre20ResourceGroupManager27DEFAULT_RESOURCE_GROUP_NAMEE

All the above shouldn't be necessary on linux except for additional libraries such as CEGUIFalagardBase. The the library names / includes should be retrieved from the associated package config .pc files

2. The link stage looks wierd, shouldn't this be g++ -shared .....:

gcc -pthread -shared -shared -o bin/release/cegui/ bin/release/cegui/cegui_wrap.os -L/usr/libs -Ldependencies/cegui/lib -L/usr/local/lib -lCEGUIBase -lCEGUIOpenGLRenderer -lCEGUIOgreRenderer

3. How do you install?, I had to copy accross the cegui/'s to's build dir and issue sudo python install.


26-07-2006 16:10:21

Of course this change alone doesn't change build times, it only reduces build time after I have split the bindings into smaller libraries.
That way only the specific binary that the change is in needs to be rebuilt.

There is support for pkg-config in SCons. I'm just pretty much a newbie when it comes to the Linux build environment
and I don't even know what half of the tools do. I'll try to figure something out.

The gcc -pthread -shared line comes from Python distutils.sysconfig.get_config_var('LDSHARED')
But it could also just as well be skipped and the config made in SPosix

The install step needs to be done, but should be pretty simple since
distutils.sysconfig.get_python_lib() returns the path to site_packages.

I'll take a closer look at the cegui build when I get home.


26-07-2006 18:32:22

Sorry misread your initial post regarding build times :D.


26-07-2006 19:48:56

With swig in the path it worked.
One little thing, it would be nice if it was possible to set the swigDefs in the user options file (or maybe its possible now?)

btw, a bit unrelated but not important enough to creat a new thread: are there any reasons why there is no %feature("autodoc", "1"); in cegui.i?


26-07-2006 21:09:09

Do those not have something similar to how you do it in boost::python? For my Ogre bindings I have a single header file that just contains function signature (the binding function, "void init_Ogre(void);", and helper ones like "void addVector3(void)", etc..). I then have many implementation (cpp) files, I have the basic things like Vector2/3, Quats, etc... in a single file, each in their own init function. I have a file for SM's, etc.. In the main init_Ogre function I just call each of the functions in turn. If I change something, recompiles quite a bit faster as it just recompiles the one changed file.


26-07-2006 21:47:19

@OvermindDL1: I think it's pretty much the same idea.

@viblo2: It should be no problem to set swigDefs in the user options file, I'll add it.


27-07-2006 14:04:56

Could you please download the new build script from my server and try it.

I have made a few changes:
  1. Swig doesn't need to be on the path in win32
    Uses pkg-config to discover library and header paths in Linux
    Can install the modules to site-packages/pyogre with the scons install command
    Added a new option *_DLLS which tells the install script where to search for .dll files to copy to the installation folder
    *_HEADERS, *_LIBS and *_DLLS only need to be set if you are building for Win32
    Defines for Swig can be set in the SWIG_DEFINE user option, look at SUserOptions for samples of use[/list:u]


27-07-2006 22:54:46

I asked about setting the swig defs was to build cegui for ogre only (instead of opengl and ogre). Now I realize I forgot that you need to remove OpenGLGUIRenderer from LIBS in SConscript. Maybe you could add that as an option to? (Or you just skip it, I guess most people want to link to all libs :) )

I also noted that when you do scons install, you get not only *.pyd and *.py, but *.lib, *.exp and *.pdb. Was this done on purpose?

Other than that it worked just fine.


28-07-2006 00:06:59

The .lib and .exp are autodetected as belonging to the .pyd/.dll and are therefore installed by default. There is probably a way around it, I'll just have to look for it.
The .pdb file I don't mind, since it's always nice to have the option to debug.

I could maybe add something that checks the swig defs and removes OpenGLGUIRenderer as a dependency if it has been defined out.