Skip to content

Commit 18d8cb1

Browse files
committed
WIP: clash-ghc: Fixup files for formatting compatibility
1 parent 58f6995 commit 18d8cb1

File tree

16 files changed

+153
-74
lines changed

16 files changed

+153
-74
lines changed

clash-ghc/src-bin-8.10/Clash/GHCi/UI.hs

+8-3
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,13 @@ default_prompt_cont = generatePromptFunctionFromString "%s| "
454454
default_args :: [String]
455455
default_args = []
456456

457+
setEncodingUtf8mingw :: IO ()
458+
#if defined(mingw32_HOST_OS)
459+
setEncodingUtf8mingw = hSetEncoding stdin utf8
460+
#else
461+
setEncodingUtf8mingw = pure ()
462+
#endif
463+
457464
interactiveUI :: GhciSettings -> [(FilePath, Maybe Phase)] -> Maybe [String]
458465
-> Ghc ()
459466
interactiveUI config srcs maybe_exprs = do
@@ -504,12 +511,10 @@ interactiveUI config srcs maybe_exprs = do
504511
-- intended for the program, so unbuffer stdin.
505512
liftIO $ hSetBuffering stdin NoBuffering
506513
liftIO $ hSetBuffering stderr NoBuffering
507-
#if defined(mingw32_HOST_OS)
508514
-- On Unix, stdin will use the locale encoding. The IO library
509515
-- doesn't do this on Windows (yet), so for now we use UTF-8,
510516
-- for consistency with GHC 6.10 and to make the tests work.
511-
liftIO $ hSetEncoding stdin utf8
512-
#endif
517+
liftIO setEncodingUtf8mingw
513518

514519
default_editor <- liftIO $ findEditor
515520
eval_wrapper <- mkEvalWrapper default_progname default_args

clash-ghc/src-bin-8.10/Clash/Main.hs

+17-10
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@ defaultMainWithAction startAction = flip withArgs $ do
186186
Right postLoadMode ->
187187
main' postLoadMode dflagsExtra1 argv3 flagWarnings startAction r
188188

189+
strt_dot_sl :: String -> Bool
190+
#if defined(mingw32_HOST_OS)
191+
strt_dot_sl fp = "./" `isPrefixOf` fp || ".\\" `isPrefixOf` fp
192+
#else
193+
strt_dot_sl fp = "./" `isPrefixOf` fp
194+
#endif
195+
189196
main' :: PostLoadMode -> DynFlags -> [Located String] -> [Warn]
190197
-> Ghc ()
191198
-> IORef ClashOpts
@@ -274,14 +281,9 @@ main' postLoadMode dflags0 args flagWarnings startAction clashOpts = do
274281
-- #12674: Filenames starting with a hypen get normalised from ./-foo.hs
275282
-- to -foo.hs. We have to re-prepend the current directory.
276283
normalise_hyp fp
277-
| strt_dot_sl && "-" `isPrefixOf` nfp = cur_dir ++ nfp
284+
| strt_dot_sl fp && "-" `isPrefixOf` nfp = cur_dir ++ nfp
278285
| otherwise = nfp
279286
where
280-
#if defined(mingw32_HOST_OS)
281-
strt_dot_sl = "./" `isPrefixOf` fp || ".\\" `isPrefixOf` fp
282-
#else
283-
strt_dot_sl = "./" `isPrefixOf` fp
284-
#endif
285287
cur_dir = '.' : [pathSeparator]
286288
nfp = normalise fp
287289
normal_fileish_paths = map (normalise_hyp . unLoc) fileish_args
@@ -828,14 +830,19 @@ doShowIface dflags file = do
828830
-- ---------------------------------------------------------------------------
829831
-- Various banners and verbosity output.
830832

833+
-- Show the GHCi banner
834+
showGhciWelcomeMsg :: IO ()
835+
#if defined(HAVE_INTERNAL_INTERPRETER)
836+
showGhciWelcomeMsg = putStrLn ghciWelcomeMsg
837+
#else
838+
showGhciWelcomeMsg = pure ()
839+
#endif
840+
831841
showBanner :: PostLoadMode -> DynFlags -> IO ()
832842
showBanner _postLoadMode dflags = do
833843
let verb = verbosity dflags
834844

