ats-pkg 2.8.0.0 → 2.8.0.8
raw patch · 16 files changed
+164/−77 lines, 16 filesdep ~dhalldep ~shake-ats
Dependency ranges changed: dhall, shake-ats
Files
- README.md +2/−0
- app/Main.hs +1/−1
- ats-pkg.cabal +3/−3
- dhall/atslib.dhall +31/−23
- dhall/config.dhall +5/−7
- man/atspkg.1 +4/−1
- src/Distribution/ATS/Build.hs +4/−1
- src/Language/ATS/Package/Build.hs +43/−13
- src/Language/ATS/Package/Build/C.hs +28/−11
- src/Language/ATS/Package/Compiler.hs +4/−5
- src/Language/ATS/Package/Dependency.hs +9/−9
- src/Language/ATS/Package/Error.hs +1/−1
- src/Language/ATS/Package/Generic.hs +25/−1
- src/Language/ATS/Package/PackageSet.hs +1/−1
- src/Language/ATS/Package/Type.hs +2/−0
- src/Quaalude.hs +1/−0
README.md view
@@ -5,6 +5,8 @@ This is a build system for ATS written in Haskell and configured with Dhall. It is not fully working, but the configuration format is now stable. +`atspkg` works quite well as a build system, and less well as a package manager.+ ## Features & Non-Features Things that `atspkg` will do for you:
app/Main.hs view
@@ -183,7 +183,7 @@ fetchPkg :: String -> IO () fetchPkg pkg = withSystemTempDirectory "atspkg" $ \p -> do let (lib, dirName, url') = (mempty, p, pkg) & each %~ TL.pack- buildHelper True (ATSDependency lib dirName url' undefined undefined mempty mempty mempty)+ buildHelper True (ATSDependency lib dirName url' undefined undefined mempty mempty mempty mempty) ps <- getSubdirs p pkgDir <- fromMaybe p <$> findFile (p:ps) "atspkg.dhall" let a = withCurrentDirectory (takeDirectory pkgDir) (mkPkg False False False mempty ["install"] Nothing 0)
ats-pkg.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: ats-pkg-version: 2.8.0.0+version: 2.8.0.8 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2018 Vanessa McHale@@ -86,9 +86,9 @@ microlens -any, microlens-th -any, mtl -any,- dhall >=1.12.0,+ dhall >=1.11.0 && <=1.12.0, ansi-wl-pprint -any,- shake-ats >=1.3.0.0,+ shake-ats >=1.6.0.0, shake-ext >=2.6.0.0, composition-prelude >=1.3.0.0, zip-archive -any,
dhall/atslib.dhall view
@@ -37,26 +37,34 @@ {- ATSPackage parts -} let prelude = https://raw.githubusercontent.com/vmchale/atspkg/master/ats-pkg/dhall/atspkg-prelude.dhall -in prelude.default ⫽- { libraries =- [- prelude.staticLib ⫽- { libTarget = "target/lib/libatslib.a"- , name = "atslib"- , src =- concat Text- [ mapPre [ "bool", "integer", "basics", "pointer", "integer_long", "integer_short", "integer_size", "char", "float", "string", "strptr", "integer_ptr", "integer_fixed", "filebas" ]- , mapC [ "math", "float", "errno", "fcntl", "dirent", "stdio", "stdlib", "string", "strings", "time", "unistd" ]- , mapML [ "list0", "option0", "array0", "matrix0", "string", "strarr", "gvalue", "dynarray", "hashtblref", "filebas", "filebas_dirent" ]- ]- , includes = ([] : List Text)- }- , prelude.staticLib ⫽- { libTarget = "target/lib/libatsopt.a"- , name = "atsopt"- , src = mapUtil [ "main", "print", "util" ]- }- ]- , cflags = [ "-fPIC" ]- , compiler = [0,3,10]- }+in++let atslib =+ λ(compilerVersion : List Integer) →+ λ(libVersion : List Integer) →+ prelude.default ⫽+ { libraries =+ [+ prelude.staticLib ⫽+ { libTarget = "lib/ats2-postiats-${prelude.showVersion libVersion}/ccomp/atslib/lib/libatslib.a"+ , name = "atslib"+ , src =+ concat Text+ [ mapPre [ "bool", "integer", "basics", "pointer", "integer_long", "integer_short", "integer_size", "char", "float", "string", "strptr", "integer_ptr", "integer_fixed", "filebas" ]+ , mapC [ "math", "float", "errno", "fcntl", "dirent", "stdio", "stdlib", "string", "strings", "time", "unistd" ]+ , mapML [ "list0", "option0", "array0", "matrix0", "string", "strarr", "gvalue", "dynarray", "hashtblref", "filebas", "filebas_dirent" ]+ ]+ , includes = ([] : List Text)+ }+ , prelude.staticLib ⫽+ { libTarget = "lib/ats2-postiats-${prelude.showVersion libVersion}/ccomp/atslib/lib/libatsopt.a"+ , name = "atsopt"+ , src = mapUtil [ "main", "print", "util" ]+ }+ ]+ , cflags = [ "-fPIC" ]+ , compiler = compilerVersion+ }+in++atslib [0,3,10] [0,3,9]
dhall/config.dhall view
@@ -1,10 +1,8 @@ let version = "master" in -let cfg =- { defaultPkgs = "https://raw.githubusercontent.com/vmchale/atspkg/${version}/ats-pkg/pkgs/pkg-set.dhall"- , path = ([] : Optional Text)- , githubUsername = ""- , filterErrors = False- }-in cfg+{ defaultPkgs = "https://raw.githubusercontent.com/vmchale/atspkg/${version}/ats-pkg/pkgs/pkg-set.dhall"+, path = ([] : Optional Text)+, githubUsername = ""+, filterErrors = False+}
man/atspkg.1 view
@@ -41,7 +41,10 @@ .PP \f[B]run\f[] \- Run the generated binary .PP-\f[B]check\f[] \- Check a package set to make sure it is well\-typed.+\f[B]check\f[] \- Check a pkg.dhall file to make sure it is well\-typed.+.PP+\f[B]check\-set\f[] \- Check a package set to make sure it is+well\-typed. .PP \f[B]list\f[] \- List all available packages in current package set. .PP
src/Distribution/ATS/Build.hs view
@@ -24,7 +24,9 @@ modifyBuildInfo libDir bi = let olds = extraLibDirs bi in bi { extraLibDirs = (libDir <>) <$> olds } -modifyConf :: String -> LocalBuildInfo -> LocalBuildInfo+modifyConf :: FilePath -- ^ New library directory (absolute)+ -> LocalBuildInfo+ -> LocalBuildInfo modifyConf libDir bi = let old = localPkgDescr bi in bi { localPkgDescr = modifyPkgDescr libDir old } @@ -36,6 +38,7 @@ modifyLibrary libDir lib = let old = libBuildInfo lib in lib { libBuildInfo = modifyBuildInfo libDir old } +-- | Write a dummy file that will allow packaging to work. writeDummyFile :: IO () writeDummyFile = createDirectoryIfMissing True "dist-newstyle/lib" >>
src/Language/ATS/Package/Build.hs view
@@ -13,6 +13,7 @@ import Control.Concurrent.ParallelIO.Global import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as BSL+import Data.List (intercalate) import Development.Shake.ATS import Development.Shake.C (ccFromString) import Development.Shake.Check@@ -43,6 +44,13 @@ where fetchDef = fetchCompiler setupDef = setupCompiler atslibSetup tgt' +build' :: FilePath -- ^ Directory+ -> Maybe String -- ^ Target triple+ -> [String] -- ^ Targets+ -> IO ()+build' dir tgt' rs = withCurrentDirectory dir (mkPkgEmpty mempty)+ where mkPkgEmpty ts = mkPkg False True False ts rs tgt' 1+ -- | Build a set of targets build :: [String] -- ^ Targets -> IO ()@@ -134,7 +142,7 @@ toVerbosity 1 = Loud toVerbosity 2 = Chatty toVerbosity 3 = Diagnostic-toVerbosity _ = Diagnostic -- really should be a warning+toVerbosity _ = Diagnostic -- should be a warning options :: Bool -- ^ Whether to rebuild all targets -> Bool -- ^ Whether to run the linter@@ -216,11 +224,31 @@ -> IO () atslibSetup tgt' lib' p = do putStrLn $ "installing " ++ lib' ++ "..."- subdirs <- allSubdirs p+ subdirs <- (p:) <$> allSubdirs p pkgPath <- fromMaybe p <$> findFile subdirs "atspkg.dhall" let installDir = takeDirectory pkgPath- buildAll tgt' (Just installDir)+ build' installDir tgt' mempty +-- | The directory @~/.atspkg@+pkgHome :: MonadIO m => CCompiler -> m String+pkgHome cc' = liftIO $ (++ ("/.atspkg/" ++ ccToDir cc')) <$> getEnv "HOME"++-- | The directory that will be @PATSHOME@.+patsHomeAtsPkg :: MonadIO m => Version -> m String+patsHomeAtsPkg v = fmap (++ (show v ++ "/")) (pkgHome (GCC Nothing))++home' :: MonadIO m => Version -- ^ Compiler version+ -> Version -- ^ Library version+ -> m String+home' compV libV = do+ h <- patsHomeAtsPkg compV+ pure $ h ++ "lib/ats2-postiats-" ++ show libV++-- | This is the @$PATSHOMELOCS@ variable to be passed to the shell.+patsHomeLocsAtsPkg :: Int -> String+patsHomeLocsAtsPkg n = intercalate ":" $ (<> ".atspkg/contrib") . ("./" <>) <$> g+ where g = [ join $ replicate i "../" | i <- [0..n] ]+ pkgToAction :: [IO ()] -- ^ Setup actions to be performed -> [String] -- ^ Targets -> Maybe String -- ^ Optional compiler triple (overrides 'ccompiler')@@ -242,27 +270,29 @@ let bins = unpack . target <$> bs setTargets rs bins mt - cDepsRules >> bits tgt rs+ ph <- home' v' v - mapM_ h lbs+ cDepsRules ph >> bits tgt rs - mapM_ g (bs ++ ts)+ mapM_ (h ph) lbs - where g (Bin s t ls hs' atg gc' extra) =- atsBin (ATSTarget (unpack <$> cf) atsToolConfig gc' (unpack <$> ls) [unpack s] hs' (unpackBoth . asTuple <$> atg) mempty (unpack t) (deps extra) Executable)+ mapM_ (g ph) (bs ++ ts) - h (Lib _ s t ls _ hs' lnk atg extra sta) =- atsBin (ATSTarget (unpack <$> cf) atsToolConfig False (unpack <$> ls) (unpack <$> s) hs' (unpackBoth . asTuple <$> atg) (both unpack <$> lnk) (unpack t) (deps extra) (k sta))+ where g ph (Bin s t ls hs' atg gc' extra) =+ atsBin (ATSTarget (unpack <$> cf) (atsToolConfig ph) gc' (unpack <$> ls) [unpack s] hs' (unpackBoth . asTuple <$> atg) mempty (unpack t) (deps extra) Executable) + h ph (Lib _ s t ls _ hs' lnk atg extra sta) =+ atsBin (ATSTarget (unpack <$> cf) (atsToolConfig ph) False (unpack <$> ls) (unpack <$> s) hs' (unpackBoth . asTuple <$> atg) (both unpack <$> lnk) (unpack t) (deps extra) (k sta))+ k False = SharedLibrary k True = StaticLibrary - atsToolConfig = ATSToolConfig v v' False (ccFromString cc') (not dl)+ atsToolConfig ph = ATSToolConfig ph (patsHomeLocsAtsPkg 5) False (ccFromString cc') (not dl) - cDepsRules = unless (null as) $ do+ cDepsRules ph = unless (null as) $ do let targets = fmap (unpack . cTarget) as sources = fmap (unpack . atsSrc) as- zipWithM_ (cgen atsToolConfig [specialDeps, ".atspkg/config"] (fmap (unpack . ats) . atsGen =<< as)) sources targets+ zipWithM_ (cgen (atsToolConfig ph) [specialDeps, ".atspkg/config"] (fmap (unpack . ats) . atsGen =<< as)) sources targets cc' = maybe (unpack ccLocal) (<> "-gcc") tgt deps = (specialDeps:) . (".atspkg/config":) . fmap unpack
src/Language/ATS/Package/Build/C.hs view
@@ -1,5 +1,5 @@ module Language.ATS.Package.Build.C ( clibSetup- , pkgHome+ , cpkgHome , allSubdirs ) where @@ -7,8 +7,8 @@ import Development.Shake.C import Quaalude -pkgHome :: CCompiler -> IO FilePath-pkgHome cc' = (++ ("/.atspkg/" ++ ccToDir cc')) <$> getEnv "HOME"+cpkgHome :: CCompiler -> IO FilePath+cpkgHome cc' = (++ ("/.atspkg/" ++ ccToDir cc')) <$> getEnv "HOME" allSubdirs :: FilePath -> IO [FilePath] allSubdirs [] = pure mempty@@ -28,25 +28,42 @@ -- Find configure script and make it executable subdirs <- allSubdirs p configurePath <- findFile (p:subdirs) "configure"+ cmakeLists <- findFile (p:subdirs) "CMakeLists.txt" fold (setFileMode <$> configurePath <*> pure ownerModes) -- Set environment variables for configure script- h <- pkgHome cc'+ h <- cpkgHome cc' let procEnv = Just [("CC", ccToString cc'), ("CFLAGS" :: String, "-I" <> h <> "include"), ("PATH", "/usr/bin:/bin")] - biaxe [fold (configure h <$> configurePath <*> pure procEnv), make, install] lib' p+ biaxe [fold (configure h <$> configurePath <*> pure procEnv), cmake h cmakeLists, make, install] lib' p +-- TODO only do this if @./configure@ is missing+cmake :: FilePath -> Maybe FilePath -> String -> FilePath -> IO ()+cmake _ Nothing _ _ = mempty+cmake prefixPath (Just cfgLists) _ _ = do+ let p = takeDirectory cfgLists+ silentCreateProcess ((proc "cmake" ["-DCMAKE_INSTALL_PREFIX:PATH=" ++ prefixPath, p]) { cwd = Just p })+ configure :: FilePath -> FilePath -> Maybe [(String, String)] -> String -> FilePath -> IO () configure prefixPath configurePath procEnv lib' p = putStrLn ("configuring " ++ lib' ++ "...") >> silentCreateProcess ((proc configurePath ["--prefix", prefixPath, "--host", host]) { cwd = Just p, env = procEnv }) +findMakefile :: FilePath -> IO FilePath+findMakefile p = do+ subdirs <- allSubdirs p+ -- mc <- findFile (p:subdirs) "CMakeLists.txt"+ mp <- findFile (p:subdirs) "Makefile"+ pure $ maybe p takeDirectory mp -- (maybe p takeDirectory mp) takeDirectory mc+ make :: String -> FilePath -> IO ()-make lib' p =- putStrLn ("building " ++ lib' ++ "...") >>- silentCreateProcess ((proc "make" ["-j4"]) { cwd = Just p })+make lib' p = do+ putStrLn ("building " ++ lib' ++ "...")+ p' <- findMakefile p+ silentCreateProcess ((proc "make" ["-j4"]) { cwd = Just p' }) install :: String -> FilePath -> IO ()-install lib' p =- putStrLn ("installing " ++ lib' ++ "...") >>- silentCreateProcess ((proc "make" ["install"]) { cwd = Just p })+install lib' p = do+ putStrLn ("installing " ++ lib' ++ "...")+ p' <- findMakefile p+ silentCreateProcess ((proc "make" ["install"]) { cwd = Just p' })
src/Language/ATS/Package/Compiler.hs view
@@ -68,9 +68,9 @@ silentCreateProcess ((proc "make" []) { cwd = Just cd }) type SetupScript = Maybe String -- ^ Optional target triple- -> String -- ^ Library name- -> FilePath -- ^ File path- -> IO ()+ -> String -- ^ Library name+ -> FilePath -- ^ File path+ -> IO () libInstall :: SetupScript -> FilePath -> String -> IO () libInstall atslibSetup cd triple =@@ -88,6 +88,7 @@ install tgt' als v cd = withCompiler "Installing" v >> silentCreateProcess ((proc "make" ["install"]) { cwd = Just cd }) >>+ writeFile (cd ++ "/done") "" >> maybe mempty (libInstall als cd) tgt' configure :: FilePath -> Version -> FilePath -> IO ()@@ -108,8 +109,6 @@ cd <- compilerDir v biaxe [configure (cd ++ "/configure"), make, install tgt' als] v cd-- writeFile (cd ++ "/done") "" cleanAll :: IO () cleanAll = do
src/Language/ATS/Package/Dependency.hs view
@@ -50,14 +50,14 @@ cdeps' <- setBuildPlan "c" libDeps pkgSet cdeps -- Set up actions- d <- (<> "lib/") <$> pkgHome cc'+ d <- (<> "lib/") <$> cpkgHome cc' let tgt' = getTgt cc' libs' = fmap (buildHelper False) (join deps') unpacked = fmap (over dirLens (pack d <>)) <$> cdeps' clibs = fmap (buildHelper False) (join unpacked) atsLibs = fmap (buildHelper False) (join atsDeps')- cBuild = mapM_ (setup cc') <$> transpose unpacked- atsBuild = mapM_ (atsPkgSetup als tgt') <$> transpose atsDeps'+ cBuild = mapM_ (setup cc') <$> (transpose . fmap reverse) unpacked+ atsBuild = mapM_ (atsPkgSetup als tgt') <$> (transpose . fmap reverse) atsDeps' -- Fetch all packages & build compiler parallel' $ join [ setup', libs', clibs, atsLibs ]@@ -65,7 +65,7 @@ let tagBuild str bld = unless (null bld) $ putStrLn (mconcat ["Building ", str, " dependencies..."]) >>- parallel' bld+ sequence_ bld -- FIXME parallel' zipWithM_ tagBuild [ "C", "ATS" ] [ cBuild, atsBuild ] @@ -76,8 +76,8 @@ -> Maybe String -> ATSDependency -> IO ()-atsPkgSetup als tgt' (ATSDependency lib' dirName' _ _ _ _ _ _) = do- lib'' <- (<> unpack lib') <$> pkgHome GCCStd+atsPkgSetup als tgt' (ATSDependency lib' dirName' _ _ _ _ _ _ _) = do+ lib'' <- (<> unpack lib') <$> cpkgHome GCCStd b <- doesFileExist lib'' unless b $ do als tgt' (unpack lib') (unpack dirName')@@ -86,8 +86,8 @@ setup :: CCompiler -- ^ C compiler to use -> ATSDependency -- ^ ATSDependency itself -> IO ()-setup cc' (ATSDependency lib' dirName' _ _ _ _ _ _) = do- lib'' <- (<> unpack lib') <$> pkgHome cc'+setup cc' (ATSDependency lib' dirName' _ _ _ _ _ _ _) = do+ lib'' <- (<> unpack lib') <$> cpkgHome cc' b <- doesFileExist lib'' unless b $ do clibSetup cc' (unpack lib') (unpack dirName')@@ -113,7 +113,7 @@ extractFilesFromArchive [options] (toArchive response) buildHelper :: Bool -> ATSDependency -> IO ()-buildHelper b (ATSDependency lib' dirName' url'' _ _ _ _ _) = do+buildHelper b (ATSDependency lib' dirName' url'' _ _ _ _ _ _) = do let (lib, dirName, url') = (lib', dirName', url'') & each %~ unpack isLib = bool "" "library " b
src/Language/ATS/Package/Error.hs view
@@ -21,7 +21,7 @@ | DepErr ResolveError instance Pretty PackageError where- pretty (Unrecognized t) = dullred "Error:" <+> "Unrecognized archive format when unpacking" <#> hang 2 (text t)+ pretty (Unrecognized t) = dullred "Error:" <+> "Unrecognized archive format when unpacking" <#> hang 2 (text t) <> linebreak pretty (DepErr d) = pretty d -- TODO monaderror?
src/Language/ATS/Package/Generic.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} +-- | Module containing types and functions for generic package installs. module Language.ATS.Package.Generic ( GenericPackage (..) , InstallDirs (..) , Package (..)@@ -13,6 +14,29 @@ import Data.Hashable (Hashable (..)) import Quaalude +-- TODO pkgconfig dirs?+-- also possibly using pkg-config.+-- pkg-config --cflags ~/.atspkg/lib/pkgconfig/bdw-gc.pc+-- e.g. -I/home/vanessa/.atspkg/include+-- pkg-config --cflags mircore+-- PKG_CONFIG_PATH=$HOME/.atspkg ??+-- autogen pkg-config (??)++-- ALSO: packaging for vim plugins would be nice.++{-+prefix=/home/vanessa/.atspkg+exec_prefix=${prefix}+libdir=${exec_prefix}/lib+includedir=${prefix}/include++Name: Boehm-Demers-Weiser Conservative Garbage Collector+Description: A garbage collector for C and C+++Version: 7.6.4+Libs: -L${libdir} -lgc+Cflags: -I${includedir}+-}+ -- | Functions containing installation information about a particular type. data InstallDirs a = InstallDirs { binDir :: a -> FilePath , libDir :: a -> String -> FilePath@@ -21,7 +45,7 @@ , libDeps :: a -> [FilePath] } --- | The default set of install dirs for an ATS package.+-- | The default set of install directories for an ATS package. atsInstallDirs :: Hashable a => IO (InstallDirs a) atsInstallDirs = do h <- getEnv "HOME"
src/Language/ATS/Package/PackageSet.hs view
@@ -26,7 +26,7 @@ pretty v = text (show v) instance Pretty ATSDependency where- pretty (ATSDependency ln _ url md v _ _ _) = dullyellow (text (unpack ln)) <#> indent 4 (g md "url:" <+> text (unpack url) <#> "version:" <+> pretty v) <> hardline+ pretty (ATSDependency ln _ url md v _ _ _ _) = dullyellow (text (unpack ln)) <#> indent 4 (g md "url:" <+> text (unpack url) <#> "version:" <+> pretty v) <> hardline where g (Just d) = ("description:" <+> text (unpack d) <#>) g Nothing = id
src/Language/ATS/Package/Type.hs view
@@ -46,6 +46,7 @@ -- | You likely want 'libDeps' or 'libBldDeps' type DepSelector = ATSDependency -> [LibDep] +-- TODO add a field for configure stage?? -- | Type for a dependency data ATSDependency = ATSDependency { libName :: Text -- ^ Library name, e.g. , dir :: Text -- ^ Directory we should unpack to@@ -55,6 +56,7 @@ , libDeps :: [LibDep] -- ^ Dependencies to be unpacked , libBldDeps :: [LibDep] -- ^ Dependencies to be built , libCDeps :: [LibDep] -- ^ C dependencies to be built+ , script :: [Text] -- ^ Optional build script for C library } deriving (Eq, Show, Generic, Interpret, Binary, Hashable)
src/Quaalude.hs view
@@ -91,6 +91,7 @@ , text , punctuate , dullred+ , linebreak , dullyellow , hardline , hang