Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove stringsearch dependency #2765

Merged
merged 1 commit into from
Jul 26, 2024
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
1 change: 1 addition & 0 deletions changelog/2024-07-21T16_46_47+02_00_remove_stringsearch
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FIXED: Removed `stringsearch` dependency from `v16-upgrade-primitives`. See [#2726](https://github.com/clash-lang/clash-compiler/issues/2726)
2 changes: 1 addition & 1 deletion clash-lib/clash-lib.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,9 @@ executable v16-upgrade-primitives
yaml,
bytestring,
clash-lib,
text,
containers,
directory,
stringsearch,
Glob
GHC-Options: -Wall -Wcompat
default-language: Haskell2010
Expand Down
8 changes: 5 additions & 3 deletions clash-lib/tools/v16-upgrade-primitives.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ module Main where

#if MIN_VERSION_aeson(2,0,0)
import qualified Data.Aeson.KeyMap as Aeson
import Data.ByteString.Lazy.Search (replace)
import Data.String (IsString)
import qualified Data.Text.Lazy as LazyText
import qualified Data.Text.Lazy.Encoding as LazyText
#endif

import qualified Data.Aeson.Extra as AesonExtra
Expand Down Expand Up @@ -89,9 +90,10 @@ customSortOutput x = case x of
Just val -> Aeson.insert kNew val (Aeson.delete kOld obj)

removeTempKey :: ByteString -> ByteString
removeTempKey inp = foldl go inp keySortingRenames
removeTempKey inp =
LazyText.encodeUtf8 (foldl go (LazyText.decodeUtf8 inp) keySortingRenames)
where
go bs (orig,temp) = replace (ByteString.toStrict temp) orig bs
go txt (orig,temp) = LazyText.replace temp orig txt
#else
-- < aeson-2.0 stores keys in HashMaps, whose order we can't possibly predict.
removeTempKey :: ByteString -> ByteString
Expand Down