mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
Fixes for buildWeb
This commit is contained in:
11
Setup.hs
11
Setup.hs
@@ -2,6 +2,8 @@ import Distribution.Simple(defaultMainWithHooks,UserHooks(..),simpleUserHooks)
|
||||
import Distribution.Simple.LocalBuildInfo(LocalBuildInfo(..),absoluteInstallDirs,datadir)
|
||||
import Distribution.Simple.Setup(BuildFlags(..),Flag(..),InstallFlags(..),CopyDest(..),CopyFlags(..),SDistFlags(..))
|
||||
import Distribution.PackageDescription(PackageDescription(..),emptyHookedBuildInfo)
|
||||
import Distribution.Simple.BuildPaths(exeExtension)
|
||||
import System.FilePath((</>),(<.>))
|
||||
|
||||
import WebSetup
|
||||
|
||||
@@ -33,6 +35,8 @@ main = defaultMainWithHooks simpleUserHooks
|
||||
|
||||
gfPostBuild args flags pkg lbi = do
|
||||
noRGLmsg
|
||||
let gf = default_gf lbi
|
||||
buildWeb gf flags (pkg,lbi)
|
||||
|
||||
gfPostInst args flags pkg lbi = do
|
||||
noRGLmsg
|
||||
@@ -65,3 +69,10 @@ saveCopyPath args flags bi = do
|
||||
-- can determine where to put the compiled RGL files
|
||||
dataDirFile :: String
|
||||
dataDirFile = "DATA_DIR"
|
||||
|
||||
-- | Get path to locally-built gf
|
||||
default_gf :: LocalBuildInfo -> FilePath
|
||||
default_gf lbi = buildDir lbi </> exeName' </> exeNameReal
|
||||
where
|
||||
exeName' = "gf"
|
||||
exeNameReal = exeName' <.> exeExtension
|
||||
|
||||
18
WebSetup.hs
18
WebSetup.hs
@@ -1,6 +1,6 @@
|
||||
module WebSetup(buildWeb,installWeb,copyWeb,numJobs,execute) where
|
||||
|
||||
import System.Directory(createDirectoryIfMissing,copyFile,doesDirectoryExist)
|
||||
import System.Directory(createDirectoryIfMissing,copyFile,doesDirectoryExist,doesFileExist)
|
||||
import System.FilePath((</>),dropExtension)
|
||||
import System.Process(rawSystem)
|
||||
import System.Exit(ExitCode(..))
|
||||
@@ -45,21 +45,20 @@ example_grammars =
|
||||
contrib_dir :: FilePath
|
||||
contrib_dir = ".."</>"gf-contrib"
|
||||
|
||||
buildWeb :: String -> (BuildFlags, PackageDescription, LocalBuildInfo) -> IO ()
|
||||
buildWeb gf (flags,pkg,lbi) = do
|
||||
buildWeb :: String -> BuildFlags -> (PackageDescription, LocalBuildInfo) -> IO ()
|
||||
buildWeb gf flags (pkg,lbi) = do
|
||||
contrib_exists <- doesDirectoryExist contrib_dir
|
||||
if contrib_exists
|
||||
then mapM_ build_pgf example_grammars
|
||||
else putStr $ unlines
|
||||
[ "---"
|
||||
, "Example grammars are no longer included in the main GF repository, but have moved to gf-contrib."
|
||||
[ "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"
|
||||
|
||||
build_pgf :: (String, String, [String]) -> IO Bool
|
||||
build_pgf (pgf,subdir,src) =
|
||||
do createDirectoryIfMissing True tmp_dir
|
||||
putStrLn $ "Building "++pgf
|
||||
@@ -101,10 +100,13 @@ setupWeb dest (pkg,lbi) = do
|
||||
www_dir = datadir (absoluteInstallDirs pkg lbi dest) </> "www"
|
||||
gfo_dir = buildDir lbi </> "examples"
|
||||
|
||||
copy_pgf :: (String, String, [String]) -> IO ()
|
||||
copy_pgf (pgf,subdir,_) =
|
||||
do let dst = grammars_dir</>pgf
|
||||
do let src = gfo_dir </> pgf
|
||||
let dst = grammars_dir </> pgf
|
||||
putStrLn $ "Installing "++dst
|
||||
copyFile (gfo_dir</>pgf) dst
|
||||
ex <- doesFileExist src
|
||||
if ex then copyFile src dst else return ()
|
||||
|
||||
gf_logo = "gf0.png"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user