Compile example grammars during the build phase instead of the install phase

This allows more errors to be detected by the build bot.
TODO: fix the gf --output-dir flag, which does not seem to change where PGF
file are put.
This commit is contained in:
hallgren
2014-06-18 23:57:45 +00:00
parent 5146f4aaba
commit 131ef1f444
2 changed files with 41 additions and 32 deletions

View File

@@ -24,7 +24,7 @@ tryIOE = E.try
main :: IO ()
main = defaultMainWithHooks simpleUserHooks{ preBuild =gfPreBuild
, postBuild=buildRGL
, postBuild=gfPostBuild
, preInst =gfPreInst
, postInst =gfPostInst
, preCopy =const . checkRGLArgs
@@ -41,6 +41,11 @@ main = defaultMainWithHooks simpleUserHooks{ preBuild =gfPreBuild
extractDarcsVersion distFlag
return h
gfPostBuild args flags pkg lbi =
do buildRGL args flags pkg lbi
let gf = default_gf pkg lbi
buildWeb gf args flags pkg lbi
gfPostInst args flags pkg lbi =
do installRGL args flags pkg lbi
let gf = default_gf pkg lbi

View File

@@ -1,4 +1,4 @@
module WebSetup(installWeb,copyWeb) where
module WebSetup(buildWeb,installWeb,copyWeb) where
import System.Directory(createDirectoryIfMissing,copyFile,removeFile)
import System.FilePath((</>))
@@ -15,27 +15,41 @@ import Distribution.Simple.LocalBuildInfo(datadir,buildDir,absoluteInstallDirs)
Chrome). The example grammars listed below will be available in the minibar.
-}
example_grammars = -- :: [(pgf, tmp, src)]
[("Foods.pgf","foods",foodsSrc)
example_grammars = -- :: [(pgf, subdir, src)]
[("Letter.pgf","letter",letterSrc)
,("Foods.pgf","foods",foodsSrc)
,("Phrasebook.pgf","phrasebook",phrasebookSrc)
,("Letter.pgf","letter",letterSrc)
]
where
foodsDir ="examples"</>"foods"
--foodsSrc = foodsDir</>"Foods???.gf" -- doesn't work on Win32
foodsSrc = unwords [foodsDir</>"Foods"++lang++".gf"|lang<-foodsLangs]
--foodsSrc = "Foods???.gf" -- doesn't work on Win32
foodsSrc = ["Foods"++lang++".gf"|lang<-foodsLangs]
foodsLangs = words "Afr Amh Bul Cat Cze Dut Eng Epo Fin Fre Ger Gle Heb Hin Ice Ita Jpn Lav Mlt Mon Nep Pes Por Ron Spa Swe Tha Tsn Tur Urd"
phrasebookDir ="examples"</>"phrasebook"
--phrasebookSrc = phrasebookDir</>"Phrasebook???.gf" -- doesn't work on Win32
phrasebookSrc = unwords [phrasebookDir</>"Phrasebook"++lang++".gf"|lang<-phrasebookLangs]
phrasebookLangs = words "Bul Cat Dan Dut Eng Hin Lav Nor Spa Swe Tha" -- only fastish languages
--phrasebookSrc = "Phrasebook???.gf" -- doesn't work on Win32
phrasebookSrc = ["Phrasebook"++lang++".gf"|lang<-phrasebookLangs]
phrasebookLangs = words "Bul Cat Dan Dut Eng Lav Hin Nor Spa Swe Tha" -- only fastish languages
letterDir = "examples"</>"letter"
--letterSrc = letterDir</>"Letter???.gf"
letterSrc = unwords [letterDir</>"Letter"++lang++".gf"|lang<-letterLangs]
--letterSrc = "Letter???.gf"
letterSrc = ["Letter"++lang++".gf"|lang<-letterLangs]
letterLangs = words "Eng Fin Fre Heb Rus Swe"
buildWeb gf args flags pkg lbi =
do putStrLn "buildWeb"
mapM_ build_pgf example_grammars
where
gfo_dir = buildDir lbi </> "examples"
build_pgf (pgf,subdir,src) =
do createDirectoryIfMissing True tmp_dir
putStrLn $ "Building "++pgf
execute cmd
where
tmp_dir = gfo_dir</>subdir
dir = "examples"</>subdir
cmd = gf++" -make -s -optimize-pgf --gfo-dir="++tmp_dir++
" --gf-lib-path="++buildDir lbi </> "rgl"++
-- " --output-dir="++tmp_dir++ -- has no effect?!
" "++unwords [dir</>file|file<-src]
installWeb gf args flags pki lbi = setupWeb gf args dest pki lbi
where
@@ -48,29 +62,19 @@ copyWeb gf args flags pki lbi = setupWeb gf args dest pki lbi
Flag d -> d
setupWeb gf args dest pkg lbi =
do putStrLn "setupWeb"
mapM_ (createDirectoryIfMissing True) [grammars_dir,cloud_dir]
mapM_ build_pgf example_grammars
do mapM_ (createDirectoryIfMissing True) [grammars_dir,cloud_dir]
mapM_ copy_pgf example_grammars
copyGFLogo
where
grammars_dir = www_dir </> "grammars"
cloud_dir = www_dir </> "tmp" -- hmm
logo_dir = www_dir </> "Logos"
www_dir = datadir (absoluteInstallDirs pkg lbi dest) </> "www"
gfo_dir = buildDir lbi </> "gfo"
build_pgf (pgf,tmp,src) =
do createDirectoryIfMissing True tmp_dir
execute cmd
copyFile pgf (grammars_dir</>pgf)
putStrLn (grammars_dir</>pgf)
removeFile pgf
where
tmp_dir = gfo_dir</>tmp
cmd = gf++" -make -s -optimize-pgf --gfo-dir="++tmp_dir++
" --gf-lib-path="++buildDir lbi </> "rgl"++
-- " --output-dir="++grammars_dir++ -- has no effect?!
" "++src
copy_pgf (pgf,subdir,_) =
do let dst = grammars_dir</>pgf
putStrLn $ "Installing "++dst
copyFile pgf dst
gf_logo = "gf0.png"
@@ -79,7 +83,7 @@ setupWeb gf args dest pkg lbi =
copyFile ("doc"</>"Logos"</>gf_logo) (logo_dir</>gf_logo)
execute command =
do putStrLn command
do --putStrLn command
e <- system command
case e of
ExitSuccess -> return ()