[darcs-users] [patch436] add a couple of cabal flags

Florent Becker bugs at darcs.net
Thu Nov 11 13:00:47 UTC 2010


Florent Becker <florent.becker at ens-lyon.org> added the comment:

Applying

make test harness optional
--------------------------
Ganesh Sittampalam <ganesh at earth.li>**20101020054443

hunk ./darcs.cabal 110
>    default:     False
>    description: A cunning trick to have cabal install build 
dependencies
>  
> +flag test
> +  default:     False
> +  description: Build test harness
> +
>  -- ------------------------------------------------------------------
----
>  -- darcs library
>  -- ------------------------------------------------------------------
----

Add a test flag.

hunk ./darcs.cabal 509
>  Executable          darcs-test
>    main-is:          test.hs
>  
> -  buildable: True
> -  build-depends:   base          < 5,
> -                   extensible-exceptions >= 0.1 && < 0.2,
> -                   regex-compat >= 0.71 && < 0.94,
> -                   mtl          >= 1.0 && < 1.2,
> -                   parsec       >= 2.0 && < 3.1,
> -                   html         == 1.0.*,
> -                   filepath     == 1.1.*,
> -                   QuickCheck   >= 2.1.0.0,
> -                   HUnit        >= 1.0,
> -                   cmdlib       >= 0.2.1 && < 0.3,
> -                   shellish     >= 0.1.1 && < 0.2,
> -                   test-framework             >= 0.2.2,
> -                   test-framework-hunit       >= 0.2.2,
> -                   test-framework-quickcheck2 >= 0.2.2
> +  if !flag(test)
> +    buildable: False
> +  else
> +    buildable: True
> +    build-depends:   base          < 5,
> +                     extensible-exceptions >= 0.1 && < 0.2,
> +                     regex-compat >= 0.71 && < 0.94,
> +                     mtl          >= 1.0 && < 1.2,
> +                     parsec       >= 2.0 && < 3.1,
> +                     html         == 1.0.*,
> +                     filepath     == 1.1.*,
> +                     QuickCheck   >= 2.1.0.0,
> +                     HUnit        >= 1.0,
> +                     cmdlib       >= 0.2.1 && < 0.3,
> +                     shellish     >= 0.1.1 && < 0.2,
> +                     test-framework             >= 0.2.2,
> +                     test-framework-hunit       >= 0.2.2,
> +                     test-framework-quickcheck2 >= 0.2.2
>  

Do not build tests when user said no tests.

hunk ./darcs.cabal 528
> -  hs-source-dirs:   src
> -  include-dirs:     src
> -  c-sources:        src/atomic_create.c
> -                    src/fpstring.c
> -                    src/maybe_relink.c
> -                    src/umask.c
> -                    src/Crypt/sha2.c
> -  -- list all unit test modules not exported by libdarcs; otherwise 
Cabal won't
> -  -- include them in the tarball
> -  other-modules:    Darcs.Test.Email
> -                    Darcs.Test.Patch.Check
> -                    Darcs.Test.Patch.Info
> -                    Darcs.Test.Patch.Properties
> -                    Darcs.Test.Patch.QuickCheck
> -                    Darcs.Test.Patch.Test
> -                    Darcs.Test.Patch.Unit
> -                    Darcs.Test.Patch.Unit2
> -                    Darcs.Test.Patch
> -                    Darcs.Test.Misc
> +    hs-source-dirs:   src
> +    include-dirs:     src
> +    c-sources:        src/atomic_create.c
> +                      src/fpstring.c
> +                      src/maybe_relink.c
> +                      src/umask.c
> +                      src/Crypt/sha2.c
> +    -- list all unit test modules not exported by libdarcs; otherwise 
Cabal won't
> +    -- include them in the tarball
> +    other-modules:    Darcs.Test.Email
> +                      Darcs.Test.Patch.Check
> +                      Darcs.Test.Patch.Info
> +                      Darcs.Test.Patch.Properties
> +                      Darcs.Test.Patch.QuickCheck
> +                      Darcs.Test.Patch.Test
> +                      Darcs.Test.Patch.Unit
> +                      Darcs.Test.Patch.Unit2
> +                      Darcs.Test.Patch
> +                      Darcs.Test.Misc
>  

indentation

hunk ./darcs.cabal 548
> -  -- We need optimizations, regardless of what Hackage says
> -  -- Note: "if true" works around a cabal bug with order of flag 
composition
> -  if true
> -    ghc-options:      -Wall -O2 -funbox-strict-fields -fwarn-tabs
> +    -- We need optimizations, regardless of what Hackage says
> +    -- Note: "if true" works around a cabal bug with order of flag 
composition
> +    if true
> +      ghc-options:      -Wall -O2 -funbox-strict-fields -fwarn-tabs
>  

more indentation

hunk ./darcs.cabal 553
> -  if impl(ghc>=6.12)
> -    ghc-options: -fno-warn-unused-do-bind
> +    if impl(ghc>=6.12)
> +      ghc-options: -fno-warn-unused-do-bind
>  

yet more indentation

hunk ./darcs.cabal 556
> -  ghc-prof-options: -prof -auto-all
> -  if flag(threaded)
> -    ghc-options:    -threaded
> +    ghc-prof-options: -prof -auto-all
> +    if flag(threaded)
> +      ghc-options:    -threaded
>  

i8n

hunk ./darcs.cabal 560
> -  cc-options:       -D_REENTRANT
> +    cc-options:       -D_REENTRANT
>  

