1
0
forked from GitHub/gf-rgl

Updade Make.sh to read languages.csv, more specific about what to compile

This commit is contained in:
John J. Camilleri
2018-08-07 10:06:12 +02:00
parent 1208cdf9bc
commit b76d8512e4
6 changed files with 46 additions and 34 deletions

1
.gitignore vendored
View File

@@ -3,3 +3,4 @@ dist/
*.hi *.hi
*.o *.o
*.pgf *.pgf
*.tmp

View File

@@ -6,6 +6,7 @@ REM Non-Haskell RGL build script for Windows machines
REM --- REM ---
REM Modules to compile for each language 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 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_langs=All Symbol Compatibility
set modules_api=Try Symbolic set modules_api=Try Symbolic

View File

@@ -192,9 +192,9 @@ rglCommands =
-- summary f _ = f (LangInfo "*" "*" Nothing Nothing False False False False) -- summary f _ = f (LangInfo "*" "*" Nothing Nothing False False False False)
l mode args = (lang,optml mode langAll args) 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) 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) sc mode args = (symbolic,optml mode langSymbolic args)
optml :: Mode -> (LangInfo -> Bool) -> [String] -> ([LangInfo] -> [LangInfo]) optml :: Mode -> (LangInfo -> Bool) -> [String] -> ([LangInfo] -> [LangInfo])
@@ -335,7 +335,7 @@ data LangInfo = LangInfo
, langUnlexer :: Maybe String -- ^ decoding for postprocessing linearizations , langUnlexer :: Maybe String -- ^ decoding for postprocessing linearizations
, langPresent :: Bool , langPresent :: Bool
, langAll :: Bool , langAll :: Bool
, langAPI :: Bool , langTry :: Bool
, langSymbolic :: Bool , langSymbolic :: Bool
, langCompatibility :: Bool , langCompatibility :: Bool
} deriving (Show,Eq) } deriving (Show,Eq)
@@ -360,7 +360,7 @@ loadLangs = do
, langUnlexer = maybeBit bits 3 , langUnlexer = maybeBit bits 3
, langPresent = boolBit bits 4 False , langPresent = boolBit bits 4 False
, langAll = boolBit bits 5 True , langAll = boolBit bits 5 True
, langAPI = boolBit bits 6 True , langTry = boolBit bits 6 True
, langSymbolic = boolBit bits 7 True , langSymbolic = boolBit bits 7 True
, langCompatibility = boolBit bits 8 False , langCompatibility = boolBit bits 8 False
} }

34
Make.sh
View File

@@ -4,8 +4,14 @@
# Non-Haskell RGL build script for Unix-based machines # 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 # 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_langs="All Symbol Compatibility"
modules_api="Try Symbolic" modules_api="Try Symbolic"
@@ -46,7 +52,7 @@ fi
# A few more definitions before we get started # A few more definitions before we get started
src="src" src="src"
dist="dist" dist="dist"
gfc="${gf} --batch --gf-lib-path=${src} --quiet" gfc="${gf} --batch --quiet"
# Redirect stderr if not verbose # Redirect stderr if not verbose
if [ $verbose = false ]; then if [ $verbose = false ]; then
@@ -60,29 +66,35 @@ mkdir -p "${dist}/alltenses"
# Build: prelude # Build: prelude
echo "Building [prelude]" echo "Building [prelude]"
if [ $verbose = true ]; then echo "${src}"/prelude/*.gf; fi
${gfc} --gfo-dir="${dist}"/prelude "${src}"/prelude/*.gf ${gfc} --gfo-dir="${dist}"/prelude "${src}"/prelude/*.gf
# Gather all language modules for building # Gather all language modules for building
for mod in $modules_langs; do modules_present=
for file in "${src}"/*/"${mod}"???.gf; do modules_alltenses=
modules="${modules} ${file}" 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
for mod in $modules_api; do
for file in "${src}"/api/"${mod}"???.gf; do
modules="${modules} ${file}"
done done
done done
# Build: present # Build: present
echo "Building [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}" ${gfc} --no-pmcfg --gfo-dir="${dist}"/present --preproc=mkPresent "${module}"
done done
# Build: alltenses # Build: alltenses
echo "Building [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}" ${gfc} --no-pmcfg --gfo-dir="${dist}"/alltenses "${module}"
done done

View File

@@ -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`. 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. 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: Description of columns:
- Code - Code, e,g, `Eng`
- Directory - Directory, e.g. `english`
- Functor: (not used) - Functor (not used)
- Unlexer - Unlexer (not used)
- Present: languages that have notpresent marked - Present: languages that have `--# notpresent` marked
- All: languages for which to compile All - All: languages for which to compile `All`
- API: languages for which to compile Try - Try: languages for which to compile `Try`
- Symbolic: languages for which to compile Symbolic - Symbolic: languages for which to compile `Symbolic`
- Compatibility: languages for which Compatibility exists - 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`). 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`, `present`,
`alltenses` `alltenses`
(default is both). (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 _override_ the default language list with `--langs=...`
- You can _add_ languages to the default list with `--langs=+...` - You can _add_ languages to the default list with `--langs=+...`
- You can _remove_ languages from 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 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 `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` ## 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 - `--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 - `--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` ## Windows batch file: `Make.bat`
**This script is still untested.** **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. 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. 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 ## About this repository

View File

@@ -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, Afr,afrikaans,,,,,,n,
Amh,amharic,,,,,n,n, Amh,amharic,,,,,n,n,
Ara,arabic,,,,,n,n, Ara,arabic,,,,,n,n,
1 Code Directory Functor Unlexer Present All API Try Symbolic Compatibility
2 Afr afrikaans n
3 Amh amharic n n
4 Ara arabic n n