forked from GitHub/gf-core
workaround for the Nix madness
This commit is contained in:
15
README.md
15
README.md
@@ -38,6 +38,21 @@ or:
|
|||||||
```
|
```
|
||||||
stack install
|
stack install
|
||||||
```
|
```
|
||||||
|
Note that if you are unlucky to have Cabal 3.0 or later, then it uses
|
||||||
|
the so-called Nix style commands. Using those for GF development is
|
||||||
|
a pain. Every time when you change something in the source code, Cabal
|
||||||
|
will generate a new folder for GF to look for the GF libraries and
|
||||||
|
the GF cloud. Either reinstall everything with every change in the
|
||||||
|
compiler, or be sane and stop using cabal-install. Instead you can do:
|
||||||
|
```
|
||||||
|
runghc Setup.hs configure
|
||||||
|
runghc Setup.hs build
|
||||||
|
runghc Setup.hs install
|
||||||
|
```
|
||||||
|
The script will install the GF dependencies globally. The only solution
|
||||||
|
to the Nix madness that I found is radical:
|
||||||
|
|
||||||
|
"No person, no problem" (Нет человека – нет проблемы).
|
||||||
|
|
||||||
For more information, including links to precompiled binaries, see the [download page](https://www.grammaticalframework.org/download/index.html).
|
For more information, including links to precompiled binaries, see the [download page](https://www.grammaticalframework.org/download/index.html).
|
||||||
|
|
||||||
|
|||||||
81
Setup.hs
81
Setup.hs
@@ -4,42 +4,68 @@ import Distribution.Simple.LocalBuildInfo(LocalBuildInfo(..),absoluteInstallDirs
|
|||||||
import Distribution.Simple.Setup(BuildFlags(..),Flag(..),InstallFlags(..),CopyDest(..),CopyFlags(..),SDistFlags(..))
|
import Distribution.Simple.Setup(BuildFlags(..),Flag(..),InstallFlags(..),CopyDest(..),CopyFlags(..),SDistFlags(..))
|
||||||
import Distribution.PackageDescription(PackageDescription(..),emptyHookedBuildInfo)
|
import Distribution.PackageDescription(PackageDescription(..),emptyHookedBuildInfo)
|
||||||
import Distribution.Simple.BuildPaths(exeExtension)
|
import Distribution.Simple.BuildPaths(exeExtension)
|
||||||
|
import System.Directory
|
||||||
import System.FilePath((</>),(<.>))
|
import System.FilePath((</>),(<.>))
|
||||||
|
import System.Process
|
||||||
|
import Control.Monad(forM_,unless)
|
||||||
|
import Control.Exception(bracket_)
|
||||||
|
import Data.Char(isSpace)
|
||||||
|
|
||||||
import WebSetup
|
import WebSetup
|
||||||
|
|
||||||
-- | Notice about RGL not built anymore
|
|
||||||
noRGLmsg :: IO ()
|
|
||||||
noRGLmsg = putStrLn "Notice: the RGL is not built as part of GF anymore. See https://github.com/GrammaticalFramework/gf-rgl"
|
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = defaultMainWithHooks simpleUserHooks
|
main = defaultMainWithHooks simpleUserHooks
|
||||||
{ preBuild = gfPreBuild
|
{ preConf = gfPreConf
|
||||||
|
, preBuild = gfPreBuild
|
||||||
, postBuild = gfPostBuild
|
, postBuild = gfPostBuild
|
||||||
, preInst = gfPreInst
|
, preInst = gfPreInst
|
||||||
, postInst = gfPostInst
|
, postInst = gfPostInst
|
||||||
, postCopy = gfPostCopy
|
, postCopy = gfPostCopy
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
gfPreBuild args = gfPre args . buildDistPref
|
gfPreConf args flags = do
|
||||||
gfPreInst args = gfPre args . installDistPref
|
pkgs <- fmap (map (dropWhile isSpace) . tail . lines)
|
||||||
|
(readProcess "ghc-pkg" ["list"] "")
|
||||||
|
forM_ dependencies $ \pkg -> do
|
||||||
|
let name = takeWhile (/='/') (drop 36 pkg)
|
||||||
|
unless (name `elem` pkgs) $ do
|
||||||
|
let fname = name <.> ".tar.gz"
|
||||||
|
callProcess "wget" [pkg,"-O",fname]
|
||||||
|
callProcess "tar" ["-xzf",fname]
|
||||||
|
removeFile fname
|
||||||
|
bracket_ (setCurrentDirectory name) (setCurrentDirectory ".." >> removeDirectoryRecursive name) $ do
|
||||||
|
exists <- doesFileExist "Setup.hs"
|
||||||
|
unless exists $ do
|
||||||
|
writeFile "Setup.hs" (unlines [
|
||||||
|
"import Distribution.Simple",
|
||||||
|
"main = defaultMain"
|
||||||
|
])
|
||||||
|
let to_descr = reverse .
|
||||||
|
(++) (reverse ".cabal") .
|
||||||
|
drop 1 .
|
||||||
|
dropWhile (/='-') .
|
||||||
|
reverse
|
||||||
|
callProcess "wget" [to_descr pkg, "-O", to_descr name]
|
||||||
|
callProcess "runghc" ["Setup.hs","configure"]
|
||||||
|
callProcess "runghc" ["Setup.hs","build"]
|
||||||
|
callProcess "sudo" ["runghc","Setup.hs","install"]
|
||||||
|
|
||||||
|
preConf simpleUserHooks args flags
|
||||||
|
|
||||||
|
gfPreBuild args = gfPre args . buildDistPref
|
||||||
|
gfPreInst args = gfPre args . installDistPref
|
||||||
|
|
||||||
gfPre args distFlag = do
|
gfPre args distFlag = do
|
||||||
return emptyHookedBuildInfo
|
return emptyHookedBuildInfo
|
||||||
|
|
||||||
gfPostBuild args flags pkg lbi = do
|
gfPostBuild args flags pkg lbi = do
|
||||||
-- noRGLmsg
|
|
||||||
let gf = default_gf lbi
|
let gf = default_gf lbi
|
||||||
buildWeb gf flags (pkg,lbi)
|
buildWeb gf flags (pkg,lbi)
|
||||||
|
|
||||||
gfPostInst args flags pkg lbi = do
|
gfPostInst args flags pkg lbi = do
|
||||||
-- noRGLmsg
|
|
||||||
saveInstallPath args flags (pkg,lbi)
|
|
||||||
installWeb (pkg,lbi)
|
installWeb (pkg,lbi)
|
||||||
|
|
||||||
gfPostCopy args flags pkg lbi = do
|
gfPostCopy args flags pkg lbi = do
|
||||||
-- noRGLmsg
|
|
||||||
saveCopyPath args flags (pkg,lbi)
|
|
||||||
copyWeb flags (pkg,lbi)
|
copyWeb flags (pkg,lbi)
|
||||||
|
|
||||||
-- `cabal sdist` will not make a proper dist archive, for that see `make sdist`
|
-- `cabal sdist` will not make a proper dist archive, for that see `make sdist`
|
||||||
@@ -47,27 +73,16 @@ main = defaultMainWithHooks simpleUserHooks
|
|||||||
gfSDist pkg lbi hooks flags = do
|
gfSDist pkg lbi hooks flags = do
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
saveInstallPath :: [String] -> InstallFlags -> (PackageDescription, LocalBuildInfo) -> IO ()
|
dependencies = [
|
||||||
saveInstallPath args flags bi = do
|
"https://hackage.haskell.org/package/utf8-string-1.0.2/utf8-string-1.0.2.tar.gz",
|
||||||
let
|
"https://hackage.haskell.org/package/json-0.10/json-0.10.tar.gz",
|
||||||
dest = NoCopyDest
|
"https://hackage.haskell.org/package/network-bsd-2.8.1.0/network-bsd-2.8.1.0.tar.gz",
|
||||||
dir = datadir (uncurry absoluteInstallDirs bi dest)
|
"https://hackage.haskell.org/package/httpd-shed-0.4.1.1/httpd-shed-0.4.1.1.tar.gz",
|
||||||
writeFile dataDirFile dir
|
"https://hackage.haskell.org/package/exceptions-0.10.5/exceptions-0.10.5.tar.gz",
|
||||||
|
"https://hackage.haskell.org/package/stringsearch-0.3.6.6/stringsearch-0.3.6.6.tar.gz",
|
||||||
saveCopyPath :: [String] -> CopyFlags -> (PackageDescription, LocalBuildInfo) -> IO ()
|
"https://hackage.haskell.org/package/multipart-0.2.1/multipart-0.2.1.tar.gz",
|
||||||
saveCopyPath args flags bi = do
|
"https://hackage.haskell.org/package/cgi-3001.5.0.0/cgi-3001.5.0.0.tar.gz"
|
||||||
let
|
]
|
||||||
dest = case copyDest flags of
|
|
||||||
NoFlag -> NoCopyDest
|
|
||||||
Flag d -> d
|
|
||||||
dir = datadir (uncurry absoluteInstallDirs bi dest)
|
|
||||||
writeFile dataDirFile dir
|
|
||||||
|
|
||||||
-- | Name of file where installation's data directory is recording
|
|
||||||
-- This is a last-resort way in which the seprate RGL build script
|
|
||||||
-- can determine where to put the compiled RGL files
|
|
||||||
dataDirFile :: String
|
|
||||||
dataDirFile = "DATA_DIR"
|
|
||||||
|
|
||||||
-- | Get path to locally-built gf
|
-- | Get path to locally-built gf
|
||||||
default_gf :: LocalBuildInfo -> FilePath
|
default_gf :: LocalBuildInfo -> FilePath
|
||||||
|
|||||||
14
gf.cabal
14
gf.cabal
@@ -2,7 +2,7 @@ name: gf
|
|||||||
version: 3.11.0-git
|
version: 3.11.0-git
|
||||||
|
|
||||||
cabal-version: 1.22
|
cabal-version: 1.22
|
||||||
build-type: Custom
|
build-type: Simple
|
||||||
license: OtherLicense
|
license: OtherLicense
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
category: Natural Language Processing, Compiler
|
category: Natural Language Processing, Compiler
|
||||||
@@ -44,14 +44,6 @@ data-files:
|
|||||||
www/translator/*.css
|
www/translator/*.css
|
||||||
www/translator/*.js
|
www/translator/*.js
|
||||||
|
|
||||||
custom-setup
|
|
||||||
setup-depends:
|
|
||||||
base >= 4.9.1 && < 4.16,
|
|
||||||
Cabal >= 1.22.0.0,
|
|
||||||
directory >= 1.3.0 && < 1.4,
|
|
||||||
filepath >= 1.4.1 && < 1.5,
|
|
||||||
process >= 1.0.1.1 && < 1.7
|
|
||||||
|
|
||||||
source-repository head
|
source-repository head
|
||||||
type: git
|
type: git
|
||||||
location: https://github.com/GrammaticalFramework/gf-core.git
|
location: https://github.com/GrammaticalFramework/gf-core.git
|
||||||
@@ -89,9 +81,7 @@ library
|
|||||||
mtl >= 2.2.1 && < 2.3,
|
mtl >= 2.2.1 && < 2.3,
|
||||||
pretty >= 1.1.3 && < 1.2,
|
pretty >= 1.1.3 && < 1.2,
|
||||||
random >= 1.1 && < 1.3,
|
random >= 1.1 && < 1.3,
|
||||||
utf8-string >= 1.0.1.1 && < 1.1,
|
utf8-string >= 1.0.1.1 && < 1.1
|
||||||
-- We need transformers-compat >= 0.6.3, but that is only in newer snapshots where it is redundant.
|
|
||||||
transformers-compat >= 0.5.1.4 && < 0.7
|
|
||||||
|
|
||||||
if impl(ghc<8.0)
|
if impl(ghc<8.0)
|
||||||
build-depends:
|
build-depends:
|
||||||
|
|||||||
@@ -38,8 +38,6 @@ import GF.Server(server)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
import GF.Command.Messages(welcome)
|
import GF.Command.Messages(welcome)
|
||||||
-- Provides an orphan instance of MonadFail for StateT in ghc versions < 8
|
|
||||||
import Control.Monad.Trans.Instances ()
|
|
||||||
|
|
||||||
-- | Run the GF Shell in quiet mode (@gf -run@).
|
-- | Run the GF Shell in quiet mode (@gf -run@).
|
||||||
mainRunGFI :: Options -> [FilePath] -> IO ()
|
mainRunGFI :: Options -> [FilePath] -> IO ()
|
||||||
|
|||||||
Reference in New Issue
Block a user