Permalink
Browse files

Cabal: first go at a canibalization.

  • Loading branch information...
1 parent 1f6adac commit a586c8dc7030b1804a0b1b60f60b6488d959aa81 Pierre-Evariste Dagand committed Aug 1, 2010
Showing with 65 additions and 2 deletions.
  1. +3 −0 .boringfile
  2. +49 −0 Setup.hs
  3. +12 −0 epigram.cabal
  4. +1 −2 src/Makefile
View
@@ -1,3 +1,6 @@
+# cabal stuffs
+^dist
+
# ICFP paper
papers/icfp-2010-desc/propagation\.pdf
papers/icfp-2010-desc/type_theory\.pdf
View
@@ -0,0 +1,49 @@
+import System
+
+import Data.List
+
+import Distribution.Simple
+import Distribution.Simple.UserHooks
+import Distribution.PackageDescription
+import Distribution.Simple.LocalBuildInfo
+import Distribution.Simple.Setup
+
+
+-- All right. So, if we want to compile that damned thing, we have to
+-- call |src/Makefile|. We don't do that because we are sadic, we do
+-- it because we are masochist. Indeed, She needs a special treatment
+-- in order to compile. For now, only a Makefile can make it.
+
+-- Therefore, we overwrite the |buildHook| of |Cabal| by our own junk
+-- calling the Makefile and copying the binary at the excepted
+-- place. We extract the dependencies from the package description and
+-- pass it along.
+
+callMake :: PackageDescription -> LocalBuildInfo -> UserHooks -> BuildFlags -> IO ()
+callMake pkgDesc buildInfo userHooks buildFlags = do
+ let pkgs = "HC_PACKAGE=\"" ++
+ (intercalate " "
+ (map (\(Dependency (PackageName name) _) -> "-package " ++ name) $
+ buildDepends pkgDesc))
+ ++ "\""
+ exit <- system $ "cd src; make clean dep " ++ pkgs
+ if exit /= ExitSuccess
+ then exitFailure
+ else return ()
+ exit <- system $ "cd src; make Pig " ++ pkgs
+ if exit /= ExitSuccess
+ then exitFailure
+ else return ()
+ system $ "mkdir -p dist/build/Pig/"
+ system $ "cp -f src/Pig dist/build/Pig/Pig"
+ return ()
+
+-- An obvious question remain: We've stripped the package
+-- dependencies, good. But is there anything else we should care
+-- about? No clue.
+
+
+-- Let's compile, whohoooooo!
+
+main = defaultMainWithHooks $
+ simpleUserHooks { buildHook = callMake }
View
@@ -0,0 +1,12 @@
+Name: Epigram
+Version: 0.1
+Cabal-Version: >= 1.2
+license: MIT
+Author: The Epigram Posse
+Synopsis: A dependently-typed programming language
+Build-Type: Custom
+
+Executable Pig
+ Build-Depends: base, mtl, haskell98, pretty, filepath
+ Main-Is: Main.lhs
+ Hs-Source-Dirs: src
View
@@ -5,8 +5,7 @@
################
#### GHC
-HC = ghc
-HC_PACKAGE = -package mtl -package pretty
+HC = ghc -hide-all-packages
HC_OPTS_DEV = $(HC_PACKAGE)
HC_OPTS_TEST = $(HC_PACKAGE) -fhpc
HC_OPTS_RELEASE = $(HC_PACKAGE) -O2

0 comments on commit a586c8d

Please sign in to comment.