packages feed

ngx-export-distribution 0.2.0.0 → 0.3.0.0

raw patch · 4 files changed

+39/−32 lines, 4 filesdep +directoryPVP ok

version bump matches the API change (PVP)

Dependencies added: directory

API changes (from Hackage documentation)

- NgxExport.Distribution: instance GHC.Exception.Type.Exception NgxExport.Distribution.LibNameNotSpecified
- NgxExport.Distribution: instance GHC.Show.Show NgxExport.Distribution.LibNameNotSpecified

Files

Changelog.md view
@@ -1,3 +1,10 @@+### 0.3.0.0++- GHC option *-flink-rts* was added to the list of default GHC options.+- Add GHC options *$pkg.hs -o $pkg.so* when building without+  option *-o* specified.+- More robust naming of paths to build artifacts.+ ### 0.2.0.0  - More robust processing of build and configuration flags.@@ -5,7 +12,7 @@  ### 0.1.1.0 -- Support only Cabal versions >= 3.0.0.0.+- Support only Cabal versions >= *3.0.0.0*.  ### 0.1.0.0 
LICENSE view
@@ -1,7 +1,7 @@ The following license covers this documentation, and the source code, except where otherwise indicated. -Copyright 2018-2021, Alexey Radkov. All rights reserved.+Copyright 2021, Alexey Radkov. All rights reserved.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
NgxExport/Distribution.hs view
@@ -38,8 +38,8 @@ import Distribution.Types.Library import Distribution.Verbosity import Distribution.Pretty+import System.Directory import System.FilePath-import Control.Exception import Control.Arrow import Control.Monad import Data.Maybe@@ -100,11 +100,9 @@ -- were found in the paths of environment variable /$PATH/. -- -- Building is a bit cumbersome: it expects explicit option /--prefix/ at the--- configuration step (which will be interpreted as the first part of the--- /rpath/ by utility /hslibdeps/), and requires explicit ghc option /-o/ at--- the build step which is as well used by /hslibdeps/ as the name of the--- target library. The build also requires the explicit option for linkage--- against the Haskell RTS library.+-- configuration step (which will be interpreted as the prefix part of the+-- /rpath/ by utility /hslibdeps/) and explicit ghc option /-o/ at the build+-- step which is as well used by /hslibdeps/ as the name of the target library. -- -- Let's build the example with commands /cabal v1-configure/ and -- /cabal v1-build/ (the /v2-/commands should probably work as well).@@ -115,11 +113,11 @@ -- > Linking ./dist/setup/setup ... -- > Configuring ngx-distribution-test-0.1.0.0... ----- > $ cabal v1-build --ghc-options="ngx_distribution_test.hs -o ngx_distribution_test.so -lHSrts_thr-ghc$(ghc --numeric-version)"+-- > $ cabal v1-build --ghc-options="ngx_distribution_test.hs -o ngx_distribution_test.so" -- > [1 of 1] Compiling NgxDistributionTest ( ngx_distribution_test.hs, ngx_distribution_test.o ) -- > Linking ngx_distribution_test.so ... -- > ---> Collecting libraries--- > '/usr/lib64/libHSrts_thr-ghc8.10.5.so' -> 'x86_64-linux-ghc-8.10.5/libHSrts_thr-ghc8.10.5.so'+-- > '/usr/lib64/libHSrts-ghc8.10.5.so' -> 'x86_64-linux-ghc-8.10.5/libHSrts-ghc8.10.5.so' -- > '/home/lyokha/.cabal/lib/x86_64-linux-ghc-8.10.5/libHSngx-export-1.7.5-JzTEmHewqdC9gGi6rzcAtt-ghc8.10.5.so' -> 'x86_64-linux-ghc-8.10.5/libHSngx-export-1.7.5-JzTEmHewqdC9gGi6rzcAtt-ghc8.10.5.so' -- > '/home/lyokha/.cabal/lib/x86_64-linux-ghc-8.10.5/libHSmonad-loops-0.4.3-8Lx5Hn3pTtO62yOPdPW77x-ghc8.10.5.so' -> 'x86_64-linux-ghc-8.10.5/libHSmonad-loops-0.4.3-8Lx5Hn3pTtO62yOPdPW77x-ghc8.10.5.so' -- > '/home/lyokha/.cabal/lib/x86_64-linux-ghc-8.10.5/libHSasync-2.2.4-ENjuIeC23kaKyMVDRYThP3-ghc8.10.5.so' -> 'x86_64-linux-ghc-8.10.5/libHSasync-2.2.4-ENjuIeC23kaKyMVDRYThP3-ghc8.10.5.so'@@ -136,7 +134,7 @@ -- > /var/lib/nginx/x86_64-linux-ghc-8.10.5:/home/lyokha/.cabal/lib/x86_64-linux-ghc-8.10.5:/usr/lib64:/usr/lib64/ghc-8.10.5/rts -- -- Now the current working directory contains new files--- /ngx_distribution_test.so/ and /ngx_distribution_test-0.1.0.0.tar.gz/ and a+-- /ngx_distribution_test.so/ and /ngx-distribution-test-0.1.0.0.tar.gz/ and a -- new directory /x86_64-linux-ghc-8.10.5/. The tar-file contains the patched -- shared library and the directory with dependent libraries: it is ready for -- installation in directory /\/var\/lib\/nginx/ at the target system.@@ -150,13 +148,6 @@ -- - behavior of Cabal commands other than /configure/, /build/ and /clean/ is --   not well defined. -data LibNameNotSpecified = LibNameNotSpecified--instance Exception LibNameNotSpecified-instance Show LibNameNotSpecified where-    show = const "Error: the library name was not specified, \-                 \the name must be passed in ghc with option -o"- hslibdeps :: Program hslibdeps = simpleProgram "hslibdeps" @@ -167,12 +158,10 @@ -- -- Runs /ghc/ compiler with the following arguments. ----- - /-dynamic/, /-shared/, /-fPIC/,+-- - /-dynamic/, /-shared/, /-fPIC/, /-flink-rts/, -- - all arguments listed in /ghc-options/ in the Cabal file,--- - all arguments passed in option /--ghc-options/ from command-line.------ Requires that the arguments contain /-o path/ for the path to the shared--- library to build.+-- - all arguments passed in option /--ghc-options/ from command-line,+-- - if arguments do not contain /-o path/ so far, then /$pkg.hs/, /-o $pkg.so/. -- -- Returns the path to the built shared library. buildSharedLib :: Verbosity                         -- ^ Verbosity level@@ -201,12 +190,23 @@                   ) (Nothing, False) $                       buildProgramArgs flags ++                           map (second pure) configGhcOptions-    when (isNothing lib) $ throwIO LibNameNotSpecified+        (lib', extraGhcOptions) =+            maybe (let name = unPackageName $ pkgName $ package desc+                       nameSo = addExtension name "so"+                   in (nameSo, [addExtension name "hs", "-o", nameSo])+                  ) (, []) lib+    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"     ghcP <- fst <$> requireProgram verbosity ghcProgram (withPrograms lbi)-    let ghcR = programInvocation ghcP $ ["-dynamic", "-shared", "-fPIC"] ++-            map snd configGhcOptions+    let ghcR = programInvocation ghcP $+            ["-dynamic", "-shared", "-fPIC", "-flink-rts"] +++                map snd configGhcOptions ++ extraGhcOptions     runProgramInvocation verbosity ghcR-    return $ fromJust lib+    return lib'  -- | Patches the shared library and collects dependent Haskell libraries. --@@ -228,8 +228,8 @@                              -> LocalBuildInfo      -- ^ Local build info                              -> IO () patchAndCollectDependentLibs verbosity lib desc lbi = do-    let dir = prettyShow (hostPlatform lbi) ++-            '-' : prettyShow (compilerId $ compiler lbi)+    let dir = maybe "unspecified-abi" fromPathTemplate $ lookup AbiVar $+            abiTemplateEnv (compilerInfo $ compiler lbi) $ hostPlatform lbi         dirArg = "-d" : [dir]         rpathArg = maybe [] (("-t" :) . pure . (</> dir) . fromPathTemplate) $             flagToMaybe $ prefix $ configInstallDirs $ configFlags lbi@@ -238,8 +238,7 @@     let hslibdepsR = programInvocation hslibdepsP $ lib : rpathArg ++ dirArg     runProgramInvocation verbosity hslibdepsR     tarP <- fst <$> requireProgram verbosity tarProgram plbi-    let ver = pkgVersion $ package desc-        tar = addExtension (takeBaseName lib ++ '-' : prettyShow ver) "tar.gz"+    let tar = addExtension (prettyShow $ package desc) "tar.gz"         tarR = programInvocation tarP ["czf", tar, lib, dir]     runProgramInvocation verbosity tarR 
ngx-export-distribution.cabal view
@@ -1,5 +1,5 @@ name:                       ngx-export-distribution-version:                    0.2.0.0+version:                    0.3.0.0 synopsis:                   Build custom libraries for Nginx haskell module description:                Build custom libraries for         <http://github.com/lyokha/nginx-haskell-module Nginx haskell module>.@@ -19,6 +19,7 @@   default-language:         Haskell2010   build-depends:            base >= 4.8 && < 5                           , Cabal >= 3.0.0.0+                          , directory                           , filepath    exposed-modules:          NgxExport.Distribution