835-
#if defined(HAVE_INTERNAL_INTERPRETER)
836-
-- Show the GHCi banner
837-
when (isInteractiveMode _postLoadMode && verb >= 1) $ putStrLn ghciWelcomeMsg
838-
#endif
845+
when (isInteractiveMode _postLoadMode && verb >= 1) showGhciWelcomeMsg
839846

840847
-- Display details of the configuration in verbose mode
841848
when (verb >= 2) $

clash-ghc/src-bin-9.0/Clash/GHCi/UI.hs

+8-3
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,13 @@ default_prompt_cont = generatePromptFunctionFromString "| "
460460
default_args :: [String]
461461
default_args = []
462462

463+
setEncodingUtf8mingw :: IO ()
464+
#if defined(mingw32_HOST_OS)
465+
setEncodingUtf8mingw = hSetEncoding stdin utf8
466+
#else
467+
setEncodingUtf8mingw = pure ()
468+
#endif
469+
463470
interactiveUI :: GhciSettings -> [(FilePath, Maybe Phase)] -> Maybe [String]
464471
-> Ghc ()
465472
interactiveUI config srcs maybe_exprs = do
@@ -510,12 +517,10 @@ interactiveUI config srcs maybe_exprs = do
510517
-- intended for the program, so unbuffer stdin.
511518
liftIO $ hSetBuffering stdin NoBuffering
512519
liftIO $ hSetBuffering stderr NoBuffering
513-
#if defined(mingw32_HOST_OS)
514520
-- On Unix, stdin will use the locale encoding. The IO library
515521
-- doesn't do this on Windows (yet), so for now we use UTF-8,
516522
-- for consistency with GHC 6.10 and to make the tests work.
517-
liftIO $ hSetEncoding stdin utf8
518-
#endif
523+
liftIO setEncodingUtf8mingw
519524

520525
default_editor <- liftIO $ findEditor
521526
eval_wrapper <- mkEvalWrapper default_progname default_args

clash-ghc/src-bin-9.0/Clash/Main.hs

+17-10
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ defaultMainWithAction startAction = flip withArgs $ do
188188
Right postLoadMode ->
189189
main' postLoadMode dflagsExtra1 argv3 flagWarnings startAction r
190190

191+
strt_dot_sl :: String -> Bool
192+
#if defined(mingw32_HOST_OS)
193+
strt_dot_sl fp = "./" `isPrefixOf` fp || ".\\" `isPrefixOf` fp
194+
#else
195+
strt_dot_sl fp = "./" `isPrefixOf` fp
196+
#endif
197+
191198
main' :: PostLoadMode -> DynFlags -> [Located String] -> [Warn]
192199
-> Ghc () -> IORef ClashOpts
193200
-> Ghc ()
@@ -275,14 +282,9 @@ main' postLoadMode dflags0 args flagWarnings startAction clashOpts = do
275282
-- #12674: Filenames starting with a hypen get normalised from ./-foo.hs
276283
-- to -foo.hs. We have to re-prepend the current directory.
277284
normalise_hyp fp
278-
| strt_dot_sl && "-" `isPrefixOf` nfp = cur_dir ++ nfp
285+
| strt_dot_sl fp && "-" `isPrefixOf` nfp = cur_dir ++ nfp
279286
| otherwise = nfp
280287
where
281-
#if defined(mingw32_HOST_OS)
282-
strt_dot_sl = "./" `isPrefixOf` fp || ".\\" `isPrefixOf` fp
283-
#else
284-
strt_dot_sl = "./" `isPrefixOf` fp
285-
#endif
286288
cur_dir = '.' : [pathSeparator]
287289
nfp = normalise fp
288290
normal_fileish_paths = map (normalise_hyp . unLoc) fileish_args
@@ -829,14 +831,19 @@ doShowIface dflags file = do
829831
-- ---------------------------------------------------------------------------
830832
-- Various banners and verbosity output.
831833

834+
-- Show the GHCi banner
835+
showGhciWelcomeMsg :: IO ()
836+
#if defined(HAVE_INTERNAL_INTERPRETER)
837+
showGhciWelcomeMsg = putStrLn ghciWelcomeMsg
838+
#else
839+
showGhciWelcomeMsg = pure ()
840+
#endif
841+
832842
showBanner :: PostLoadMode -> DynFlags -> IO ()
833843
showBanner _postLoadMode dflags = do
834844
let verb = verbosity dflags
835845

