summaryrefslogtreecommitdiff
path: root/scons/generic.py
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2009-12-31 17:58:56 +0000
committerJosé Fonseca <jfonseca@vmware.com>2010-01-01 11:00:58 +0000
commit97e2c5ac0bba7298c9a32703fe3d19de1f7b815a (patch)
tree655c923defd9055cfc51716a4575ad6a7285bd49 /scons/generic.py
parent700a2ebbf1ce0737ffdc3c9f08415dcf59550465 (diff)
scons: Expose convienience libraries to the host environment.
This fixes MinGW cross compilation build, recently broken due to the use of convenience libraries in the GLSL preprocessor.
Diffstat (limited to 'scons/generic.py')
-rw-r--r--scons/generic.py104
1 files changed, 1 insertions, 103 deletions
diff --git a/scons/generic.py b/scons/generic.py
index 859bf2ae64..208e3b6526 100644
--- a/scons/generic.py
+++ b/scons/generic.py
@@ -41,107 +41,6 @@ import SCons.Builder
import SCons.Scanner
-def quietCommandLines(env):
- # Quiet command lines
- # See also http://www.scons.org/wiki/HidingCommandLinesInOutput
- env['CCCOMSTR'] = "Compiling $SOURCE ..."
- env['CXXCOMSTR'] = "Compiling $SOURCE ..."
- env['ARCOMSTR'] = "Archiving $TARGET ..."
- env['RANLIBCOMSTR'] = ""
- env['LINKCOMSTR'] = "Linking $TARGET ..."
-
-
-def createConvenienceLibBuilder(env):
- """This is a utility function that creates the ConvenienceLibrary
- Builder in an Environment if it is not there already.
-
- If it is already there, we return the existing one.
-
- Based on the stock StaticLibrary and SharedLibrary builders.
- """
-
- try:
- convenience_lib = env['BUILDERS']['ConvenienceLibrary']
- except KeyError:
- action_list = [ SCons.Action.Action("$ARCOM", "$ARCOMSTR") ]
- if env.Detect('ranlib'):
- ranlib_action = SCons.Action.Action("$RANLIBCOM", "$RANLIBCOMSTR")
- action_list.append(ranlib_action)
-
- convenience_lib = SCons.Builder.Builder(action = action_list,
- emitter = '$LIBEMITTER',
- prefix = '$LIBPREFIX',
- suffix = '$LIBSUFFIX',
- src_suffix = '$SHOBJSUFFIX',
- src_builder = 'SharedObject')
- env['BUILDERS']['ConvenienceLibrary'] = convenience_lib
-
- return convenience_lib
-
-
-# TODO: handle import statements with multiple modules
-# TODO: handle from import statements
-import_re = re.compile(r'^import\s+(\S+)$', re.M)
-
-def python_scan(node, env, path):
- # http://www.scons.org/doc/0.98.5/HTML/scons-user/c2781.html#AEN2789
- contents = node.get_contents()
- source_dir = node.get_dir()
- imports = import_re.findall(contents)
- results = []
- for imp in imports:
- for dir in path:
- file = os.path.join(str(dir), imp.replace('.', os.sep) + '.py')
- if os.path.exists(file):
- results.append(env.File(file))
- break
- file = os.path.join(str(dir), imp.replace('.', os.sep), '__init__.py')
- if os.path.exists(file):
- results.append(env.File(file))
- break
- return results
-
-python_scanner = SCons.Scanner.Scanner(function = python_scan, skeys = ['.py'])
-
-
-def code_generate(env, script, target, source, command):
- """Method to simplify code generation via python scripts.
-
- http://www.scons.org/wiki/UsingCodeGenerators
- http://www.scons.org/doc/0.98.5/HTML/scons-user/c2768.html
- """
-
- # We're generating code using Python scripts, so we have to be
- # careful with our scons elements. This entry represents
- # the generator file *in the source directory*.
- script_src = env.File(script).srcnode()
-
- # This command creates generated code *in the build directory*.
- command = command.replace('$SCRIPT', script_src.path)
- code = env.Command(target, source, command)
-
- # Explicitly mark that the generated code depends on the generator,
- # and on implicitly imported python modules
- path = (script_src.get_dir(),)
- deps = [script_src]
- deps += script_src.get_implicit_deps(env, python_scanner, path)
- env.Depends(code, deps)
-
- # Running the Python script causes .pyc files to be generated in the
- # source directory. When we clean up, they should go too. So add side
- # effects for .pyc files
- for dep in deps:
- pyc = env.File(str(dep) + 'c')
- env.SideEffect(pyc, code)
-
- return code
-
-
-def createCodeGenerateMethod(env):
- env.Append(SCANNERS = python_scanner)
- env.AddMethod(code_generate, 'CodeGenerate')
-
-
def symlink(target, source, env):
target = str(target[0])
source = str(source[0])
@@ -578,8 +477,7 @@ def generate(env):
env.Append(LIBS = [])
# Custom builders and methods
- createConvenienceLibBuilder(env)
- createCodeGenerateMethod(env)
+ env.Tool('custom')
createInstallMethods(env)
# for debugging