summaryrefslogtreecommitdiff
path: root/WebSetup.hs
diff options
context:
space:
mode:
Diffstat (limited to 'WebSetup.hs')
-rw-r--r--WebSetup.hs46
1 files changed, 35 insertions, 11 deletions
diff --git a/WebSetup.hs b/WebSetup.hs
index ee9f741d6..e18847a6b 100644
--- a/WebSetup.hs
+++ b/WebSetup.hs
@@ -1,12 +1,13 @@
module WebSetup(buildWeb,installWeb,copyWeb,numJobs,execute) where
-import System.Directory(createDirectoryIfMissing,copyFile)
+import System.Directory(createDirectoryIfMissing,copyFile,doesDirectoryExist)
import System.FilePath((</>),dropExtension)
import System.Process(rawSystem)
import System.Exit(ExitCode(..))
import Distribution.Simple.Setup(BuildFlags(..),Flag(..),CopyDest(..),copyDest)
import Distribution.Simple.LocalBuildInfo(datadir,buildDir,absoluteInstallDirs)
-import Distribution.Simple.Utils(die)
+import Distribution.Simple.Utils(die,noticeNoWrap)
+import qualified Distribution.Verbosity
{-
To test the GF web services, the minibar and the grammar editor, use
@@ -16,6 +17,16 @@ import Distribution.Simple.Utils(die)
Chrome). The example grammars listed below will be available in the minibar.
-}
+{-
+ Update 2018-07-04
+
+ The example grammars have now been removed from the GF repository.
+ This script will look for them in ../gf-contrib and build them from there if possible.
+ If not, the user will be given a message and nothing is build or copied.
+ (Unfortunately cabal install seems to hide all messages from stdout,
+ so users won't see this message unless they check the log.)
+-}
+
example_grammars = -- :: [(pgf, subdir, src)]
[("Letter.pgf","letter",letterSrc)
,("Foods.pgf","foods",foodsSrc)
@@ -34,10 +45,20 @@ example_grammars = -- :: [(pgf, subdir, src)]
letterSrc = ["Letter"++lang++".gf"|lang<-letterLangs]
letterLangs = words "Eng Fin Fre Heb Rus Swe"
-
-buildWeb gf (flags,pkg,lbi) =
- do --putStrLn "buildWeb"
- mapM_ build_pgf example_grammars
+contrib_dir :: FilePath
+contrib_dir = ".."</>"gf-contrib"
+
+buildWeb gf (flags,pkg,lbi) = do
+ contrib_exists <- doesDirectoryExist contrib_dir
+ if contrib_exists
+ then mapM_ build_pgf example_grammars
+ else noticeNoWrap Distribution.Verbosity.normal $ unlines
+ [ "---"
+ , "Example grammars are no longer included in the main GF repository, but have moved to gf-contrib."
+ , "If you want these example grammars to be built, clone this repository in the same top-level directory as GF:"
+ , "https://github.com/GrammaticalFramework/gf-contrib.git"
+ , "---"
+ ]
where
gfo_dir = buildDir lbi </> "examples"
@@ -47,7 +68,7 @@ buildWeb gf (flags,pkg,lbi) =
execute gf args
where
tmp_dir = gfo_dir</>subdir
- dir = "examples"</>subdir
+ dir = contrib_dir</>subdir
args = numJobs flags++["-make","-s"] -- ,"-optimize-pgf"
++["--gfo-dir="++tmp_dir,
"--gf-lib-path="++buildDir lbi </> "rgl",
@@ -63,10 +84,13 @@ copyWeb flags = setupWeb dest
NoFlag -> NoCopyDest
Flag d -> d
-setupWeb dest (pkg,lbi) =
- do mapM_ (createDirectoryIfMissing True) [grammars_dir,cloud_dir]
- mapM_ copy_pgf example_grammars
- copyGFLogo
+setupWeb dest (pkg,lbi) = do
+ mapM_ (createDirectoryIfMissing True) [grammars_dir,cloud_dir]
+ contrib_exists <- doesDirectoryExist contrib_dir
+ if contrib_exists
+ then mapM_ copy_pgf example_grammars
+ else return () -- message already displayed from buildWeb
+ copyGFLogo
where
grammars_dir = www_dir </> "grammars"
cloud_dir = www_dir </> "tmp" -- hmm