Skip to content

Commit bd0046b

Browse files
authored
Fix hls-graph build with embed-files flag (#2395)
* [hls-graph] fix build with embed-files flag * bump hls-graph version number * fix build without the flag too
1 parent 4b7d139 commit bd0046b

File tree

3 files changed

+15
-31
lines changed

3 files changed

+15
-31
lines changed

Diff for: hls-graph/hls-graph.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.4
22
name: hls-graph
3-
version: 1.5.1.0
3+
version: 1.5.1.1
44
synopsis: Haskell Language Server internal graph API
55
description:
66
Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>
+13-27
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11
{-# LANGUAGE CPP #-}
22
{-# LANGUAGE TemplateHaskell #-}
33

4-
module Development.IDE.Graph.Internal.Paths (getDataFile) where
5-
6-
import Paths_hls_graph
4+
module Development.IDE.Graph.Internal.Paths (readDataFileHTML) where
75

86
#ifndef FILE_EMBED
9-
import Control.Exception (SomeException (SomeException), catch)
10-
import Control.Monad (filterM)
11-
import System.Directory (doesFileExist, getCurrentDirectory)
12-
import System.Environment (getExecutablePath)
13-
import System.FilePath (takeDirectory, (</>))
14-
import System.IO.Unsafe (unsafePerformIO)
7+
import Control.Exception (SomeException (SomeException), catch)
8+
import Control.Monad (filterM)
9+
import Paths_hls_graph
10+
import System.Directory (doesFileExist, getCurrentDirectory)
11+
import System.Environment (getExecutablePath)
12+
import System.FilePath (takeDirectory, (</>))
13+
import System.IO.Unsafe (unsafePerformIO)
1514
#endif
15+
import qualified Data.ByteString.Lazy as LBS
1616

1717
#ifdef FILE_EMBED
18-
import qualified Data.ByteString as BS
19-
import qualified Data.ByteString as LBS
18+
import qualified Data.ByteString as BS
2019
import Data.FileEmbed
2120

22-
initDataDirectory :: IO ()
23-
initDataDirectory = pure ()
24-
2521
htmlDataFiles :: [(FilePath, BS.ByteString)]
2622
htmlDataFiles =
2723
[ ("profile.html", $(embedFile "html/profile.html"))
28-
, ("progress.html", $(embedFile "html/progress.html"))
2924
, ("shake.js", $(embedFile "html/shake.js"))
3025
]
3126

@@ -35,18 +30,6 @@ readDataFileHTML file = do
3530
Nothing -> fail $ "Could not find data file " ++ file ++ " in embedded data files!"
3631
Just x -> pure (LBS.fromStrict x)
3732

38-
manualDirData :: [(FilePath, BS.ByteString)]
39-
manualDirData = $(embedDir "docs/manual")
40-
41-
hasManualData :: IO Bool
42-
hasManualData = pure True
43-
44-
copyManualData :: FilePath -> IO ()
45-
copyManualData dest = do
46-
createDirectoryRecursive dest
47-
forM_ manualDirData $ \(file, bs) -> do
48-
BS.writeFile (dest </> file) bs
49-
5033
#else
5134
-- We want getDataFileName to be relative to the current directory on program startup,
5235
-- even if we issue a change directory command. Therefore, first call caches, future ones read.
@@ -68,4 +51,7 @@ getDataFile file = do
6851
[] -> fail $ unlines $ ("Could not find data file " ++ file ++ ", looked in:") : map (" " ++) poss
6952
x:_ -> pure x
7053

54+
readDataFileHTML :: FilePath -> IO LBS.ByteString
55+
readDataFileHTML file = LBS.readFile =<< getDataFile ("html" </> file)
56+
7157
#endif

Diff for: hls-graph/src/Development/IDE/Graph/Internal/Profile.hs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE CPP #-}
22
{-# LANGUAGE RecordWildCards #-}
3+
{-# LANGUAGE TemplateHaskell #-}
34
{-# LANGUAGE ViewPatterns #-}
45

56
{- HLINT ignore "Redundant bracket" -} -- a result of CPP expansion
@@ -135,9 +136,6 @@ toReport db = do
135136
alwaysRerunResult :: Step -> Result
136137
alwaysRerunResult current = Result (Value $ toDyn "<alwaysRerun>") (Step 0) (Step 0) current (ResultDeps []) 0 mempty
137138

138-
readDataFileHTML :: FilePath -> IO LBS.ByteString
139-
readDataFileHTML file = LBS.readFile =<< getDataFile ("html" </> file)
140-
141139
generateHTML :: Maybe [Int] -> [ProfileEntry] -> IO LBS.ByteString
142140
generateHTML dirtyKeys xs = do
143141
report <- readDataFileHTML "profile.html"

0 commit comments

Comments
 (0)