Scons build files for Irrlicht

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
wyrmmage
Posts: 204
Joined: Sun Mar 16, 2008 3:12 am
Contact:

Scons build files for Irrlicht

Post by wyrmmage »

I'm not quite sure if this is the place to post this but I didn't really see anywhere better. As some of you may have noticed from my posts around the forum, I use a build tool called Scons. Scons is a cross-platform build tool that can easily be integrated with makefiles, and can handle complex builds more easily than makefiles IMHO. I'd like to make some SConstruct files (which is what Scons uses instead of makefiles), and have them shipped with the source alongside the makefiles that are already used with Irrlicht.
The advantage of this would be that people who build Irrlicht on different OS's should be able to use the same SConstruct file. I'd eventually like to see the code for MacOSX integrated with the normal Irrlicht code, but that's a separate project, eh? ;) Another advantage is that people could use either gcc or MSVC by just changing a flag in the SConstruct file...don't know if you can do this with Makefiles, since I haven't really used them too much.
Anyway....does anyone else here use Scons? Would it even be worth making SConstruct files to ship alongside the existing Makefiles? It should only be a couple of hours worth of work; if people will actually use this, I'll submit a patch to the tracker and hopefully it'll get put into the main trunk. I've never worked on an open source project before, so we'll see how this goes XD
I'm probably going to write files so I can use Scons anyway, but I wont bother submitting it as a patch unless people would actually use this (I'll post the files in case anyone is interested, though) 8)

Thanks in advance :)
-wyrmmage
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Since no one of the devs use this tool (AFAIK), it could be hard to maintain it. But it might be worth posting it to the tracker or even better to the Wiki (because it could be maintained more easily then).
Raedwulf
Posts: 62
Joined: Sat Aug 20, 2005 7:08 am

Post by Raedwulf »

I second this, scons is quite good but for most of the devs here are more or less solo OS users/developers, it wouldn't be dramatically useful :P.
Raedwulf
wyrmmage
Posts: 204
Joined: Sun Mar 16, 2008 3:12 am
Contact:

Post by wyrmmage »

alright, the SCons file is finally done! ^_^

Here's the file:

Code: Select all

import os
import sys

USE_GCC = 1;
NDEBUG = 1;
PROFILE = 1;

APPLICATION_NAME = 'Irrlicht';
LIBRARIES = ['gdi32', 'opengl32', 'd3dx9d'];
if USE_GCC==1 and PROFILE==1:
	LIBRARIES += ['gmon'];

CXXINCS = ['../../include/', 'zlib/', 'jpeglib/', 'libpng/'];

if USE_GCC==0:
	env = Environment(ENV = {
        'PATH': os.environ['PATH']
    }, CPPPATH=CXXINCS);
else:
	env = Environment(ENV = {
        'PATH': os.environ['PATH']
    }, tools = ['mingw'], CPPPATH=CXXINCS);

IRRMESHLOADER = ['CBSPMeshFileLoader.cpp', 'CMD2MeshFileLoader.cpp', 'CMD3MeshFileLoader.cpp', 'CMS3DMeshFileLoader.cpp', 'CB3DMeshFileLoader.cpp', 'C3DSMeshFileLoader.cpp', 'COgreMeshFileLoader.cpp', 'COBJMeshFileLoader.cpp', 'CColladaFileLoader.cpp', 'CCSMLoader.cpp', 'CDMFLoader.cpp', 'CLMTSMeshFileLoader.cpp', 'CMY3DMeshFileLoader.cpp', 'COCTLoader.cpp', 'CXMeshFileLoader.cpp', 'CIrrMeshFileLoader.cpp', 'CSTLMeshFileLoader.cpp', 'CLWOMeshFileLoader.cpp'];

IRRMESHWRITER = ['CColladaMeshWriter.cpp', 'CIrrMeshWriter.cpp', 'CSTLMeshWriter.cpp'];

IRRMESHOBJ = IRRMESHLOADER + IRRMESHWRITER + ['CSkinnedMesh.cpp', 'CBoneSceneNode.cpp', 'CMeshSceneNode.cpp', 'CAnimatedMeshSceneNode.cpp', 'CAnimatedMeshMD2.cpp', 'CAnimatedMeshMD3.cpp', 'CQ3LevelMesh.cpp', 'CQuake3ShaderSceneNode.cpp'];

