Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration of dhall #72

Merged
merged 46 commits into from
Sep 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
4ff0bc8
Add dhall-to-etlas submodule
jneira Aug 8, 2018
1005384
bump up to latest forced tag
jneira Aug 8, 2018
d1e8a27
allow build dhall-to-etlas (including allow-newer to true)
jneira Aug 8, 2018
acafc3a
add dhall-to-etlas dep to etlas lib
jneira Aug 8, 2018
18b9bd8
Add dhall as a new valid ProjectPackageLocation
jneira Aug 9, 2018
08a5c38
Add project location dir with dhall file
jneira Aug 10, 2018
f84ea85
Package with the dhall-to-etlas specific functions
jneira Aug 10, 2018
d3674b5
Add deps and module for dhall integration
jneira Aug 10, 2018
b879980
Change target selection error msg to include etlas.dhall
jneira Aug 10, 2018
7563699
Include etlas.dhall in projct config
jneira Aug 10, 2018
bb0f800
remove duplicated import
jneira Aug 14, 2018
f649437
Use cabal parsec to reparse dhall GenericPackageDescription
jneira Aug 14, 2018
c7fefaf
Use readDhallGenericPackageDescription
jneira Aug 14, 2018
20157dd
Remove trace
jneira Aug 14, 2018
e19793f
Correct extension
jneira Aug 14, 2018
7671ca4
add stub of remove duplicate pkg locations
jneira Aug 20, 2018
cc11f3f
bump dhall-to-etlas
jneira Aug 21, 2018
416c0ec
Add GenericPackageDescription as setupWrapper argument
jneira Aug 21, 2018
0a78bae
complete readGenericPackageDescription using dhall file
jneira Aug 22, 2018
4eeccce
stick to master version
jneira Aug 24, 2018
f1658f9
use dhall version with caching hashed imports
jneira Aug 24, 2018
a354ed4
remove unnecesary log
jneira Aug 24, 2018
7022ccb
Write derived cabal file before self exec methods in setupWrapper
jneira Aug 24, 2018
770c87c
write derived cabal file before self exec mehod
jneira Aug 26, 2018
e2d2e06
bump up dhall-to-etlas to last master
jneira Aug 27, 2018
225d8e2
Examine flags to honor --cabal-file arg
jneira Aug 27, 2018
255ea7d
add etlas.dhall file case to (old-)install tarball
jneira Aug 27, 2018
79b0d05
Initial support for etlas.dhall in Targets
jneira Aug 28, 2018
c4e5290
Complete support for etlas.dhall in Targets
jneira Aug 28, 2018
95914a6
Continue handling of etlas.dhall
jneira Aug 30, 2018
0d16ef6
set master version of dhall
jneira Aug 31, 2018
28290a5
set correct repo version of dhall
jneira Aug 31, 2018
2aadc55
Add supoort for etlas.dhall in package list cache read
jneira Aug 31, 2018
6f7f477
bump up dhall-to-etlas to master
jneira Aug 31, 2018
3d047d1
Set PARSEC to false and fix compiler errors
jneira Aug 31, 2018
8005435
Enable Parsec again
jneira Aug 31, 2018
1847005
Cherry pick changes of cabal pr 4654 to allow parse of flags with dou…
jneira Aug 31, 2018
1ba5974
set dhall version to 1.17
jneira Aug 31, 2018
b473bc5
bump up master version
jneira Sep 2, 2018
b6b84e0
correct new dhall version
jneira Sep 2, 2018
ab290a2
Pull latest master
jneira Sep 3, 2018
44c6158
Bump up dhall version to 1.17
jneira Sep 3, 2018
2133396
Relax lower bound of directory to remove allow-newer
jneira Sep 3, 2018
c59460e
remove overlapping package locations between dhall and cabal
jneira Sep 3, 2018
3df78cc
Bump up version to 1.6.0.0
jneira Sep 3, 2018
cb37ef3
Remove TODO comments
jneira Sep 3, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "hackage-security"]
path = hackage-security
url = https://github.com/Jyothsnasrinivas/hackage-security.git
[submodule "dhall-to-etlas"]
path = dhall-to-etlas
url = https://github.com/eta-lang/dhall-to-etlas
1 change: 1 addition & 0 deletions dhall-to-etlas
Submodule dhall-to-etlas added at 428ee1
33 changes: 20 additions & 13 deletions etlas-cabal/Distribution/PackageDescription/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1781,19 +1781,26 @@ findPackageDesc :: Monad m => CheckPackageContentOps m
-> m (Either PackageCheck FilePath) -- ^<pkgname>.cabal
findPackageDesc ops
= do let dir = "."
files <- getDirectoryContents ops dir
-- to make sure we do not mistake a ~/.cabal/ dir for a <pkgname>.cabal
-- file we filter to exclude dirs and null base file names:
cabalFiles <- filterM (doesFileExist ops)
[ dir </> file
| file <- files
, let (name, ext) = splitExtension file
, not (null name) && ext == ".cabal" ]
case cabalFiles of
[] -> return (Left $ PackageBuildImpossible noDesc)
[cabalFile] -> return (Right cabalFile)
multiple -> return (Left $ PackageBuildImpossible
$ multiDesc multiple)
dhallFile = dir </> "etlas.dhall"