i8n yet again

hunk ./darcs.cabal 562
> -  cpp-options:      -DGADT_WITNESSES=1
> +    cpp-options:      -DGADT_WITNESSES=1
>  

…

hunk ./darcs.cabal 564
> -  if os(windows)
> -    hs-source-dirs: src/win32
> -    include-dirs:   src/win32
> -    other-modules:  CtrlC
> -                    System.Posix
> -                    System.Posix.Files
> -                    System.Posix.IO
> -    cpp-options:    -DWIN32
> -    c-sources:      src/win32/send_email.c
> -    build-depends:  unix-compat >= 0.1.2,
> -                    regex-posix >= 0.94.4 && < 0.95
> +    if os(windows)
> +      hs-source-dirs: src/win32
> +      include-dirs:   src/win32
> +      other-modules:  CtrlC
> +                      System.Posix
> +                      System.Posix.Files
> +                      System.Posix.IO
> +      cpp-options:    -DWIN32
> +      c-sources:      src/win32/send_email.c
> +      build-depends:  unix-compat >= 0.1.2,
> +                      regex-posix >= 0.94.4 && < 0.95
>  

…

hunk ./darcs.cabal 576
> -  if os(solaris)
> -    cc-options:     -DHAVE_SIGINFO_H
> +    if os(solaris)
> +      cc-options:     -DHAVE_SIGINFO_H
>  

……

hunk ./darcs.cabal 579
> -  if !os(windows)
> -    build-depends: unix >= 1.0 && < 2.5
> +    if !os(windows)
> +      build-depends: unix >= 1.0 && < 2.5
>  

………

hunk ./darcs.cabal 582
> -  build-depends: base >= 4 && < 5,
> -                 bytestring >= 0.9.0 && < 0.10,
> -                 haskeline    >= 0.6.2.2 && < 0.7,
> -                 text >= 0.3,
> -                 old-time   == 1.0.*,
> -                 directory  == 1.0.*,
> -                 process    == 1.0.*,
> -                 containers >= 0.1 && < 0.4,
> -                 array      >= 0.1 && < 0.4,
> -                 hashed-storage >= 0.5.2 && < 0.6,
> -                 random     == 1.0.*
> +    build-depends: base >= 4 && < 5,
> +                   bytestring >= 0.9.0 && < 0.10,
> +                   haskeline    >= 0.6.2.2 && < 0.7,
> +                   text >= 0.3,
> +                   old-time   == 1.0.*,
> +                   directory  == 1.0.*,
> +                   process    == 1.0.*,
> +                   containers >= 0.1 && < 0.4,
> +                   array      >= 0.1 && < 0.4,
> +                   hashed-storage >= 0.5.2 && < 0.6,
> +                   random     == 1.0.*
>  

indentation

hunk ./darcs.cabal 594
> -  if flag(mmap) && !os(windows)
> -    build-depends:    mmap >= 0.5 && < 0.6
> -    cpp-options:      -DHAVE_MMAP
> +    if flag(mmap) && !os(windows)
> +      build-depends:    mmap >= 0.5 && < 0.6
> +      cpp-options:      -DHAVE_MMAP
>  

shouldn't darcs support a "reindent" patchtype?

hunk ./darcs.cabal 598
> -  build-depends:    zlib >= 0.5.1.0 && < 0.6.0.0
> +    build-depends:    zlib >= 0.5.1.0 && < 0.6.0.0
>  

it definitely should

hunk ./darcs.cabal 600
> -  -- The terminfo package cannot be built on Windows.
> -  if flag(terminfo) && !os(windows)
> -    build-depends:    terminfo == 0.3.*
> -    cpp-options:      -DHAVE_TERMINFO
> +    -- The terminfo package cannot be built on Windows.
> +    if flag(terminfo) && !os(windows)
> +      build-depends:    terminfo == 0.3.*
> +      cpp-options:      -DHAVE_TERMINFO
>  

indentation [snip some more of it]


move optimization setting into a flag
-------------------------------------
Ganesh Sittampalam <ganesh at earth.li>**20101022181756

hunk ./darcs.cabal 114
>    default:     False
>    description: Build test harness
>  
> +-- We need optimizations by default, regardless of what Hackage says
> +flag optimize
> +  default:     True
> +  description: Build with optimizations (-O2)
> +
>  -- ------------------------------------------------------------------
----
>  -- darcs library
>  -- ------------------------------------------------------------------
----

Add an optimization flag

hunk ./darcs.cabal 336
>                     random     == 1.0.*
>  
>  
> -    -- We need optimizations, regardless of what Hackage says
> +    if flag(optimize)
> +      ghc-options:      -O2
> +    else
> +      ghc-options:      -O0
> +
>      -- Note: "if true" works around a cabal bug with order of flag 
composition
>      if true

use the flag

hunk ./darcs.cabal 343
> -      ghc-options:      -Wall -O2 -funbox-strict-fields -fwarn-tabs
> +      ghc-options:      -Wall -funbox-strict-fields -fwarn-tabs
>  
>      if impl(ghc>=6.12)
>        ghc-options: -fno-warn-unused-do-bind

remove the hard-coded -O2

[snip]
And twice again (for the two other builds)

----------
status: needs-review -> accepted-pending-tests

__________________________________
Darcs bug tracker <bugs at darcs.net>
<http://bugs.darcs.net/patch436>
__________________________________


More information about the darcs-users mailing list