packages feed

hlibsass 0.1.2.1 → 0.1.3.0

raw patch · 4 files changed

+79/−23 lines, 4 filessetup-changedPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,6 +1,14 @@ # Change Log All notable changes to this project will be documented in this file. +## [0.1.3.0] - 2015-06-08+### Added+- Ability to link to existing version of libsass.+- Support for building (and linking to) shared version of libsass.++### Fixed+- hlibsass may be used in ghci when linked with shared version of libsass.+ ## [0.1.2.1] - 2015-06-02 ### Changed - `libsass/VERSION` file is generated during sdist phase.@@ -37,6 +45,7 @@ - Bindings to Libsass C API - Basic tests +[0.1.3.0]: https://github.com/jakubfijalkowski/hlibsass/compare/v0.1.2.1...v0.1.3.0 [0.1.2.1]: https://github.com/jakubfijalkowski/hlibsass/compare/v0.1.2.0...v0.1.2.1 [0.1.2.0]: https://github.com/jakubfijalkowski/hlibsass/compare/v0.1.1.1...v0.1.2.0 [0.1.1.1]: https://github.com/jakubfijalkowski/hlibsass/compare/v0.1.1.0...v0.1.1.1
Setup.hs view
@@ -1,4 +1,6 @@-import           Data.Maybe                         (fromJust)+import           Control.Monad                      (unless, when)+import           Data.Char                          (toLower)+import           Data.Maybe                         (fromJust, fromMaybe) import           Distribution.PackageDescription import           Distribution.Simple import           Distribution.Simple.LocalBuildInfo (InstallDirs (..),@@ -6,8 +8,10 @@                                                      absoluteInstallDirs,                                                      localPkgDescr) import           Distribution.Simple.Setup-import           Distribution.Simple.Utils          (rawSystemExit,+import           Distribution.Simple.Utils          (installExecutableFile,+                                                     rawSystemExit,                                                      rawSystemStdout)+import           Distribution.System import           System.Directory                   (getCurrentDirectory)  main = defaultMainWithHooks simpleUserHooks@@ -20,35 +24,56 @@   }  makeLibsass :: Args -> ConfigFlags -> IO ()-makeLibsass _ flags =-    let verbosity = fromFlag $ configVerbosity flags-    in rawSystemExit verbosity "env" ["make", "--directory=libsass"]+makeLibsass _ f =+    let verbosity = fromFlag $ configVerbosity f+        external = getCabalFlag "externalLibsass" f+        target = if getCabalFlag "sharedLibsass" f then "shared" else "static"+    in unless external $ rawSystemExit verbosity "env"+         ["BUILD=" ++ target, "make", "--directory=libsass"]  updateExtraLibDirs :: LocalBuildInfo -> IO LocalBuildInfo-updateExtraLibDirs localBuildInfo = do-    let packageDescription = localPkgDescr localBuildInfo-        lib = fromJust $ library packageDescription-        libBuild = libBuildInfo lib-    dir <- getCurrentDirectory-    return localBuildInfo {-        localPkgDescr = packageDescription {-            library = Just $ lib {-                libBuildInfo = libBuild {-                    extraLibDirs = (dir ++ "/libsass/lib") :-                        extraLibDirs libBuild+updateExtraLibDirs lbi+    | getCabalFlag "externalLibsass" $ configFlags lbi = return lbi+    | otherwise = do+        let packageDescription = localPkgDescr lbi+            lib = fromJust $ library packageDescription+            libBuild = libBuildInfo lib+        dir <- getCurrentDirectory+        return lbi {+            localPkgDescr = packageDescription {+                library = Just $ lib {+                    libBuildInfo = libBuild {+                        extraLibDirs = (dir ++ "/libsass/lib") :+                            extraLibDirs libBuild+                    }                 }             }         }-    }  copyLibsass :: Args -> CopyFlags -> PackageDescription -> LocalBuildInfo -> IO ()-copyLibsass _ flags pkg_descr lbi = do+copyLibsass _ flags pkg_descr lbi =     let libPref = libdir . absoluteInstallDirs pkg_descr lbi                 . fromFlag . copyDest                 $ flags-    let verb = fromFlag $ copyVerbosity flags-    rawSystemExit verb "mkdir" ["-p", libPref]-    rawSystemExit verb "cp" ["libsass/lib/libsass.a", libPref]+        verb = fromFlag $ copyVerbosity flags+        config = configFlags lbi+        external = getCabalFlag "externalLibsass" config+        Platform _ os = hostPlatform lbi+        shared = getCabalFlag "sharedLibsass" config+        ext = if shared then "so" else "a"+    in unless external $+        if os == Windows+            then do+                installExecutableFile verb+                    "libsass/lib/libsass.a"+                    (libPref ++ "/libsass.a")+                when shared $ installExecutableFile verb+                    "libsass/lib/libsass.dll"+                    (libPref ++ "/libsass.dll")+           else+                installExecutableFile verb+                    ("libsass/lib/libsass." ++ ext)+                    (libPref ++ "/libsass." ++ ext)   cleanLibsass :: Args -> CleanFlags -> PackageDescription -> () -> IO ()@@ -62,3 +87,8 @@     ver <- rawSystemStdout verbosity "env" [ "git", "-C", "libsass", "describe",         "--abbrev=4", "--dirty", "--always", "--tags" ]     writeFile "libsass/VERSION" ver++getCabalFlag :: String -> ConfigFlags -> Bool+getCabalFlag name flags = fromMaybe False (lookup (FlagName name') allFlags)+    where allFlags = configConfigurationsFlags flags+          name' = map toLower name
hlibsass.cabal view
@@ -1,5 +1,5 @@ name:                hlibsass-version:             0.1.2.1+version:             0.1.3.0 license:             MIT license-file:        LICENSE author:              Jakub Fijałkowski <fiolek94@gmail.com>@@ -35,6 +35,15 @@   type:              git   location:          git://github.com/jakubfijalkowski/hlibsass.git +flag externalLibsass+  description:       Use libsass that is installed in the system.+  default:           False++flag sharedLibsass+  description:+    Build libsass as a shared library (only if external_libsass = False).+  default:           False+ library   exposed-modules:       Bindings.Libsass@@ -48,12 +57,17 @@   default-language:    Haskell2010   default-extensions:  ForeignFunctionInterface   ghc-options:         -Wall-  extra-libraries:     sass, stdc+++  if flag(externalLibsass)+    extra-libraries:   sass+  else+    extra-libraries:   sass, stdc++  test-suite tests   hs-source-dirs:      tests   main-is:             Main.hs   type:                exitcode-stdio-1.0   ghc-options:         -Wall+  if flag(externalLibsass)+    cpp-options:       -DEXTERNAL_LIBSASS   build-depends:       base >= 4.7 && < 5, hspec, hlibsass   default-language:    Haskell2010
tests/Main.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-}+{-# LANGUAGE CPP          #-} import           Bindings.Libsass import           Foreign import           Foreign.C@@ -31,9 +32,11 @@     it "should correctly compile simple expression" $         simpleCompile sampleInput `shouldReturn` sampleOutput +#ifndef EXTERNAL_LIBSASS     it "should report correct version" $ do         str <- peekCString libsass_version         str `shouldBe` "3.2.4-18-g3672"+#endif      it "should support quoted strings" $ withCString "sample" $ \cstr -> do         str <- sass_make_qstring cstr