Karya, built on 2018-03-16T03:22:32 (patch df7306861219887e676081746f4a4edfe05eb0b5)

Safe HaskellNone




Shakefile for seq and associated binaries.




type Package = String Source #

Package, with or without version e.g. containers-

allPackages :: [Package] Source #

This is the big list of enabled packages.

basicPackages :: [(Package, String)] Source #

This is used to create karya.cabal and supply -package arguments to ghc.

synthPackages :: [(Package, String)] Source #

Packages needed only for targets in Synth.

reallyAllPackages :: [(Package, String)] Source #

All packages, not just enabled ones.

extraPackagesFor :: IO.FilePath -> [Package] Source #

This is a hack so I can add packages that aren't in enabledPackages. This is for packages with tons of dependencies that I usually don't need.

extraPackages :: [Package] Source #

Ack. Haddock needs all packages, but it's not convenient to call extraPackagesFor with everything.

config implementation

data Config Source #





oDir :: Config -> IO.FilePath Source #

Root of .o and .hi hierarchy.

buildDocDir :: IO.FilePath Source #

Root for generated documentation.

docDir :: IO.FilePath Source #

Root for documentation source.


data Flags Source #




  • define :: [Flag]
    • D flags. This is used by both g++ and ghc.
  • midiLibs :: [Flag]

    Linker flags to link in whatever MIDI driver we are using today. There should be corresponding flags in define to enable said driver.

  • cInclude :: [Flag]

    There's one global list of include dirs, for both haskell and C++. Technically they don't all need the same dirs, but it doesn't hurt to have unneeded ones.

  • cLibDirs :: [Flag]

    Analogous to cInclude, this has -L flags, used when linking all C++ binaries. TODO also use when linking hs?

  • globalCcFlags :: [Flag]

    Flags for g++. This is the complete list and includes the defines and cIncludes. This is global because all CcBinaries get these flags.

  • fltkCc :: [Flag]

    Additional flags needed when compiling fltk.

  • fltkLd :: [Flag]

    Additional flags needed when linking fltk.

  • hcFlags :: [Flag]

    GHC-specific flags. Unlike globalCcFlags, this *isn't* the complete list.

  • hLinkFlags :: [Flag]

    Flags needed when linking haskell. Doesn't include the -packages.

  • sandboxFlags :: [Flag]

    Package DB flags to use a cabal sandbox, if there is one.




data HsBinary Source #

Describe a single haskell binary. The dependencies are inferred by chasing imports.





defaultRtsFlags :: [Flag] Source #

RTS flags for generated binaries without an explicit target in hsBinaries, like tests and profiles.

data GuiType Source #

GUI apps require some postprocessing.



plain app


run make_bundle on mac


run make_bundle, and add an icon from build/name.icns


runProfileTest :: IO.FilePath Source #

This is run as a test, but must be compiled with optimization like a profile.

cppFlags :: Config -> IO.FilePath -> Maybe.Maybe [String] Source #

Hardcoded list of files that should be processed with CPP when chasing deps.

cppInImports :: [IO.FilePath] Source #

Hardcoded list of modules that use CPP to determine their imports. This means I need to CPP the file first before tracking the dependencies.

It would be more robust to always run CPP if the file includes 'LANGUAGE .*CPP' but there aren't many modules with CPP in their import lists so it should be faster to hardcode them.

TODO this is error-prone, maybe I should have a hack in HsDeps to look for #include in the import block.

generatedSrc :: HsDeps.Generated Source #

Generated src files.

nameToMain :: Map IO.FilePath IO.FilePath Source #

Module that define main and should get linked to their own binaries, and the names of their eventual binaries.

hsToCc :: Map IO.FilePath [IO.FilePath] Source #

Haskell files that use the FFI likely have dependencies on C++ source. I could figure this out automatically by looking for foreign import ... and searching for a neighboring .cc file with those symbols, but it's simpler to give the dependency explicitly. TODO a somewhat more modular way would be a magic comment that declares a dependency on a C file.


