Line 3: Imports the env from the parent script

Line 5&7: Sets up the C compiler to look in both the current directory and the include directory underneath the main directory in which SCons was started. Note the "#" in the "#include". This is important. That include directory contains a "config.h" file that almost all the C code references and it is not copied over to the build/etc/etc hierarchy.

Line 9: Gambit Scheme input files (sources) Line 12: Extra input source files. This is here because these files have extra dependencies.

Line 16&17: Converts the Gambit Scheme input files into C output files (targets) via the GambitCompiler Builder defined in the top-level SConstruct. ie. _gsi.scm becomes _gsi.c. Note that I am saving the targets here for later reference.

Line 23,23,25,26,27: Lots of dependencies. Make the targets dependent upon libgambc. As the comment says, only the gsc executable is, strictly speaking, dependent upon libgambc. However, the easiest way to pick up the dependencies from lots of the source files to the lib files is to make the targets depend on the whole library. Yes, it's a bit of a hack which forces libgambc to build first.

Line 29: Gambit requires some extra link information to produce a stand-alone executable. This uses the GambitLinker Builder that was defined in the top-level SConstruct to produce that file. It demonstrates multiple sources compiling into one target.

Line 31: Invoke the normal SCons Program Builder to produce an executable and remember it

Line 33: Not used yet, but I send the reference to the executable back up to the SConstruct for later use, if required.

   1 # -*-python-*-
   3 Import(["env", "libgambc"])
   5 cpppath = [".", "#include", "#lib"]
   7 env.Replace(CPPPATH=cpppath)
   9 gambitSourceFiles = ["_back.scm", "_env.scm", "_front.scm", "_gvm.scm", "_host.scm",
  10                      "_parms.scm", "_prims.scm", "_ptree1.scm", "_ptree2.scm", "_source.scm",
  11                      "_t-c-1.scm", "_t-c-2.scm", "_utils.scm"]
  12 gambitGenericDependentSourceFiles = ["_t-c-3.scm", "_gsc.scm"]
  15 # This "GenericDependent" contortion is because source files can't have dependencies
  16 gambitTargetFiles = env.GambitCompiler(gambitSourceFiles)
  17 gambitGenericDependentTargetFiles = env.GambitCompiler(gambitGenericDependentSourceFiles)
  20 # The target files are not strictly dependent upon the entire
  21 # libgambc but on some of the files generated during its build
  22 env.Depends(gambitTargetFiles, libgambc)
  23 env.Depends(gambitGenericDependentTargetFiles, libgambc)
  25 env.Depends(gambitTargetFiles, ["fixnum.scm", "_envadt.scm", "_gvmadt.scm", "_ptreeadt.scm", "_sourceadt.scm"])
  26 env.Depends(gambitGenericDependentTargetFiles, ["fixnum.scm", "_envadt.scm", "_gvmadt.scm", "_ptreeadt.scm", "_sourceadt.scm"])
  27 env.Depends(gambitGenericDependentTargetFiles, ["generic.scm"])
  29 gscLinkerFile = env.GambitLinker([gambitTargetFiles, gambitGenericDependentTargetFiles])
  31 gsc = env.Program("gsc", [gambitTargetFiles, gambitGenericDependentTargetFiles,
  32                           gscLinkerFile, libgambc])
  33 Return("gsc")

APLSConscript01-gsc (last edited 2013-08-28 20:45:37 by WilliamDeegan)