Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Lot's of changes to a new layout.

darcs-hash:20051106233730-71b0c-d557a7164fdf312e3e0350df0b974a37b0771be6.gz
  • Loading branch information...
commit d81adfcf40010375ae4a4ca36c8128988a873278 1 parent d9ded11
@pupeno authored
View
8 README
@@ -5,7 +5,6 @@ scons-chicken is an add-on for SCons (http://www.scons.org), a building system (
Installation
------------
-
To install it you'll need SCons (http://www.scons.org) and all you need is to run:
scons install
and it will install chicken.py on /usr/lib/scons/Scons/Tool/. If you installed SCons somewhere else, edit SConstruct and fix.
@@ -13,9 +12,12 @@ If you know of a better fix that will work no matter where you installed SCons (
Usage
-----
-
To learn how to use scons-chicken, check out the examples directories.
sc-ofl: scons-chicken one-file-library
sc-mfl: scons-chicken multiple-file-library (depends on sc-ofl)
sc-ofp: scons-chicken one-file-program
-sc-mfp: scons-chicken multiple-file-program (depends on sc-tfl)
+sc-mfp: scons-chicken multiple-file-program (depends on sc-tfl)
+
+Limitations
+-----------
+It can't create extensions of multiple libraries (but it can create libraries of multiple files).
View
162 chicken.py
@@ -9,36 +9,128 @@
import SCons.Tool
import os
+import os.path
+from SCons.Builder import Builder
from SCons.Node.FS import File
-from string import strip
+from string import strip, split
def generate(env):
+ env["CHICKEN"] = env.Detect("chicken") or "chicken"
+ env["CHICKENPROFLAGS"] = ""
+ env["CHICKENLIBFLAGS"] = "-dynamic -feature chicken-compile-shared -feature compiling-extension"
+ #"-dynamic -feature chicken-compile-shared -feature compiling-extension"
+ env['CHICKENREPOSITORY'] = strip(os.popen('chicken-setup -repository').read()) + '/'
+
+ env.ChickenPro = Builder(action = "$CHICKEN $SOURCE -output-file $TARGET $CHICKENPROFLAGS")
+ def chickenLibGenerator(source, target, env, for_signature):
+ actions = []
+ for s, t in zip(source, target):
+ actions.append("%s %s -output-file %s %s" % (env["CHICKEN"], s, t, env["CHICKENLIBFLAGS"]))
+ return actions
+
+ env.ChickenLib = Builder(#action = "$CHICKEN $SOURCE -output-file $TARGET $CHICKENLIBFLAGS",
+ generator = chickenLibGenerator,
+ sufix = '.c',
+ src_sufix = '.scm')
+
# Get the builders for c and c++
- c_file, cxx_file = SCons.Tool.createCFileBuilders(env)
+ #c_file, cxx_file = SCons.Tool.createCFileBuilders(env)
# and add .scm extensions to the c builder with our own action.
- c_file.add_action('.scm', SCons.Action.Action("$CHICKENCOM"))
+ #c_file.add_action('.scm', SCons.Action.Action("$CHICKENCOM"))
- # Chicken variable/constans.
- env['CHICKEN'] = env.Detect('chicken') or 'chicken'
- env['CHICKENFLAGS'] = SCons.Util.CLVar('')
- env['CHICKENCOM'] = '$CHICKEN $SOURCE -output-file $TARGET $CHICKENFLAGS'
+ def ChickenProgram(env, target, source = None, *args, **kw):
+ """Pseudo builder to make a Chicken program."""
+
+ # Check if we have Chiken instaled.
+ conf = env.Configure()
+ if not conf.CheckLibWithHeader("chicken",
+ "chicken.h",
+ "c",
+ "C_alloc(C_SIZEOF_LIST(3));"):
+ 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()
+
+ # If no source provided, source is what is on target and target should be generated.
+ if not source:
+ source = target
+ if isinstance(source, list):
+ target = split(source[0], ".")[0]
+ else:
+ target = split(source, ".")[0]
+
+ # Separate Scheme sources from the rest
+ schemeSources, schemeAsCSources, otherSources = GroupSources(source)
- env['CHICKENREPOSITORY'] = strip(os.popen('chicken-setup -repository').read()) + '/'
-
- def CheckChicken(context):
- """ This procedure should be running on a Configure context.
- It will return True if there's a working Chicken installation,
- false otherwise."""
+ # Compile Scheme sources into C using Chicken (for programs).
+ env.ChickenPro(env, schemeAsCSources, schemeSources)
+
+ # Add the needed libraries.
+ env.ParseConfig('chicken-config -shared -libs -cflags')
- context.Message("Checking for Chicken... ")
+ return apply(env.Program, (target, schemeAsCSources + otherSources) + args, kw)
+
+ def ChickenExtension(env, target, source = None, *args, **kw):
+ """Pseudo builder to make a Chicken extension."""
+
+ # If no source provided, source is what is on target and target should be generated.
+ if not source:
+ source = target
+ if isinstance(source, list):
+ target = split(source[0], ".")[0]
+ else:
+ target = split(source, ".")[0]
+ target = [target, target + ".setup"]
+
+ # Separate Scheme sources from the rest
+ schemeSources, schemeAsCSources, otherSources = GroupSources(source)
+
+ # Compile Scheme sources into C using Chicken (for programs).
+ env.ChickenLib(env, schemeAsCSources, schemeSources)
+
+ # Add the needed libraries.
+ env.ParseConfig('chicken-config -shared -libs -cflags')
+
+ kw["SHLIBPREFIX"] = ""
+ lib = apply(env.SharedLibrary, (target, schemeAsCSources + otherSources) + args, kw)
- # Try to compile and run a simple Scheme program.
- result = context.TryRun("(display (+ 1 2))", ".scm")
- context.Result(result[0])
- return result[0]
+ # Generate the .setup file.
+ setup = ChickenSetup(os.path.splitext(str(lib[0]))[0] + ".setup", lib[0])
- def ChickenSetup(env, target, source, *args, **kw):
+ # Clean the .setup file when cleaning the library.
+ env.Clean(lib, setup)
+
+ return lib, setup
+
+ # Attach the pseudo-Builders to the Environment so they can be called like a real Builder.
+ env.ChickenProgram = ChickenProgram
+ env.ChickenExtension = ChickenExtension
+
+ def GroupSources(sources):
+ """Perform the set of common operations for any Chicken project."""
+
+ if not isinstance(sources, list):
+ sources = [sources]
+
+ # Lists for the names of the scheme sources and others respectively.
+ schemeSources = []
+ schemeAsCSources = []
+ otherSources = []
+
+ # Separate sources into scheme, generated and other sources
+ for s in sources:
+ if os.path.splitext(s)[1] == '.scm':
+ schemeSources.append(s)
+ schemeAsCSources.append(os.path.splitext(s)[0]+'.c')
+ else:
+ otherSources.append(s)
+
+ return schemeSources, schemeAsCSources, otherSources
+
+ def ChickenSetup(setup, files, documentation = None, syntax = False, requires = None):
""" This procedure works like a builder and it builds the .setup files.
Parameters:
1. env (any way to fix this ?)
@@ -83,42 +175,34 @@ def buildPath(item):
return l
# Open the list (a .setup is a list).
- setup = "("
+ content = "("
# Make a list of the sources, the .so files. All located on CHICKENREPOSITOR.
- setup += makeLispList("files", source, env['CHICKENREPOSITORY'])
+ content += makeLispList("files", files, env['CHICKENREPOSITORY'])
# Add the documentation.
- if kw.has_key('documentation'):
- setup += "\n(documentation \"" + kw['documentation'] + "\")"
+ if documentation:
+ content += "\n(documentation \"" + documentation + "\")"
# Is this a syntax extension ?
- if kw.has_key('syntax') and kw('syntax') == True:
- setup += "\n(syntax)"
+ if syntax == True:
+ content += "\n(syntax)"
# What other extensions are necesary by this one ?
- if kw.has_key('requires'):
+ if requires:
# Make a list of extensions.
- setup += "\n" + makeLispList("requires", kw['requires'])
+ coetent += "\n" + makeLispList("requires", requires)
# Close the list.
- setup += ")\n"
-
- # The target should be one and only one file, if it is a list, we take the first one.
- if(isinstance(target, list)):
- target = target[0]
+ content += ")\n"
# Write the list (being hold as a string on setup) to the file.
- setupFile = open(target, 'w')
- setupFile.write(setup)
+ setupFile = open(setup, 'w')
+ setupFile.write(content)
setupFile.close()
# Return an object representing the file for further handling.
- return env.File(target)
-
- # Put the procedures on env, so the SConstruct file can find them.
- env.CheckChicken = CheckChicken
- env.ChickenSetup = ChickenSetup
+ return env.File(setup)
def exists(env):
return env.Detect(['chicken'])
View
59 examples/sc-mfl/SConstruct
@@ -12,54 +12,19 @@ env = Environment(tools = ["default", "chicken"], toolpath=["../../"])
# The previous line is to use the non-installed scons-chicken. In your project use:
# env = Environment(tools = ["default", "chicken"])
-# Parse the parameters that Chicken tell us we'll need to pass to the C compiler.
-env.ParseConfig('chicken-config -libs -cflags -shared')
+# sc-mfl1.so composed of sc-mfl1.scm y sc-mfl2.scm.
+sc_mfl1, sc_mfl1_setup = env.ChickenExtension(env,
+ "sc-mfl1",
+ ["sc-mfl1.scm", "sc-mfl2.scm"])
-# Start some checks.
-conf = env.Configure(custom_tests = {'CheckChicken' : env.CheckChicken})
-
-# Check if Chicken is present and it can create binaries.
-if not conf.CheckChicken():
- 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)
-
-# Add your specific checks here!
-
-# Finished checking.
-env = conf.Finish()
-
-# sc-mfl1.so composed of sc-mfl1.scm y sc-mfl3.scm.
-# SHLIBPREFIX = "" is needed so we generate sc-mfl1.so instead of libsc-mfl1.so.
-scmfl1 = env.SharedLibrary("sc-mfl1",
- ["sc-mfl1.scm", "sc-mfl3.scm"],
- SHLIBPREFIX = "")
-
-# sc-mfl2.so composed of sc-mfl2.scm y sc-mfl4.scm.
-scmfl2 = env.SharedLibrary("sc-mfl2",
- ["sc-mfl2.scm", "sc-mfl4.scm"],
- SHLIBPREFIX = "")
-
-# Generate a .setup file.
-# Parameters:
-# 1. env (any way to fix this ?)
-# 2. Name of the .setup file to generate.
-# 3. 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.
-setup = env.ChickenSetup(env,
- "sc-mfl.setup",
- [scmfl1, scmfl2],
- requires="sc-ofl")
-
-# Delete the setup file when cleaning (scmfl1).
-env.Clean(scmfl1, setup)
+# sc-mfl3.so composed of sc-mfl3.scm y sc-mfl4.scm.
+#sc_mfl3, sc_mfl3_setup = env.ChickenExtension(env,
+# "sc-mfl3",
+# ["sc-mfl3.scm", "sc-mfl4.scm"])
# Install the .so files and the .setup file on the extension directory.
-env.Install(env['CHICKENREPOSITORY'], scmfl1)
-env.Install(env['CHICKENREPOSITORY'], scmfl2)
-env.Install(env['CHICKENREPOSITORY'], setup)
+env.Install(env['CHICKENREPOSITORY'], sc_mfl1)
+env.Install(env['CHICKENREPOSITORY'], sc_mfl1_setup)
+#env.Install(env['CHICKENREPOSITORY'], sc_mfl3)
+#env.Install(env['CHICKENREPOSITORY'], sc_mfl3_setup)
env.Alias('install', env['CHICKENREPOSITORY'])
View
2  examples/sc-mfl/sc-mfl1.scm
@@ -7,7 +7,7 @@
;;;; You should have received a copy of the GNU General Public License along with scons-chicken; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
(define-extension sc-mfl1)
-(export sc-mfl1-proc)
+(declare (export sc-mfl1-proc))
(use sc-ofl)
(define (sc-mfl1-proc)
View
5 examples/sc-mfl/sc-mfl2.scm
@@ -6,8 +6,9 @@
;;;; scons-chicken is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
;;;; You should have received a copy of the GNU General Public License along with scons-chicken; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-(define-extension sc-mfl2)
-(export sc-mfl2-proc)
+;(define-extension sc-mfl2)
+;(declare (unit sc-mfl1))
+(declare (export sc-mfl2-proc))
(use sc-ofl)
(define (sc-mfl2-proc)
View
8 examples/sc-mfl/sc-mfl3.scm
@@ -6,13 +6,13 @@
;;;; scons-chicken is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
;;;; You should have received a copy of the GNU General Public License along with scons-chicken; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-(define-extension sc-mfl3)
-(export sc-mfl3-proc)
+;(declare (unit sc-mfl3))
+;(define-extension sc-mfl3)
+(declare (export sc-mfl3-proc))
(use sc-ofl)
(define (sc-mfl3-proc)
- (display "Hello from sc-mfl3, the scons-chicken multiple-file-library 3.")
+ (display "Hello from sc-mfl2, the scons-chicken multiple-file-library 3.")
(newline)
(display " ")
(sc-ofl-proc))
-
View
4 examples/sc-mfl/sc-mfl4.scm
@@ -6,8 +6,8 @@
;;;; scons-chicken is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
;;;; You should have received a copy of the GNU General Public License along with scons-chicken; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-(define-extension sc-mfl4)
-(export sc-mfl4-proc)
+(declare (unit sc-mfl4))
+(declare (export sc-mfl4-proc))
(use sc-ofl)
(define (sc-mfl4-proc)
View
41 examples/sc-ofl/SConstruct
@@ -12,46 +12,11 @@ env = Environment(tools = ["default", "chicken"], toolpath=["../../"])
# The previous line is to use the non-installed scons-chicken. In your project use:
# env = Environment(tools = ["default", "chicken"])
-# Parse the parameters that Chicken tell us we'll need to pass to the C compiler.
-env.ParseConfig('chicken-config -libs -cflags -shared')
-
-# Start some checks.
-conf = env.Configure(custom_tests = {'CheckChicken' : env.CheckChicken})
-
-# Check if Chicken is present and it can create binaries.
-if not conf.CheckChicken():
- 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)
-
-# Add your specific checks here!
-
-# Finished checking.
-env = conf.Finish()
-
-# Flags to make Chicken build an extension.
-env['CHICKENFLAGS'] = "-dynamic -feature chicken-compile-shared -quiet -feature compiling-extension -optimize-level 2 -no-trace"
-
# sc-ofl.so made of sc-ofl.scm.
# SHLIBPREFIX = "" is needed so we generate sc-mfl1.so instead of libsc-mfl1.so.
-scofl = env.SharedLibrary("sc-ofl.scm", SHLIBPREFIX = "")
-
-# Generate a .setup file.
-# Parameters:
-# 1. env (any way to fix this ?)
-# 2. Name of the .setup file to generate.
-# 3. 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.
-setup = env.ChickenSetup(env, "sc-ofl.setup", scofl)
-
-# Delete the .setup when deleting scofl.
-env.Clean(scofl, setup)
+sc_ofl, sc_ofl_setup = env.ChickenExtension(env, "sc-ofl.scm", SHLIBPREFIX = "")
# Instal the lib and the .setup file.
-env.Install(env['CHICKENREPOSITORY'], scofl)
-env.Install(env['CHICKENREPOSITORY'], setup)
+env.Install(env['CHICKENREPOSITORY'], sc_ofl)
+env.Install(env['CHICKENREPOSITORY'], sc_ofl_setup)
env.Alias('install', env['CHICKENREPOSITORY'])
View
25 examples/sc-ofp/SConstruct
@@ -12,30 +12,9 @@ env = Environment(tools = ["default", "chicken"], toolpath=["../../"])
# The previous line is to use the non-installed scons-chicken. In your project use:
# env = Environment(tools = ["default", "chicken"])
-# Parse the parameters that Chicken tell us we'll need to pass to the C compiler.
-env.ParseConfig('chicken-config -cflags -libs -shared')
-
-# Start some checks.
-conf = env.Configure(custom_tests = {'CheckChicken' : env.CheckChicken})
-
-# Check if Chicken is present and it can create binaries.
-if not conf.CheckChicken():
- 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)
-
-# Add your specific checks here!
-
-# Finished checking.
-env = conf.Finish()
-
-# Flags to make Chicken build an program.
-env['CHICKENFLAGS'] = "-quiet"
-
# sc-ofp (executable binary) made of sc-ofp.scm.
-scofp = env.Program('sc-ofp.scm')
+sc_ofp = env.ChickenProgram(env, "sc-ofp.scm")
# Install sc-ofp.
-env.Install('/usr/bin/', scofp)
+env.Install('/usr/bin/', sc_ofp)
env.Alias('install', '/usr/bin/')
View
2  examples/sc-ofp/sc-ofp.scm
@@ -15,4 +15,4 @@
(newline)
(sc-ofl-proc))
-(sc-ofp-proc)
+(sc-ofp-proc)
View
23 examples/sc-sap/SConstruct
@@ -12,28 +12,9 @@ env = Environment(tools = ["default", "chicken"], toolpath=["../../"])
# The previous line is to use the non-installed scons-chicken. In your project use:
# env = Environment(tools = ["default", "chicken"])
-
-# Parse the parameters that Chicken tell us we'll need to pass to the C compiler.
-env.ParseConfig('chicken-config -libs -cflags -shared')
-
-# Start some checks.
-conf = env.Configure(custom_tests = {'CheckChicken' : env.CheckChicken})
-
-# Check if Chicken is present and it can create binaries.
-if not conf.CheckChicken():
- 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)
-
-# Add your specific checks here!
-
-# Finished checking.
-env = conf.Finish()
-
# sc-sap (executable binary) made of sc-sap.scm.
-scsap = env.Program('sc-sap.scm')
+sc_sap = env.ChickenProgram(env, "sc-sap.scm")
# Install sc-sap.
-env.Install('/usr/bin/', scsap)
+env.Install('/usr/bin/', sc_sap)
env.Alias('install', '/usr/bin/')
Please sign in to comment.
Something went wrong with that request. Please try again.