data CcBinary Source #

Describe a C++ binary target. Unlike HsBinary, this has all the binary's obj file dependencies explicitly listed. This is because C source files import separate include files, so I can't infer all the dependencies just by chasing imports, unless I want to assume that each name.h has a corresponding name.cc. In any case, I have relatively little C++ and it changes rarely, so I don't mind a hardcoded list. An explicit list of deps means I can also give compile flags per source file, instead of having a global list of flags that applies to all sources.




fltkDeps :: Config -> [IO.FilePath] Source #

Since fltk.a is a library, not a binary, I can't just chase includes to know all the source files. I could read fltk/*.cc at runtime, but the fltk directory changes so rarely it seems not a great burden to just hardcode them all here.

ccORule has a special hack to give these fltkCc flags, since I don't have a separate CcLibrary target.


data Mode Source #




Enum Mode # 


succ :: Mode -> Mode #

pred :: Mode -> Mode #

toEnum :: Int -> Mode #

fromEnum :: Mode -> Int #

enumFrom :: Mode -> [Mode] #

enumFromThen :: Mode -> Mode -> [Mode] #

enumFromTo :: Mode -> Mode -> [Mode] #

enumFromThenTo :: Mode -> Mode -> Mode -> [Mode] #

Eq Mode # 


(==) :: Mode -> Mode -> Bool #

(/=) :: Mode -> Mode -> Bool #

Show Mode # 


showsPrec :: Int -> Mode -> ShowS #

show :: Mode -> String #

showList :: [Mode] -> ShowS #

platformDefines :: [Flag] Source #

When using gcc I get these defines automatically, but I need to add them myself for ghci. But then c2hs complains about duplicate definitions, so filter them back out for that. Nothing you can't fix by layering on another hack!

parseGhcVersion :: IO.FilePath -> String Source #

Parse the GHC version out of the ghc --print-libdir path. The format is "71002" for "7.10.2". This way it can be compared as a number by CPP. It doesn't have a leading 0 because then CPP thinks its octal. It'll break at ghc-10, but I can fix it when it happens.

inferConfig :: (Mode -> Config) -> InferConfig Source #

Figure out the Config for a given target by looking at its directory.



newtype Question a Source #


Question () 


Eq (Question a) # 


(==) :: Question a -> Question a -> Bool #

(/=) :: Question a -> Question a -> Bool #

Show (Question a) # 


showsPrec :: Int -> Question a -> ShowS #

show :: Question a -> String #

showList :: [Question a] -> ShowS #

DeepSeq.NFData (Question a) # 


rnf :: Question a -> () #

Hashable (Question a) # 


hashWithSalt :: Int -> Question a -> Int #

hash :: Question a -> Int #

Binary (Question a) # 


put :: Question a -> Put #

get :: Get (Question a) #

putList :: [Question a] -> Put #

misc rules

hsconfigH :: IO.FilePath Source #

Dynamically generated header.

hsconfigHRule :: IO.FilePath -> Shake.Action () Source #

Write a header to configure the haskell compilation.

It's in a separate file so that the relevant haskell files can include it. This way only those files will recompile when the config changes.

matchObj :: Shake.FilePattern -> IO.FilePath -> Bool Source #

Match a file in buildmodeobj/ or buildmode.


makeAllDocumentation :: Config -> Shake.Action () Source #

Make all documentation.

extractableDocs :: [IO.FilePath] Source #

Docs produced by extract_doc.

getHaddockInterfaces :: [Package] -> IO.IO [String] Source #

Get paths to haddock interface files for all the packages.

wantsHaddock :: MidiConfig -> IO.FilePath -> Bool Source #

Should this module have haddock documentation generated?



buildHs :: Config -> [Flag] -> [IO.FilePath] -> [Package] -> IO.FilePath -> IO.FilePath -> Shake.Action () Source #

Build a haskell binary.

tests and profiles

testRules :: Config -> Shake.Rules () Source #

