Skip to content

Commit

Permalink
Make cabal-install build-type: Simple
Browse files Browse the repository at this point in the history
  • Loading branch information
phadej committed Feb 21, 2020
1 parent 6cd7bb5 commit 91ac075
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/artifacts.yml
Expand Up @@ -124,7 +124,7 @@ jobs:
shell: bash
run: |
cabal v2-build cabal-install:exe:cabal
cp dist-newstyle/build/x86_64-windows/ghc-8.6.5/cabal-install-3.3.0.0/build/cabal/cabal.exe cabal.exe
cp dist-newstyle/build/x86_64-windows/ghc-8.6.5/cabal-install-3.3.0.0/x/cabal/build/cabal/cabal.exe cabal.exe
- name: Smoke test
shell: bash
run: |
Expand Down
2 changes: 1 addition & 1 deletion boot/ci-artifacts.template.yml
Expand Up @@ -124,7 +124,7 @@ jobs:
shell: bash
run: |
cabal v2-build cabal-install:exe:cabal
cp dist-newstyle/build/x86_64-windows/ghc-8.6.5/cabal-install-3.3.0.0/build/cabal/cabal.exe cabal.exe
cp dist-newstyle/build/x86_64-windows/ghc-8.6.5/cabal-install-3.3.0.0/x/cabal/build/cabal/cabal.exe cabal.exe
- name: Smoke test
shell: bash
run: |
Expand Down
64 changes: 2 additions & 62 deletions cabal-install/Setup.hs
@@ -1,63 +1,3 @@
import Distribution.PackageDescription ( PackageDescription )
import Distribution.Simple ( defaultMainWithHooks
, simpleUserHooks
, postBuild
, postCopy
, postInst
)
import Distribution.Simple.InstallDirs ( mandir
, CopyDest (NoCopyDest)
)
import Distribution.Simple.LocalBuildInfo ( LocalBuildInfo(..)
, absoluteInstallDirs
)
import Distribution.Simple.Utils ( installOrdinaryFiles
, notice )
import Distribution.Simple.Setup ( buildVerbosity
, copyDest
, copyVerbosity
, fromFlag
, installVerbosity
)
import Distribution.Verbosity ( Verbosity )

import System.IO ( openFile
, IOMode (WriteMode)
)
import System.Process ( runProcess )
import System.FilePath ( (</>) )

-- WARNING to editors of this file:
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- At this moment (Cabal 1.23), whatever you write here must be
-- compatible with ALL Cabal libraries which we support bootstrapping
-- with. This is because pre-setup-depends versions of cabal-install will
-- build Setup.hs against the version of Cabal which MATCHES the library
-- that cabal-install was built against. There is no way of overriding
-- this behavior without bumping the required 'cabal-version' in our
-- Cabal file. Travis will let you know if we fail to install from
-- tarball!

import Distribution.Simple
main :: IO ()
main = defaultMainWithHooks $ simpleUserHooks
{ postBuild = \ _ flags _ lbi ->
buildManpage lbi (fromFlag $ buildVerbosity flags)
, postCopy = \ _ flags pkg lbi ->
installManpage pkg lbi (fromFlag $ copyVerbosity flags) (fromFlag $ copyDest flags)
, postInst = \ _ flags pkg lbi ->
installManpage pkg lbi (fromFlag $ installVerbosity flags) NoCopyDest
}

buildManpage :: LocalBuildInfo -> Verbosity -> IO ()
buildManpage lbi verbosity = do
let cabal = buildDir lbi </> "cabal/cabal"
manpage = buildDir lbi </> "cabal/cabal.1"
manpageHandle <- openFile manpage WriteMode
notice verbosity ("Generating manual page " ++ manpage ++ " ...")
_ <- runProcess cabal ["man","--raw"] Nothing Nothing Nothing (Just manpageHandle) Nothing
return ()

installManpage :: PackageDescription -> LocalBuildInfo -> Verbosity -> CopyDest -> IO ()
installManpage pkg lbi verbosity copy = do
let destDir = mandir (absoluteInstallDirs pkg lbi copy) </> "man1"
installOrdinaryFiles verbosity destDir [(buildDir lbi </> "cabal", "cabal.1")]
main = defaultMain
9 changes: 1 addition & 8 deletions cabal-install/cabal-install.cabal
Expand Up @@ -18,7 +18,7 @@ Author: Cabal Development Team (see AUTHORS file)
Maintainer: Cabal Development Team <cabal-devel@haskell.org>
Copyright: 2003-2019, Cabal Development Team
Category: Distribution
Build-type: Custom
Build-type: Simple
Extra-Source-Files:
README.md bash-completion/cabal bootstrap.sh changelog

Expand Down Expand Up @@ -126,13 +126,6 @@ Flag lukko
default: True
manual: True

custom-setup
setup-depends:
Cabal >= 2.2,
base,
process >= 1.1.0.1 && < 1.7,
filepath >= 1.3 && < 1.5

executable cabal
main-is: Main.hs
hs-source-dirs: main
Expand Down
14 changes: 0 additions & 14 deletions cabal-install/cabal-install.cabal.pp
Expand Up @@ -279,11 +279,7 @@
Maintainer: Cabal Development Team <cabal-devel@haskell.org>
Copyright: 2003-2019, Cabal Development Team
Category: Distribution
%if CABAL_FLAG_LIB
Build-type: Simple
%else
Build-type: Custom
%endif
Extra-Source-Files:
README.md bash-completion/cabal bootstrap.sh changelog
Expand Down Expand Up @@ -391,16 +387,6 @@
default: True
manual: True
%if CABAL_FLAG_LIB
%else
custom-setup
setup-depends:
Cabal >= 2.2,
base,
process >= 1.1.0.1 && < 1.7,
filepath >= 1.3 && < 1.5
%endif
#
# Libraries, if CABAL_FLAG_LIB
#
Expand Down

0 comments on commit 91ac075

Please sign in to comment.