diff --git a/.gitignore b/.gitignore index 94e6cb95..1e335725 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ dist/ *.hi *.o *.pgf +*.tmp diff --git a/Make.bat b/Make.bat index d4b9418f..16ba98fa 100644 --- a/Make.bat +++ b/Make.bat @@ -6,6 +6,7 @@ REM Non-Haskell RGL build script for Windows machines REM --- REM Modules to compile for each language +REM TODO read from languages.csv set langs=Afr Amh Ara Eus Bul Cat Chi Dan Dut Eng Est Fin Fre Grc Gre Heb Hin Ger Ice Ina Ita Jpn Lat Lav Mlt Mon Nep Nor Nno Pes Pol Por Pnb Ron Rus Snd Spa Swe Tha Tur Urd set modules_langs=All Symbol Compatibility set modules_api=Try Symbolic diff --git a/Make.hs b/Make.hs index 011c0dcd..686067d1 100644 --- a/Make.hs +++ b/Make.hs @@ -192,9 +192,9 @@ rglCommands = -- summary f _ = f (LangInfo "*" "*" Nothing Nothing False False False False) l mode args = (lang,optml mode langAll args) - s mode args = (symbol,optml mode langAPI args) + s mode args = (symbol,optml mode langTry args) c mode args = (compat,optml AllTenses langCompatibility args) - t mode args = (try,optml mode langAPI args) + t mode args = (try,optml mode langTry args) sc mode args = (symbolic,optml mode langSymbolic args) optml :: Mode -> (LangInfo -> Bool) -> [String] -> ([LangInfo] -> [LangInfo]) @@ -335,7 +335,7 @@ data LangInfo = LangInfo , langUnlexer :: Maybe String -- ^ decoding for postprocessing linearizations , langPresent :: Bool , langAll :: Bool - , langAPI :: Bool + , langTry :: Bool , langSymbolic :: Bool , langCompatibility :: Bool } deriving (Show,Eq) @@ -360,7 +360,7 @@ loadLangs = do , langUnlexer = maybeBit bits 3 , langPresent = boolBit bits 4 False , langAll = boolBit bits 5 True - , langAPI = boolBit bits 6 True + , langTry = boolBit bits 6 True , langSymbolic = boolBit bits 7 True , langCompatibility = boolBit bits 8 False } diff --git a/Make.sh b/Make.sh index b5b6512f..4aa66b7e 100755 --- a/Make.sh +++ b/Make.sh @@ -4,8 +4,14 @@ # Non-Haskell RGL build script for Unix-based machines # --- +# Get languages from config +langs=$(tail -n +2 languages.csv | awk -F ',' '{ if ($6 != "n") { print $1 } }') +langs_present=$(tail -n +2 languages.csv | awk -F ',' '{ if ($5 == "y") { print $1 } }') +langs_try=$(tail -n +2 languages.csv | awk -F ',' '{ if ($7 != "n") { print $1 } }') +langs_symbolic=$(tail -n +2 languages.csv | awk -F ',' '{ if ($8 != "n") { print $1 } }') +langs_compat=$(tail -n +2 languages.csv | awk -F ',' '{ if ($9 == "y") { print $1 } }') + # Modules to compile for each language -# langs="Afr Amh Ara Eus Bul Cat Chi Dan Dut Eng Est Fin Fre Grc Gre Heb Hin Ger Ice Ina Ita Jpn Lat Lav Mlt Mon Nep Nor Nno Pes Pol Por Pnb Ron Rus Snd Spa Swe Tha Tur Urd" modules_langs="All Symbol Compatibility" modules_api="Try Symbolic" @@ -46,7 +52,7 @@ fi # A few more definitions before we get started src="src" dist="dist" -gfc="${gf} --batch --gf-lib-path=${src} --quiet" +gfc="${gf} --batch --quiet" # Redirect stderr if not verbose if [ $verbose = false ]; then @@ -60,29 +66,35 @@ mkdir -p "${dist}/alltenses" # Build: prelude echo "Building [prelude]" +if [ $verbose = true ]; then echo "${src}"/prelude/*.gf; fi ${gfc} --gfo-dir="${dist}"/prelude "${src}"/prelude/*.gf # Gather all language modules for building -for mod in $modules_langs; do - for file in "${src}"/*/"${mod}"???.gf; do - modules="${modules} ${file}" - done -done -for mod in $modules_api; do - for file in "${src}"/api/"${mod}"???.gf; do - modules="${modules} ${file}" +modules_present= +modules_alltenses= +for lang in $langs; do + for mod in $modules_langs $modules_api; do + if [ $mod == "Compatibility" ] && [[ "$langs_compat" != *"$lang"* ]]; then continue; fi + if [ $mod == "Try" ] && [[ "$langs_try" != *"$lang"* ]]; then continue; fi + if [ $mod == "Symbolic" ] && [[ "$langs_symbolic" != *"$lang"* ]]; then continue; fi + for file in "${src}"/*/"${mod}${lang}".gf; do + if [[ "$langs_present" = *"$lang"* ]]; then modules_present="${modules_present} ${file}"; fi + modules_alltenses="${modules_alltenses} ${file}" + done done done # Build: present echo "Building [present]" -for module in $modules; do +if [ $verbose = true ]; then echo $modules_present; fi +for module in $modules_present; do ${gfc} --no-pmcfg --gfo-dir="${dist}"/present --preproc=mkPresent "${module}" done # Build: alltenses echo "Building [alltenses]" -for module in $modules; do +if [ $verbose = true ]; then echo $modules_alltenses; fi +for module in $modules_alltenses; do ${gfc} --no-pmcfg --gfo-dir="${dist}"/alltenses "${module}" done diff --git a/README.md b/README.md index 06296989..db12cad0 100644 --- a/README.md +++ b/README.md @@ -27,18 +27,18 @@ It will look for, in this order: A list of all languages and their properties is maintained centrally in `languages.csv`. This file should be kept up-to-date and all build methods should read this config file. -If you see something wrong, please report/fix it. +**If you see something wrong, please report/fix it.** Description of columns: -- Code -- Directory -- Functor: (not used) -- Unlexer -- Present: languages that have notpresent marked -- All: languages for which to compile All -- API: languages for which to compile Try -- Symbolic: languages for which to compile Symbolic -- Compatibility: languages for which Compatibility exists +- Code, e,g, `Eng` +- Directory, e.g. `english` +- Functor (not used) +- Unlexer (not used) +- Present: languages that have `--# notpresent` marked +- All: languages for which to compile `All` +- Try: languages for which to compile `Try` +- Symbolic: languages for which to compile `Symbolic` +- Compatibility: languages for which to complile `Compatibility` Columns can be a string, just `y`'s (where nothing means `n`) or just (`n`'s where nothing means `y`). @@ -86,12 +86,12 @@ or an explicit module name (e.g. `ExtraEng.gf`. You don't need to specify to lan `present`, `alltenses` (default is both). +- `LANG` is a 3-letter language code, e.g. `Eng`, `Swe` etc. - You can _override_ the default language list with `--langs=...` - You can _add_ languages to the default list with `--langs=+...` - You can _remove_ languages from the default list with `langs=-...` -- `LANG` is a 3-letter language code, e.g. `Eng`, `Swe` etc. -- The path to GF installed on your system can be specified via the `gf` flag (default is that the `gf` executable is in the global system path). -- The `dest` flag can be used to manually specify where the compiled RGL modules should be copied/installed. This is the same place as `GF_LIB_PATH`. +- The path to GF installed on your system can be specified via the `--gf` flag (default is that the `gf` executable is in the global system path). +- The `--dest` flag can be used to manually specify where the compiled RGL modules should be copied/installed. This is the same place as `GF_LIB_PATH`. ## Shell script: `Make.sh` @@ -103,8 +103,6 @@ You can pass the following flags: - `--gf=...` to specify the path to the `gf` executable, if not available on the system path - `--verbose` or `-v` to show all GF warnings and errors -This build method tries to build all languages found in the `src` directory, even those which are not considered complete. - ## Windows batch file: `Make.bat` **This script is still untested.** @@ -114,7 +112,7 @@ This method is provided as an alternative for Windows users who don't have Haske It is supposed to be a port of Make.sh and works in largely the same way. In particular, it accepts the same flags (in the same format) as described above. -One difference is that the list of languages to be compiled is specified manually in the script in the `langs` variable. +However it currently tries to build all modules for all languages and doesn't consider the details of which modules should be compiled for each language (specified in `languages.csv`) ## About this repository diff --git a/languages.csv b/languages.csv index 7ee44f86..633fabd1 100644 --- a/languages.csv +++ b/languages.csv @@ -1,4 +1,4 @@ -Code,Directory,Functor,Unlexer,Present,All,API,Symbolic,Compatibility +Code,Directory,Functor,Unlexer,Present,All,Try,Symbolic,Compatibility Afr,afrikaans,,,,,,n, Amh,amharic,,,,,n,n, Ara,arabic,,,,,n,n, @@ -42,4 +42,4 @@ Swe,swedish,Scand,,y,,,,y Tel,telugu,,,y,n,n,n, Tha,thai,,to_thai,,,,, Tur,turkish,,,,,n,n, -Urd,urdu,Hindustani,,,,,, \ No newline at end of file +Urd,urdu,Hindustani,,,,,,