Generate RunTests.hs and compile it.

criterionRules :: Config -> Shake.Rules () Source #

Build build(mode)RunCriterion-A.B.C from ABC_criterion.hs

runCriterionToSrc :: Config -> IO.FilePath -> IO.FilePath Source #

build(mode)RunCriterion-Derive.Derive -> Derive/Derive_criterion.hs

srcToRunCriterion :: Config -> IO.FilePath -> IO.FilePath Source #

DeriveDerive_criterion.hs -> build(mode)/RunCriterion-Derive.Derive

getCriterionTargets :: Config -> Shake.Action [IO.FilePath] Source #

Find targets for all criterion benchmarks.

binaryWithPrefix :: IO.FilePath -> IO.FilePath -> Bool Source #

Match any filename that starts with the given prefix but doesn't have an extension, i.e. binaries.

generated haskell


generatedFaustAll :: IO.FilePath Source #

This is in build instead of build/faust because that makes it simpler to just say buildfaust*.cc is generated by faust.

srcToDsp :: IO.FilePath -> IO.FilePath Source #

buildfaustx.cc -> SynthFaustdsp/x.dsp

dspToSrc :: IO.FilePath -> IO.FilePath Source #

SynthFaustdspx.dsp -> buildfaust/x.cc


htmlToDoc :: IO.FilePath -> IO.FilePath Source #

builddocxyz.md.html -> doc/xyz.md

docToHtml :: IO.FilePath -> IO.FilePath Source #

docxyz.md -> builddoc/xyz.md.html


matchHsObjHi :: IO.FilePath -> Maybe.Maybe [IO.FilePath] Source #

Generate both .hs.o and .hi from a .hs file.

writeGhciFlags :: (Mode -> Config) -> IO.IO () Source #

ghci has to be called with the same flags that the .o files were compiled with or it won't load them.

makeDataLinks :: IO.IO () Source #

Make links to large binary files I don't want to put into source control.

ghcFlags :: Config -> [Flag] Source #

Get the file-independent flags for a haskell compile.

ghcLanguageFlags :: [String] Source #

Language extensions which are globally enabled.


findFlags :: Config -> IO.FilePath -> Maybe.Maybe [Flag] Source #

Find which CcBinary has the obj file in its ccDeps and get its ccCompileFlags. This assumes that each obj file only occurs in one CcBinary. Another way to do this would be to create explicit rules for each Mode for each source file, but I wonder if that would add to startup overhead.




srcToObj :: Config -> IO.FilePath -> IO.FilePath Source #

AB.{hs,hsc,chs} -> builddebugobjA/B.hs.o AB.cc -> builddebugobjA/B.cc.o buildAB.hs -> buildAB.hs.o build{hsc,chs}UiKey.hs -> builddebugobjUi/Key.hs.o

Generated .hs files are already in build so they shouldn't have buildetc. prepended. Unless they were .hsc or .chs generated files.

objToSrc :: Config -> IO.FilePath -> IO.FilePath Source #

builddebugobjAB.hs.o -> A/B.hs

objToHscHs :: Config -> IO.FilePath -> IO.FilePath Source #

builddebugobjAB.o -> buildhscA/B.hs

objToChsHs :: Config -> IO.FilePath -> IO.FilePath Source #

builddebugobjAB.o -> buildchsA/B.hs

hsToHsc :: IO.FilePath -> IO.FilePath -> IO.FilePath Source #

buildhscAB.hs -> AB.hsc

hscToHs :: IO.FilePath -> IO.FilePath -> IO.FilePath Source #

AB.hsc -> buildhscAB.hs

hsToChs :: IO.FilePath -> IO.FilePath -> IO.FilePath Source #

buildchsAB.hs -> AB.chs

pathToModule :: IO.FilePath -> String Source #

Foor/Bar.hs -> Foo.Bar

moduleToPath :: String -> IO.FilePath Source #

Foo.Bar -> Foo/Bar