packages feed

ats-pkg (empty) → 0.1.0.0

raw patch · 14 files changed

+410/−0 lines, 14 filesdep +ats-pkgdep +basedep +bytestringsetup-changed

Dependencies added: ats-pkg, base, bytestring, criterion, dhall, directory, filemanip, hspec, http-client, http-client-tls, optparse-applicative, process, shake, shake-ext, tar, text, unix, zlib

Files

+ .travis.yml view
@@ -0,0 +1,81 @@+---+sudo: false+cache:+  directories:+    - $HOME/.stack+addons:+  apt:+    packages:+      - libgmp3-dev+matrix:+  include:++    # Linux+    - env: TARGET=x86_64-unkown-linux-gnu+      language: python++    # OS X+    - env: TARGET=x86_64-apple-darwin+      os: osx+      language: default++before_install:+  - mkdir -p ~/.local/bin+  - export PATH=$HOME/.local/bin:$PATH+  - |+    if [ `uname` = "Darwin" ]+    then+      curl --insecure -L https://www.stackage.org/stack/osx-x86_64 | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin+    else+      curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'+    fi+  - chmod a+x ~/.local/bin/stack+  - |+    if [ `uname` = "Linux" ]+    then+      pip install yamllint+    else+      echo "skipping yaml verification..."+    fi++install:+  - stack --no-terminal --install-ghc test --only-dependencies++script:+  - stack --no-terminal build --haddock --no-haddock-deps+  - stack test --no-run-tests+  - |+    if [ `uname` = "Linux" ]+    then+      yamllint stack.yaml+      yamllint appveyor.yml+      yamllint .travis.yml+    else+      echo "skipping yaml verification..."+    fi+  - stack bench --no-bench+  - curl -sL https://raw.github.com/ndmitchell/hlint/master/misc/travis.sh | sh -s .+  - curl -sL https://raw.github.com/ndmitchell/weeder/master/misc/travis.sh | sh -s .+  - |+    if [ `uname` = "Darwin" ]+    then+      export BINPATH="$(find . -name ats-pkg -perm 755 | tail -n1)"+    else+      export BINPATH="$(find -name ats-pkg -executable | tail -n2 | head -n1)"+    fi+  - echo $BINPATH+  - mv $BINPATH ats-pkg-$TARGET+  - ls ats-pkg-$TARGET++deploy:+  api_key:+    secure: "bdJVbM9pdNqkeQb9O4mUocyA+zLAHupCLUYMPyi5jZVXF5hDPQeB93C7bMb+G4DzfYdDhDvy/VACYSGWnV2JwbSDObtAi8//wiN4Ir/AjK6aELEF8oVuoPOr4geIOMpjcUbT5JZhqqTF4Ogtd0jW97eg6LnkOZj/Nmirk7NL9FV85r3iw1MEIWBsLdHbpHKgyItOo2YKh0dM3QTZ3tjaeEhEVgd4VQQlEB2SAtueOu/lJhbjT6Y7ztGLW+UXE6ITXuG623ewA8tXt8oyeDx0HES04RVnfkDN7QIDC7Crcx7Q7Kb+yCc1cRe9QQ/9/kaeloCYd0XAKf+Bd1kyH2MIm+/Pnriz5pkM+2z1xEUhTXqXM6Wm1cXHVXRUHJQWayii1TSDp8DhVVoz8N0L3GMEIIJi1rdkO4qA84JcZkQFnH4NhvVK9Bkd/a++h6vh2WOg/nvwnOUBooNLkKik78PrIgpgTapW8yFyXrOlVqtQ9sdCmhrpQGn7Ja1P2z3tNmZgSvIcyhx/SLgHegPae5EJ9roFWRNJ9A/tlgyqNbxBdr5hLWSo3zqyJXj51cqd68tp09lloXLlC9Q2HlAejenfWYQ4KEwT1A8u+cK9lJ7pN+hgmlbQFCz9aYzokD6CCzsdJo01yQMCW2LtlKEeWiUVuA3MrWZ3l+oFQ6/npGQoOQY="+  file: ats-pkg-$TARGET+  on:+    tags: true+  provider: releases+  skip_cleanup: true++branches:+  only:+    - /\d+\.\d+\.\d+\.\d+.*$/
+ LICENSE view
@@ -0,0 +1,11 @@+Copyright Vanessa McHale (c) 2017++Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.++2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.++3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,15 @@+# ats-pkg++This is a build system for ATS written in Haskell and configured with Dhall. It+is currently a work-in-progress. You can see a working example+[here](http://github.com/vmchale/polyglot).++## Installation++Currently, the best way to install is++```+cabal new-install atspkg --symlink-bindor ~/.local/bin+```++Make sure that `~/.local/bin` is on your `PATH`.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ app/Main.hs view
@@ -0,0 +1,6 @@+module Main where++import           Language.ATS.Package.Exec (exec)++main :: IO ()+main = exec
+ appveyor.yml view
@@ -0,0 +1,35 @@+---++build: off++before_test:+  - set PATH=C:\Program Files\Git\mingw64\bin;%PATH%++  - curl -sS -ostack.zip -L --insecure http://www.stackage.org/stack/windows-i386+  - 7z x stack.zip stack.exe++clone_folder: "c:\\stack"+environment:+  global:+    STACK_ROOT: "c:\\sr"++test_script:+  - stack setup > nul+  - echo "" | stack --no-terminal install+  - ps: Get-ChildItem . -name -recurse ats-pkg.exe+  - ps: Copy-Item c:\\stack\\.stack-work\\install\\afd8a623\\bin\\ats-pkg.exe ats-pkg-x86_64-pc-windows.exe+  - ps: Push-AppveyorArtifact ats-pkg-x86_64-pc-windows.exe++deploy:+  artifacts: ats-pkg-x86_64-pc-windows.exe+  provider: GitHub+  on:+    appveyor_repo_tag: true+  auth_token:+    secure: 0qzMr6xmEwRoj/9TJOgDuW/LXWfGVM/4A7kvAXGe0BAwWCF13AWE2SARrYkyc3ji++branches:+  only:+    # Release tags+    - master+    - /\d+\.\d+\.\d+\.\d+.*$/
+ ats-pkg.cabal view
@@ -0,0 +1,84 @@+name:                ats-pkg+version:             0.1.0.0+synopsis:            Package manager for ATS+description:         A collection of scripts to make building ATS projects easy.+homepage:            https://github.com/vmchale/ats-pkg#readme+license:             BSD3+license-file:        LICENSE+author:              Vanessa McHale+maintainer:          vamchale@gmail.com+copyright:           Copyright: (c) 2017 Vanessa McHale+category:            Development+build-type:          Simple+extra-doc-files:     README.md+data-files:          .travis.yml+                   , appveyor.yml+extra-source-files:  stack.yaml+cabal-version:       >=1.18++Flag development {+  Description: Enable `-Werror`+  manual: True+  default: False+}++library+  hs-source-dirs:      src+  exposed-modules:     Language.ATS.Package+                     , Language.ATS.Package.Exec+                     , Language.ATS.Package.Contents+                     , Language.ATS.Package.Type+  build-depends:       base >= 4.7 && < 5+                     , http-client+                     , filemanip+                     , bytestring+                     , shake+                     , tar+                     , zlib+                     , http-client-tls+                     , text+                     , directory+                     , optparse-applicative+                     , process+                     , unix+                     , dhall+                     , shake-ext >= 0.4.0.1+  default-language:    Haskell2010+  if flag(development)+    ghc-options: -Werror+  ghc-options:         -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Wcompat++executable atspkg+  hs-source-dirs:      app+  main-is:             Main.hs+  ghc-options:         -threaded -rtsopts -with-rtsopts=-N+  build-depends:       base+                     , ats-pkg+  default-language:    Haskell2010+  if flag(development)+    ghc-options: -Werror+  ghc-options:         -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Wcompat++test-suite ats-pkg-test+  type:                exitcode-stdio-1.0+  hs-source-dirs:      test+  main-is:             Spec.hs+  build-depends:       base+                     , ats-pkg+                     , hspec+  ghc-options:         -threaded -rtsopts -with-rtsopts=-N -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Wcompat+  default-language:    Haskell2010++benchmark ats-pkg-bench+  type:                exitcode-stdio-1.0+  hs-source-dirs:      bench+  main-is:             Bench.hs+  build-depends:       base+                     , ats-pkg+                     , criterion+  ghc-options:         -threaded -rtsopts -with-rtsopts=-N -O3 -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Wcompat+  default-language:    Haskell2010++source-repository head+  type:     git+  location: https://github.com/vmchale/ats-pkg
+ bench/Bench.hs view
@@ -0,0 +1,9 @@+module Main where++import Criterion.Main++main :: IO ()+main =+    defaultMain [ bgroup "head"+                      [ bench "head" $ whnf head [1..] ]+                ]
+ src/Language/ATS/Package.hs view
@@ -0,0 +1,72 @@+{-# LANGUAGE OverloadedStrings #-}++module Language.ATS.Package+    ( packageCompiler+    , nuke+    , fetchCompiler+    , setupCompiler+    ) where++import qualified Codec.Archive.Tar       as Tar+import           Codec.Compression.GZip  (compress, decompress)+import           Control.Monad           (void, when)+import qualified Data.ByteString.Lazy    as BS+import           Data.List               (intercalate)+import           Network.HTTP.Client     hiding (decompress)+import           Network.HTTP.Client.TLS (tlsManagerSettings)+import           System.Directory+import           System.Environment      (getEnv)+import           System.FilePath.Find    (find)+import           System.Posix.Files+import           System.Process++nuke :: IO ()+nuke = do+    putStrLn "Cleaning everything..."+    b <- doesDirectoryExist =<< compilerDir+    when b+        (removeDirectoryRecursive =<< compilerDir)++newtype Version = Version [Integer]++instance Show Version where+    show (Version is) = intercalate "." (show <$> is)++compilerDir :: IO FilePath+compilerDir = (++ "/.atspkg/compiler") <$> getEnv "HOME"++packageCompiler :: FilePath -> IO ()+packageCompiler directory = do+    files <- find (pure True) (pure True) directory+    bytes <- fmap Tar.write . Tar.pack directory $ fmap (drop $ length (directory :: String) + 1) files+    BS.writeFile (directory ++ ".tar.gz") (compress bytes)++fetchCompiler :: IO ()+fetchCompiler = do++    cd <- compilerDir+    needsSetup <- not <$> doesDirectoryExist cd++    when needsSetup $ do++        putStrLn "Fetching compiler..."+        manager <- newManager tlsManagerSettings+        initialRequest <- parseRequest "https://github.com/vmchale/fastcat/releases/download/0.1.5/ATS2-Postiats-0.3.8.tar.gz"+        response <- responseBody <$> httpLbs (initialRequest { method = "GET" }) manager++        putStrLn "Unpacking compiler..."+        Tar.unpack cd . Tar.read . decompress $ response++setupCompiler :: IO ()+setupCompiler = do++    putStrLn "configuring compiler..."+    cd <- compilerDir+    let configurePath = cd ++ "/configure"+    setFileMode configurePath ownerModes+    setFileMode (cd ++ "/autogen.sh") ownerModes+    void $ readCreateProcess ((proc (cd ++ "/autogen.sh") []) { cwd = Just cd }) ""+    void $ readCreateProcess ((proc configurePath ["--prefix", cd]) { cwd = Just cd }) ""++    putStrLn "building compiler..."+    void $ readCreateProcess ((proc "make" []) { cwd = Just cd, std_err = CreatePipe }) ""
+ src/Language/ATS/Package/Contents.hs view
@@ -0,0 +1,12 @@+module Language.ATS.Package.Contents ( parsePackageContents+                                     , PackageContents (..)+                                     ) where++data PackageContents = PackageContents { _srcDirs    :: [FilePath]+                                       , _files      :: [FilePath]+                                       , _binTargets :: [(FilePath, FilePath)]+                                       , _libTargets :: [(FilePath, FilePath)] -- for foreign libraries (builds a c dependency)+                                       } deriving (Show, Eq)++parsePackageContents :: IO PackageContents+parsePackageContents = pure $ PackageContents mempty mempty mempty mempty
+ src/Language/ATS/Package/Exec.hs view
@@ -0,0 +1,25 @@+module Language.ATS.Package.Exec ( exec+                                 , compiler+                                 ) where++import           Data.Bool                 (bool)+import           Language.ATS.Package+import           Language.ATS.Package.Type+import           System.Directory          (doesFileExist)+import           System.Environment        (getEnv)++check :: IO Bool+check = do+    home <- getEnv "HOME"+    doesFileExist (home ++ "/.atspkg/compiler/bin/patsopt")++exec :: IO ()+exec = mkPkg++compiler :: IO ()+compiler = bool buildAll printConfig =<< check++buildAll :: IO ()+buildAll =+    fetchCompiler >>+    setupCompiler
+ src/Language/ATS/Package/Type.hs view
@@ -0,0 +1,38 @@+{-# LANGUAGE DeriveAnyClass    #-}+{-# LANGUAGE DeriveGeneric     #-}+{-# LANGUAGE OverloadedStrings #-}++module Language.ATS.Package.Type ( Pkg (..)+                                 , Bin (..)+                                 , printConfig+                                 , pkgToAction+                                 , mkPkg+                                 ) where++import qualified Data.Text.Lazy        as TL+import           Development.Shake+import           Development.Shake.ATS+import           Dhall++mkPkg :: IO ()+mkPkg = shake shakeOptions+    (pkgToAction =<< liftIO (input auto "./atspkg.dhall"))++-- TODO need @atspkg.dhall@+pkgToAction :: Pkg -> Rules ()+pkgToAction (Pkg bs ts) =+    mapM_ g (bs ++ ts) >>+    want (TL.unpack . target <$> bs)++    where g (Bin s t ls) = atsBin (TL.unpack <$> ls) (TL.unpack s) (TL.unpack t)++data Bin = Bin { src :: Text, target :: Text, libs :: [Text] }+    deriving (Show, Eq, Generic, Interpret)++data Pkg = Pkg { bin :: [Bin], test :: [Bin] }+    deriving (Show, Eq, Generic, Interpret)++printConfig :: IO ()+printConfig = do+    x <- input auto "./atspkg.dhall"+    print (x :: Pkg)
+ stack.yaml view
@@ -0,0 +1,12 @@+---+resolver: lts-10.3+packages:+  - '.'+extra-deps:+  - shake-ext-0.4.0.2+  - composition-prelude-1.1.0.0+  - language-ats-0.1.0.3+flags:+  ats-pkg:+    development: false+extra-package-dbs: []
+ test/Spec.hs view
@@ -0,0 +1,8 @@+import           Language.ATS.Package+import           Test.Hspec++main :: IO ()+main = hspec $+    describe "head" $+        parallel $ it "gets the head of an infinite list" $+            head [1..] `shouldBe` 1