Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Better handling of meta-information of .setup files.

darcs-hash:20051128065516-71b0c-912f1eb7d5b849e9de4f662a167c5c900096242b.gz
  • Loading branch information...
commit 7061a760661495fe2f4dd047058b0bb86b9d3dae 1 parent 362284f
@pupeno authored
Showing with 30 additions and 49 deletions.
  1. +6 −0 README
  2. +23 −48 chicken.py
  3. +1 −1  examples/sc-mfl/SConstruct
View
6 README
@@ -30,6 +30,12 @@ To learn how to use scons-chicken, check out the examples directories:
- sc-mfp: scons-chicken multiple-file-program (depends on sc-tfl).
- sc-lap: scons-chicken library-and-file (it is a mix of ofl and ofp).
+ChickenSetup
+''''''''''''
+This builders helps creating the .setup file needed to be installed along extensions.
+The first parameter can be the name of the .setup or can be omited (like in any other sane builder). The second parameter (or first if the real first is omited) is a list of the files to be referenced (on files) on the .setup. That list can contain strings or File objects.
+Optionally, a parameter named meta can be passed with a dictionary of the rest of the metainformation. Any value can be a string, or list, or number. If it is None, nothing will be output (thus "syntax" : None, will result in (syntax)).
+
ChickenEgg
''''''''''
This builders helps creating an Egg, the Chicken extensions.
View
71 chicken.py
@@ -42,30 +42,17 @@ def includedFiles(node, env, path):
def ChickenSetup(target = None, source = None, env = None):
""" Function that works as a builder action wrapping chickenSetup. """
-
- # Do we have documentation ?
- if env._dict.has_key("DOCUMENTATION"):
- documentation = env._dict["DOCUMENTATION"]
- else:
- documentation = ""
-
- # Is this a syntax extension ?
- if env._dict.has_key("SYNTAX"):
- syntax = env._dict["SYNTAX"]
- else:
- syntax = False
-
- # What should we require ?
- if env._dict.has_key("REQUIRES"):
- requires = env._dict["REQUIRES"]
- else:
- requires = []
+
+ # 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, documentation, syntax, requires))
+ setupFile.write(chickenSetup(source, meta))
# Close it.
setupFile.close()
@@ -75,7 +62,7 @@ def ChickenSetup(target = None, source = None, env = None):
env["BUILDERS"]["ChickenSetup"] = SCons.Builder.Builder(action = ChickenSetup,
suffix = ".setup")
- def chickenSetup(files, documentation = None, syntax = False, requires = None):
+ 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.
@@ -92,26 +79,22 @@ def makeLispList(head, items, prefix = ""):
Prefix is an optional parameter that will be prepended to each item
on the list."""
- def buildPath(item):
- """ Procedure that builds a path using the prefix and a string or
- File object."""
+ 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, list):
- return prefix + str(item[0])
+ return "\"" + prefix + item + "\""
elif isinstance(item, File):
- return prefix + item.name
+ return "\"" + prefix + item.name + "\""
else:
- print "Type not recognized to build .setup file."
- return ""
-
+ return str(item)
+
l = "(" + head
if isinstance(items, list):
for i in items:
- l += " \"" + buildPath(i) + "\" "
- else:
- l += " \"" + buildPath(items) + "\""
+ l += " " + prepareObject(i)
+ elif items is not None:
+ l += " " + prepareObject(items)
l += ")"
return l
@@ -119,22 +102,14 @@ def buildPath(item):
# Open the list (a .setup is a list).
content = "("
- # Make a list of the sources, the .so files. All located on CHICKENREPOSITOR.
- content += makeLispList("files", files + [documentation], env["CHICKENREPOSITORY"])
-
- # Add the documentation.
- if documentation:
- content += "\n(documentation \"" + documentation + "\")"
-
- # Is this a syntax extension ?
- if syntax == True:
- content += "\n(syntax)"
-
- # What other extensions are necesary by this one ?
- if requires:
- # Make a list of extensions.
- content += "\n" + makeLispList("requires", requires)
+ # 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])
+
# Close the list.
content += ")\n"
View
2  examples/sc-mfl/SConstruct
@@ -26,7 +26,7 @@ sc_mfl = env.SharedLibrary("sc-mfl", ["sc-mfl1.scm", "sc-mfl2.scm"], SHLIBPREFIX
env.Install(env['CHICKENREPOSITORY'], sc_mfl)
# setup file for sc-mfl.
-sc_mfl_setup = env.ChickenSetup(sc_mfl, REQUIRES=["sc-ofl"])
+sc_mfl_setup = env.ChickenSetup(sc_mfl, meta = { "requires" : ["sc-ofl"]})
env.Install(env['CHICKENREPOSITORY'], sc_mfl_setup)
# Install alias.
Please sign in to comment.
Something went wrong with that request. Please try again.