IRROBJ = ['CBillboardSceneNode.cpp', 'CCameraSceneNode.cpp', 'CDummyTransformationSceneNode.cpp', 'CEmptySceneNode.cpp', 'CGeometryCreator.cpp', 'CLightSceneNode.cpp', 'CMeshManipulator.cpp', 'CMetaTriangleSelector.cpp', 'COctTreeSceneNode.cpp', 'COctTreeTriangleSelector.cpp', 'CSceneCollisionManager.cpp', 'CSceneManager.cpp', 'CShadowVolumeSceneNode.cpp', 'CSkyBoxSceneNode.cpp', 'CSkyDomeSceneNode.cpp', 'CTerrainSceneNode.cpp', 'CTerrainTriangleSelector.cpp', 'CVolumeLightSceneNode.cpp', 'CCubeSceneNode.cpp', 'CSphereSceneNode.cpp', 'CTextSceneNode.cpp', 'CTriangleBBSelector.cpp', 'CTriangleSelector.cpp', 'CWaterSurfaceSceneNode.cpp', 'CMeshCache.cpp', 'CDefaultSceneNodeAnimatorFactory.cpp', 'CDefaultSceneNodeFactory.cpp'];

IRRPARTICLEOBJ = ['CParticleAnimatedMeshSceneNodeEmitter.cpp', 'CParticleBoxEmitter.cpp', 'CParticleCylinderEmitter.cpp', 'CParticleMeshEmitter.cpp', 'CParticlePointEmitter.cpp', 'CParticleRingEmitter.cpp', 'CParticleSphereEmitter.cpp', 'CParticleAttractionAffector.cpp', 'CParticleFadeOutAffector.cpp', 'CParticleGravityAffector.cpp', 'CParticleRotationAffector.cpp', 'CParticleSystemSceneNode.cpp'];

IRRANIMOBJ = ['CSceneNodeAnimatorCameraFPS.cpp', 'CSceneNodeAnimatorCameraMaya.cpp', 'CSceneNodeAnimatorCollisionResponse.cpp', 'CSceneNodeAnimatorDelete.cpp', 'CSceneNodeAnimatorFlyCircle.cpp', 'CSceneNodeAnimatorFlyStraight.cpp', 'CSceneNodeAnimatorFollowSpline.cpp', 'CSceneNodeAnimatorRotation.cpp', 'CSceneNodeAnimatorTexture.cpp'];

IRRDRVROBJ = ['CNullDriver.cpp', 'COpenGLDriver.cpp', 'COpenGLNormalMapRenderer.cpp', 'COpenGLParallaxMapRenderer.cpp', 'COpenGLShaderMaterialRenderer.cpp', 'COpenGLTexture.cpp', 'COpenGLSLMaterialRenderer.cpp', 'COpenGLExtensionHandler.cpp', 'CD3D8Driver.cpp', 'CD3D8NormalMapRenderer.cpp', 'CD3D8ParallaxMapRenderer.cpp', 'CD3D8ShaderMaterialRenderer.cpp', 'CD3D8Texture.cpp', 'CD3D9Driver.cpp', 'CD3D9HLSLMaterialRenderer.cpp', 'CD3D9NormalMapRenderer.cpp', 'CD3D9ParallaxMapRenderer.cpp', 'CD3D9ShaderMaterialRenderer.cpp', 'CD3D9Texture.cpp'];

IRRIMAGEOBJ = ['CColorConverter.cpp', 'CImage.cpp', 'CImageLoaderBMP.cpp', 'CImageLoaderJPG.cpp', 'CImageLoaderPCX.cpp', 'CImageLoaderPNG.cpp', 'CImageLoaderPSD.cpp', 'CImageLoaderTGA.cpp', 'CImageLoaderPPM.cpp', 'CImageLoaderWAL.cpp', 'CImageWriterBMP.cpp', 'CImageWriterJPG.cpp', 'CImageWriterPCX.cpp', 'CImageWriterPNG.cpp', 'CImageWriterPPM.cpp', 'CImageWriterPSD.cpp', 'CImageWriterTGA.cpp'];

IRRVIDEOOBJ = ['CVideoModeList.cpp', 'CFPSCounter.cpp'] + IRRDRVROBJ + IRRIMAGEOBJ;

