blucontrol 0.2.0.0 → 0.2.1.0
raw patch · 4 files changed
+40/−17 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- blucontrol.cabal +3/−2
- src/Blucontrol/Main/CLI.hs +21/−15
- src/Blucontrol/Main/GHC/Internal.hs +11/−0
CHANGELOG.md view
@@ -1,5 +1,10 @@ # Revision history for blucontrol +## 0.2.1.0 -- 2020-08-12++* Compile user config only when it has been modified.+* New internal module `Blucontrol.Main.GHC.Internal` for setting ghc flags.+ ## 0.2.0.0 -- 2020-08-10 * Rename the whole application from bludigon to blucontrol.
blucontrol.cabal view
@@ -1,5 +1,5 @@ name: blucontrol-version: 0.2.0.0+version: 0.2.1.0 synopsis: Configurable blue light filter description: This application is a blue light filter, with the main focus on configurability.@@ -41,7 +41,8 @@ Blucontrol.Recolor.X Blucontrol.RGB Blucontrol.RGB.Temperature- other-modules: Blucontrol.Recolor.X.Internal+ other-modules: Blucontrol.Main.GHC.Internal+ Blucontrol.Recolor.X.Internal Paths_blucontrol build-depends: base >= 4.11 && < 5 , containers >= 0.6.2.1 && < 0.7
src/Blucontrol/Main/CLI.hs view
@@ -3,10 +3,11 @@ ) where import Control.DeepSeq+import Control.Monad (when) import Data.Version (showVersion) import GHC.Generics import System.Console.GetOpt-import System.Directory (XdgDirectory (..), createDirectoryIfMissing, doesFileExist, getXdgDirectory)+import System.Directory (XdgDirectory (..), createDirectoryIfMissing, doesFileExist, getModificationTime, getXdgDirectory) import System.Environment (getArgs, getProgName) import System.Exit (ExitCode (..), exitFailure, exitSuccess) import System.FilePath ((</>))@@ -14,6 +15,7 @@ import System.Posix.Process (executeFile) import System.Process (runProcess, waitForProcess) +import Blucontrol.Main.GHC.Internal import Paths_blucontrol (version) data Flag = Help@@ -61,27 +63,31 @@ build = do configPath <- (</> configLeafname) <$> getXdgDir XdgConfig configExists <- doesFileExist configPath- if configExists- then do progName <- getProgName- if progName == compiledConfigLeafname- then return ()- else do compile- cacheDir <- getXdgDir XdgCache- executeFile (cacheDir </> compiledConfigLeafname) False [] Nothing- else return ()+ when configExists $ do+ progName <- getProgName+ compiledConfigPath <- (</> compiledConfigLeafname) <$> getXdgDir XdgCache+ if progName == compiledConfigLeafname+ then do configTime <- getModificationTime configPath -- TODO: getModificationTime can fail+ compiledConfigTime <- getModificationTime compiledConfigPath+ when (configTime > compiledConfigTime) $ do+ compile+ executeFile compiledConfigPath False [] Nothing+ else do compile+ executeFile compiledConfigPath False [] Nothing compile :: IO () compile = do configDir <- getXdgDir XdgConfig cacheDir <- getXdgDir XdgCache createDirectoryIfMissing False cacheDir+ let ghcFlags = [ "--make"+ , configLeafname+ , "-main-is", "main"+ , "-v0"+ , "-o", cacheDir </> compiledConfigLeafname+ ] <> ghcAdditionalFlags status <- waitForProcess =<<- runProcess "ghc" [ "--make"- , configLeafname- , "-main-is", "main"- , "-v0"- , "-o", cacheDir </> compiledConfigLeafname- ] (Just configDir) Nothing Nothing Nothing Nothing+ runProcess ghcBinary ghcFlags (Just configDir) Nothing Nothing Nothing Nothing case status of ExitSuccess -> return () ExitFailure _ -> exitFailure
+ src/Blucontrol/Main/GHC/Internal.hs view
@@ -0,0 +1,11 @@+module Blucontrol.Main.GHC.Internal (+ ghcBinary+, ghcAdditionalFlags+) where++ghcBinary :: String+ghcBinary = "ghc"++ghcAdditionalFlags :: [String]+ghcAdditionalFlags = [+ ]