diff options
-rw-r--r-- | cabal-helper.cabal | 100 | ||||
-rw-r--r-- | scripts/update-cabal-common-section-instantiations.awk | 34 |
2 files changed, 108 insertions, 26 deletions
diff --git a/cabal-helper.cabal b/cabal-helper.cabal index e285e69..f62744f 100644 --- a/cabal-helper.cabal +++ b/cabal-helper.cabal @@ -68,6 +68,25 @@ custom-setup , filepath < 1.5 , directory < 1.4 +flag dev + description: Build development components + default: False + manual: True + + +-- [Note test dependencies] Vaious tests need access to modules used in other +-- components, unfortunately we can't use Cabal 2.0's new internal libraries for +-- this because we'd like to support ancient Cabal versions. Instead we just +-- copy 'hs-source-dirs', 'build-depends' and 'other-modules' fields as +-- appropriate. +-- +-- The following awk command will copy paragraphs starting with: +-- -- Common some-name +-- to following paragraphs starting with: +-- -- Instantiate common some-name +-- +-- $ gawk -i inplace -f scripts/update-cabal-common-section-instantiations.awk cabal-helper.cabal + library default-language: Haskell2010 default-extensions: NondecreasingIndentation @@ -78,6 +97,10 @@ library CabalHelper.Shared.Sandbox Paths_cabal_helper ghc-options: -Wall + + -- TODO: figure out where exactly to put this + build-tool-depends: cabal-install:cabal + build-depends: base < 5 && >= 4.5 if os(windows) build-depends: base >= 4.7 @@ -96,11 +119,18 @@ library -- [Note ghc-prim] -- Exports GHC.Generics in GHC-7.4 + executable cabal-helper-wrapper + main-is: CabalHelper/Compiletime/Wrapper.hs + if flag(dev) + ghc-options: -Wall + scope: private + x-scope: private + + -- Common c-h-wrapper-fields -- See [Note test dependencies] default-language: Haskell2010 default-extensions: NondecreasingIndentation other-extensions: TemplateHaskell - main-is: CabalHelper/Compiletime/Wrapper.hs hs-source-dirs: src other-modules: CabalHelper.Compiletime.Compat.Environment @@ -114,12 +144,6 @@ executable cabal-helper-wrapper CabalHelper.Shared.InterfaceTypes CabalHelper.Shared.Sandbox Paths_cabal_helper - if flag(dev) - ghc-options: -Wall - scope: private - x-scope: private - - -- Remember to copy to compile-test! build-depends: base < 5 && >= 4.5 if os(windows) build-depends: base >= 4.7 @@ -140,26 +164,31 @@ executable cabal-helper-wrapper , ghc-prim build-tools: cabal + test-suite compile-test - default-language: Haskell2010 - default-extensions: NondecreasingIndentation type: exitcode-stdio-1.0 main-is: CompileTest.hs - hs-source-dirs: tests, src + hs-source-dirs: tests + ghc-options: -Wall + build-tools: cabal + + -- Instantiate common c-h-wrapper-fields -- See [Note test dependencies] + default-language: Haskell2010 + default-extensions: NondecreasingIndentation + other-extensions: TemplateHaskell + hs-source-dirs: src other-modules: CabalHelper.Compiletime.Compat.Environment CabalHelper.Compiletime.Compat.Version CabalHelper.Compiletime.Compile CabalHelper.Compiletime.Data + CabalHelper.Compiletime.GuessGhc CabalHelper.Compiletime.Log CabalHelper.Compiletime.Types CabalHelper.Shared.Common + CabalHelper.Shared.InterfaceTypes CabalHelper.Shared.Sandbox Paths_cabal_helper - ghc-options: -Wall - build-tools: cabal - - -- Same as cabal-helper-wrapper build-depends: base < 5 && >= 4.5 if os(windows) build-depends: base >= 4.7 @@ -178,22 +207,40 @@ test-suite compile-test build-depends: unix-compat < 0.6 && >= 0.4.3.1 , utf8-string < 1.1 && >= 1.0.1.1 , ghc-prim + build-tools: cabal + test-suite ghc-session - default-language: Haskell2010 - default-extensions: NondecreasingIndentation type: exitcode-stdio-1.0 main-is: GhcSession.hs - hs-source-dirs: tests, src + hs-source-dirs: tests ghc-options: -Wall build-depends: base < 5 && >= 4.5 , ghc < 8.3 && >= 7.4 , ghc-paths < 0.2 && >= 0.1.0.9 , cabal-helper - -- Same as cabal-helper-wrapper + -- Instantiate common c-h-wrapper-fields -- See [Note test dependencies] + default-language: Haskell2010 + default-extensions: NondecreasingIndentation + other-extensions: TemplateHaskell + hs-source-dirs: src + other-modules: + CabalHelper.Compiletime.Compat.Environment + CabalHelper.Compiletime.Compat.Version + CabalHelper.Compiletime.Compile + CabalHelper.Compiletime.Data + CabalHelper.Compiletime.GuessGhc + CabalHelper.Compiletime.Log + CabalHelper.Compiletime.Types + CabalHelper.Shared.Common + CabalHelper.Shared.InterfaceTypes + CabalHelper.Shared.Sandbox + Paths_cabal_helper build-depends: base < 5 && >= 4.5 - , Cabal < 2.1 && >= 2.0 || < 1.26 && >= 1.14 + if os(windows) + build-depends: base >= 4.7 + build-depends: Cabal < 2.1 && >= 2.0 || < 1.26 && >= 1.14 , bytestring < 0.11 && >= 0.9.2.1 , directory < 1.4 && >= 1.1.0.2 , exceptions < 0.9 && >= 0.8.3 @@ -203,9 +250,13 @@ test-suite ghc-session , template-haskell < 2.13 && >= 2.7.0.0 , temporary < 1.3 && >= 1.2.0.4 , transformers < 0.6 && >= 0.3.0.0 - , unix < 2.8 && >= 2.5.1.1 + if !os(windows) + build-depends: unix < 2.8 && >= 2.5.1.1 + build-depends: unix-compat < 0.6 && >= 0.4.3.1 , utf8-string < 1.1 && >= 1.0.1.1 , ghc-prim + build-tools: cabal + executable cabal-helper-main default-language: Haskell2010 @@ -221,16 +272,13 @@ executable cabal-helper-main CabalHelper.Shared.Common CabalHelper.Shared.InterfaceTypes CabalHelper.Shared.Sandbox + + -- Common c-h-main-fields -- See [Note test dependencies] ghc-options: -Wall -fno-warn-unused-imports - build-depends: base + build-depends: base < 5 && >= 4.5 , Cabal , containers , bytestring , filepath , directory , ghc-prim - -flag dev - description: Build development components - default: False - manual: True diff --git a/scripts/update-cabal-common-section-instantiations.awk b/scripts/update-cabal-common-section-instantiations.awk new file mode 100644 index 0000000..0bfacae --- /dev/null +++ b/scripts/update-cabal-common-section-instantiations.awk @@ -0,0 +1,34 @@ +BEGIN { + delete sections; + section=""; + ignoring=0; +} + +/^[[:space:]]*$/ { + section=""; + ignoring=0; +} + +{ + if(section) { + tmp = sections[section]; + sections[section] = tmp (tmp ? RS : "") $0; + } +} + +/^[[:space:]]*-- *Common/ { + section = $3 +} + +/^[[:space:]]*-- *Instantiate *common/ { + ignoring=1 + + print $0; + print sections[$4]; +} + +{ + if(!ignoring) { + print $0; + } +} |