existDhallFile <- doesFileExist ops dhallFile

if existDhallFile then return (Right dhallFile)
else do

files <- getDirectoryContents ops dir
-- to make sure we do not mistake a ~/.cabal/ dir for a <pkgname>.cabal
-- file we filter to exclude dirs and null base file names:
cabalFiles <- filterM (doesFileExist ops)
[ dir </> file
| file <- files
, let (name, ext) = splitExtension file
, not (null name) && ext == ".cabal" ]
case cabalFiles of
[] -> return (Left $ PackageBuildImpossible noDesc)
[cabalFile] -> return (Right cabalFile)
multiple -> return (Left $ PackageBuildImpossible
$ multiDesc multiple)

where
noDesc :: String
Expand Down
10 changes: 5 additions & 5 deletions etlas-cabal/Distribution/Parsec/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Data.Functor.Identity (Identity)
import qualified Distribution.Compat.Parsec as P
import Distribution.Parsec.Types.Common
(PWarnType (..), PWarning (..), Position (..))
import Distribution.Utils.Generic (lowercase)
import qualified Text.Parsec as Parsec
import qualified Text.Parsec.Language as Parsec
import qualified Text.Parsec.Token as Parsec
Expand Down Expand Up @@ -125,12 +126,11 @@ instance Parsec ModuleName where
validModuleChar c = isAlphaNum c || c == '_' || c == '\''

instance Parsec FlagName where
parsec = mkFlagName . map toLower . intercalate "-" <$> P.sepBy1 component (P.char '-')
parsec = mkFlagName . lowercase <$> parsec'
where
-- http://hackage.haskell.org/package/cabal-debian-4.24.8/cabal-debian.cabal
-- has flag with all digit component: pretty-112
component :: P.Stream s Identity Char => P.Parsec s [PWarning] String
component = P.munch1 (\c -> isAlphaNum c || c `elem` "_")
parsec' = (:) <$> lead <*> rest
lead = P.satisfy (\c -> isAlphaNum c || c == '_')
rest = P.munch (\c -> isAlphaNum c || c == '_' || c == '-')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these changes change the parsing behavior or is it just a refactoring?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok looks like a refactor.

Copy link
Collaborator Author

@jneira jneira Sep 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is weird but testing with .cabal files gave me an error when indexing cassava with PARSEC option. It has an infamous flag with an internal double dash. Dont know why previous etlas version that has PARSEC enabled didnt throw the error
(See 1847005)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a weird thing in that stack.yaml in this repo turns on the parsec flag, while the stack.yaml in the main eta repo doesn't. So the etlas you use normally when doing ./cleaninstall.sh doesn't use parsec.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhh, ok, however i think i've used etlas installed from its own repo and i dont remember having that error (cassava is always indexed?).. anyway afaik the new flag parser is more robust cause it will support previous and future flag formats

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! :)


instance Parsec Dependency where
parsec = do
Expand Down
17 changes: 11 additions & 6 deletions etlas-cabal/Distribution/Simple.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ module Distribution.Simple (
module Distribution.Simple.Compiler,
module Language.Haskell.Extension,
-- * Simple interface
defaultMain, defaultMainNoRead, defaultMainArgs,
defaultMain, defaultMainNoRead,
defaultMainNoReadArgs, defaultMainArgs,
-- * Customization
UserHooks(..), Args,
defaultMainWithHooks, defaultMainWithHooksArgs,
defaultMainWithHooksNoRead,
defaultMainWithHooksNoRead, defaultMainWithHooksNoReadArgs,
-- ** Standard sets of hooks
simpleUserHooks,
autoconfUserHooks,
Expand Down Expand Up @@ -139,10 +140,17 @@ defaultMainWithHooksArgs = defaultMainHelper
defaultMainNoRead :: GenericPackageDescription -> IO ()
defaultMainNoRead = defaultMainWithHooksNoRead simpleUserHooks

defaultMainNoReadArgs :: GenericPackageDescription -> [String] -> IO ()
defaultMainNoReadArgs = defaultMainWithHooksNoReadArgs simpleUserHooks

-- | A customizable version of 'defaultMainNoRead'.
defaultMainWithHooksNoRead :: UserHooks -> GenericPackageDescription -> IO ()
defaultMainWithHooksNoRead hooks pkg_descr =
getArgs >>=
getArgs >>= defaultMainWithHooksNoReadArgs hooks pkg_descr

defaultMainWithHooksNoReadArgs :: UserHooks -> GenericPackageDescription
-> [String] -> IO ()
defaultMainWithHooksNoReadArgs hooks pkg_descr =
defaultMainHelper hooks { readDesc = return (Just pkg_descr) }

defaultMainHelper :: UserHooks -> Args -> IO ()
Expand Down Expand Up @@ -239,9 +247,6 @@ confPkgDescr hooks verbosity mb_path = do
pdfile <- case mb_path of
Nothing -> defaultPackageDesc verbosity
Just path -> return path
#ifdef CABAL_PARSEC
info verbosity "Using Parsec parser"
#endif
descr <- readGenericPackageDescription verbosity pdfile
return (Just pdfile, descr)

Expand Down
32 changes: 19 additions & 13 deletions etlas-cabal/Distribution/Simple/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1472,22 +1472,28 @@ defaultPackageDesc :: Verbosity -> IO FilePath
defaultPackageDesc _verbosity = tryFindPackageDesc currentDir

-- |Find a package description file in the given directory. Looks for
-- @.cabal@ files.
-- an @etlas.dhall@ file or @.cabal@ files.
findPackageDesc :: FilePath -- ^Where to look
-> NoCallStackIO (Either String FilePath) -- ^<pkgname>.cabal
findPackageDesc dir
= do files <- getDirectoryContents dir
-- to make sure we do not mistake a ~/.cabal/ dir for a <pkgname>.cabal
-- file we filter to exclude dirs and null base file names:
cabalFiles <- filterM doesFileExist
[ dir </> file
| file <- files
, let (name, ext) = splitExtension file
, not (null name) && ext == ".cabal" ]
case cabalFiles of
[] -> return (Left noDesc)
[cabalFile] -> return (Right cabalFile)
multiple -> return (Left $ multiDesc multiple)
= do let dhallFile = dir </> "etlas.dhall"

existDhallFile <- doesFileExist dhallFile

if existDhallFile then return (Right dhallFile)
else do
files <- getDirectoryContents dir
-- to make sure we do not mistake a ~/.cabal/ dir for a <pkgname>.cabal
-- file we filter to exclude dirs and null base file names:
cabalFiles <- filterM doesFileExist
[ dir </> file
| file <- files
, let (name, ext) = splitExtension file
, not (null name) && ext == ".cabal" ]
case cabalFiles of
[] -> return (Left noDesc)
[cabalFile] -> return (Right cabalFile)
multiple -> return (Left $ multiDesc multiple)

where
noDesc :: String
Expand Down
2 changes: 1 addition & 1 deletion etlas-cabal/etlas-cabal.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: etlas-cabal
-- @VERSION
version: 1.5.1.0
version: 1.6.0.0
copyright: 2017, TypeLead, Inc.
license: BSD3
license-file: LICENSE
Expand Down
15 changes: 5 additions & 10 deletions etlas/Distribution/Client/BinaryDist.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@ import Distribution.PackageDescription
( PackageDescription )
import Distribution.PackageDescription.Configuration
( flattenPackageDescription )
#ifdef CABAL_PARSEC
import Distribution.PackageDescription.Parsec
import Distribution.Client.PackageDescription.Dhall
( readGenericPackageDescription )
#else
import Distribution.PackageDescription.Parse
( readGenericPackageDescription )
#endif
import Distribution.Simple.Utils
( createDirectoryIfMissingVerbose, defaultPackageDesc
, withTempDirectory )
Expand All @@ -38,13 +33,13 @@ import Distribution.Simple.BuildPaths ( binPref )
import Distribution.Text ( display )

import System.FilePath ((</>))
import Control.Monad (liftM)

-- |Create a binary distribution.
bdist :: BDistFlags -> BDistExFlags -> IO ()
bdist flags exflags = do
pkg <- liftM flattenPackageDescription
(readGenericPackageDescription verbosity =<< defaultPackageDesc verbosity)
genPkg <- readGenericPackageDescription verbosity =<< defaultPackageDesc verbosity
let pkg = flattenPackageDescription genPkg

let withDir :: (FilePath -> IO a) -> IO a
withDir = withTempDirectory verbosity tmpTargetDir "bdist."

Expand All @@ -57,7 +52,7 @@ bdist flags exflags = do
createDirectoryIfMissingVerbose verbosity True outDir
createDirectoryIfMissingVerbose verbosity True tarBallPath

setupWrapper verbosity setupOpts (Just pkg) bdistCommand (const flags') []
setupWrapper verbosity setupOpts (Just genPkg) (Just pkg) bdistCommand (const flags') []

createArchive verbosity pkg tmpDir tarBallPath

Expand Down
7 changes: 2 additions & 5 deletions etlas/Distribution/Client/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ module Distribution.Client.Check (

import Control.Monad ( when, unless )

#ifdef CABAL_PARSEC
import Distribution.PackageDescription.Parsec ( readGenericPackageDescription )
#else
import Distribution.PackageDescription.Parse ( readGenericPackageDescription )
#endif
import Distribution.Client.PackageDescription.Dhall
( readGenericPackageDescription )

import Distribution.PackageDescription.Check
import Distribution.PackageDescription.Configuration
Expand Down
11 changes: 3 additions & 8 deletions etlas/Distribution/Client/Configure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,8 @@ import Distribution.Package
import Distribution.Types.Dependency
( Dependency(..), thisPackageVersion )
import qualified Distribution.PackageDescription as PkgDesc
#ifdef CABAL_PARSEC
import Distribution.PackageDescription.Parsec
import Distribution.Client.PackageDescription.Dhall
( readGenericPackageDescription )
#else
import Distribution.PackageDescription.Parse
( readGenericPackageDescription )
#endif
import Distribution.PackageDescription.Configuration
( finalizePD )
import Distribution.Version
Expand Down Expand Up @@ -144,7 +139,7 @@ configure verbosity packageDBs repoCtxt binariesPath comp platform progdb
++ message
++ "\nTrying configure anyway."
setupWrapper verbosity (setupScriptOptions installedPkgIndex Nothing)
Nothing configureCommand (const configFlags) extraArgs
Nothing Nothing configureCommand (const configFlags) extraArgs

Right installPlan0 ->
let installPlan = InstallPlan.configureInstallPlan configFlags installPlan0
Expand Down Expand Up @@ -397,7 +392,7 @@ configurePackage verbosity platform comp scriptOptions configFlags
extraArgs =

setupWrapper verbosity
scriptOptions (Just pkg) configureCommand configureFlags extraArgs
scriptOptions (Just gpkg) (Just pkg) configureCommand configureFlags extraArgs

where
gpkg = packageDescription spkg
Expand Down
7 changes: 1 addition & 6 deletions etlas/Distribution/Client/GenBounds.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,8 @@ import Distribution.PackageDescription
( buildDepends )
import Distribution.PackageDescription.Configuration
( finalizePD )
#ifdef CABAL_PARSEC
import Distribution.PackageDescription.Parsec
import Distribution.Client.PackageDescription.Dhall
( readGenericPackageDescription )
#else
import Distribution.PackageDescription.Parse
( readGenericPackageDescription )
#endif
import Distribution.Types.ComponentRequestedSpec
( defaultComponentRequestedSpec )
import Distribution.Types.Dependency
Expand Down
4 changes: 2 additions & 2 deletions etlas/Distribution/Client/Get.hs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ get verbosity repoCtxt globalFlags getFlags userTargets = do

checkTarget :: Verbosity -> UserTarget -> IO ()
checkTarget verbosity target = case target of
UserTargetLocalDir dir -> die' verbosity (notTarball dir)
UserTargetLocalCabalFile file -> die' verbosity (notTarball file)
UserTargetLocalDir dir -> die' verbosity (notTarball dir)
UserTargetLocalPkgConfigFile file -> die' verbosity (notTarball file)
_ -> return ()
where
notTarball t =
Expand Down
Loading