Permalink
Browse files

Scanner to search for includes.

darcs-hash:20051117070755-71b0c-dc9718cbe2344a981df8643633fa38368c64087b.gz
  • Loading branch information...
1 parent d0e7556 commit 10bf00260d7fdbe52975f40c51ad66f75ba0c927 @pupeno committed Nov 17, 2005
Showing with 78 additions and 10 deletions.
  1. +26 −6 SConstruct
  2. +0 −3 TODO
  3. +32 −0 chicken-il.scm
  4. +20 −1 chicken.py
View
@@ -10,18 +10,38 @@
import os
# Create an environment.
-env = Environment()
+env = Environment(tools = ["default", "chicken"], toolpath=["./"])
+
+# Check for Chicken.
+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)
+env = conf.Finish()
# Configuration.
opts = Options(".scons-chicken.conf")
-opts.Add(PathOption("PREFIX", "Prefix directory for SCons", os.environ.get('PYTHON_ROOT',"/usr/local")))
+opts.Add(PathOption("SCONSPREFIX", "Prefix directory for SCons", os.environ.get('PYTHON_ROOT',"/usr/local")))
+opts.Add(PathOption("PREFIX", "Prefix directory for everything else", "/usr/local"))
opts.Update(env)
opts.Save(".scons-chicken.conf", env)
# Help.
Help(opts.GenerateHelpText(env))
-# Install.
-installDir = "$PREFIX/lib/scons/SCons/Tool/"
-env.Install(installDir, 'chicken.py')
-env.Alias('install', installDir)
+# Install directories.
+sconsInstallDir = "$SCONSPREFIX/lib/scons/SCons/Tool/"
+binInstallDir = "$PREFIX/bin/"
+
+# chicken.py, no build needed.
+env.Install(sconsInstallDir, 'chicken.py')
+
+# chicken-il
+chicken_il = env.Program("chicken-il.scm")
+env.Install(binInstallDir, chicken_il)
+
+# Alias for installing.
+env.Alias("install", sconsInstallDir)
+env.Alias("install", binInstallDir)
View
3 TODO
@@ -1,6 +1,3 @@
-- Upercase scons-chicken on the begining of a sentence on all headers.
-- Not have to pass env to env.ChickenSetup as first parameter.
-- Make a scanner to look for (include blah) http://www.scons.org/doc/HTML/scons-user/c2244.html
- Make support for automatic generation of eggs.
- Add the files to be on the directories, like the free software directory and all that.
- Release scons-chicken 0.2.0 when there's nothing else above this line.
View
@@ -0,0 +1,32 @@
+;;;; Copyright (C) 2005 José Pablo Ezequiel "Pupeno" Fernández Silva
+;;;;
+;;;; This file is part of scons-chicken.
+;;;;
+;;;; scons-chicken is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+;;;; 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
+
+(use srfi-1 srfi-13 posix)
+(define rest cdr)
+
+(define (get-includes filename)
+ (call-with-input-file filename
+ (lambda (file-port)
+ (let process-form ((form (read file-port))) ; Read a form from form-port
+ (if (eof-object? form) ; If it is eof
+ '() ; return the empty list.
+ (if (eq? (first form) 'include) ; If it is 'include
+ (lset-union eq? ; make the union
+ (rest form) ; of the include and
+ (process-form (read file-port))) ; the rest of the includes on file.
+ (process-form (read file-port)))))))) ; Otherwise keep processing.
+
+;; Get the list of files passed as arguments to this program.
+(define file (first (rest (argv))))
+
+;; Get a list of the extensions needed by those files.
+(define includes (get-includes file))
+
+;; Print the list of includes with no parenthesis and separated by spaces.
+(display (string-join includes " "))
+(newline)
View
@@ -8,9 +8,10 @@
# 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
import SCons.Tool
+import SCons.Scanner
import os
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"
@@ -22,6 +23,24 @@ def generate(env):
c_file, cxx_file = SCons.Tool.createCFileBuilders(env)
c_file.add_action(".scm", SCons.Action.Action(env["CHICKENCOM"]))
+ def includedFiles(node, env, path):
+ for path in env['ENV']['PATH'].split(':'):
+ if os.path.exists(path + '/' + "chicken-il"):
+ includes = split(strip(os.popen("chicken-il " + 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. """

0 comments on commit 10bf002

Please sign in to comment.