Commit df4848c9 authored by Neil Mitchell's avatar Neil Mitchell Committed by Andrey Mokhov
Browse files

.bat file tidy up plus shake-0.16 compatibility (#392)

* Switch from @ to @echo off in the batch files

* Make sure the .bat files do setlocal - ensures if it fails you don't keep the directory change

* Give RuleResult instances to all the oracles, as required by the forthcoming shake-0.16
parent 67ae38d6
@cd %~dp0
@mkdir bin 2> nul
@echo off
setlocal
cd %~dp0
mkdir bin 2> nul
@set ghcArgs=--make ^
-Wall ^
-fno-warn-name-shadowing ^
-XRecordWildCards ^
src\Main.hs ^
-threaded ^
-isrc ^
-i..\libraries\Cabal\Cabal ^
-rtsopts ^
-with-rtsopts=-I0 ^
-outputdir=bin ^
-j ^
-O ^
-o bin\hadrian
set ghcArgs=--make ^
-Wall ^
-fno-warn-name-shadowing ^
-XRecordWildCards ^
src\Main.hs ^
-threaded ^
-isrc ^
-i..\libraries\Cabal\Cabal ^
-rtsopts ^
-with-rtsopts=-I0 ^
-outputdir=bin ^
-j ^
-O ^
-o bin\hadrian
@set hadrianArgs=--lint ^
--directory ^
".." ^
%*
set hadrianArgs=--lint ^
--directory ^
".." ^
%*
@ghc %ghcArgs%
ghc %ghcArgs%
@if %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
if %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
@rem Unset GHC_PACKAGE_PATH variable, as otherwise ghc-cabal complains
@set GHC_PACKAGE_PATH=
@bin\hadrian %hadrianArgs%
rem Unset GHC_PACKAGE_PATH variable, as otherwise ghc-cabal complains
set GHC_PACKAGE_PATH=
bin\hadrian %hadrianArgs%
@rem Change the current directory to the one containing this script
@cd %~dp0
@echo off
setlocal
rem Change the current directory to the one containing this script
cd %~dp0
@rem Build Hadrian and dependencies and exit the script if the build failed
@stack build
@if %errorlevel% neq 0 exit /B %errorlevel%
rem Build Hadrian and dependencies and exit the script if the build failed
stack build
if %errorlevel% neq 0 exit /B %errorlevel%
@rem Run Hadrian in GHC top directory forwarding additional user arguments
@stack exec hadrian -- --lint --directory ".." %*
rem Run Hadrian in GHC top directory forwarding additional user arguments
stack exec hadrian -- --lint --directory ".." %*
{-# LANGUAGE TypeFamilies #-}
module Hadrian.Oracles.ArgsHash (
TrackArgument, trackAllArguments, trackArgsHash, argsHashOracle
) where
......@@ -8,6 +9,7 @@ import Development.Shake.Classes
import Hadrian.Expression hiding (inputs, outputs)
import Hadrian.Target
import Hadrian.Utilities
-- | 'TrackArgument' is used to specify the arguments that should be tracked by
-- the @ArgsHash@ oracle. The safest option is to track all arguments, but some
......@@ -38,6 +40,7 @@ trackArgsHash t = do
newtype ArgsHash c b = ArgsHash (Target c b)
deriving (Binary, Eq, Hashable, NFData, Show, Typeable)
type instance RuleResult (ArgsHash c b) = Int
-- | This oracle stores per-target argument list hashes in the Shake database,
-- allowing the user to track them between builds using 'trackArgsHash' queries.
......
{-# LANGUAGE TypeFamilies #-}
module Hadrian.Oracles.DirectoryContents (
directoryContents, copyDirectoryContents, directoryContentsOracle,
Match (..), matches, matchAll
......@@ -46,6 +47,7 @@ copyDirectoryContents expr source target = do
newtype DirectoryContents = DirectoryContents (Match, FilePath)
deriving (Binary, Eq, Hashable, NFData, Show, Typeable)
type instance RuleResult DirectoryContents = [FilePath]
-- | This oracle answers 'directoryContents' queries and tracks the results.
directoryContentsOracle :: Rules ()
......
{-# LANGUAGE TypeFamilies #-}
-----------------------------------------------------------------------------
-- |
-- Module : Hadrian.Oracles.FileCache
......@@ -22,6 +23,7 @@ import Hadrian.Utilities
newtype FileCache = FileCache FilePath
deriving (Binary, Eq, Hashable, NFData, Show, Typeable)
type instance RuleResult FileCache = String
-- | Read a text file, caching and tracking the result. To read and track
-- individual lines of the file, see "Hadrian.Oracles.KeyValue".
......
{-# LANGUAGE TypeFamilies #-}
module Hadrian.Oracles.KeyValue (
lookupValue, lookupValueOrEmpty, lookupValueOrError, lookupValues,
lookupValuesOrEmpty, lookupValuesOrError, lookupDependencies, keyValueOracle
......@@ -14,9 +15,11 @@ import Hadrian.Utilities
newtype KeyValue = KeyValue (FilePath, String)
deriving (Binary, Eq, Hashable, NFData, Show, Typeable)
type instance RuleResult KeyValue = Maybe String
newtype KeyValues = KeyValues (FilePath, String)
deriving (Binary, Eq, Hashable, NFData, Show, Typeable)
type instance RuleResult KeyValues = Maybe [String]
-- | Lookup a value in a text file, tracking the result. Each line of the file
-- is expected to have @key = value@ format.
......
{-# LANGUAGE TypeFamilies #-}
module Hadrian.Oracles.Path (
lookupInPath, bashPath, fixAbsolutePathOnWindows, pathOracle
) where
......@@ -39,9 +40,11 @@ fixAbsolutePathOnWindows path = do
newtype LookupInPath = LookupInPath String
deriving (Binary, Eq, Hashable, NFData, Show, Typeable)
type instance RuleResult LookupInPath = String
newtype WindowsPath = WindowsPath FilePath
deriving (Binary, Eq, Hashable, NFData, Show, Typeable)
type instance RuleResult WindowsPath = String
-- | Oracles for looking up paths. These are slow and require caching.
pathOracle :: Rules ()
......
{-# LANGUAGE TypeFamilies #-}
module Hadrian.Utilities (
-- * List manipulation
fromSingleton, replaceEq, minusOrd, intersectOrd, lookupAll,
......@@ -24,6 +25,9 @@ module Hadrian.Utilities (
putProgressInfo, renderAction, renderProgram, renderLibrary, renderBox,
renderUnicorn,
-- * Shake compatibility
RuleResult,
-- * Miscellaneous
(<&>), (%%>),
......@@ -156,6 +160,9 @@ buildRoot = do
infixl 1 <&>
-- | Introduced in shake-0.16, so use to make the rest of the code compatible
type family RuleResult a
-- | Given a 'FilePath' to a source file, return 'True' if it is generated.
-- The current implementation simply assumes that a file is generated if it
-- lives in the 'buildRoot' directory. Since most files are not generated the
......
{-# LANGUAGE TypeFamilies #-}
module Oracles.ModuleFiles (
decodeModule, encodeModule, findGenerator, hsSources, hsObjects, moduleFilesOracle
) where
......@@ -11,9 +12,11 @@ import Oracles.PackageData
newtype ModuleFiles = ModuleFiles (Stage, Package)
deriving (Binary, Eq, Hashable, NFData, Show, Typeable)
type instance RuleResult ModuleFiles = [Maybe FilePath]
newtype Generator = Generator (Stage, Package, FilePath)
deriving (Binary, Eq, Hashable, NFData, Show, Typeable)
type instance RuleResult Generator = Maybe FilePath
-- | We scan for the following Haskell source extensions when looking for module
-- files. Note, we do not list "*.(l)hs-boot" files here, as they can never
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment