Permalink
Browse files

Succesful creation of a basic .setup file.

darcs-hash:20070115041956-de23e-47dba0b8b12691e13ca48c4b897e9e383a0f9f30.gz
  • Loading branch information...
1 parent a54db27 commit c1448381a7df65a3e52fb39caf2aee07006b5f20 @pupeno committed Jan 15, 2007
Showing with 94 additions and 62 deletions.
  1. +85 −57 chicken.py
  2. +0 −1 examples/sc-lap/SConstruct
  3. +9 −4 examples/sc-ofl/SConstruct
View
@@ -55,17 +55,31 @@ def includedFiles(node, env, path):
def ChickenSetup(target = None, source = None, env = None):
""" Function that works as a builder action wrapping chickenSetup. """
+ if env.has_key("name"):
+ name = env["name"]
+ else:
+ name = str(target[0]).split("/")[-1].split(".")[0] # Get the name from the target, that is, "blih" out of "something/blah/bleh/blih.setup".
+
+ if env.has_key("installFiles"):
+ installFiles = env["installFiles"]
+ else:
+ installFiles = []
+
+ if env.has_key("version"):
+ version = env["version"]
+ else:
+ version = "0"
- # Meta information passed to us.
- meta = None
- if env._dict.has_key("meta"):
- meta = env._dict["meta"]
+ if env.has_key("docs"):
+ docs = env["docs"]
+ else:
+ docs = []
# Open the .setup file for writing.
setupFile = open(str(target[0]), "w")
# Generate and write its content.
- setupFile.write(chickenSetup(source, meta))
+ setupFile.write(chickenSetup(source, name, installFiles, version, docs))
# Close it.
setupFile.close()
@@ -74,59 +88,74 @@ def ChickenSetup(target = None, source = None, env = 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
-
- if isinstance(items, list):
- for i in items:
- l += " " + prepareObject(i)
- elif items is not None:
- l += " " + prepareObject(items)
-
- l += ")"
- return l
-
- # 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"])
-
- # Create the rest of the meta-information.
- if meta:
- for k in meta:
- content += "\n" + makeLispList(k, meta[k])
+ def chickenSetup(sources, name, installFiles, version, docs):
+ output = ""
- # Close the list.
- content += ")\n"
+ for source in sources:
+ output += "(compile -s -O2 -d1 %s)" % source
- # Return the generated content.
- return content
+ output += "\n(install-extension"
+ output += "\n ; Name of your extension:"
+ output += "\n '%s" % name
+ output += "\n ; Files to install for your extension:"
+ output += "\n '(%s)" % " ".join(map(lambda x: "\"" + str(x) +"\"", installFiles))
+ output += "\n ; Assoc list with properties for your extension:"
+ output += "\n '((version %s)" % version
+ output += "\n (documentation %s))" % " ".join(map(lambda x: "\"" + str(x) +"\"", docs))
+ output += ")"
+ return output + "\n"
+# """ 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
+#
+# if isinstance(items, list):
+# for i in items:
+# l += " " + prepareObject(i)
+# elif items is not None:
+# l += " " + prepareObject(items)
+#
+# l += ")"
+# return l
+#
+# # 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"])
+#
+# # Create the rest of the meta-information.
+# if meta:
+# for k in meta:
+# content += "\n" + makeLispList(k, meta[k])
+#
+# # Close the list.
+# content += ")\n"
+#
+# # Return the generated content.
+# return content
def EmitEggContents(target = None, source = None, env = None):
""" Return the files that should go into an egg. """
@@ -164,7 +193,6 @@ def CheckChickenProgram(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.
result = context.TryBuild(context.env.SharedLibrary, "(display (+ 1 2))", ".scm")
context.Result(result)
return result
@@ -24,7 +24,6 @@ if not conf.CheckChickenLibrary():
Exit(1)
lib = conf.Finish()
-# sc-ofl.so made of sc-ofl.scm.
sc_lapl = lib.SharedLibrary("sc-lapl.scm", SHLIBPREFIX="")
lib.Install(lib["CHICKENREPOSITORY"], sc_lapl)
View
@@ -22,15 +22,20 @@ if not conf.CheckChickenLibrary():
env = conf.Finish()
# sc-ofl.so made of sc-ofl.scm.
-sc_ofl = env.SharedLibrary("sc-ofl.scm", SHLIBPREFIX="")
+sources = ["sc-ofl.scm"]
+sc_ofl = env.SharedLibrary(sources, SHLIBPREFIX="")
env.Install(env['CHICKENREPOSITORY'], sc_ofl)
# Setup file for sc-ofl.
-sc_ofl_setup = env.ChickenSetup(sc_ofl, meta = {"version" : [0, 1, 99]})
-env.Install(env['CHICKENREPOSITORY'], sc_ofl_setup)
+sc_ofl_setup = env.ChickenSetup(sources,
+ name = "sc-ofl", # Can be omited, it would be picked from the target, sc-ofl.setup minus the .setup part.
+ installFiles = sc_ofl + ["sc-ofl.html"],
+ version = "0.1.99",
+ docs = ["sc-ofl.html"])
+#env.Install(env['CHICKENREPOSITORY'], sc_ofl_setup)
# Install alias
#env.Alias('install', env['CHICKENREPOSITORY'])
# Build an egg
-env.ChickenEgg(sc_ofl)
+#env.ChickenEgg(sc_ofl)

0 comments on commit c144838

Please sign in to comment.