getConcretePackageDescription
    :: GenericPackageDescription
    -> Either [Dependency] PackageDescription
getConcretePackageDescription genericDesc = do
#if Cabal2
    let enabled :: ComponentRequestedSpec
        enabled = ComponentRequestedSpec
            { testsRequested      = True
            , benchmarksRequested = True
            }
    fst A.<$> finalizePD
        []           -- Flag assignment
        enabled      -- Enable all components
        (const True) -- Whether given dependency is available
        buildPlatform
        buildCompilerId
        []           -- Additional constraints
        genericDesc
#else
    -- This let block is eerily like one in Cabal.Distribution.Simple.Configure
    let enableTest :: TestSuite -> TestSuite
        enableTest t = t { testEnabled = True }
        enableBenchmark :: Benchmark -> Benchmark
        enableBenchmark bm = bm { benchmarkEnabled = True }
        flaggedTests =
            map (second (mapTreeData enableTest)) (condTestSuites genericDesc)
        flaggedBenchmarks =
            map
                (second (mapTreeData enableBenchmark))
                (condBenchmarks genericDesc)
        genericDesc' =
            genericDesc
            { condTestSuites = flaggedTests
            , condBenchmarks = flaggedBenchmarks
            }
    fst A.<$> finalizePackageDescription
        []
        (const True)
        buildPlatform
        buildCompilerId
        []
        genericDesc'
#endif


#ifdef USE_COMPILER_ID
getConcretePackageDescription
    :: GenericPackageDescription
    -> Either [Dependency] PackageDescription
getConcretePackageDescription genericDesc = do
#if Cabal2
    let enabled :: ComponentRequestedSpec
        enabled = ComponentRequestedSpec
            { testsRequested      = True
            , benchmarksRequested = True
            }
    fst A.<$> finalizePD
        []           -- Flag assignment
        enabled      -- Enable all components
        (const True) -- Whether given dependency is available
        buildPlatform
        buildCompilerId
        []           -- Additional constraints
        genericDesc
#else
    -- This let block is eerily like one in Cabal.Distribution.Simple.Configure
    let enableTest :: TestSuite -> TestSuite
        enableTest t = t { testEnabled = True }
        enableBenchmark :: Benchmark -> Benchmark
        enableBenchmark bm = bm { benchmarkEnabled = True }
        flaggedTests =
            map (second (mapTreeData enableTest)) (condTestSuites genericDesc)
        flaggedBenchmarks =
            map
                (second (mapTreeData enableBenchmark))
                (condBenchmarks genericDesc)
        genericDesc' =
            genericDesc
            { condTestSuites = flaggedTests
            , condBenchmarks = flaggedBenchmarks
            }
    fst A.<$> finalizePackageDescription
        []
        (const True)
        buildPlatform
        buildCompilerId
        []
        genericDesc'
#endif


#ifdef USE_COMPILER_ID
getConcretePackageDescription genericDesc = do
#if Cabal2
    let enabled :: ComponentRequestedSpec
        enabled = ComponentRequestedSpec
            { testsRequested      = True
            , benchmarksRequested = True
            }
    fst A.<$> finalizePD
        []           -- Flag assignment
        enabled      -- Enable all components
        (const True) -- Whether given dependency is available
        buildPlatform
        buildCompilerId
        []           -- Additional constraints
        genericDesc
#else
    -- This let block is eerily like one in Cabal.Distribution.Simple.Configure
    let enableTest :: TestSuite -> TestSuite
        enableTest t = t { testEnabled = True }
        enableBenchmark :: Benchmark -> Benchmark
        enableBenchmark bm = bm { benchmarkEnabled = True }
        flaggedTests =
            map (second (mapTreeData enableTest)) (condTestSuites genericDesc)
        flaggedBenchmarks =
            map
                (second (mapTreeData enableBenchmark))
                (condBenchmarks genericDesc)
        genericDesc' =
            genericDesc
            { condTestSuites = flaggedTests
            , condBenchmarks = flaggedBenchmarks
            }
    fst A.<$> finalizePackageDescription
        []
        (const True)
        buildPlatform
        buildCompilerId
        []
        genericDesc'
#endif


#ifdef USE_COMPILER_ID