IRRSWRENDEROBJ = ['CSoftwareDriver.cpp', 'CSoftwareTexture.cpp', 'CTRFlat.cpp', 'CTRFlatWire.cpp', 'CTRGouraud.cpp', 'CTRGouraudWire.cpp', 'CTRTextureFlat.cpp', 'CTRTextureFlatWire.cpp', 'CTRTextureGouraud.cpp', 'CTRTextureGouraudAdd.cpp', 'CTRTextureGouraudNoZ.cpp', 'CTRTextureGouraudWire.cpp', 'CZBuffer.cpp', 'CTRTextureGouraudVertexAlpha2.cpp', 'CTRTextureGouraudNoZ2.cpp', 'CTRTextureLightMap2_M2.cpp', 'CTRTextureLightMap2_M4.cpp', 'CTRTextureLightMap2_M1.cpp', 'CSoftwareDriver2.cpp', 'CSoftwareTexture2.cpp', 'CTRTextureGouraud2.cpp', 'CTRGouraud2.cpp', 'CTRGouraudAlpha2.cpp', 'CTRGouraudAlphaNoZ2.cpp', 'CTRTextureDetailMap2.cpp', 'CTRTextureGouraudAdd2.cpp', 'CTRTextureGouraudAddNoZ2.cpp', 'CTRTextureWire2.cpp', 'CTRTextureLightMap2_Add.cpp', 'CTRTextureLightMapGouraud2_M4.cpp', 'IBurningShader.cpp', 'CTRTextureBlend.cpp', 'CTRTextureGouraudAlpha.cpp', 'CTRTextureGouraudAlphaNoZ.cpp', 'CDepthBuffer.cpp', 'CBurningShader_Raster_Reference.cpp'];

IRRIOOBJ = ['CFileList.cpp', 'CFileSystem.cpp', 'CLimitReadFile.cpp', 'CMemoryReadFile.cpp', 'CReadFile.cpp', 'CWriteFile.cpp', 'CXMLReader.cpp', 'CXMLWriter.cpp', 'CZipReader.cpp', 'CPakReader.cpp', 'irrXML.cpp', 'CAttributes.cpp'];

IRROTHEROBJ = ['CIrrDeviceSDL.cpp', 'CIrrDeviceLinux.cpp', 'CIrrDeviceStub.cpp', 'CIrrDeviceWin32.cpp', 'CLogger.cpp', 'COSOperator.cpp', 'Irrlicht.cpp', 'os.cpp'];

IRRGUIOBJ = ['CGUIButton.cpp', 'CGUICheckBox.cpp', 'CGUIComboBox.cpp', 'CGUIContextMenu.cpp', 'CGUIEditBox.cpp', 'CGUIEnvironment.cpp', 'CGUIFileOpenDialog.cpp', 'CGUIFont.cpp', 'CGUIImage.cpp', 'CGUIInOutFader.cpp', 'CGUIListBox.cpp', 'CGUIMenu.cpp', 'CGUIMeshViewer.cpp', 'CGUIMessageBox.cpp', 'CGUIModalScreen.cpp', 'CGUIScrollBar.cpp', 'CGUISpinBox.cpp', 'CGUISkin.cpp', 'CGUIStaticText.cpp', 'CGUITabControl.cpp', 'CGUITable.cpp', 'CGUIToolBar.cpp', 'CGUIWindow.cpp', 'CGUIColorSelectDialog.cpp', 'CDefaultGUIElementFactory.cpp', 'CGUISpriteBank.cpp'];

ZLIB_PREFIX = 'zlib/';
ZLIBNAMES = ['adler32.c', 'compress.c', 'crc32.c', 'deflate.c', 'inffast.c', 'inflate.c', 'inftrees.c', 'trees.c', 'uncompr.c', 'zutil.c'];
ZLIBOBJ = [];
for fileName in ZLIBNAMES:
	ZLIBOBJ += [ZLIB_PREFIX + fileName];

