ngx-export-distribution 0.4.0.0 → 0.4.1.0
raw patch · 3 files changed
+40/−35 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Changelog.md +5/−0
- NgxExport/Distribution.hs +34/−34
- ngx-export-distribution.cabal +1/−1
Changelog.md view
@@ -1,3 +1,8 @@+### 0.4.1.0++- Test GHC version to figure out whether to use option *-flink-rts* in run-time.+- Note on where to get *hslibdeps* when build fails due to its unavailability.+ ### 0.4.0.0 - Get verbosity level for all program invocations from configuration and build
NgxExport/Distribution.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP, TupleSections #-}+{-# LANGUAGE TupleSections #-} ----------------------------------------------------------------------------- -- |@@ -45,11 +45,12 @@ import Distribution.Simple hiding (defaultMain) import Distribution.Simple.LocalBuildInfo+import Distribution.Simple.Program.Types import Distribution.Simple.Program.Builtin import Distribution.Simple.Program.Run import Distribution.Simple.Program.Db-import Distribution.Simple.Program import Distribution.Simple.Setup+import Distribution.Simple.Utils import Distribution.Types.PackageDescription import Distribution.Types.BuildInfo import Distribution.Types.Library@@ -239,29 +240,13 @@ -- Before running the /configure/ command, we commented out all packages listed -- in the GHC environment file. The build step requires linking the target -- library against the direct dependencies and their dependencies in turn. With--- [cabal-plan](https://hackage.haskell.org/package/cabal-plan), re-enabling--- the direct dependencies in the GHC environment file can be done--- automatically.------ The following bash script collects all direct dependencies reported by--- /cabal-plan/.------ ==== File /cabal-plan-direct-deps.sh/--- > #!/usr/bin/env bash--- >--- > CABAL_PLAN=$(cabal-plan info --ascii)--- > UNIT_ID="^UnitId\s\+\""--- > while IFS= read -r pkg--- > do sed -n "/$UNIT_ID$pkg/s/$UNIT_ID\(.*\)\"\$/package-id \1/p" <<< "$CABAL_PLAN"--- > done < <(sed -n '/^CompNameLib$/,/^$/s/^\s\+//p' <<< "$CABAL_PLAN") |--- > awk '!x[$0]++'--- > unset CABAL_PLAN UNIT_ID------ After running this as+-- [cabal-plan](https://hackage.haskell.org/package/cabal-plan), finding the+-- direct dependencies in the /cabal plan/ can be done automatically. ----- > $ . cabal-plan-direct-deps.sh >> .ghc.environment.x86_64-linux-$(ghc --numeric-version)+-- > $ hslibdeps -e >> .ghc.environment.x86_64-linux-$(ghc --numeric-version) ----- four lines looking similar to+-- Command /hslibdeps -e/ is a convenient wrapper around /cabal-plan/. After+-- running this, four lines looking similar to -- -- > package-id aeson-2.1.0.0-9b19e87ee2a82567866c50e13806427068fd4bcc78cedb01ecad7389791f6761 -- > package-id base-4.17.0.0@@ -294,6 +279,21 @@ patchelf :: Program patchelf = simpleProgram "patchelf" +requireHslibdeps :: Verbosity -> ProgramDb -> IO (ConfiguredProgram, ProgramDb)+requireHslibdeps verbosity progdb = do+ mres <- needProgram verbosity prog progdb+ case mres of+ Nothing -> die' verbosity notFound+ Just res -> return res+ where prog = hslibdeps+ progName = programName prog+ notFound = "The program '" ++ progName +++ "' is required but it could not be found." +++ "\nNote: Get '" ++ progName ++ "' from " ++ url +++ " and put it into a directory listed in the PATH."+ url = "https://github.com/lyokha/nginx-haskell-module\+ \/blob/master/utils/hslibdeps"+ -- | Builds a shared library. -- -- Runs /ghc/ compiler with the following arguments.@@ -338,16 +338,16 @@ unless (null extraGhcOptions) $ do let extraSourceFile = head extraGhcOptions extraSourceFileExists <- doesFileExist extraSourceFile- unless extraSourceFileExists $ ioError $ userError $- "File " ++ extraSourceFile ++ " does not exist, " ++- "you may want to specify input and output files in --ghc-options"+ unless extraSourceFileExists $ die' verbosity $+ "File " ++ extraSourceFile ++ " does not exist, \+ \you may want to specify input and output files in --ghc-options" ghcP <- fst <$> requireProgram verbosity ghcProgram (withPrograms lbi)- let ghcR = programInvocation ghcP $-#if MIN_TOOL_VERSION_ghc(8,10,6)- "-flink-rts" :-#endif- ["-dynamic", "-shared", "-fPIC"] ++- map snd configGhcOptions ++ extraGhcOptions+ let libGhcOptions = ["-dynamic", "-shared", "-fPIC"]+ libGhcOptions' = if programVersion ghcP >= Just (mkVersion [8, 10, 6])+ then "-flink-rts" : libGhcOptions+ else libGhcOptions+ ghcR = programInvocation ghcP $+ libGhcOptions' ++ map snd configGhcOptions ++ extraGhcOptions runProgramInvocation verbosity ghcR return lib' @@ -380,7 +380,7 @@ rpathArg = maybe [] (("-t" :) . pure . (</> dir) . fromPathTemplate) $ flagToMaybe $ prefix $ configInstallDirs $ configFlags lbi archiveArg = "-a" : [prettyShow $ package desc]- hslibdepsP <- fst <$> requireProgram verbosity hslibdeps (withPrograms lbi)+ hslibdepsP <- fst <$> requireHslibdeps verbosity (withPrograms lbi) let hslibdepsR = programInvocation hslibdepsP $ lib : rpathArg ++ dirArg ++ archiveArg runProgramInvocation verbosity hslibdepsR@@ -402,7 +402,7 @@ , confHook = \desc flags -> do let verbosity = toVerbosity $ configVerbosity flags pdb = configPrograms flags- _ <- requireProgram verbosity hslibdeps pdb >>=+ _ <- requireHslibdeps verbosity pdb >>= requireProgram verbosity patchelf . snd confHook simpleUserHooks desc flags , buildHook = \desc lbi _ flags -> do
ngx-export-distribution.cabal view
@@ -1,5 +1,5 @@ name: ngx-export-distribution-version: 0.4.0.0+version: 0.4.1.0 synopsis: Build custom libraries for Nginx haskell module description: Build custom libraries for <https://github.com/lyokha/nginx-haskell-module Nginx haskell module>.