# -*- mode:python;indent-tabs-mode:nil;show-trailing-whitespace:t; -*-
#
# Main build script for all librosetta projects.
# Schedules all the directories which contain build targets of their own.

# Bring in the shared build state
Import("build")


# Generate .cc file with svn revision number/range.
# Provide empty dictionaries so local environment is not modified.
execfile("svn_version.py", {}, {})


for kind in build.options.cat:
    for project in build.projects[kind]:
        # Sources and test are further broken down by platform
        if kind in ("src", "test"):
          if kind == "src" and project in ( "apps", "pilot_apps", "demo", "rdwizard" ) :
            #These sconscript files lead to executables
            if project in ( "apps", "pilot_apps" ) :
              build_path = "build/%s/%s" % (kind, build.platform)
              script = "src/SConscript.apps"
            elif project == 'rdwizard':
              build_path = "build/%s/%s" % (kind, build.platform)
              script = "src/SConscript.rdwizard"
            else : 
              #This will be going away once everyone is comfortable with compiling
              #executables in the apps framework
              build_path = "build/demo/%s" % (build.platform)
              script = "demo/SConscript.demo"
          else:
            build_path = "build/%s/%s" % (kind, build.platform)
            script = "%s/SConscript.%s" % ( kind, kind ) 
        # Documentation is built once regardless of platform
        else:
          build_path = "build/%s" % (kind)
          script = "%s/SConscript.%s" % (kind, kind)
        SConscript(script, exports = ["build", "project"],
          build_dir = build_path, duplicate = False)

#if "my" in map(str, BUILD_TARGETS) :
#  BUILD_TARGETS.remove("my")
#if "my_pilot_apps" in map(str, BUILD_TARGETS) :
#  BUILD_TARGETS.remove("my_pilot_apps")
#if "pilot_apps_all" in map(str, BUILD_TARGETS) :
#  BUILD_TARGETS.remove("pilot_apps_all")