JPEGLIB_PREFIX = 'jpeglib/';
JPEGLIBNAMES = ['jcapimin.c', 'jcapistd.c', 'jccoefct.c', 'jccolor.c', 'jcdctmgr.c', 'jchuff.c', 'jcinit.c', 'jcmainct.c', 'jcmarker.c', 'jcmaster.c', 'jcomapi.c', 'jcparam.c', 'jcphuff.c', 'jcprepct.c', 'jcsample.c', 'jctrans.c', 'jdapimin.c', 'jdapistd.c', 'jdatadst.c', 'jdatasrc.c', 'jdcoefct.c', 'jdcolor.c', 'jddctmgr.c', 'jdhuff.c', 'jdinput.c', 'jdmainct.c', 'jdmarker.c', 'jdmaster.c', 'jdmerge.c', 'jdphuff.c', 'jdpostct.c', 'jdsample.c', 'jdtrans.c', 'jerror.c', 'jfdctflt.c', 'jfdctfst.c', 'jfdctint.c', 'jidctflt.c', 'jidctfst.c', 'jidctint.c', 'jidctred.c', 'jmemmgr.c', 'jmemnobs.c', 'jquant1.c', 'jquant2.c', 'jutils.c'];
JPEGLIBOBJ = [];
for fileName in JPEGLIBNAMES:
	JPEGLIBOBJ += [JPEGLIB_PREFIX + fileName];

LIBPNG_PREFIX = 'libpng/';
LIBPNGNAMES = ['png.c', 'pngerror.c', 'pngget.c', 'pngmem.c', 'pngpread.c', 'pngread.c', 'pngrio.c', 'pngrtran.c', 'pngrutil.c', 'pngset.c', 'pngtrans.c', 'pngwio.c', 'pngwrite.c', 'pngwtran.c', 'pngwutil.c'];
LIBPNGOBJ = [];
for fileName in LIBPNGNAMES:
	LIBPNGOBJ += [LIBPNG_PREFIX + fileName];

# Next variable is for additional scene nodes etc. of customized Irrlicht versions
EXTRAOBJ = [];

LINKOBJ = IRRMESHOBJ + IRROBJ + IRRPARTICLEOBJ + IRRANIMOBJ + IRRVIDEOOBJ + IRRSWRENDEROBJ + IRRIOOBJ + IRROTHEROBJ + IRRGUIOBJ + ZLIBOBJ + JPEGLIBOBJ + LIBPNGOBJ + EXTRAOBJ;

env.Append(LIBS = LIBRARIES, LIBPATH = CXXINCS);

CXXFLAGS = ['-Wall'];
if NDEBUG:
	CXXFLAGS += ['-g', '-D_DEBUG'];
else:
	CXXFLAGS += ['-fexpensive-optimizations', '-O3'];

if PROFILE:
	CXXFLAGS += ['-pg'];

CXXFLAGS += ['-DPNG_NO_MMX_CODE', '-DPNG_NO_MNG_FEATURES', '-DIRRLICHT_EXPORTS=1'];
env.Append(CCFLAGS = CXXFLAGS);

IrrlichtLibrary = env.SharedLibrary("Irrlicht.dll", LINKOBJ);
The file still has some things that needs to be done, but at least it builds with mingw32 now :)
Building the file with MSVC seems to work fine, although it can't find the DX9SDK include files (I believe this is a problem with my DX9SDK installation, however, since the VC++ project that comes with the Irrlicht source can't find the files either).

There are several things that need to be done to the files still:
at the moment, the libIrrlicht.a and Irrlicht.dll are just dumped in the directory containing the SConstruct file.
The file doesn't recognize command-line flags, so there are three flags at the top that dictate whether debugging and/or profiling is turned on, and whether the compiling is to be done with MingW tools or MSVC ones.

I've only really been able to test this on Vista 32-bit, so if anyone else could test this on another platform and report if it works, that would be great :)

I'll be posting a patch with this, and hopefully I'll submit it to the wiki along with an article on how to use it and modify it.

Oh, and if you want to use this file with makefiles so that you can use it in an editor and still have the compile and clean buttons work, just save the above code into a file names SConstruct and then save the below code into a file named Makefile

Code: Select all

all:
	scons

clean:
	scons -c
then just link with the makefile and everything should be fine :)

Hope this is helpful to some people ^_^
-wyrmmage
Worlds at War (Current Project) - http://www.awkward-games.com
Ganadu'r, The Eternal Sage (Other Current Project) - http://rpg.naget.com
Post Reply