836-
#if defined(HAVE_INTERNAL_INTERPRETER)
837-
-- Show the GHCi banner
838-
when (isInteractiveMode _postLoadMode && verb >= 1) $ putStrLn ghciWelcomeMsg
839-
#endif
846+
when (isInteractiveMode _postLoadMode && verb >= 1) showGhciWelcomeMsg
840847

841848
-- Display details of the configuration in verbose mode
842849
when (verb >= 2) $

clash-ghc/src-bin-9.2/Clash/GHCi/UI.hs

+8-3
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,13 @@ default_prompt_cont = generatePromptFunctionFromString "clashi| "
481481
default_args :: [String]
482482
default_args = []
483483

484+
setEncodingUtf8mingw :: IO ()
485+
#if defined(mingw32_HOST_OS)
486+
setEncodingUtf8mingw = hSetEncoding stdin utf8
487+
#else
488+
setEncodingUtf8mingw = pure ()
489+
#endif
490+
484491
interactiveUI :: GhciSettings -> [(FilePath, Maybe Phase)] -> Maybe [String]
485492
-> Ghc ()
486493
interactiveUI config srcs maybe_exprs = do
@@ -528,12 +535,10 @@ interactiveUI config srcs maybe_exprs = do
528535
-- intended for the program, so unbuffer stdin.
529536
liftIO $ hSetBuffering stdin NoBuffering
530537
liftIO $ hSetBuffering stderr NoBuffering
531-
#if defined(mingw32_HOST_OS)
532538
-- On Unix, stdin will use the locale encoding. The IO library
533539
-- doesn't do this on Windows (yet), so for now we use UTF-8,
534540
-- for consistency with GHC 6.10 and to make the tests work.
535-
liftIO $ hSetEncoding stdin utf8
536-
#endif
541+
liftIO setEncodingUtf8mingw
537542

538543
default_editor <- liftIO $ findEditor
539544
eval_wrapper <- mkEvalWrapper default_progname default_args

clash-ghc/src-bin-9.2/Clash/Main.hs

+9-4
Original file line numberDiff line numberDiff line change
@@ -780,14 +780,19 @@ doMake srcs = do
780780
-- ---------------------------------------------------------------------------
781781
-- Various banners and verbosity output.
782782

783+
-- Show the GHCi banner
784+
showGhciWelcomeMsg :: IO ()
785+
#if defined(HAVE_INTERNAL_INTERPRETER)
786+
showGhciWelcomeMsg = putStrLn ghciWelcomeMsg
787+
#else
788+
showGhciWelcomeMsg = pure ()
789+
#endif
790+
783791
showBanner :: PostLoadMode -> DynFlags -> IO ()
784792
showBanner _postLoadMode dflags = do
785793
let verb = verbosity dflags
786794

787-
#if defined(HAVE_INTERNAL_INTERPRETER)
788-
-- Show the GHCi banner
789-
when (isInteractiveMode _postLoadMode && verb >= 1) $ putStrLn ghciWelcomeMsg
790-
#endif
795+
when (isInteractiveMode _postLoadMode && verb >= 1) showGhciWelcomeMsg
791796

792797
-- Display details of the configuration in verbose mode
793798
when (verb >= 2) $

clash-ghc/src-bin-9.4/Clash/GHCi/UI.hs

+8-3
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,13 @@ default_prompt_cont = generatePromptFunctionFromString "clashi| "
503503
default_args :: [String]
504504
default_args = []
505505

506+
setEncodingUtf8mingw :: IO ()
507+
#if defined(mingw32_HOST_OS)
508+
setEncodingUtf8mingw = hSetEncoding stdin utf8
509+
#else
510+
setEncodingUtf8mingw = pure ()
511+
#endif
512+
506513
interactiveUI :: GhciSettings -> [(FilePath, Maybe UnitId, Maybe Phase)] -> Maybe [String]
507514
-> Ghc ()
508515
interactiveUI config srcs maybe_exprs = do
@@ -557,12 +564,10 @@ interactiveUI config srcs maybe_exprs = do
557564
-- intended for the program, so unbuffer stdin.
558565
liftIO $ hSetBuffering stdin NoBuffering
559566
liftIO $ hSetBuffering stderr NoBuffering
560-
#if defined(mingw32_HOST_OS)
561567
-- On Unix, stdin will use the locale encoding. The IO library
562568
-- doesn't do this on Windows (yet), so for now we use UTF-8,
563569
-- for consistency with GHC 6.10 and to make the tests work.
564-
liftIO $ hSetEncoding stdin utf8
565-
#endif
570+
liftIO setEncodingUtf8mingw
566571

