Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/1138'
Browse files Browse the repository at this point in the history
  • Loading branch information
hasufell committed Dec 19, 2024
2 parents 9f66b41 + 175da25 commit 0c3b09b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cabal.project.release
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import: cabal.project.common

optimization: 2

-- The release project file always wants to build with -tar.
-- The tar flag is only there to circumvent complicated errors during
-- development, which sometimes happens due to libarchive.
-- The release project file always wants to build with -tar on the
-- platforms it supports (which are those it provides config.h files
-- for). The tar flag is only there to circumvent complicated errors
-- during development, which sometimes happens due to libarchive.
package ghcup
flags: +tui

Expand Down Expand Up @@ -32,3 +33,6 @@ elif os(freebsd)
xz -system-xz
package *
ghc-options: -split-sections
else
package ghcup
flags: +tar
1 change: 1 addition & 0 deletions lib-opt/GHCup/OptParse/ChangeLog.hs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ changelog ChangeLogOptions{..} runAppState runLogger = do
Darwin -> exec "open" [T.unpack $ decUTF8Safe $ serializeURIRef' uri] Nothing Nothing
Linux _ -> exec "xdg-open" [T.unpack $ decUTF8Safe $ serializeURIRef' uri] Nothing Nothing
FreeBSD -> exec "xdg-open" [T.unpack $ decUTF8Safe $ serializeURIRef' uri] Nothing Nothing
OpenBSD -> exec "xdg-open" [T.unpack $ decUTF8Safe $ serializeURIRef' uri] Nothing Nothing
Windows -> do
let args = "start \"\" " ++ (T.unpack $ decUTF8Safe $ serializeURIRef' uri)
c <- liftIO $ system $ args
Expand Down
10 changes: 10 additions & 0 deletions lib/GHCup/Platform.hs
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,17 @@ getPlatform = do
either (const Nothing) Just . versioning . decUTF8Safe'
<$> getFreeBSDVersion
pure $ PlatformResult { _platform = FreeBSD, _distroVersion = ver }
"openbsd" -> do
ver <-
either (const Nothing) Just . versioning . decUTF8Safe'
<$> getOpenBSDVersion
pure $ PlatformResult { _platform = OpenBSD, _distroVersion = ver }
"mingw32" -> pure PlatformResult { _platform = Windows, _distroVersion = Nothing }
what -> throwE $ NoCompatiblePlatform what
lift $ logDebug $ "Identified Platform as: " <> T.pack (prettyShow pfr)
pure pfr
where
getOpenBSDVersion = lift $ fmap _stdOut $ executeOut "uname" ["-r"] Nothing
getFreeBSDVersion = lift $ fmap _stdOut $ executeOut "freebsd-version" [] Nothing
getDarwinVersion = lift $ fmap _stdOut $ executeOut "sw_vers"
["-productVersion"]
Expand Down Expand Up @@ -306,6 +312,7 @@ getStackGhcBuilds PlatformResult{..} = do
[] -> []
_ -> L.intercalate "-" c)
libComponents
OpenBSD -> pure []
FreeBSD ->
case _distroVersion of
Just fVer
Expand Down Expand Up @@ -343,13 +350,16 @@ getStackOSKey PlatformRequest { .. } =
(A_64 , Darwin ) -> pure "macosx"
(A_32 , FreeBSD) -> pure "freebsd32"
(A_64 , FreeBSD) -> pure "freebsd64"
(A_32 , OpenBSD) -> pure "openbsd32"
(A_64 , OpenBSD) -> pure "openbsd64"
(A_32 , Windows) -> pure "windows32"
(A_64 , Windows) -> pure "windows64"
(A_ARM , Linux _) -> pure "linux-armv7"
(A_ARM64, Linux _) -> pure "linux-aarch64"
(A_Sparc, Linux _) -> pure "linux-sparc"
(A_ARM64, Darwin ) -> pure "macosx-aarch64"
(A_ARM64, FreeBSD) -> pure "freebsd-aarch64"
(A_ARM64, OpenBSD) -> pure "openbsd-aarch64"
(arch', os') -> throwE $ UnsupportedSetupCombo arch' os'

getStackPlatformKey :: (MonadReader env m, MonadFail m, HasLog env, MonadCatch m, MonadIO m)
Expand Down
2 changes: 2 additions & 0 deletions lib/GHCup/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ data Platform = Linux LinuxDistro
| Darwin
-- ^ must exit
| FreeBSD
| OpenBSD
| Windows
-- ^ must exit
deriving (Eq, GHC.Generic, Ord, Show)
Expand All @@ -240,6 +241,7 @@ platformToString :: Platform -> String
platformToString (Linux distro) = "linux-" ++ distroToString distro
platformToString Darwin = "darwin"
platformToString FreeBSD = "freebsd"
platformToString OpenBSD = "openbsd"
platformToString Windows = "windows"

instance Pretty Platform where
Expand Down
2 changes: 2 additions & 0 deletions lib/GHCup/Types/JSON.hs
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,14 @@ instance ToJSONKey Platform where
Darwin -> T.pack "Darwin"
FreeBSD -> T.pack "FreeBSD"
Linux d -> T.pack ("Linux_" <> show d)
OpenBSD -> T.pack "OpenBSD"
Windows -> T.pack "Windows"

instance FromJSONKey Platform where
fromJSONKey = FromJSONKeyTextParser $ \t -> if
| T.pack "Darwin" == t -> pure Darwin
| T.pack "FreeBSD" == t -> pure FreeBSD
| T.pack "OpenBSD" == t -> pure OpenBSD
| T.pack "Windows" == t -> pure Windows
| T.pack "Linux_" `T.isPrefixOf` t -> case
T.stripPrefix (T.pack "Linux_") t
Expand Down

0 comments on commit 0c3b09b

Please sign in to comment.