From 56a7b739d2812389691d825758f2c8fc831c8f76 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Wed, 24 Nov 2021 14:16:17 +0000 Subject: [PATCH 1/3] [hls-graph] fix build with embed-files flag --- .../Development/IDE/Graph/Internal/Paths.hs | 40 ++++++------------- .../Development/IDE/Graph/Internal/Profile.hs | 4 +- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/hls-graph/src/Development/IDE/Graph/Internal/Paths.hs b/hls-graph/src/Development/IDE/Graph/Internal/Paths.hs index 9d8da59273..68ce31be67 100644 --- a/hls-graph/src/Development/IDE/Graph/Internal/Paths.hs +++ b/hls-graph/src/Development/IDE/Graph/Internal/Paths.hs @@ -1,31 +1,26 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE TemplateHaskell #-} -module Development.IDE.Graph.Internal.Paths (getDataFile) where - -import Paths_hls_graph +module Development.IDE.Graph.Internal.Paths (readDataFileHTML) where #ifndef FILE_EMBED -import Control.Exception (SomeException (SomeException), catch) -import Control.Monad (filterM) -import System.Directory (doesFileExist, getCurrentDirectory) -import System.Environment (getExecutablePath) -import System.FilePath (takeDirectory, ()) -import System.IO.Unsafe (unsafePerformIO) +import Control.Exception (SomeException (SomeException), catch) +import Control.Monad (filterM) +import Paths_hls_graph +import System.Directory (doesFileExist, getCurrentDirectory) +import System.Environment (getExecutablePath) +import System.FilePath (takeDirectory, ()) +import System.IO.Unsafe (unsafePerformIO) #endif #ifdef FILE_EMBED -import qualified Data.ByteString as BS -import qualified Data.ByteString as LBS +import qualified Data.ByteString as BS +import qualified Data.ByteString.Lazy as LBS import Data.FileEmbed -initDataDirectory :: IO () -initDataDirectory = pure () - htmlDataFiles :: [(FilePath, BS.ByteString)] htmlDataFiles = [ ("profile.html", $(embedFile "html/profile.html")) - , ("progress.html", $(embedFile "html/progress.html")) , ("shake.js", $(embedFile "html/shake.js")) ] @@ -35,18 +30,6 @@ readDataFileHTML file = do Nothing -> fail $ "Could not find data file " ++ file ++ " in embedded data files!" Just x -> pure (LBS.fromStrict x) -manualDirData :: [(FilePath, BS.ByteString)] -manualDirData = $(embedDir "docs/manual") - -hasManualData :: IO Bool -hasManualData = pure True - -copyManualData :: FilePath -> IO () -copyManualData dest = do - createDirectoryRecursive dest - forM_ manualDirData $ \(file, bs) -> do - BS.writeFile (dest file) bs - #else -- We want getDataFileName to be relative to the current directory on program startup, -- even if we issue a change directory command. Therefore, first call caches, future ones read. @@ -68,4 +51,7 @@ getDataFile file = do [] -> fail $ unlines $ ("Could not find data file " ++ file ++ ", looked in:") : map (" " ++) poss x:_ -> pure x +readDataFileHTML :: FilePath -> IO LBS.ByteString +readDataFileHTML file = LBS.readFile =<< getDataFile ("html" file) + #endif diff --git a/hls-graph/src/Development/IDE/Graph/Internal/Profile.hs b/hls-graph/src/Development/IDE/Graph/Internal/Profile.hs index 86afdb47ae..e8f5af6a4d 100644 --- a/hls-graph/src/Development/IDE/Graph/Internal/Profile.hs +++ b/hls-graph/src/Development/IDE/Graph/Internal/Profile.hs @@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE ViewPatterns #-} {- HLINT ignore "Redundant bracket" -} -- a result of CPP expansion @@ -135,9 +136,6 @@ toReport db = do alwaysRerunResult :: Step -> Result alwaysRerunResult current = Result (Value $ toDyn "") (Step 0) (Step 0) current (ResultDeps []) 0 mempty -readDataFileHTML :: FilePath -> IO LBS.ByteString -readDataFileHTML file = LBS.readFile =<< getDataFile ("html" file) - generateHTML :: Maybe [Int] -> [ProfileEntry] -> IO LBS.ByteString generateHTML dirtyKeys xs = do report <- readDataFileHTML "profile.html" From c2b92070905c008e216f9407b69bb2673f5fccfc Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Wed, 24 Nov 2021 14:22:32 +0000 Subject: [PATCH 2/3] bump hls-graph version number --- hls-graph/hls-graph.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hls-graph/hls-graph.cabal b/hls-graph/hls-graph.cabal index e44d4f75d5..1fbac6533b 100644 --- a/hls-graph/hls-graph.cabal +++ b/hls-graph/hls-graph.cabal @@ -1,6 +1,6 @@ cabal-version: 2.4 name: hls-graph -version: 1.5.1.0 +version: 1.5.1.1 synopsis: Haskell Language Server internal graph API description: Please see the README on GitHub at From a8b8e3a278134092a429cb9ea5ef8cc79a94cd83 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Wed, 24 Nov 2021 15:42:55 +0000 Subject: [PATCH 3/3] fix build without the flag too --- hls-graph/src/Development/IDE/Graph/Internal/Paths.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hls-graph/src/Development/IDE/Graph/Internal/Paths.hs b/hls-graph/src/Development/IDE/Graph/Internal/Paths.hs index 68ce31be67..4cb56239bb 100644 --- a/hls-graph/src/Development/IDE/Graph/Internal/Paths.hs +++ b/hls-graph/src/Development/IDE/Graph/Internal/Paths.hs @@ -12,10 +12,10 @@ import System.Environment (getExecutablePath) import System.FilePath (takeDirectory, ()) import System.IO.Unsafe (unsafePerformIO) #endif +import qualified Data.ByteString.Lazy as LBS #ifdef FILE_EMBED import qualified Data.ByteString as BS -import qualified Data.ByteString.Lazy as LBS import Data.FileEmbed htmlDataFiles :: [(FilePath, BS.ByteString)]