567572
default_editor <- liftIO $ findEditor
568573
eval_wrapper <- mkEvalWrapper default_progname default_args

clash-ghc/src-bin-9.4/Clash/Main.hs

+9-4
Original file line numberDiff line numberDiff line change
@@ -1003,14 +1003,19 @@ createUnitEnvFromFlags unitDflags =
10031003
-- ---------------------------------------------------------------------------
10041004
-- Various banners and verbosity output.
10051005

1006+
-- Show the GHCi banner
1007+
showGhciWelcomeMsg :: IO ()
1008+
#if defined(HAVE_INTERNAL_INTERPRETER)
1009+
showGhciWelcomeMsg = putStrLn ghciWelcomeMsg
1010+
#else
1011+
showGhciWelcomeMsg = pure ()
1012+
#endif
1013+
10061014
showBanner :: PostLoadMode -> DynFlags -> IO ()
10071015
showBanner _postLoadMode dflags = do
10081016
let verb = verbosity dflags
10091017

1010-
#if defined(HAVE_INTERNAL_INTERPRETER)
1011-
-- Show the GHCi banner
1012-
when (isInteractiveMode _postLoadMode && verb >= 1) $ putStrLn ghciWelcomeMsg
1013-
#endif
1018+
when (isInteractiveMode _postLoadMode && verb >= 1) showGhciWelcomeMsg
10141019

10151020
-- Display details of the configuration in verbose mode
10161021
when (verb >= 2) $

clash-ghc/src-bin-9.6/Clash/GHCi/UI.hs

+9-3
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,13 @@ default_prompt_cont = generatePromptFunctionFromString "clashi| "
520520
default_args :: [String]
521521
default_args = []
522522

523+
setEncodingUtf8mingw :: IO ()
524+
#if defined(mingw32_HOST_OS)
525+
setEncodingUtf8mingw = hSetEncoding stdin utf8
526+
#else
527+
setEncodingUtf8mingw = pure ()
528+
#endif
529+
523530
interactiveUI :: GhciSettings -> [(FilePath, Maybe UnitId, Maybe Phase)] -> Maybe [String]
524531
-> Ghc ()
525532
interactiveUI config srcs maybe_exprs = do
@@ -574,12 +581,11 @@ interactiveUI config srcs maybe_exprs = do
574581
-- intended for the program, so unbuffer stdin.
575582
liftIO $ hSetBuffering stdin NoBuffering
576583
liftIO $ hSetBuffering stderr NoBuffering
577-
#if defined(mingw32_HOST_OS)
584+
578585
-- On Unix, stdin will use the locale encoding. The IO library
579586
-- doesn't do this on Windows (yet), so for now we use UTF-8,
580587
-- for consistency with GHC 6.10 and to make the tests work.
581-
liftIO $ hSetEncoding stdin utf8
582-
#endif
588+
liftIO setEncodingUtf8mingw
583589

584590
default_editor <- liftIO $ findEditor
585591
eval_wrapper <- mkEvalWrapper default_progname default_args

clash-ghc/src-bin-9.6/Clash/Main.hs

+9-4
Original file line numberDiff line numberDiff line change
@@ -1016,14 +1016,19 @@ createUnitEnvFromFlags unitDflags =
10161016
-- ---------------------------------------------------------------------------
10171017
-- Various banners and verbosity output.
10181018

1019+
-- Show the GHCi banner
1020+
showGhciWelcomeMsg :: IO ()
1021+
#if defined(HAVE_INTERNAL_INTERPRETER)
1022+
showGhciWelcomeMsg = putStrLn ghciWelcomeMsg
1023+
#else
1024+
showGhciWelcomeMsg = pure ()
1025+
#endif
1026+
10191027
showBanner :: PostLoadMode -> DynFlags -> IO ()
10201028
showBanner _postLoadMode dflags = do
10211029
let verb = verbosity dflags
10221030

1023-
#if defined(HAVE_INTERNAL_INTERPRETER)
1024-
-- Show the GHCi banner
1025-
when (isInteractiveMode _postLoadMode && verb >= 1) $ putStrLn ghciWelcomeMsg
1026-
#endif
1031+
when (isInteractiveMode _postLoadMode && verb >= 1) showGhciWelcomeMsg
10271032

10281033
-- Display details of the configuration in verbose mode
10291034
when (verb >= 2) $

clash-ghc/src-bin-9.8/Clash/GHCi/UI.hs

+9-3
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,13 @@ default_prompt_cont = generatePromptFunctionFromString "clashi| "
516516
default_args :: [String]
517517
default_args = []
518518

519+
setEncodingUtf8mingw :: IO ()
520+
#if defined(mingw32_HOST_OS)
521+
setEncodingUtf8mingw = hSetEncoding stdin utf8
522+
#else
523+
setEncodingUtf8mingw = pure ()
524+
#endif
525+
519526
interactiveUI :: GhciSettings -> [(FilePath, Maybe UnitId, Maybe Phase)] -> Maybe [String]
520527
-> Ghc ()
521528
interactiveUI config srcs maybe_exprs = do
@@ -570,12 +577,11 @@ interactiveUI config srcs maybe_exprs = do
570577
-- intended for the program, so unbuffer stdin.
571578
liftIO $ hSetBuffering stdin NoBuffering
572579
liftIO $ hSetBuffering stderr NoBuffering
573-
#if defined(mingw32_HOST_OS)
580+
574581
-- On Unix, stdin will use the locale encoding. The IO library
575582
-- doesn't do this on Windows (yet), so for now we use UTF-8,
576583
-- for consistency with GHC 6.10 and to make the tests work.
577-
liftIO $ hSetEncoding stdin utf8
578-
#endif
584+
liftIO setEncodingUtf8mingw
579585

580586
default_editor <- liftIO $ findEditor
581587
eval_wrapper <- mkEvalWrapper default_progname default_args

clash-ghc/src-bin-9.8/Clash/Main.hs

+9-4
Original file line numberDiff line numberDiff line change
@@ -1015,14 +1015,19 @@ createUnitEnvFromFlags unitDflags =
10151015
-- ---------------------------------------------------------------------------
10161016
-- Various banners and verbosity output.
10171017

1018+
-- Show the GHCi banner
1019+
showGhciWelcomeMsg :: IO ()
1020+
#if defined(HAVE_INTERNAL_INTERPRETER)
1021+
showGhciWelcomeMsg = putStrLn ghciWelcomeMsg
1022+
#else
1023+
showGhciWelcomeMsg = pure ()
1024+
#endif
1025+
10181026
showBanner :: PostLoadMode -> DynFlags -> IO ()
10191027
showBanner _postLoadMode dflags = do
10201028
let verb = verbosity dflags
10211029

1022-
#if defined(HAVE_INTERNAL_INTERPRETER)
1023-
-- Show the GHCi banner
1024-
when (isInteractiveMode _postLoadMode && verb >= 1) $ putStrLn ghciWelcomeMsg
1025-
#endif
1030+
when (isInteractiveMode _postLoadMode && verb >= 1) showGhciWelcomeMsg
10261031

10271032
-- Display details of the configuration in verbose mode
10281033
when (verb >= 2) $

clash-ghc/src-ghc/Clash/GHC/ClashFlags.hs

+9-5
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,18 @@ parseClashFlags :: IORef ClashOpts -> [Located String]
4343
-> IO ([Located String],[Warn])
4444
parseClashFlags r = parseClashFlagsFull (flagsClash r)
4545

46-
parseClashFlagsFull :: [Flag IO] -> [Located String]
47-
-> IO ([Located String],[Warn])
48-
parseClashFlagsFull flagsAvialable args = do
49-
(leftovers,errs,warns) <- processArgs flagsAvialable args
46+
processGhcArgs :: [Flag IO] -> [Located String] -> IO ([Located String], [Err], [Warn])
5047
#if MIN_VERSION_ghc(9,4,0)
51-
parseResponseFile
48+
processGhcArgs flagsAvailable args = processArgs flagsAvailable args parseResponseFile
49+
#else
50+
processGhcArgs flagsAvailable args = processArgs flagsAvailable args
5251
#endif
5352

53+
parseClashFlagsFull :: [Flag IO] -> [Located String]
54+
-> IO ([Located String],[Warn])
55+
parseClashFlagsFull flagsAvailable args = do
56+
(leftovers,errs,warns) <- processGhcArgs flagsAvailable args
57+
5458
unless (null errs) $ throwGhcExceptionIO $
5559
errorsToGhcException . map (("on the commandline", ) . unLoc . errMsg)
5660
$ errs

0 commit comments

Comments
 (0)