Browse Source

ivory backend: makefile can grab ivory sources

Pat Hickey 10 years ago
parent
commit
fe0550cf74
3 changed files with 40 additions and 24 deletions
  1. 0 15
      src/Gidl/Backend/Cabal.hs
  2. 16 0
      src/Gidl/Backend/Haskell.hs
  3. 24 9
      src/Gidl/Backend/Ivory.hs

+ 0 - 15
src/Gidl/Backend/Cabal.hs

@@ -86,18 +86,3 @@ filePathToPackage ('/':as) = '.' : filePathToPackage as
 filePathToPackage (a:as) = a : filePathToPackage as
 filePathToPackage [] = []
 
-makefile :: Artifact
-makefile = artifactText "Makefile" $
-  prettyLazyText 80 $ stack
-    [ text "default:"
-    , text "\tcabal build"
-    , empty
-    , text "create-sandbox:"
-    , text "\tcabal sandbox init"
-    , text "\tcabal install --enable-tests --dependencies-only"
-    , empty
-    , text "test:"
-    , text "\tcabal test"
-    , empty
-    ]
-

+ 16 - 0
src/Gidl/Backend/Haskell.hs

@@ -10,6 +10,7 @@ import Gidl.Backend.Haskell.Interface
 import Ivory.Artifact
 
 import Data.Char (isSpace)
+import Text.PrettyPrint.Mainland
 
 haskellBackend :: TypeEnv -> InterfaceEnv -> String -> String -> [Artifact]
 haskellBackend te@(TypeEnv te') ie@(InterfaceEnv ie') pkgname namespace_raw =
@@ -48,3 +49,18 @@ haskellBackend te@(TypeEnv te') ie@(InterfaceEnv ie') pkgname namespace_raw =
     s' -> let  (w, s'') = break isDot s' in w : dotwords s''
   isDot c = (c == '.') || isSpace c
 
+makefile :: Artifact
+makefile = artifactText "Makefile" $
+  prettyLazyText 80 $ stack
+    [ text "default:"
+    , text "\tcabal build"
+    , empty
+    , text "create-sandbox:"
+    , text "\tcabal sandbox init"
+    , text "\tcabal install --enable-tests --dependencies-only"
+    , empty
+    , text "test:"
+    , text "\tcabal test"
+    , empty
+    ]
+

+ 24 - 9
src/Gidl/Backend/Ivory.hs

@@ -4,18 +4,17 @@ import Gidl.Types
 import Gidl.Interface
 import Gidl.Backend.Cabal
 import Gidl.Backend.Ivory.Types
-import Gidl.Backend.Ivory.Test
 import Gidl.Backend.Ivory.Interface
 
 import Ivory.Artifact
 
 import Data.Char (isSpace)
+import Text.PrettyPrint.Mainland
 
 ivoryBackend :: TypeEnv -> InterfaceEnv -> String -> String -> [Artifact]
 ivoryBackend te@(TypeEnv te') ie@(InterfaceEnv ie') pkgname namespace_raw =
   [ cabalFileArtifact cf
   , makefile
-  , artifactPath "tests" serializeTestMod
   ] ++
   [ artifactPath "src" m | m <- sourceMods
   ]
@@ -30,14 +29,9 @@ ivoryBackend te@(TypeEnv te') ie@(InterfaceEnv ie') pkgname namespace_raw =
           , let ir = interfaceDescrToRepr iname ie te
           ]
   sourceMods = tmods ++ imods
-  cf = (defaultCabalFile pkgname cabalmods deps) { tests = [ serializeTest ] }
+  cf = (defaultCabalFile pkgname cabalmods deps)
   cabalmods = [ filePathToPackage (artifactFileName m) | m <- sourceMods ]
-  deps = [ "cereal", "QuickCheck" ]
-
-  serializeTest = defaultCabalTest "serialize-test" "SerializeTest.hs"
-                      (pkgname:deps)
-  serializeTestMod = serializeTestModule namespace
-                        [ interfaceDescrToRepr iname ie te | (iname, _i) <- ie']
+  deps = words "ivory ivory-stdlib ivory-serialize"
 
   namespace = dotwords namespace_raw
 
@@ -48,3 +42,24 @@ ivoryBackend te@(TypeEnv te') ie@(InterfaceEnv ie') pkgname namespace_raw =
     s' -> let  (w, s'') = break isDot s' in w : dotwords s''
   isDot c = (c == '.') || isSpace c
 
+makefile :: Artifact
+makefile = artifactText "Makefile" $
+  prettyLazyText 80 $ stack
+    [ text "IVORY_REPO ?= ../../../ivory"
+    , empty
+    , text "default:"
+    , text "\tcabal build"
+    , empty
+    , text "create-sandbox:"
+    , text "\tcabal sandbox init"
+    , text "\tcabal sandbox add-source $(IVORY_REPO)/ivory"
+    , text "\tcabal sandbox add-source $(IVORY_REPO)/ivory-artifact"
+    , text "\tcabal sandbox add-source $(IVORY_REPO)/ivory-serialize"
+    , text "\tcabal sandbox add-source $(IVORY_REPO)/ivory-stdlib"
+    , text "\tcabal install --enable-tests --dependencies-only"
+    , empty
+    , text "test:"
+    , text "\tcabal test"
+    , empty
+    ]
+