Skip to content

Instantly share code, notes, and snippets.

@johnfredcee
Created April 24, 2012 20:22
Show Gist options
  • Select an option

  • Save johnfredcee/2483379 to your computer and use it in GitHub Desktop.

Select an option

Save johnfredcee/2483379 to your computer and use it in GitHub Desktop.
SConstruct file for working with flymake.
import os
import tempfile
import shlex
import subprocess
import sys
vars = Variables()
vars.Add(BoolVariable('SYNTAX', 'Set to 1 for a syntax check',0))
vars.Add(BoolVariable('DUMPENV', 'Set to 1 to dump environment',0))
def run_etags(env, target, source):
listfile = tempfile.NamedTemporaryFile(mode="w+", dir=os.getcwd(), delete=False)
listname = listfile.name
for sfile in source:
print >>listfile, str(sfile)
listfile.close()
etagargs = shlex.split("ctags -e --verbose --c++-kinds=cfnstunedm --extra=+q -o %s -L %s" % (target[0], listname))
print etagargs
try:
retcode = subprocess.call(etagargs)
if retcode < 0:
print >>sys.stderr, "Child was terminated by signal", -retcode
else:
print >>sys.stderr, "Child returned", retcode
except OSError, e:
print >>sys.stderr, "Execution failed:", e
os.remove(listname)
if os.name == "posix":
env = Environment(variables=vars)
env["ENV"]["PKG_CONFIG_PATH"] = os.environ.get("PKG_CONFIG_PATH")
env["CXXFLAGS"] = [ "-g", "-fpermissive" ]
env["CPPPATH"] = [ '/usr/include', './include' ]
if (env["SYNTAX"]):
env["CCFLAGS"] += [ '-fsyntax-only']
env["LIBPATH"] = [ '/usr/lib' ]
env.ParseConfig("pkg-config OGRE --cflags --libs")
env.ParseConfig("pkg-config assimp --cflags --libs")
env.ParseConfig("pkg-config OIS --cflags --libs")
env.ParseConfig("wx-config base --cflags --libs")
# env.ParseConfig("pkg-config atk --cflags --libs")
# env.ParseConfig("pkg-config gdk-2.0 --cflags --libs")
# env.ParseConfig("pkg-config gdk-x11-2.0 --cflags --libs")
# env.ParseConfig("pkg-config gtk+-2.0 --cflags --libs")
# env.ParseConfig("pkg-config gtk+-x11-2.0 --cflags --libs")
# env.ParseConfig("pkg-config gl --cflags --libs")
# env.ParseConfig("pkg-config glu --cflags --libs")
# env.Append(LIBS = "X11")
main_program_list=Glob("src/*.cpp")
if (env["DUMPENV"]==True):
print env.Dump('CPPPATH')
else:
env.Program('bin/bvhtwiddler', main_program_list)
if (not(env["SYNTAX"])):
env.Command("TAGS", env.Glob(r"src/*.cpp") + env.Glob(r"include/*.h"), [ run_etags ])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment