Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

Other improvements:
- Allow `verify` and `verify-set` to work with alternate backends (when run in the context
of a `spago.dhall` with `backend` set)

## [0.19.1] - 2021-02-22

Bugfixes:
Expand Down
20 changes: 17 additions & 3 deletions src/Spago/Command/Verify.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ verify chkModsUniq maybePackage = do
quotedName = surroundQuote $ packageName name
Fetch.fetchPackages deps
logInfo $ display $ "Verifying package " <> quotedName
Purs.compile globs []
compile globs
logInfo $ display $ "Successfully verified " <> quotedName

compileEverything :: RIO env ()
Expand All @@ -63,5 +63,19 @@ verify chkModsUniq maybePackage = do
globs = Packages.getGlobs deps Packages.DepsOnly []
Fetch.fetchPackages deps
logInfo "Compiling everything (will fail if module names conflict)"
Purs.compile globs []
logInfo "Successfully compiled everything"
compile globs
logInfo "Successfully compiled everything"

compile :: [SourcePath] -> RIO env ()
compile globs = do
config <- view (the @(Maybe Config))
case config >>= alternateBackend of
Nothing ->
Purs.compile globs []
Just backend -> do
Purs.compile globs [ PursArg "--codegen", PursArg "corefn" ]
let backendCmd = backend -- In future there will be some arguments here
logDebug $ "Running command `" <> display backendCmd <> "`"
shell backendCmd empty >>= \case
ExitSuccess -> pure ()
ExitFailure n -> die [ "Backend " <> displayShow backend <> " exited with error:" <> repr n ]
3 changes: 3 additions & 0 deletions src/Spago/Env.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ type HasEnv env =
)

type HasConfig env = ( HasType Config env, HasPackageSet env )
type HasMaybeConfig env = ( HasType (Maybe Config) env, HasPackageSet env )

type HasVerifyEnv env =
( HasLogFunc env
, HasJobs env
, HasGlobalCache env
, HasPurs env
, HasPackageSet env
, HasMaybeConfig env
)

type HasPublishEnv env =
Expand Down Expand Up @@ -108,6 +110,7 @@ data VerifyEnv = VerifyEnv
, envGlobalCache :: !GlobalCache
, envPursCmd :: !PursCmd
, envPackageSet :: !PackageSet
, envConfig :: !(Maybe Config)
} deriving (Generic)

data InstallEnv = InstallEnv
Expand Down
1 change: 1 addition & 0 deletions src/Spago/RunEnv.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ withVerifyEnv usePsa app = do
Env{..} <- getEnv
envPursCmd <- getPurs usePsa
envPackageSet <- getPackageSet
envConfig <- hush <$> Config.ensureConfig
runRIO VerifyEnv{..} app

withPublishEnv
Expand Down