on master help sign in
Merge pull request #498 from gabemc/build-changes

Refactored the build inside Setup.hs and the various Makefiles.

commitb31f3092a70286321757d35264198f912ce0da22 authorEdwin Brady <edwin.brady@gmail.com> dateFri 27 Sep 2013, 07:20 (13 years ago) parentf70befb14ef6f1
7 files changed+299−229
Setup.hs+117−137 effects/Makefile+5−4 idris.cabal+166−79 javascript/Makefile+4−3 lib/Makefile+5−4 llvm/Makefile+1−1 rts/Makefile+1−1
Setup.hs+117−137
@@ -20,158 +20,138 @@ import qualified Data.Text.IO as TIO
2020
2121-- After Idris is built, we need to check and install the prelude and other libs
2222
23−make verbosity = P.runProgramInvocation verbosity . P.simpleProgramInvocation "make"
23+-- -----------------------------------------------------------------------------
24+-- Idris Command Path
2425
25−#ifdef mingw32_HOST_OS
2626-- make on mingw32 exepects unix style separators
27+#ifdef mingw32_HOST_OS
2728(<//>) = (Px.</>)
28−idrisCmd local = Px.joinPath $ splitDirectories $
29− ".." <//> buildDir local <//> "idris" <//> "idris"
30−rtsDir local = Px.joinPath $ splitDirectories $
31− ".." <//> buildDir local <//> "rts" <//> "libidris_rts"
29+idrisCmd local = Px.joinPath $ splitDirectories $ ".." <//> buildDir local <//> "idris" <//> "idris"
3230#else
3331idrisCmd local = ".." </> buildDir local </> "idris" </> "idris"
34−rtsDir local = ".." </> buildDir local </> "rts" </> "libidris_rts"
3532#endif
3633
37−cleanStdLib verbosity
38− = do make verbosity [ "-C", "lib", "clean", "IDRIS=idris" ]
39− make verbosity [ "-C", "effects", "clean", "IDRIS=idris" ]
40− make verbosity [ "-C", "javascript", "clean", "IDRIS=idris" ]
41−
42−cleanJavaPom verbosity
43− = do execPomExists <- doesFileExist ("java" </> "executable_pom.xml")
44− when execPomExists $ removeFile ("java" </> "executable_pom.xml")
45−
46−cleanLLVMLib verbosity = make verbosity ["-C", "llvm", "clean"]
47−
48−installStdLib pkg local withoutEffects verbosity copy
49− = do let dirs = L.absoluteInstallDirs pkg local copy
50− let idir = datadir dirs
51− let icmd = idrisCmd local
52− putStrLn $ "Installing libraries in " ++ idir
53− make verbosity
54− [ "-C", "lib", "install"
55− , "TARGET=" ++ idir
56− , "IDRIS=" ++ icmd
57− ]
58− unless withoutEffects $
59− make verbosity
60− [ "-C", "effects", "install"
61− , "TARGET=" ++ idir
62− , "IDRIS=" ++ icmd
63− ]
64− make verbosity
65− [ "-C", "javascript", "install"
66− , "TARGET=" ++ idir
67− , "IDRIS=" ++ icmd
68− ]
69− let idirRts = idir </> "rts"
70− putStrLn $ "Installing run time system in " ++ idirRts
71− make verbosity
72− [ "-C", "rts", "install"
73− , "TARGET=" ++ idirRts
74− , "IDRIS=" ++ icmd
75− ]
76−
77−installLLVMLib verbosity pkg local copy =
78− let idir = datadir $ L.absoluteInstallDirs pkg local copy in
79− make verbosity ["-C", "llvm", "install", "TARGET=" ++ idir </> "llvm"]
80−
81−buildLLVMLib verbosity = make verbosity ["-C", "llvm", "all"]
82−
83−installJavaPom pkg local verbosity copy version = do
84− putStrLn $ "Installing java pom template"
85− let dir = datadir $ L.absoluteInstallDirs pkg local copy
86− copyFile ("java" </> "executable_pom.xml") (dir </> "executable_pom.xml")
87−
88−-- This is a hack. I don't know how to tell cabal that a data file needs
89−-- installing but shouldn't be in the distribution. And it won't make the
90−-- distribution if it's not there, so instead I just delete
91−-- the file after configure.
92−
93−removeLibIdris local verbosity
94− = do let icmd = idrisCmd local
95− make verbosity
96− [ "-C", "rts", "clean"
97− , "IDRIS=" ++ icmd
98− ]
99−
100−checkStdLib local withoutEffects verbosity
101− = do let icmd = idrisCmd local
102− putStrLn $ "Building libraries..."
103− make verbosity
104− [ "-C", "lib", "check"
105− , "IDRIS=" ++ icmd
106− ]
107− unless withoutEffects $
108− make verbosity
109− [ "-C", "effects", "check"
110− , "IDRIS=" ++ icmd
111− ]
112− make verbosity
113− [ "-C", "javascript", "check"
114− , "IDRIS=" ++ icmd
115− ]
116− make verbosity
117− [ "-C", "rts", "check"
118− , "IDRIS=" ++ icmd
119− ]
120−
121−llvmFlag flags =
34+-- -----------------------------------------------------------------------------
35+-- Make Commands
36+
37+make verbosity =
38+ P.runProgramInvocation verbosity . P.simpleProgramInvocation "make"
39+
40+-- -----------------------------------------------------------------------------
41+-- Flags
42+
43+usesLLVM :: S.ConfigFlags -> Bool
44+usesLLVM flags =
12245 case lookup (FlagName "llvm") (S.configConfigurationsFlags flags) of
12346 Just True -> True
12447 Just False -> False
12548 Nothing -> True
12649
127−noEffectsFlag flags =
128− case lookup (FlagName "noeffects") (S.configConfigurationsFlags flags) of
50+usesEffects :: S.ConfigFlags -> Bool
51+usesEffects flags =
52+ case lookup (FlagName "effects") (S.configConfigurationsFlags flags) of
12953 Just True -> True
13054 Just False -> False
131− Nothing -> False
55+ Nothing -> True
56+
57+-- -----------------------------------------------------------------------------
58+-- Clean
59+
60+idrisClean _ flags _ _ = do
61+ cleanStdLib
62+ cleanLLVM
63+ where
64+ verbosity = S.fromFlag $ S.cleanVerbosity flags
65+
66+ cleanStdLib = do
67+ makeClean "lib"
68+ makeClean "effects"
69+ makeClean "javascript"
70+
71+ cleanLLVM = makeClean "llvm"
72+
73+ makeClean dir = make verbosity [ "-C", dir, "clean", "IDRIS=idris" ]
74+
75+
76+-- -----------------------------------------------------------------------------
77+-- Configure
78+
79+idrisConfigure _ flags _ local = do
80+ configureRTS
81+ where
82+ verbosity = S.fromFlag $ S.configVerbosity flags
83+ version = pkgVersion . package $ localPkgDescr local
84+
85+ -- This is a hack. I don't know how to tell cabal that a data file needs
86+ -- installing but shouldn't be in the distribution. And it won't make the
87+ -- distribution if it's not there, so instead I just delete
88+ -- the file after configure.
89+ configureRTS = make verbosity ["-C", "rts", "clean"]
90+
91+-- -----------------------------------------------------------------------------
92+-- Build
93+
94+idrisBuild _ flags _ local = do
95+ buildStdLib
96+ buildRTS
97+ when (usesLLVM $ configFlags local) buildLLVM
98+ where
99+ verbosity = S.fromFlag $ S.buildVerbosity flags
100+
101+ buildStdLib = do
102+ putStrLn "Building libraries..."
103+ makeBuild "lib"
104+ when (usesEffects $ configFlags local) $ makeBuild "effects"
105+ makeBuild "javascript"
106+ where
107+ makeBuild dir = make verbosity [ "-C", dir, "build" , "IDRIS=" ++ idrisCmd local]
108+
109+ buildRTS = make verbosity ["-C", "rts", "build"]
110+
111+ buildLLVM = make verbosity ["-C", "llvm", "build"]
112+
113+-- -----------------------------------------------------------------------------
114+-- Copy/Install
115+
116+idrisInstall verbosity copy pkg local = do
117+ installStdLib
118+ installRTS
119+ when (usesLLVM $ configFlags local) installLLVM
120+ where
121+ target = datadir $ L.absoluteInstallDirs pkg local copy
122+
123+ installStdLib = do
124+ putStrLn $ "Installing libraries in " ++ target
125+ makeInstall "lib" target
126+ when (usesEffects $ configFlags local) $ makeInstall "effects" target
127+ makeInstall "javascript" target
128+
129+ installRTS = do
130+ let target' = target </> "rts"
131+ putStrLn $ "Installing run time system in " ++ target'
132+ makeInstall "rts" target'
133+
134+ installLLVM = do
135+ let target' = target </> "llvm"
136+ putStrLn $ "Installing LLVM library in " ++ target
137+ makeInstall "llvm" target
138+
139+ makeInstall src target =
140+ make verbosity [ "-C", src, "install" , "TARGET=" ++ target, "IDRIS=" ++ idrisCmd local]
132141
133−preparePoms version
134− = do execPomTemplate <- TIO.readFile ("java" </> "executable_pom_template.xml")
135− TIO.writeFile ("java" </> "executable_pom.xml") (insertVersion execPomTemplate)
136− where
137− insertVersion template =
138− T.replace (T.pack "$RTS-VERSION$") (T.pack $ display version) template
142+-- -----------------------------------------------------------------------------
143+-- Main
139144
140145-- Install libraries during both copy and install
141146-- See http://hackage.haskell.org/trac/hackage/ticket/718
142−main = do
143− defaultMainWithHooks $ simpleUserHooks
144− { postCopy = \ _ flags pkg lbi -> do
145− let verb = S.fromFlag $ S.copyVerbosity flags
146− let withoutEffects = noEffectsFlag $ configFlags lbi
147− installStdLib pkg lbi withoutEffects verb
148− (S.fromFlag $ S.copyDest flags)
149− installJavaPom pkg lbi verb
150− (S.fromFlag $ S.copyDest flags)
151− (pkgVersion . package $ localPkgDescr lbi)
152− when (llvmFlag $ configFlags lbi)
153− (installLLVMLib verb pkg lbi (S.fromFlag $ S.copyDest flags))
154− , postInst = \ _ flags pkg lbi -> do
155− let verb = (S.fromFlag $ S.installVerbosity flags)
156− let withoutEffects = noEffectsFlag $ configFlags lbi
157− installStdLib pkg lbi withoutEffects verb
158− NoCopyDest
159− installJavaPom pkg lbi verb
160− NoCopyDest
161− (pkgVersion . package $ localPkgDescr lbi)
162− when (llvmFlag $ configFlags lbi)
163− (installLLVMLib verb pkg lbi NoCopyDest)
164− , postConf = \ _ flags _ lbi -> do
165− removeLibIdris lbi (S.fromFlag $ S.configVerbosity flags)
166− preparePoms . pkgVersion . package $ localPkgDescr lbi
167− , postClean = \ _ flags _ _ -> do
168− let verb = S.fromFlag $ S.cleanVerbosity flags
169− cleanStdLib verb
170− cleanLLVMLib verb
171− cleanJavaPom verb
172− , postBuild = \ _ flags _ lbi -> do
173− let verb = S.fromFlag $ S.buildVerbosity flags
174− when (llvmFlag $ configFlags lbi) (buildLLVMLib verb)
175− let withoutEffects = noEffectsFlag $ configFlags lbi
176− checkStdLib lbi withoutEffects verb
177− }
147+main = defaultMainWithHooks $ simpleUserHooks
148+ { postClean = idrisClean
149+ , postConf = idrisConfigure
150+ , postBuild = idrisBuild
151+ , postCopy = \_ flags pkg local ->
152+ idrisInstall (S.fromFlag $ S.copyVerbosity flags)
153+ (S.fromFlag $ S.copyDest flags) pkg local
154+ , postInst = \_ flags pkg local ->
155+ idrisInstall (S.fromFlag $ S.installVerbosity flags)
156+ NoCopyDest pkg local
157+ }
effects/Makefile+5−4
@@ -1,13 +1,14 @@
1+IDRIS := idris
12
2−check: .PHONY
3+build: .PHONY
34 $(IDRIS) --build effects.ipkg
45
5−recheck: clean check
6+clean: .PHONY
7+ $(IDRIS) --clean effects.ipkg
68
79install:
810 $(IDRIS) --install effects.ipkg
911
10−clean: .PHONY
11− $(IDRIS) --clean effects.ipkg
12+rebuild: clean build
1213
1314.PHONY:
idris.cabal+166−79
@@ -14,7 +14,8 @@ Description: Idris is a general purpose language with full dependent types.
1414 Dependent types allow types to be predicated on values,
1515 meaning that some aspects of a program's behaviour can be
1616 specified precisely in the type. The language is closely
17− related to Epigram and Agda. There is a tutorial at <http://www.idris-lang.org/documentation>.
17+ related to Epigram and Agda. There is a tutorial at
18+ <http://www.idris-lang.org/documentation>.
1819 Features include:
1920 .
2021 * Full dependent types with dependent pattern matching
@@ -43,38 +44,60 @@ Description: Idris is a general purpose language with full dependent types.
4344
4445Cabal-Version: >= 1.6
4546
46−
4747Build-type: Custom
4848
49−
50−Data-files: rts/idris_rts.h rts/idris_gc.h rts/idris_stdfgn.h
51− rts/idris_main.c rts/idris_gmp.h
52− rts/libtest.c
49+Data-files: js/Runtime-browser.js
5350 js/Runtime-common.js
5451 js/Runtime-node.js
55− js/Runtime-browser.js
56−Extra-source-files: lib/Makefile lib/*.idr lib/Prelude/*.idr
57− lib/Network/*.idr lib/Control/*.idr
58− lib/Control/Monad/*.idr lib/Language/*.idr
59− lib/Language/Reflection/*.idr
60− lib/System/Concurrency/*.idr
61− lib/Data/*.idr lib/Debug/*.idr
52+ rts/idris_gc.h
53+ rts/idris_gmp.h
54+ rts/idris_main.c
55+ rts/idris_rts.h
56+ rts/idris_stdfgn.h
57+ rts/libtest.c
58+
59+Extra-source-files:
60+ Makefile
61+ config.mk
62+
63+ rts/*.c
64+ rts/*.h
65+ rts/Makefile
66+
67+ lib/base.ipkg
68+ lib/*.idr
69+ lib/Control/*.idr
70+ lib/Control/Monad/*.idr
71+ lib/Data/*.idr
6272 lib/Data/Vect/*.idr
73+ lib/Debug/*.idr
6374 lib/Decidable/*.idr
64− tutorial/examples/*.idr lib/base.ipkg
65− effects/Makefile effects/*.idr effects/Effect/*.idr
75+ lib/Language/*.idr
76+ lib/Language/Reflection/*.idr
77+ lib/Makefile
78+ lib/Network/*.idr
79+ lib/Prelude/*.idr
80+ lib/System/Concurrency/*.idr
81+
82+ effects/Makefile
6683 effects/effects.ipkg
67− javascript/Makefile
68− javascript/JavaScript/*.idr
84+ effects/Effect/*.idr
85+ effects/*.idr
86+
87+ java/*.xml
88+
6989 javascript/*.idr
90+ javascript/JavaScript/*.idr
91+ javascript/Makefile
7092 javascript/javascript.ipkg
71− config.mk
72− rts/*.c rts/*.h rts/Makefile
73− llvm/*.c llvm/Makefile
93+
7494 js/*.js
75− java/*.xml
7695
77− Makefile
96+ llvm/*.c
97+ llvm/Makefile
98+
99+ tutorial/examples/*.idr
100+
78101 test/Makefile
79102 test/runtest.pl
80103 test/reg001/run
@@ -234,76 +257,140 @@ Extra-source-files: lib/Makefile lib/*.idr lib/Prelude/*.idr
234257 test/test030/*.idr
235258 test/test030/expected
236259
237−
238260source-repository head
239261 type: git
240262 location: git://github.com/edwinb/Idris-dev.git
241263
242−Flag NoEffects
243− Description: Do not build the effects package
244− Default: False
264+Flag Effects
265+ Description: Build the effects package
266+ Default: True
245267
246268Flag LLVM
247269 Description: Build the LLVM backend
248270 Default: True
249271 manual: True
250272
251−Executable idris
252− Main-is: Main.hs
253− hs-source-dirs: src
254− Other-modules: Core.TT, Core.Evaluate, Core.Execute, Core.Typecheck,
255− Core.ProofShell, Core.ProofState, Core.CoreParser,
256− Core.ShellParser, Core.Unify, Core.Elaborate,
257− Core.CaseTree, Core.Constraints,
273+Executable idris
274+ Main-is: Main.hs
275+ hs-source-dirs: src
276+ Other-modules:
277+ Core.CaseTree
278+ , Core.Constraints
279+ , Core.CoreParser
280+ , Core.Elaborate
281+ , Core.Evaluate
282+ , Core.Execute
283+ , Core.ProofShell
284+ , Core.ProofState
285+ , Core.ShellParser
286+ , Core.TT
287+ , Core.Typecheck
288+ , Core.Unify
289+
290+ , Idris.AbsSyntax
291+ , Idris.AbsSyntaxTree
292+ , Idris.Chaser
293+ , Idris.Colours
294+ , Idris.Completion
295+ , Idris.Coverage
296+ , Idris.DSL
297+ , Idris.DataOpts
298+ , Idris.Delaborate
299+ , Idris.Docs
300+ , Idris.ElabDecls
301+ , Idris.ElabTerm
302+ , Idris.Error
303+ , Idris.Help
304+ , Idris.IBC
305+ , Idris.IdeSlave
306+ , Idris.Imports
307+ , Idris.Inliner
308+ , Idris.Parser
309+ , Idris.PartialEval
310+ , Idris.Primitives
311+ , Idris.Prover
312+ , Idris.Providers
313+ , Idris.REPL
314+ , Idris.REPLParser
315+ , Idris.Transforms
316+ , Idris.Unlit
317+ , Idris.UnusedArgs
318+
319+ , IRTS.BCImp
320+ , IRTS.Bytecode
321+ , IRTS.CodegenC
322+ , IRTS.CodegenCommon
323+ , IRTS.CodegenJava
324+ , IRTS.CodegenJavaScript
325+ , IRTS.Compiler
326+ , IRTS.Defunctionalise
327+ , IRTS.DumpBC
328+ , IRTS.Inliner
329+ , IRTS.Java.ASTBuilding
330+ , IRTS.Java.JTypes
331+ , IRTS.Java.Mangling
332+ , IRTS.LParser
333+ , IRTS.Lang
334+ , IRTS.Simplified
335+
336+ , Util.Pretty
337+ , Util.System
338+ , Util.DynamicLinker
258339
259− Idris.AbsSyntax, Idris.AbsSyntaxTree, Idris.Colours,
260− Idris.Parser, Idris.Help, Idris.IdeSlave, Idris.REPL,
261− Idris.REPLParser, Idris.ElabDecls, Idris.Error,
262− Idris.Delaborate, Idris.Primitives, Idris.Imports,
263− Idris.Prover, Idris.ElabTerm,
264− Idris.Coverage, Idris.IBC, Idris.Unlit,
265− Idris.DataOpts, Idris.Transforms, Idris.DSL,
266− Idris.UnusedArgs, Idris.Docs, Idris.Completion,
267− Idris.PartialEval, Idris.Providers, Idris.Chaser,
268− Idris.Inliner,
340+ , Pkg.Package
341+ , Pkg.PParser
269342
270− Util.Pretty, Util.System, Util.DynamicLinker,
271− Pkg.Package, Pkg.PParser,
343+ -- Auto Generated
344+ Paths_idris
272345
273− IRTS.Lang, IRTS.LParser, IRTS.Bytecode, IRTS.Simplified,
274− IRTS.CodegenC, IRTS.Defunctionalise, IRTS.Inliner,
275− IRTS.Compiler, IRTS.CodegenJava, IRTS.Java.ASTBuilding,
276− IRTS.Java.JTypes, IRTS.Java.Mangling, IRTS.BCImp,
277− IRTS.CodegenJavaScript,
278− IRTS.CodegenCommon, IRTS.DumpBC
346+ Build-depends: base >=4 && <5
347+ , Cabal
348+ , ansi-terminal
349+ , binary
350+ , bytestring
351+ , containers
352+ , directory
353+ , directory >= 1.2
354+ , filepath
355+ , haskeline >= 0.7
356+ , language-java >= 0.2.2
357+ , libffi
358+ , mtl
359+ , parsec >= 3
360+ , parsers >= 0.9
361+ , pretty
362+ , process
363+ , split
364+ , text
365+ , time >= 1.4
366+ , transformers
367+ , trifecta >= 1.1
368+ , unordered-containers
369+ , utf8-string
370+ , vector
371+ , vector-binary-instances
279372
280− Paths_idris
373+ Extensions: MultiParamTypeClasses
374+ , FunctionalDependencies
375+ , FlexibleInstances
376+ , TemplateHaskell
281377
282− Build-depends: base>=4 && <5, parsec>=3, mtl, Cabal,
283− haskeline>=0.7, split, directory>=1.2,
284− time>=1.4,
285− containers, process, transformers, filepath,
286− directory, binary, bytestring, text, pretty,
287− language-java>=0.2.2, libffi,
288− vector, vector-binary-instances, ansi-terminal,
289− utf8-string, unordered-containers, parsers>=0.9, trifecta>=1.1
378+ ghc-prof-options: -auto-all -caf-all
379+ ghc-options: -rtsopts
290380
291− Extensions: MultiParamTypeClasses, FunctionalDependencies,
292− FlexibleInstances, TemplateHaskell
293− ghc-prof-options: -auto-all -caf-all
294− ghc-options: -rtsopts
295− if os(linux)
296− cpp-options: -DLINUX
297− build-depends: unix
298− if os(darwin)
299− cpp-options: -DMACOSX
300− build-depends: unix
301− if os(windows)
302− cpp-options: -DWINDOWS
303− build-depends: Win32
304− if flag(LLVM)
305− other-modules: IRTS.CodegenLLVM
306− cpp-options: -DIDRIS_LLVM
307− build-depends: llvm-general==3.3.8.*, llvm-general-pure==3.3.8.*
308− else
309− other-modules: Util.LLVMStubs
381+ if os(linux)
382+ cpp-options: -DLINUX
383+ build-depends: unix
384+ if os(darwin)
385+ cpp-options: -DMACOSX
386+ build-depends: unix
387+ if os(windows)
388+ cpp-options: -DWINDOWS
389+ build-depends: Win32
390+ if flag(LLVM)
391+ other-modules: IRTS.CodegenLLVM
392+ cpp-options: -DIDRIS_LLVM
393+ build-depends: llvm-general == 3.3.8.*
394+ , llvm-general-pure == 3.3.8.*
395+ else
396+ other-modules: Util.LLVMStubs
javascript/Makefile+4−3
@@ -1,13 +1,14 @@
1+IDRIS := idris
12
2−check: .PHONY
3+build: .PHONY
34 $(IDRIS) --build javascript.ipkg
45
5−recheck: clean check
6−
76install:
87 $(IDRIS) --install javascript.ipkg
98
109clean: .PHONY
1110 $(IDRIS) --clean javascript.ipkg
1211
12+rebuild: clean build
13+
1314.PHONY:
lib/Makefile+5−4
@@ -1,16 +1,17 @@
1+IDRIS := idris
12
2−check: .PHONY
3+build: .PHONY
34 $(IDRIS) --build base.ipkg
45
5−recheck: clean check
6−
76install:
87 $(IDRIS) --install base.ipkg
98
109clean: .PHONY
1110 $(IDRIS) --clean base.ipkg
1211
12+rebuild: clean build
13+
1314linecount: .PHONY
14− wc -l *.idr Network/*.idr Language/*.idr Prelude/*.idr Data/*.idr Control/Monad/*.idr Control/*.idr
15+ find . -name '*.idr' | xargs wc -l
1516
1617.PHONY:
llvm/Makefile+1−1
@@ -5,7 +5,7 @@ SOURCES=defs.c
55OBJECTS=$(SOURCES:.c=.o)
66LIB=libidris_rts.a
77
8−all: $(SOURCES) $(LIB)
8+build: $(SOURCES) $(LIB)
99
1010$(LIB): $(OBJECTS)
1111 ar r $@ $(OBJECTS)
rts/Makefile+1−1
@@ -9,7 +9,7 @@ endif
99
1010LIBTARGET = libidris_rts.a
1111
12−check : $(LIBTARGET) $(DYLIBTARGET)
12+build: $(LIBTARGET) $(DYLIBTARGET)
1313
1414$(LIBTARGET) : $(OBJS)
1515 ar r $(LIBTARGET) $(OBJS)