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 3d5d600236
commit a21a782e47
2 changed files with 41 additions and 32 deletions

View File

@@ -24,7 +24,7 @@ tryIOE = E.try
main :: IO () main :: IO ()
main = defaultMainWithHooks simpleUserHooks{ preBuild =gfPreBuild main = defaultMainWithHooks simpleUserHooks{ preBuild =gfPreBuild
, postBuild=buildRGL , postBuild=gfPostBuild
, preInst =gfPreInst , preInst =gfPreInst
, postInst =gfPostInst , postInst =gfPostInst
, preCopy =const . checkRGLArgs , preCopy =const . checkRGLArgs
@@ -41,6 +41,11 @@ main = defaultMainWithHooks simpleUserHooks{ preBuild =gfPreBuild
extractDarcsVersion distFlag extractDarcsVersion distFlag
return h 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 = gfPostInst args flags pkg lbi =
do installRGL args flags pkg lbi do installRGL args flags pkg lbi
let gf = default_gf 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.Directory(createDirectoryIfMissing,copyFile,removeFile)
import System.FilePath((</>)) 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. Chrome). The example grammars listed below will be available in the minibar.
-} -}
example_grammars = -- :: [(pgf, tmp, src)] example_grammars = -- :: [(pgf, subdir, src)]
[("Foods.pgf","foods",foodsSrc) [("Letter.pgf","letter",letterSrc)
,("Foods.pgf","foods",foodsSrc)
,("Phrasebook.pgf","phrasebook",phrasebookSrc) ,("Phrasebook.pgf","phrasebook",phrasebookSrc)
,("Letter.pgf","letter",letterSrc)
] ]
where where
foodsDir ="examples"</>"foods" --foodsSrc = "Foods???.gf" -- doesn't work on Win32
--foodsSrc = foodsDir</>"Foods???.gf" -- doesn't work on Win32 foodsSrc = ["Foods"++lang++".gf"|lang<-foodsLangs]
foodsSrc = unwords [foodsDir</>"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" 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 = "Phrasebook???.gf" -- doesn't work on Win32
--phrasebookSrc = phrasebookDir</>"Phrasebook???.gf" -- doesn't work on Win32 phrasebookSrc = ["Phrasebook"++lang++".gf"|lang<-phrasebookLangs]
phrasebookSrc = unwords [phrasebookDir</>"Phrasebook"++lang++".gf"|lang<-phrasebookLangs] phrasebookLangs = words "Bul Cat Dan Dut Eng Lav Hin Nor Spa Swe Tha" -- only fastish languages
phrasebookLangs = words "Bul Cat Dan Dut Eng Hin Lav Nor Spa Swe Tha" -- only fastish languages
letterDir = "examples"</>"letter" --letterSrc = "Letter???.gf"
--letterSrc = letterDir</>"Letter???.gf" letterSrc = ["Letter"++lang++".gf"|lang<-letterLangs]
letterSrc = unwords [letterDir</>"Letter"++lang++".gf"|lang<-letterLangs]
letterLangs = words "Eng Fin Fre Heb Rus Swe" 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 installWeb gf args flags pki lbi = setupWeb gf args dest pki lbi
where where
@@ -48,29 +62,19 @@ copyWeb gf args flags pki lbi = setupWeb gf args dest pki lbi
Flag d -> d Flag d -> d
setupWeb gf args dest pkg lbi = setupWeb gf args dest pkg lbi =
do putStrLn "setupWeb" do mapM_ (createDirectoryIfMissing True) [grammars_dir,cloud_dir]
mapM_ (createDirectoryIfMissing True) [grammars_dir,cloud_dir] mapM_ copy_pgf example_grammars
mapM_ build_pgf example_grammars
copyGFLogo copyGFLogo
where where
grammars_dir = www_dir </> "grammars" grammars_dir = www_dir </> "grammars"
cloud_dir = www_dir </> "tmp" -- hmm cloud_dir = www_dir </> "tmp" -- hmm
logo_dir = www_dir </> "Logos" logo_dir = www_dir </> "Logos"
www_dir = datadir (absoluteInstallDirs pkg lbi dest) </> "www" www_dir = datadir (absoluteInstallDirs pkg lbi dest) </> "www"
gfo_dir = buildDir lbi </> "gfo"
build_pgf (pgf,tmp,src) = copy_pgf (pgf,subdir,_) =
do createDirectoryIfMissing True tmp_dir do let dst = grammars_dir</>pgf
execute cmd putStrLn $ "Installing "++dst
copyFile pgf (grammars_dir</>pgf) copyFile pgf dst
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
gf_logo = "gf0.png" gf_logo = "gf0.png"
@@ -79,7 +83,7 @@ setupWeb gf args dest pkg lbi =
copyFile ("doc"</>"Logos"</>gf_logo) (logo_dir</>gf_logo) copyFile ("doc"</>"Logos"</>gf_logo) (logo_dir</>gf_logo)
execute command = execute command =
do putStrLn command do --putStrLn command
e <- system command e <- system command
case e of case e of
ExitSuccess -> return () ExitSuccess -> return ()