Skip to content
Browse files

Most of the extra features seem to be working now.

darcs-hash:20070113213704-de23e-7a308930bdff030c8795fa2af424cf8c9f26abcf.gz
  • Loading branch information...
1 parent da8ade6 commit b6d4c41be428da66c5f4aa2fb0feab20e304fe0b @pupeno committed Jan 13, 2007
Showing with 115 additions and 117 deletions.
  1. +108 −110 chicken.py
  2. +7 −7 examples/sc-sap/SConstruct
View
218 chicken.py
@@ -11,15 +11,15 @@
from SCons.Builder import Builder
#import SCons.Tool
#import SCons.Scanner
-#from SCons.Node.FS import File
+from SCons.Node.FS import File
import os
def generate(env):
#Not needed# env["CSI"] = env.Detect("csi") or "csi"
env["CSC"] = env.Detect("csc") or "csc" # Only used to gather flags.
env["CHICKEN"] = env.Detect("chicken") or "chicken"
env["CHICKENFLAGS"] = SCons.Util.CLVar("")
- #env["CHICKENREPOSITORY"] = strip(os.popen("chicken-setup -repository").read()) + "/"
+ env["CHICKENREPOSITORY"] = os.popen("chicken-setup -repository").read().strip() + "/"
env["CHICKENCOM"] = "$CHICKEN $CHICKENFLAGS $SOURCE -output-file $TARGET"
@@ -36,118 +36,117 @@ def generate(env):
c_file.add_action(".scm", SCons.Action.Action(env["CHICKENCOM"]))
- #def includedFiles(node, env, path):
- # for path in env["ENV"]["PATH"].split(":"):
- # cil = path + "/" + "chicken-include-list"
- # if os.path.exists(cil):
- # includes = split(strip(os.popen(cil + " " + str(node)).read()))
- # return includes
- # else:
- # print "Not running chicken-il, nothing to be worried about when building/installing SCons Chicken, but if that is not the case, your installation may be corrupt."
- # return []
- #
- #chickenScanner = SCons.Scanner.Scanner(function = includedFiles,
- # name = "ChickenScanner",
- # skeys = [".scm"],
- # recursive = True)
- #env.Append(SCANNERS = chickenScanner)
- #
- #def ChickenSetup(target = None, source = None, env = None):
- #""" Function that works as a builder action wrapping chickenSetup. """
+ def includedFiles(node, env, path):
+ for path in env["ENV"]["PATH"].split(":"):
+ cil = path + "/" + "chicken-include-list"
+ if os.path.exists(cil):
+ includes = os.popen(cil + " " + str(node)).read().strip().split()
+ return includes
+ else:
+ print "Not running chicken-include-list, nothing to be worried about when building/installing SCons Chicken, but if that is not the case, your installation may be corrupt."
+ return []
+
+ chickenScanner = SCons.Scanner.Scanner(function = includedFiles,
+ name = "ChickenScanner",
+ skeys = [".scm"],
+ recursive = True)
+ env.Append(SCANNERS = chickenScanner)
+
+ def ChickenSetup(target = None, source = None, env = None):
+ """ Function that works as a builder action wrapping chickenSetup. """
- ## Meta information passed to us.
- #meta = None
- #if env._dict.has_key("meta"):
- #meta = env._dict["meta"]
-
- ## Open the .setup file for writing.
- #setupFile = open(str(target[0]), "w")
-
- ## Generate and write its content.
- #setupFile.write(chickenSetup(source, meta))
-
- ## Close it.
- #setupFile.close()
-
- #return None
-
- #env["BUILDERS"]["ChickenSetup"] = SCons.Builder.Builder(action = ChickenSetup,
- #suffix = ".setup")
-
- #def chickenSetup(files, meta = None):
- #""" This procedure works like a builder and it builds the .setup files.
- #Parameters:
- #1. Name or list of names of the .so files that will be linked from the setup file.
- #Optional parameters:
- #documentation = Where is the HTML documentation.
- #syntax = Whether (true or false) this contain syntax extensions.
- #requires = other or list of other required extensions."""
-
- #def makeLispList(head, items, prefix = ""):
- #""" This procedure builds a string that resembles a Lisp list of strings.
- #The first parameter is the header of the Lisp-like list.
- #The second parameter is either a string or a list of strings that
- #will form the Lisp-like list.
- #Prefix is an optional parameter that will be prepended to each item
- #on the list."""
-
- #def prepareObject(item):
- #""" Prepares the object to be output as a string. If there"s a prefix, try to use it. """
- #if isinstance(item, str):
- #return "\"" + prefix + item + "\""
- #elif isinstance(item, File):
- #return "\"" + prefix + item.name + "\""
- #else:
- #return str(item)
+ # Meta information passed to us.
+ meta = None
+ if env._dict.has_key("meta"):
+ meta = env._dict["meta"]
+
+ # Open the .setup file for writing.
+ setupFile = open(str(target[0]), "w")
+
+ # Generate and write its content.
+ setupFile.write(chickenSetup(source, meta))
+
+ # Close it.
+ setupFile.close()
+
+ return None
+
+ env["BUILDERS"]["ChickenSetup"] = SCons.Builder.Builder(action = ChickenSetup, suffix = ".setup")
+
+ def chickenSetup(files, meta = None):
+ """ This procedure works like a builder and it builds the .setup files.
+ Parameters:
+ 1. Name or list of names of the .so files that will be linked from the setup file.
+ Optional parameters:
+ documentation = Where is the HTML documentation.
+ syntax = Whether (true or false) this contain syntax extensions.
+ requires = other or list of other required extensions."""
+
+ def makeLispList(head, items, prefix = ""):
+ """ This procedure builds a string that resembles a Lisp list of strings.
+ The first parameter is the header of the Lisp-like list.
+ The second parameter is either a string or a list of strings that
+ will form the Lisp-like list.
+ Prefix is an optional parameter that will be prepended to each item
+ on the list."""
+
+ def prepareObject(item):
+ """ Prepares the object to be output as a string. If there"s a prefix, try to use it. """
+ if isinstance(item, str):
+ return "\"" + prefix + item + "\""
+ elif isinstance(item, File):
+ return "\"" + prefix + item.name + "\""
+ else:
+ return str(item)
- #l = "(" + head
+ l = "(" + head
- #if isinstance(items, list):
- #for i in items:
- #l += " " + prepareObject(i)
- #elif items is not None:
- #l += " " + prepareObject(items)
+ if isinstance(items, list):
+ for i in items:
+ l += " " + prepareObject(i)
+ elif items is not None:
+ l += " " + prepareObject(items)
- #l += ")"
- #return l
+ l += ")"
+ return l
- ## Open the list (a .setup is a list).
- #content = "("
+ # Open the list (a .setup is a list).
+ content = "("
- ## Make a list of installed files. All located on CHICKENREPOSITORY.
- #content += makeLispList("files", files, env["CHICKENREPOSITORY"])
+ # Make a list of installed files. All located on CHICKENREPOSITORY.
+ content += makeLispList("files", files, env["CHICKENREPOSITORY"])
- ## Create the rest of the meta-information.
- #if meta:
- #for k in meta:
- #content += "\n" + makeLispList(k, meta[k])
+ # Create the rest of the meta-information.
+ if meta:
+ for k in meta:
+ content += "\n" + makeLispList(k, meta[k])
- ## Close the list.
- #content += ")\n"
+ # Close the list.
+ content += ")\n"
- ## Return the generated content.
- #return content
+ # Return the generated content.
+ return content
- #def EmitEggContents(target = None, source = None, env = None):
- #""" Return the files that should go into an egg. """
+ def EmitEggContents(target = None, source = None, env = None):
+ """ Return the files that should go into an egg. """
- #def getLeafSources(sources):
- #""" Get all the sources that are leafs, not branches. """
- #contents = list()
- #for source in sources:
- #if len(source.sources) == 0:
- #contents.append(source)
- #contents += source.get_found_includes(env, chickenScanner, source.path)
- #else:
- #contents += getLeafSources(source.sources)
- #return contents
-
- #contents = list(set(getLeafSources(source)))
- #return target, contents
+ def getLeafSources(sources):
+ """ Get all the sources that are leafs, not branches. """
+ contents = list()
+ for source in sources:
+ if len(source.sources) == 0:
+ contents.append(source)
+ contents += source.get_found_includes(env, chickenScanner, source.path)
+ else:
+ contents += getLeafSources(source.sources)
+ return contents
+
+ contents = list(set(getLeafSources(source)))
+ return target, contents
- #env["BUILDERS"]["ChickenEgg"] = SCons.Builder.Builder(action = "$TARCOM",
- #emitter = EmitEggContents,
- #suffix = ".egg")
+ env["BUILDERS"]["ChickenEgg"] = SCons.Builder.Builder(action = "$TARCOM",
+ emitter = EmitEggContents,
+ suffix = ".egg")
def CheckChickenProgram(context):
""" Check if a Chicken program can be built and run. If not, try adding the libraries. """
@@ -161,15 +160,14 @@ def CheckChickenProgram(context):
return result[0]
env.CheckChickenProgram = CheckChickenProgram
- #def CheckChickenLibrary(context):
+ def CheckChickenLibrary(context):
#""" Check if a Chicken library can be built after adding the libraries. """
- #context.Message("Checking for building Chicken libraries... ")
- ## A library compiles correctly even without the right flags (in that case, it compiles, but it can't be used. So, we just add the flags.
- #context.env.ParseConfig("chicken-config -shared -cflags -libs")
- #result = context.TryBuild(context.env.SharedLibrary, "(display (+ 1 2))", ".scm")
- #context.Result(result)
- #return result
- #env.CheckChickenLibrary = CheckChickenLibrary
+ context.Message("Checking for building Chicken libraries... ")
+ # A library compiles correctly even without the right flags (in that case, it compiles, but it can't be used. So, we just add the flags.
+ result = context.TryBuild(context.env.SharedLibrary, "(display (+ 1 2))", ".scm")
+ context.Result(result)
+ return result
+ env.CheckChickenLibrary = CheckChickenLibrary
def exists(env):
return env.Detect(["csc"])
View
14 examples/sc-sap/SConstruct
@@ -14,11 +14,11 @@ env = Environment(tools = ["default", "chicken"], toolpath=["../../"])
# Check if a Chicken program can be built (and try to alter the environment for that porpouse).
conf = Configure(env, custom_tests = {"CheckChickenProgram" : env.CheckChickenProgram})
-if not conf.CheckChickenProgram():
- print "It seems you don't have Chicken installed or it is not"
- print "installed correctly. For more information:"
- print "http://www.call-with-current-continuation.org/"
- Exit(1)
+#if not conf.CheckChickenProgram():
+# print "It seems you don't have Chicken installed or it is not"
+# print "installed correctly. For more information:"
+# print "http://www.call-with-current-continuation.org/"
+# Exit(1)
env = conf.Finish()
# sc-sap (executable binary) made of sc-sap.scm.
@@ -28,5 +28,5 @@ env.Install('/usr/bin/', sc_sap)
# Install alias.
#env.Alias('install', '/usr/bin/')
-# Build an egg
-env.ChickenEgg(sc_sap)
+# Build an egg. It doesn't really make sense because eggs are only for libraries, not for programs. Another reason of why Eggs taste bad.
+#env.ChickenEgg(sc_sap)

0 comments on commit b6d4c41

Please sign in to comment.
Something went wrong with that request. Please try again.