Documentation for Sconscript by Doxin

This commit is contained in:
jacob1 2013-05-29 21:37:57 -04:00
parent d6d20defde
commit 3929bdaf54
6 changed files with 1325 additions and 30 deletions

View File

@ -1,7 +1,38 @@
import os, sys, subprocess, time
# ============
# SCons script
# ============
# the purpose of this script is to run a build of tpt from start to finish, including dependency checks.
# .. contents :: Table of Contents
# ============
# requirements
# ============
# stdlib
# ======
import os
import sys
import subprocess
import time
# 3rd party
# =========
# nothing besides scons.
# =================
# long commandlines
# =================
# .. : Fix for long command line - http://scons.org/wiki/LongCmdLinesOnWin32
# because of an implementation detail commandlines are limited to 10000 characters on windows using mingw. the following fix was copied from
# http://scons.org/wiki/LongCmdLinesOnWin32 and circumvents this issue.
##Fix for long command line - http://scons.org/wiki/LongCmdLinesOnWin32
class ourSpawn:
def ourspawn(self, sh, escape, cmd, args, env):
newargs = ' '.join(args[1:])
@ -24,11 +55,15 @@ def SetupSpawn( env ):
buf.ourenv = env
env['SPAWN'] = buf.ourspawn
# ===================
# commandline options
# ===================
# the following defines all optional commandlines
AddOption('--opengl',dest="opengl",action='store_true',default=False,help="Build with OpenGL interface support.")
AddOption('--opengl-renderer',dest="opengl-renderer",action='store_true',default=False,help="Build with OpenGL renderer support. (requires --opengl)")
AddOption('--renderer',dest="renderer",action='store_true',default=False,help="Save renderer")
AddOption('--win',dest="win",action='store_true',default=False,help="Windows platform target.")
AddOption('--lin',dest="lin",action='store_true',default=False,help="Linux platform target")
AddOption('--macosx',dest="macosx",action='store_true',default=False,help="Mac OS X platform target")
AddOption('--rpi',dest="rpi",action='store_true',default=False,help="Raspbain platform target")
AddOption('--64bit',dest="_64bit",action='store_true',default=False,help="64-bit platform target")
@ -56,14 +91,32 @@ AddOption('--snapshot-id',dest="snapshot-id",default=False,help="Snapshot build
AddOption('--stable',dest="stable",default=True,help="Non snapshot build")
AddOption('--aao', dest="everythingAtOnce", action='store_true', default=False, help="Compile the whole game without generating intermediate objects (very slow), enable this when using compilers like clang or mscc that don't support -fkeep-inline-functions")
# using either of these commandline options is compulsory
AddOption('--win',dest="win",action='store_true',default=False,help="Windows platform target.")
AddOption('--lin',dest="lin",action='store_true',default=False,help="Linux platform target")
# ============
# main program
# ============
# the gist of the compiling rules are defined here
# platform selection
# ==================
# generic platform settings
# +++++++++++++++++++++++++
# check if a platform is specified.
# .. : TODO: make it suggest commandline options if it isn't
if((not GetOption('lin')) and (not GetOption('win')) and (not GetOption('rpi')) and (not GetOption('macosx'))):
print "You must specify a platform to target"
raise SystemExit(1)
if(GetOption('win')):
env = Environment(tools = ['mingw'], ENV = os.environ)
else:
env = Environment(tools = ['default'], ENV = os.environ)
# check if a tool prefix is set, and if it is select the propper tools for building.
# .. : TODO someone explain wtf this actually does
if GetOption("toolprefix"):
env['CC'] = GetOption("toolprefix")+env['CC']
@ -71,9 +124,26 @@ if GetOption("toolprefix"):
if GetOption('win'):
env['RC'] = GetOption("toolprefix")+env['RC']
#Check for headers and libraries
# windows specific platform settings
# ++++++++++++++++++++++++++++++++++
# if the platform is windows switch to a mingw toolset, use the default otherwise
if(GetOption('win')):
env = Environment(tools = ['mingw'], ENV = os.environ)
else:
env = Environment(tools = ['default'], ENV = os.environ)
# macosx specific platform settings
# +++++++++++++++++++++++++++++++++
# if we're not on MACOSX check for headers etc
if not GetOption("macosx"):
conf = Configure(env)
# if sdl-dir is set check if we can find the sdl header there, if we can't just pass the header path to the compiler.
if(GetOption("sdl-dir")):
if not conf.CheckCHeader(GetOption("sdl-dir") + '/SDL.h'):
print "sdl headers not found or not installed"
@ -81,6 +151,9 @@ if not GetOption("macosx"):
else:
env.Append(CPPPATH=[GetOption("sdl-dir")])
else:
# otherwise try to parse the pkg config for sdl and grab the correct flags from there.
try:
env.ParseConfig('sdl-config --cflags')
env.ParseConfig('sdl-config --libs')
@ -90,7 +163,9 @@ if not GetOption("macosx"):
raise SystemExit(1)
#Find correct lua include dir
# if lua is enabled try to parse the lua pgk-config, if that fails try the lua-dir option
# .. : TODO: make this look the same as the SDL check, maybe make a function for it. keep it DRY.
if not GetOption("nolua"):
try:
env.ParseConfig('pkg-config --cflags lua5.1')
@ -102,12 +177,16 @@ if not GetOption("macosx"):
else:
env.Append(CPPPATH=[GetOption("lua-dir")])
# if fft is enabled try to parse its config, fail otherwise.
if not GetOption('nofft'):
#Check for FFT lib
# Check for FFT lib
if not conf.CheckLib('fftw3f') and not conf.CheckLib('fftw3f-3'):
print "libfftw3f not found or not installed"
raise SystemExit(1)
# try to autodetect some libraries, fail otherwise
#Check for Bzip lib
if not conf.CheckLib('bz2'):
print "libbz2 not found or not installed"
@ -123,43 +202,88 @@ if not GetOption("macosx"):
raise SystemExit(1)
#Check for Lua lib
if not GetOption("macosx") and not GetOption("nolua"):
if not GetOption("nolua"):
if not conf.CheckLib('lua5.1') and not conf.CheckLib('lua-5.1') and not conf.CheckLib('lua51') and not conf.CheckLib('lua'):
print "liblua not found or not installed"
raise SystemExit(1)
# finish the configuration
env = conf.Finish();
else:
# if we ARE on macosx add the libraries to LIBS
# .. : seems like we're terrible at mac support? what gives?
env.Append(LIBS=['z', 'bz2'])
if not GetOption('nofft'):
env.Append(LIBS=['fftw3f'])
# enviroment setup
# ================
# add the correct compiler flags.
# generic enviroment settings
# +++++++++++++++++++++++++++
# make sure the compiler can find the source data and generated files. enable warnings, set C++ flavor, and keep inline functions
env.Append(CPPPATH=['src/', 'data/', 'generated/'])
env.Append(CCFLAGS=['-w', '-std=c++98', '-fkeep-inline-functions'])
env.Append(LIBS=['pthread', 'm'])
env.Append(CPPDEFINES=["_GNU_SOURCE", "USE_STDINT", "_POSIX_C_SOURCE=200112L"])
# check all enabled libs, and add a define if they are enabled.
if not GetOption('nofft'):
env.Append(CPPDEFINES=["GRAVFFT"])
if not GetOption('nolua'):
env.Append(CPPDEFINES=["LUACONSOLE"])
# check if we need to use PTW32_STATIC_LIB for pthreadw32 headers, won't compile statically without this
if GetOption("ptw32-static"):
env.Append(CPPDEFINES=['PTW32_STATIC_LIB']);
# check if we need to do static linking.
if(GetOption('static')):
env.Append(LINKFLAGS=['-static-libgcc'])
# check if we need to compile the save renderer. add a define accordingly. compile the game by default.
if(GetOption('renderer')):
env.Append(CPPDEFINES=['RENDERER'])
else:
env.Append(CPPDEFINES=["USE_SDL"])
# apply optimisations if it's a release build
if(GetOption('release')):
if GetOption('macosx'):
env.Append(CCFLAGS=['-O3', '-ftree-vectorize', '-funsafe-math-optimizations', '-ffast-math', '-fomit-frame-pointer'])
else:
env.Append(CCFLAGS=['-O3', '-ftree-vectorize', '-funsafe-math-optimizations', '-ffast-math', '-fomit-frame-pointer', '-funsafe-loop-optimizations', '-Wunsafe-loop-optimizations'])
# rpi specific enviroment settings
# ++++++++++++++++++++++++++++++++
# check if we're compiling for raspberry pi, if we are include rpi specific libraries and defines.
if(GetOption('rpi')):
if(GetOption('opengl')):
env.ParseConfig('pkg-config --libs glew gl glu')
openGLLibs = ['GL']
env.Append(LIBS=['X11', 'rt'])
env.Append(CPPDEFINES=["LIN"])
# windows specific enviroment settings
# ++++++++++++++++++++++++++++++++++++
# check if we're compiling for windows, if we are include windows specific libraries and defines.
if(GetOption('win')):
openGLLibs = ['opengl32', 'glew32']
env.Prepend(LIBS=['mingw32', 'ws2_32', 'SDLmain', 'regex'])
@ -170,6 +294,12 @@ if(GetOption('win')):
if(GetOption('_64bit')):
env.Append(CPPDEFINES=['__CRT__NO_INLINE'])
env.Append(LINKFLAGS=['-Wl,--stack=16777216'])
# linux specific enviroment settings
# ++++++++++++++++++++++++++++++++++++
# check if we're compiling for linux, if we are include linux specific libraries and defines.
if(GetOption('lin')):
if(GetOption('opengl')):
env.ParseConfig('pkg-config --libs glew gl glu')
@ -182,6 +312,12 @@ if(GetOption('lin')):
else:
env.Append(LINKFLAGS=['-m32'])
env.Append(CCFLAGS=['-m32'])
# macosx specific enviroment settings
# ++++++++++++++++++++++++++++++++++++
# check if we're compiling for macosx, if we are include macosx specific libraries and defines.
if(GetOption('macosx')):
env.Append(CPPDEFINES=["MACOSX"])
env.Append(CCFLAGS=['-I/Library/Frameworks/SDL.framework/Headers'])
@ -204,13 +340,17 @@ if(GetOption('macosx')):
env.Append(LINKFLAGS=['-m32'])
env.Append(CCFLAGS=['-m32'])
# defines
# =======
# A lot of commandline flags translate directly into defines. those flags follow:
if GetOption('_64bit'):
env.Append(CPPDEFINES=["_64BIT"])
if(GetOption('beta')):
env.Append(CPPDEFINES='BETA')
if(not GetOption('snapshot') and not GetOption('beta') and not GetOption('release') and not GetOption('stable')):
env.Append(CPPDEFINES='SNAPSHOT_ID=0')
env.Append(CPPDEFINES='SNAPSHOT')
@ -261,11 +401,18 @@ elif(GetOption('opengl-renderer')):
print "opengl-renderer requires opengl"
raise SystemExit(1)
# compiling
# =========
# sources
# +++++++
# find all source files
# generic sources
# ---------------
sources=Glob("src/*.cpp")
if(GetOption('macosx')):
sources +=["SDLMain.m"]
if(GetOption('win')):
sources += env.RES('resources/powder-res.rc')
sources+=Glob("src/*/*.cpp")
sources+=Glob("src/gui/*/*.cpp")
sources+=Glob("src/simulation/elements/*.cpp")
@ -274,15 +421,32 @@ sources+=Glob("src/client/requestbroker/*.cpp")
if not GetOption('nolua'):
sources+=Glob("src/socket/*.c")
#for source in sources:
# print str(source)
# windows specific sources
# ------------------------
if(GetOption('win')):
sources = filter(lambda source: not 'src\\simulation\\Gravity.cpp' in str(source), sources)
sources = filter(lambda source: not 'src/simulation/Gravity.cpp' in str(source), sources)
sources += env.RES('resources/powder-res.rc')
sources = filter(lambda source: not 'src\\simulation\\Gravity.cpp' in str(source), sources)
sources = filter(lambda source: not 'src/simulation/Gravity.cpp' in str(source), sources)
# macosx specific sources
# -----------------------
if(GetOption('macosx')):
sources +=["SDLMain.m"]
# apply `long commandlines`_ fix
# ==============================
# apply the commandline fix
SetupSpawn(env)
# find proper executable name
# ===========================
# use some settings to detect what name to use for the executable
programName = "powder"
if(GetOption('renderer')):
@ -306,12 +470,11 @@ if(GetOption('macosx')):
if(GetOption('win')):
programName += ".exe"
if(GetOption('release')):
if GetOption('macosx'):
env.Append(CCFLAGS=['-O3', '-ftree-vectorize', '-funsafe-math-optimizations', '-ffast-math', '-fomit-frame-pointer'])
else:
env.Append(CCFLAGS=['-O3', '-ftree-vectorize', '-funsafe-math-optimizations', '-ffast-math', '-fomit-frame-pointer', '-funsafe-loop-optimizations', '-Wunsafe-loop-optimizations'])
# detect python executable name
# =============================
# detect the executable name for python so we can run some generator scripts
if(GetOption('pythonver')):
pythonVer = GetOption('pythonver')
@ -320,10 +483,16 @@ elif(GetOption('lin')):
else:
pythonVer = "python"
# Extra compiler flag to fix stack alignment
# When Windows creates the gravity calculation thread, it has 4 byte stack alignment
# But we need 16 byte alignment so that SSE instructions in FFTW work without crashing
if(GetOption('win')):
envCopy = env.Clone()
envCopy.Append(CCFLAGS=['-mincoming-stack-boundary=2'])
sources+=envCopy.Object('src/simulation/Gravity.cpp')
envCopy = env.Clone()
envCopy.Append(CCFLAGS=['-mincoming-stack-boundary=2'])
sources+=envCopy.Object('src/simulation/Gravity.cpp')
# run generator commands
# ======================
env.Command(['generated/ElementClasses.cpp', 'generated/ElementClasses.h'], Glob('src/simulation/elements/*.cpp'), pythonVer + " generator.py elements $TARGETS $SOURCES")
sources+=Glob("generated/ElementClasses.cpp")
@ -331,6 +500,14 @@ sources+=Glob("generated/ElementClasses.cpp")
env.Command(['generated/ToolClasses.cpp', 'generated/ToolClasses.h'], Glob('src/simulation/tools/*.cpp'), pythonVer + " generator.py tools $TARGETS $SOURCES")
sources+=Glob("generated/ToolClasses.cpp")
# final settings
# ==============
# make a MD5 checksum decide wether or not a file changed. we had some problems with using the modification date for this purpose.
env.Decider('MD5')
# set a defaukt target
t=env.Program(target=programName, source=sources)
Default(t)

0
docs/.py.html Normal file
View File

701
docs/SConscript.html Normal file
View File

@ -0,0 +1,701 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.10: http://docutils.sourceforge.net/" />
<title></title>
<style type="text/css">
/*
:Authors: Ian Bicking, Michael Foord
:Contact: fuzzyman@voidspace.org.uk
:Date: 2005/08/26
:Version: 0.1.0
:Copyright: This stylesheet has been placed in the public domain.
Stylesheet for Docutils.
Based on ``blue_box.css`` by Ian Bicking
and ``html4css1.css`` revision 1.46.
*/
@import url(file:///usr/local/lib/python2.7/dist-packages/docutils/writers/html4css1/html4css1.css);
body {
font-family: Arial, sans-serif;
}
em, i {
/* Typically serif fonts have much nicer italics */
font-family: Times New Roman, Times, serif;
}
a.target {
color: blue;
}
a.target {
color: blue;
}
a.toc-backref {
text-decoration: none;
color: black;
}
a.toc-backref:hover {
background-color: inherit;
}
a:hover {
background-color: #cccccc;
}
div.attention, div.caution, div.danger, div.error, div.hint,
div.important, div.note, div.tip, div.warning {
background-color: #cccccc;
padding: 3px;
width: 80%;
}
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
text-align: center;
background-color: #999999;
display: block;
margin: 0;
}
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title {
color: #cc0000;
font-family: sans-serif;
text-align: center;
background-color: #999999;
display: block;
margin: 0;
}
h1, h2, h3, h4, h5, h6 {
font-family: Helvetica, Arial, sans-serif;
border: thin solid black;
/* This makes the borders rounded on Mozilla, which pleases me */
-moz-border-radius: 8px;
padding: 4px;
}
h1 {
background-color: #444499;
color: #ffffff;
border: medium solid black;
}
h1 a.toc-backref, h2 a.toc-backref {
color: #ffffff;
}
h2 {
background-color: #666666;
color: #ffffff;
border: medium solid black;
}
h3, h4, h5, h6 {
background-color: #cccccc;
color: #000000;
}
h3 a.toc-backref, h4 a.toc-backref, h5 a.toc-backref,
h6 a.toc-backref {
color: #000000;
}
h1.title {
text-align: center;
background-color: #444499;
color: #eeeeee;
border: thick solid black;
-moz-border-radius: 20px;
}
table.footnote {
padding-left: 0.5ex;
}
table.citation {
padding-left: 0.5ex
}
pre.literal-block, pre.doctest-block {
border: thin black solid;
padding: 5px;
}
.image img { border-style : solid;
border-width : 2px;
}
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
font-size: 100%;
}
code, tt {
color: #000066;
}
</style>
</head>
<body>
<div class="document">
<div class="section" id="scons-script">
<h1><a class="toc-backref" href="#id1">SCons script</a></h1>
<p>the purpose of this script is to run a build of tpt from start to finish, including dependency checks.</p>
<div class="contents topic" id="table-of-contents">
<p class="topic-title first">Table of Contents</p>
<ul class="simple">
<li><a class="reference internal" href="#scons-script" id="id1">SCons script</a></li>
<li><a class="reference internal" href="#requirements" id="id2">requirements</a><ul>
<li><a class="reference internal" href="#stdlib" id="id3">stdlib</a></li>
<li><a class="reference internal" href="#rd-party" id="id4">3rd party</a></li>
</ul>
</li>
<li><a class="reference internal" href="#long-commandlines" id="id5">long commandlines</a></li>
<li><a class="reference internal" href="#commandline-options" id="id6">commandline options</a></li>
<li><a class="reference internal" href="#main-program" id="id7">main program</a><ul>
<li><a class="reference internal" href="#platform-selection" id="id8">platform selection</a><ul>
<li><a class="reference internal" href="#generic-platform-settings" id="id9">generic platform settings</a></li>
<li><a class="reference internal" href="#windows-specific-platform-settings" id="id10">windows specific platform settings</a></li>
<li><a class="reference internal" href="#macosx-specific-platform-settings" id="id11">macosx specific platform settings</a></li>
</ul>
</li>
<li><a class="reference internal" href="#enviroment-setup" id="id12">enviroment setup</a><ul>
<li><a class="reference internal" href="#generic-enviroment-settings" id="id13">generic enviroment settings</a></li>
<li><a class="reference internal" href="#rpi-specific-enviroment-settings" id="id14">rpi specific enviroment settings</a></li>
<li><a class="reference internal" href="#windows-specific-enviroment-settings" id="id15">windows specific enviroment settings</a></li>
<li><a class="reference internal" href="#linux-specific-enviroment-settings" id="id16">linux specific enviroment settings</a></li>
<li><a class="reference internal" href="#macosx-specific-enviroment-settings" id="id17">macosx specific enviroment settings</a></li>
</ul>
</li>
<li><a class="reference internal" href="#defines" id="id18">defines</a></li>
<li><a class="reference internal" href="#compiling" id="id19">compiling</a><ul>
<li><a class="reference internal" href="#sources" id="id20">sources</a><ul>
<li><a class="reference internal" href="#windows-specific-sources" id="id21">windows specific sources</a></li>
<li><a class="reference internal" href="#macosx-specific-sources" id="id22">macosx specific sources</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#apply-long-commandlines-fix" id="id23">apply long commandlines fix</a></li>
<li><a class="reference internal" href="#find-proper-executable-name" id="id24">find proper executable name</a></li>
<li><a class="reference internal" href="#detect-python-executable-name" id="id25">detect python executable name</a></li>
<li><a class="reference internal" href="#run-generator-commands" id="id26">run generator commands</a></li>
<li><a class="reference internal" href="#final-settings" id="id27">final settings</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="section" id="requirements">
<h1><a class="toc-backref" href="#id2">requirements</a></h1>
<div class="section" id="stdlib">
<h2><a class="toc-backref" href="#id3">stdlib</a></h2>
<pre class="literal-block">
import os
import sys
import subprocess
import time
</pre>
</div>
<div class="section" id="rd-party">
<h2><a class="toc-backref" href="#id4">3rd party</a></h2>
<p>nothing besides scons.</p>
</div>
</div>
<div class="section" id="long-commandlines">
<h1><a class="toc-backref" href="#id5">long commandlines</a></h1>
<!-- : Fix for long command line - http://scons.org/wiki/LongCmdLinesOnWin32 -->
<p>because of an implementation detail commandlines are limited to 10000 characters on windows using mingw. the following fix was copied from
<a class="reference external" href="http://scons.org/wiki/LongCmdLinesOnWin32">http://scons.org/wiki/LongCmdLinesOnWin32</a> and circumvents this issue.</p>
<pre class="literal-block">
class ourSpawn:
def ourspawn(self, sh, escape, cmd, args, env):
newargs = ' '.join(args[1:])
cmdline = cmd + &quot; &quot; + newargs
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, startupinfo=startupinfo, shell = False, env = env)
data, err = proc.communicate()
rv = proc.wait()
if rv:
print &quot;=====&quot;
print err
print &quot;=====&quot;
return rv
def SetupSpawn( env ):
if sys.platform == 'win32':
buf = ourSpawn()
buf.ourenv = env
env['SPAWN'] = buf.ourspawn
</pre>
</div>
<div class="section" id="commandline-options">
<h1><a class="toc-backref" href="#id6">commandline options</a></h1>
<p>the following defines all optional commandlines</p>
<pre class="literal-block">
AddOption('--opengl',dest=&quot;opengl&quot;,action='store_true',default=False,help=&quot;Build with OpenGL interface support.&quot;)
AddOption('--opengl-renderer',dest=&quot;opengl-renderer&quot;,action='store_true',default=False,help=&quot;Build with OpenGL renderer support. (requires --opengl)&quot;)
AddOption('--renderer',dest=&quot;renderer&quot;,action='store_true',default=False,help=&quot;Save renderer&quot;)
AddOption('--macosx',dest=&quot;macosx&quot;,action='store_true',default=False,help=&quot;Mac OS X platform target&quot;)
AddOption('--rpi',dest=&quot;rpi&quot;,action='store_true',default=False,help=&quot;Raspbain platform target&quot;)
AddOption('--64bit',dest=&quot;_64bit&quot;,action='store_true',default=False,help=&quot;64-bit platform target&quot;)
AddOption('--static',dest=&quot;static&quot;,action=&quot;store_true&quot;,default=False,help=&quot;Static linking, reduces external library dependancies but increased file size&quot;)
AddOption('--pthreadw32-static',dest=&quot;ptw32-static&quot;,action=&quot;store_true&quot;,default=False,help=&quot;Use PTW32_STATIC_LIB for pthreadw32 headers&quot;)
AddOption('--python-ver',dest=&quot;pythonver&quot;,default=False,help=&quot;Python version to use for generator.py&quot;)
AddOption('--release',dest=&quot;release&quot;,action='store_true',default=False,help=&quot;Enable optimisations (Will slow down compiling)&quot;)
AddOption('--lua-dir',dest=&quot;lua-dir&quot;,default=False,help=&quot;Directory for lua includes&quot;)
AddOption('--sdl-dir',dest=&quot;sdl-dir&quot;,default=False,help=&quot;Directory for SDL includes&quot;)
AddOption('--tool',dest=&quot;toolprefix&quot;,default=False,help=&quot;Prefix&quot;)
AddOption('--sse',dest=&quot;sse&quot;,action='store_true',default=False,help=&quot;Enable SSE optimisations&quot;)
AddOption('--sse2',dest=&quot;sse2&quot;,action='store_true',default=False,help=&quot;Enable SSE2 optimisations&quot;)
AddOption('--sse3',dest=&quot;sse3&quot;,action='store_true',default=False,help=&quot;Enable SSE3 optimisations&quot;)
AddOption('--x86',dest=&quot;x86&quot;,action='store_true',default=True,help=&quot;Target Intel x86 platform&quot;)
AddOption('--nofft',dest=&quot;nofft&quot;, action='store_true',default=False,help=&quot;Do not use fftw3f for gravity.&quot;)
AddOption('--nolua',dest=&quot;nolua&quot;, action='store_true',default=False,help=&quot;Disable all lua scripting features.&quot;)
AddOption('--debugging', dest=&quot;debug&quot;, action=&quot;store_true&quot;, default=False, help=&quot;Enable debug options&quot;)
AddOption('--beta',dest=&quot;beta&quot;,action='store_true',default=False,help=&quot;Beta build.&quot;)
AddOption('--save-version',dest=&quot;save-version&quot;,default=False,help=&quot;Save version.&quot;)
AddOption('--minor-version',dest=&quot;minor-version&quot;,default=False,help=&quot;Minor version.&quot;)
AddOption('--build-number',dest=&quot;build-number&quot;,default=False,help=&quot;Build number.&quot;)
AddOption('--snapshot',dest=&quot;snapshot&quot;,action='store_true',default=False,help=&quot;Snapshot build.&quot;)
AddOption('--snapshot-id',dest=&quot;snapshot-id&quot;,default=False,help=&quot;Snapshot build ID.&quot;)
AddOption('--stable',dest=&quot;stable&quot;,default=True,help=&quot;Non snapshot build&quot;)
AddOption('--aao', dest=&quot;everythingAtOnce&quot;, action='store_true', default=False, help=&quot;Compile the whole game without generating intermediate objects (very slow), enable this when using compilers like clang or mscc that don't support -fkeep-inline-functions&quot;)
</pre>
<p>using either of these commandline options is compulsory</p>
<pre class="literal-block">
AddOption('--win',dest=&quot;win&quot;,action='store_true',default=False,help=&quot;Windows platform target.&quot;)
AddOption('--lin',dest=&quot;lin&quot;,action='store_true',default=False,help=&quot;Linux platform target&quot;)
</pre>
</div>
<div class="section" id="main-program">
<h1><a class="toc-backref" href="#id7">main program</a></h1>
<p>the gist of the compiling rules are defined here</p>
<div class="section" id="platform-selection">
<h2><a class="toc-backref" href="#id8">platform selection</a></h2>
<div class="section" id="generic-platform-settings">
<h3><a class="toc-backref" href="#id9">generic platform settings</a></h3>
<p>check if a platform is specified.
.. : TODO: make it suggest commandline options if it isn't</p>
<pre class="literal-block">
if((not GetOption('lin')) and (not GetOption('win')) and (not GetOption('rpi')) and (not GetOption('macosx'))):
print &quot;You must specify a platform to target&quot;
raise SystemExit(1)
</pre>
<p>check if a tool prefix is set, and if it is select the propper tools for building.
.. : TODO someone explain wtf this actually does</p>
<pre class="literal-block">
if GetOption(&quot;toolprefix&quot;):
env['CC'] = GetOption(&quot;toolprefix&quot;)+env['CC']
env['CXX'] = GetOption(&quot;toolprefix&quot;)+env['CXX']
if GetOption('win'):
env['RC'] = GetOption(&quot;toolprefix&quot;)+env['RC']
</pre>
</div>
<div class="section" id="windows-specific-platform-settings">
<h3><a class="toc-backref" href="#id10">windows specific platform settings</a></h3>
<p>if the platform is windows switch to a mingw toolset, use the default otherwise</p>
<pre class="literal-block">
if(GetOption('win')):
env = Environment(tools = ['mingw'], ENV = os.environ)
else:
env = Environment(tools = ['default'], ENV = os.environ)
</pre>
</div>
<div class="section" id="macosx-specific-platform-settings">
<h3><a class="toc-backref" href="#id11">macosx specific platform settings</a></h3>
<p>if we're not on MACOSX check for headers etc</p>
<pre class="literal-block">
if not GetOption(&quot;macosx&quot;):
conf = Configure(env)
</pre>
<p>if sdl-dir is set check if we can find the sdl header there, if we can't just pass the header path to the compiler.</p>
<pre class="literal-block">
if(GetOption(&quot;sdl-dir&quot;)):
if not conf.CheckCHeader(GetOption(&quot;sdl-dir&quot;) + '/SDL.h'):
print &quot;sdl headers not found or not installed&quot;
raise SystemExit(1)
else:
env.Append(CPPPATH=[GetOption(&quot;sdl-dir&quot;)])
else:
</pre>
<p>otherwise try to parse the pkg config for sdl and grab the correct flags from there.</p>
<pre class="literal-block">
try:
env.ParseConfig('sdl-config --cflags')
env.ParseConfig('sdl-config --libs')
except:
if not conf.CheckLib(&quot;SDL&quot;):
print &quot;libSDL not found or not installed&quot;
raise SystemExit(1)
</pre>
<p>if lua is enabled try to parse the lua pgk-config, if that fails try the lua-dir option
.. : TODO: make this look the same as the SDL check, maybe make a function for it. keep it DRY.</p>
<pre class="literal-block">
if not GetOption(&quot;nolua&quot;):
try:
env.ParseConfig('pkg-config --cflags lua5.1')
except:
if(GetOption(&quot;lua-dir&quot;)):
if not conf.CheckCHeader(GetOption(&quot;lua-dir&quot;) + '/lua.h'):
print &quot;lua5.1 headers not found or not installed&quot;
raise SystemExit(1)
else:
env.Append(CPPPATH=[GetOption(&quot;lua-dir&quot;)])
</pre>
<p>if fft is enabled try to parse its config, fail otherwise.</p>
<pre class="literal-block">
if not GetOption('nofft'):
# Check for FFT lib
if not conf.CheckLib('fftw3f') and not conf.CheckLib('fftw3f-3'):
print &quot;libfftw3f not found or not installed&quot;
raise SystemExit(1)
</pre>
<p>try to autodetect some libraries, fail otherwise</p>
<pre class="literal-block">
#Check for Bzip lib
if not conf.CheckLib('bz2'):
print &quot;libbz2 not found or not installed&quot;
raise SystemExit(1)
#Check for zlib
if not conf.CheckLib('z'):
print &quot;libz not found or not installed&quot;
raise SystemExit(1)
if not conf.CheckCHeader(&quot;bzlib.h&quot;):
print &quot;bzip2 headers not found&quot;
raise SystemExit(1)
</pre>
<!-- : TODO: checking if it's macosx again? seems like bitrot. -->
<pre class="literal-block">
#Check for Lua lib
if not GetOption(&quot;macosx&quot;) and not GetOption(&quot;nolua&quot;):
if not conf.CheckLib('lua5.1') and not conf.CheckLib('lua-5.1') and not conf.CheckLib('lua51') and not conf.CheckLib('lua'):
print &quot;liblua not found or not installed&quot;
raise SystemExit(1)
</pre>
<p>finish the configuration</p>
<pre class="literal-block">
env = conf.Finish();
else:
</pre>
<p>if we ARE on macosx add the libraries to LIBS
.. : seems like we're terrible at mac support? what gives?</p>
<pre class="literal-block">
env.Append(LIBS=['z', 'bz2'])
if not GetOption('nofft'):
env.Append(LIBS=['fftw3f'])
</pre>
</div>
</div>
<div class="section" id="enviroment-setup">
<h2><a class="toc-backref" href="#id12">enviroment setup</a></h2>
<p>add the correct compiler flags.</p>
<div class="section" id="generic-enviroment-settings">
<h3><a class="toc-backref" href="#id13">generic enviroment settings</a></h3>
<p>make sure the compiler can find the source data and generated files. enable warnings, set C++ flavor, and keep inline functions</p>
<pre class="literal-block">
env.Append(CPPPATH=['src/', 'data/', 'generated/'])
env.Append(CCFLAGS=['-w', '-std=c++98', '-fkeep-inline-functions'])
env.Append(LIBS=['pthread', 'm'])
env.Append(CPPDEFINES=[&quot;_GNU_SOURCE&quot;, &quot;USE_STDINT&quot;, &quot;_POSIX_C_SOURCE=200112L&quot;])
</pre>
<p>check all enabled libs, and add a define if they are enabled.</p>
<pre class="literal-block">
if not GetOption('nofft'):
env.Append(CPPDEFINES=[&quot;GRAVFFT&quot;])
if not GetOption('nolua'):
env.Append(CPPDEFINES=[&quot;LUACONSOLE&quot;])
</pre>
<p>check if we need to use PTW32_STATIC_LIB for pthreadw32 headers
.. : TODO: explain this so it actually means something :P</p>
<pre class="literal-block">
if GetOption(&quot;ptw32-static&quot;):
env.Append(CPPDEFINES=['PTW32_STATIC_LIB']);
</pre>
<p>check if we need to do static linking.</p>
<pre class="literal-block">
if(GetOption('static')):
env.Append(LINKFLAGS=['-static-libgcc'])
</pre>
<p>check if we need to compile the save renderer. add a define accordingly. compile the game by default.</p>
<pre class="literal-block">
if(GetOption('renderer')):
env.Append(CPPDEFINES=['RENDERER'])
else:
env.Append(CPPDEFINES=[&quot;USE_SDL&quot;])
</pre>
<p>apply optimisations if it's a release build</p>
<pre class="literal-block">
if(GetOption('release')):
if GetOption('macosx'):
env.Append(CCFLAGS=['-O3', '-ftree-vectorize', '-funsafe-math-optimizations', '-ffast-math', '-fomit-frame-pointer'])
else:
env.Append(CCFLAGS=['-O3', '-ftree-vectorize', '-funsafe-math-optimizations', '-ffast-math', '-fomit-frame-pointer', '-funsafe-loop-optimizations', '-Wunsafe-loop-optimizations'])
</pre>
</div>
<div class="section" id="rpi-specific-enviroment-settings">
<h3><a class="toc-backref" href="#id14">rpi specific enviroment settings</a></h3>
<p>check if we're compiling for rpi, if we are include rpi specific libraries and defines.</p>
<pre class="literal-block">
if(GetOption('rpi')):
if(GetOption('opengl')):
env.ParseConfig('pkg-config --libs glew gl glu')
openGLLibs = ['GL']
env.Append(LIBS=['X11', 'rt'])
env.Append(CPPDEFINES=[&quot;LIN&quot;])
</pre>
</div>
<div class="section" id="windows-specific-enviroment-settings">
<h3><a class="toc-backref" href="#id15">windows specific enviroment settings</a></h3>
<p>check if we're compiling for windows, if we are include windows specific libraries and defines.</p>
<pre class="literal-block">
if(GetOption('win')):
openGLLibs = ['opengl32', 'glew32']
env.Prepend(LIBS=['mingw32', 'ws2_32', 'SDLmain', 'regex'])
env.Append(CCFLAGS=['-std=gnu++98'])
env.Append(LIBS=['winmm', 'gdi32'])
env.Append(CPPDEFINES=[&quot;WIN&quot;])
env.Append(LINKFLAGS=['-mwindows'])
if(GetOption('_64bit')):
env.Append(CPPDEFINES=['__CRT__NO_INLINE'])
env.Append(LINKFLAGS=['-Wl,--stack=16777216'])
</pre>
</div>
<div class="section" id="linux-specific-enviroment-settings">
<h3><a class="toc-backref" href="#id16">linux specific enviroment settings</a></h3>
<p>check if we're compiling for linux, if we are include linux specific libraries and defines.</p>
<pre class="literal-block">
if(GetOption('lin')):
if(GetOption('opengl')):
env.ParseConfig('pkg-config --libs glew gl glu')
openGLLibs = ['GL']
env.Append(LIBS=['X11', 'rt'])
env.Append(CPPDEFINES=[&quot;LIN&quot;])
if GetOption('_64bit'):
env.Append(LINKFLAGS=['-m64'])
env.Append(CCFLAGS=['-m64'])
else:
env.Append(LINKFLAGS=['-m32'])
env.Append(CCFLAGS=['-m32'])
</pre>
</div>
<div class="section" id="macosx-specific-enviroment-settings">
<h3><a class="toc-backref" href="#id17">macosx specific enviroment settings</a></h3>
<p>check if we're compiling for macosx, if we are include macosx specific libraries and defines.</p>
<pre class="literal-block">
if(GetOption('macosx')):
env.Append(CPPDEFINES=[&quot;MACOSX&quot;])
env.Append(CCFLAGS=['-I/Library/Frameworks/SDL.framework/Headers'])
env.Append(CCFLAGS=['-I/Library/Frameworks/Lua.framework/Headers'])
if not GetOption('nofft'):
env.Append(LINKFLAGS=['-lfftw3f'])
env.Append(LINKFLAGS=['-framework'])
env.Append(LINKFLAGS=['SDL'])
env.Append(LINKFLAGS=['-framework'])
env.Append(LINKFLAGS=['Lua'])
env.Append(LINKFLAGS=['-framework']);
env.Append(LINKFLAGS=['Cocoa'])
#env.Append(LINKFLAGS=['-framework SDL'])
#env.Append(LINKFLAGS=['-framework Lua'])
#env.Append(LINKFLAGS=['-framework Cocoa'])
if GetOption('_64bit'):
env.Append(LINKFLAGS=['-m64'])
env.Append(CCFLAGS=['-m64'])
else:
env.Append(LINKFLAGS=['-m32'])
env.Append(CCFLAGS=['-m32'])
</pre>
</div>
</div>
<div class="section" id="defines">
<h2><a class="toc-backref" href="#id18">defines</a></h2>
<p>A lot of commandline flags translate directly into defines. those flags follow:</p>
<pre class="literal-block">
if GetOption('_64bit'):
env.Append(CPPDEFINES=[&quot;_64BIT&quot;])
if(GetOption('beta')):
env.Append(CPPDEFINES='BETA')
if(not GetOption('snapshot') and not GetOption('beta') and not GetOption('release') and not GetOption('stable')):
env.Append(CPPDEFINES='SNAPSHOT_ID=0')
env.Append(CPPDEFINES='SNAPSHOT')
elif(GetOption('snapshot') or GetOption('snapshot-id')):
if(GetOption('snapshot-id')):
env.Append(CPPDEFINES=['SNAPSHOT_ID=' + GetOption('snapshot-id')])
else:
env.Append(CPPDEFINES=['SNAPSHOT_ID=' + str(int(time.time()))])
env.Append(CPPDEFINES='SNAPSHOT')
elif(GetOption('stable')):
env.Append(CPPDEFINES='STABLE')
if(GetOption('save-version')):
env.Append(CPPDEFINES=['SAVE_VERSION=' + GetOption('save-version')])
if(GetOption('minor-version')):
env.Append(CPPDEFINES=['MINOR_VERSION=' + GetOption('minor-version')])
if(GetOption('build-number')):
env.Append(CPPDEFINES=['BUILD_NUM=' + GetOption('build-number')])
if(GetOption('x86')):
env.Append(CPPDEFINES='X86')
if(GetOption('debug')):
env.Append(CPPDEFINES='DEBUG')
env.Append(CCFLAGS='-g')
if(GetOption('sse')):
env.Append(CCFLAGS='-msse')
env.Append(CPPDEFINES='X86_SSE')
if(GetOption('sse2')):
env.Append(CCFLAGS='-msse2')
env.Append(CPPDEFINES='X86_SSE2')
if(GetOption('sse3')):
env.Append(CCFLAGS='-msse3')
env.Append(CPPDEFINES='X86_SSE3')
if(GetOption('opengl')):
env.Append(CPPDEFINES=[&quot;OGLI&quot;, &quot;PIX32OGL&quot;])
env.Append(LIBS=openGLLibs)
if(GetOption('opengl') and GetOption('opengl-renderer')):
env.Append(CPPDEFINES=[&quot;OGLR&quot;])
elif(GetOption('opengl-renderer')):
print &quot;opengl-renderer requires opengl&quot;
raise SystemExit(1)
</pre>
</div>
<div class="section" id="compiling">
<h2><a class="toc-backref" href="#id19">compiling</a></h2>
<div class="section" id="sources">
<h3><a class="toc-backref" href="#id20">sources</a></h3>
<p>find all source files</p>
<pre class="literal-block">
# generic sources
# ---------------
sources=Glob(&quot;src/*.cpp&quot;)
sources+=Glob(&quot;src/*/*.cpp&quot;)
sources+=Glob(&quot;src/gui/*/*.cpp&quot;)
sources+=Glob(&quot;src/simulation/elements/*.cpp&quot;)
sources+=Glob(&quot;src/simulation/tools/*.cpp&quot;)
sources+=Glob(&quot;src/client/requestbroker/*.cpp&quot;)
if not GetOption('nolua'):
sources+=Glob(&quot;src/socket/*.c&quot;)
</pre>
<div class="section" id="windows-specific-sources">
<h4><a class="toc-backref" href="#id21">windows specific sources</a></h4>
<pre class="literal-block">
if(GetOption('win')):
sources += env.RES('resources/powder-res.rc')
sources = filter(lambda source: not 'src\\simulation\\Gravity.cpp' in str(source), sources)
sources = filter(lambda source: not 'src/simulation/Gravity.cpp' in str(source), sources)
</pre>
</div>
<div class="section" id="macosx-specific-sources">
<h4><a class="toc-backref" href="#id22">macosx specific sources</a></h4>
<pre class="literal-block">
if(GetOption('macosx')):
sources +=[&quot;SDLMain.m&quot;]
</pre>
</div>
</div>
</div>
<div class="section" id="apply-long-commandlines-fix">
<h2>apply <a class="reference internal" href="#long-commandlines">long commandlines</a> fix</h2>
<p>apply the commandline fix</p>
<pre class="literal-block">
SetupSpawn(env)
</pre>
</div>
<div class="section" id="find-proper-executable-name">
<h2><a class="toc-backref" href="#id24">find proper executable name</a></h2>
<p>use some settings to detect what name to use for the executable</p>
<pre class="literal-block">
programName = &quot;powder&quot;
if(GetOption('renderer')):
programName = &quot;render&quot;
if(GetOption('win')):
if(GetOption('renderer')):
programName = &quot;Render&quot;
else:
programName = &quot;Powder&quot;
if(GetOption('_64bit')):
programName += &quot;64&quot;
if(not (GetOption('sse2') or GetOption('sse3'))):
programName += &quot;-legacy&quot;
if(GetOption('macosx')):
programName += &quot;-x&quot;
if(GetOption('win')):
programName += &quot;.exe&quot;
</pre>
</div>
<div class="section" id="detect-python-executable-name">
<h2><a class="toc-backref" href="#id25">detect python executable name</a></h2>
<p>detect the executable name for python so we can run some generator scripts</p>
<pre class="literal-block">
if(GetOption('pythonver')):
pythonVer = GetOption('pythonver')
elif(GetOption('lin')):
pythonVer = &quot;python2&quot;
else:
pythonVer = &quot;python&quot;
</pre>
<!-- if(GetOption('win')): # this seems like dead code, when you uncomment this add some documentation please
envCopy = env.Clone()
envCopy.Append(CCFLAGS=['-mincoming-stack-boundary=2'])
sources+=envCopy.Object('src/simulation/Gravity.cpp') -->
</div>
<div class="section" id="run-generator-commands">
<h2><a class="toc-backref" href="#id26">run generator commands</a></h2>
<pre class="literal-block">
env.Command(['generated/ElementClasses.cpp', 'generated/ElementClasses.h'], Glob('src/simulation/elements/*.cpp'), pythonVer + &quot; generator.py elements $TARGETS $SOURCES&quot;)
sources+=Glob(&quot;generated/ElementClasses.cpp&quot;)
env.Command(['generated/ToolClasses.cpp', 'generated/ToolClasses.h'], Glob('src/simulation/tools/*.cpp'), pythonVer + &quot; generator.py tools $TARGETS $SOURCES&quot;)
sources+=Glob(&quot;generated/ToolClasses.cpp&quot;)
</pre>
</div>
<div class="section" id="final-settings">
<h2><a class="toc-backref" href="#id27">final settings</a></h2>
<p>make a MD5 checksum decide wether or not a file changed. we had some problems with using the modification date for this purpose.</p>
<pre class="literal-block">
env.Decider('MD5')
</pre>
<p>set a defaukt target</p>
<pre class="literal-block">
t=env.Program(target=programName, source=sources)
Default(t)
</pre>
</div>
</div>
</div>
</body>
</html>

217
docs/gendocs.sh.html Normal file
View File

@ -0,0 +1,217 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.10: http://docutils.sourceforge.net/" />
<title></title>
<style type="text/css">
/*
:Authors: Ian Bicking, Michael Foord
:Contact: fuzzyman@voidspace.org.uk
:Date: 2005/08/26
:Version: 0.1.0
:Copyright: This stylesheet has been placed in the public domain.
Stylesheet for Docutils.
Based on ``blue_box.css`` by Ian Bicking
and ``html4css1.css`` revision 1.46.
*/
@import url(file:///usr/local/lib/python2.7/dist-packages/docutils/writers/html4css1/html4css1.css);
body {
font-family: Arial, sans-serif;
}
em, i {
/* Typically serif fonts have much nicer italics */
font-family: Times New Roman, Times, serif;
}
a.target {
color: blue;
}
a.target {
color: blue;
}
a.toc-backref {
text-decoration: none;
color: black;
}
a.toc-backref:hover {
background-color: inherit;
}
a:hover {
background-color: #cccccc;
}
div.attention, div.caution, div.danger, div.error, div.hint,
div.important, div.note, div.tip, div.warning {
background-color: #cccccc;
padding: 3px;
width: 80%;
}
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
text-align: center;
background-color: #999999;
display: block;
margin: 0;
}
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title {
color: #cc0000;
font-family: sans-serif;
text-align: center;
background-color: #999999;
display: block;
margin: 0;
}
h1, h2, h3, h4, h5, h6 {
font-family: Helvetica, Arial, sans-serif;
border: thin solid black;
/* This makes the borders rounded on Mozilla, which pleases me */
-moz-border-radius: 8px;
padding: 4px;
}
h1 {
background-color: #444499;
color: #ffffff;
border: medium solid black;
}
h1 a.toc-backref, h2 a.toc-backref {
color: #ffffff;
}
h2 {
background-color: #666666;
color: #ffffff;
border: medium solid black;
}
h3, h4, h5, h6 {
background-color: #cccccc;
color: #000000;
}
h3 a.toc-backref, h4 a.toc-backref, h5 a.toc-backref,
h6 a.toc-backref {
color: #000000;
}
h1.title {
text-align: center;
background-color: #444499;
color: #eeeeee;
border: thick solid black;
-moz-border-radius: 20px;
}
table.footnote {
padding-left: 0.5ex;
}
table.citation {
padding-left: 0.5ex
}
pre.literal-block, pre.doctest-block {
border: thin black solid;
padding: 5px;
}
.image img { border-style : solid;
border-width : 2px;
}
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
font-size: 100%;
}
code, tt {
color: #000066;
}
</style>
</head>
<body>
<div class="document">
<!-- #!/bin/bash -->
<div class="section" id="documentation-generator">
<h1>Documentation generator</h1>
<p>the purpose of this script is to generate html documentation from the source code of specified files.</p>
</div>
<div class="section" id="requirements">
<h1>requirements</h1>
<p>this script requires pylit to be installed and the rst2html command to be available</p>
</div>
<div class="section" id="pre-generation">
<h1>pre generation</h1>
<p>make sure the script terminates on errors</p>
<pre class="literal-block">
set -e
</pre>
<p>skip pregeneration if we get any commandline parameters</p>
<pre class="literal-block">
if [ $# == 0 ]
then
</pre>
<p>list of files to generate documentation for. the format is always:</p>
<pre class="literal-block">
&quot;$0 filename language&quot;
</pre>
<p>the following languages are available:
- c
- c++
- css
- python
- shell
- slang
- latex</p>
<pre class="literal-block">
$0 SConscript python
$0 gendocs.sh shell
</pre>
<p>exit program after running all the generation steps</p>
<pre class="literal-block">
exit
fi
</pre>
</div>
<div class="section" id="generation">
<h1>generation</h1>
<p>inform the user of which file we're processing</p>
<pre class="literal-block">
echo &quot;--- generating docs for $1&quot;
</pre>
<p>run pylit to convert source code to restructured text</p>
<pre class="literal-block">
pylit $1 --language $2 $1.txt
</pre>
<p>run rst2html to convert restructured text to html</p>
<pre class="literal-block">
rst2html.py $1.txt --stylesheet docs/style.css &gt; docs/$1.html
</pre>
<p>clean up the restructured text file</p>
<pre class="literal-block">
rm $1.txt
</pre>
</div>
</div>
</body>
</html>

137
docs/style.css Normal file
View File

@ -0,0 +1,137 @@
/*
:Authors: Ian Bicking, Michael Foord
:Contact: fuzzyman@voidspace.org.uk
:Date: 2005/08/26
:Version: 0.1.0
:Copyright: This stylesheet has been placed in the public domain.
Stylesheet for Docutils.
Based on ``blue_box.css`` by Ian Bicking
and ``html4css1.css`` revision 1.46.
*/
@import url(file:///usr/local/lib/python2.7/dist-packages/docutils/writers/html4css1/html4css1.css);
body {
font-family: Arial, sans-serif;
}
em, i {
/* Typically serif fonts have much nicer italics */
font-family: Times New Roman, Times, serif;
}
a.target {
color: blue;
}
a.target {
color: blue;
}
a.toc-backref {
text-decoration: none;
color: black;
}
a.toc-backref:hover {
background-color: inherit;
}
a:hover {
background-color: #cccccc;
}
div.attention, div.caution, div.danger, div.error, div.hint,
div.important, div.note, div.tip, div.warning {
background-color: #cccccc;
padding: 3px;
width: 80%;
}
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
text-align: center;
background-color: #999999;
display: block;
margin: 0;
}
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title {
color: #cc0000;
font-family: sans-serif;
text-align: center;
background-color: #999999;
display: block;
margin: 0;
}
h1, h2, h3, h4, h5, h6 {
font-family: Helvetica, Arial, sans-serif;
border: thin solid black;
/* This makes the borders rounded on Mozilla, which pleases me */
-moz-border-radius: 8px;
padding: 4px;
}
h1 {
background-color: #444499;
color: #ffffff;
border: medium solid black;
}
h1 a.toc-backref, h2 a.toc-backref {
color: #ffffff;
}
h2 {
background-color: #666666;
color: #ffffff;
border: medium solid black;
}
h3, h4, h5, h6 {
background-color: #cccccc;
color: #000000;
}
h3 a.toc-backref, h4 a.toc-backref, h5 a.toc-backref,
h6 a.toc-backref {
color: #000000;
}
h1.title {
text-align: center;
background-color: #444499;
color: #eeeeee;
border: thick solid black;
-moz-border-radius: 20px;
}
table.footnote {
padding-left: 0.5ex;
}
table.citation {
padding-left: 0.5ex
}
pre.literal-block, pre.doctest-block {
border: thin black solid;
padding: 5px;
}
.image img { border-style : solid;
border-width : 2px;
}
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
font-size: 100%;
}
code, tt {
color: #000066;
}

63
gendocs.sh Executable file
View File

@ -0,0 +1,63 @@
#!/bin/bash
# Documentation generator
# =======================
# the purpose of this script is to generate html documentation from the source code of specified files.
# requirements
# ============
# this script requires pylit to be installed and the rst2html command to be available
# pre generation
# ==============
# make sure the script terminates on errors
set -e
# skip pregeneration if we get any commandline parameters
if [ $# == 0 ]
then
# list of files to generate documentation for. the format is always::
# "$0 filename language"
# the following languages are available:
# - c
# - c++
# - css
# - python
# - shell
# - slang
# - latex
$0 SConscript python
$0 gendocs.sh shell
# exit program after running all the generation steps
exit
fi
# generation
# ==========
# inform the user of which file we're processing
echo "--- generating docs for $1"
# run pylit to convert source code to restructured text
pylit $1 --language $2 $1.txt
# run rst2html to convert restructured text to html
rst2html.py $1.txt --stylesheet docs/style.css > docs/$1.html
# clean up the restructured text file
rm $1.txt