1. Russel Winder
  2. SCons_Haskell

Commits

Russel Winder  committed 74b993c

Experiment with the GHC make capability.

  • Participants
  • Parent commits 8238336
  • Branches default

Comments (0)

Files changed (1)

File __init__.py

View file
  • Ignore whitespace
 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #  This module is derived from the code to be found at http://www.scons.org/wiki/GhcBuilder.  That code has
-#  no attribution and no licence statement.
+#  no attribution and no licence statement, so the standard SCons licence has been applied.
 
 from os.path import abspath, join
 from SCons.Builder import Builder
                 env.Clean(target, stub_name + ".h")
         return (target + stubs, source)
 
+def ghc_make_emitter(target, source, env):
+        src_name = str(source[0])
+        hi_names = [ src_name.replace(source[0].suffix, extension) for extension in [ '.o', '.hi' ] ]
+        env.SideEffect(hi_names, target)
+        env.Clean(target, hi_names)
+        return (target, source)
+
 def ghc_path_function(env, dir, targets, sources):
         if dir.path != ".":
                 env.AppendUnique(HSSEARCHPATH = [dir.path])
         from os.path import dirname, exists
         imports = impdecl_regexp.findall(node.get_contents())
         modules = map(lambda (qualified, module) : module, imports)
-
         interfaces = []
         for module in modules:
                 module = module.replace(".", "/")
                 src_builder = [ ghc_compiler, ghc_c_compiler ]
                 )
 
-        env.Append( BUILDERS = { "HaskellProgram" : ghc_linker, "HaskellObject" : ghc_compiler } )
+        ghc_make = Builder(
+                action = "$HSC --make $HSCFLAGS $_HSSEARCHPATH_OPTS -o $TARGET $SOURCE",
+                src_suffix = [ ".hs", ".lhs" ],
+                suffix = "",
+                single_source = True,
+                emitter = ghc_make_emitter,
+                source_scanner = ghc_scanner
+                )
+
+        env.Append( BUILDERS = {
+                "HaskellProgram" : ghc_linker,
+                "HaskellObject" : ghc_compiler ,
+                "HaskellMake" : ghc_make
+                } )