From 412ace37c6343958ee31828e53bff4aeb132aeac Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Thu, 26 May 2016 00:31:07 -0400 Subject: [PATCH] toolcontext: introduce --share-dir Signed-off-by: Alexandre Terrasa --- src/toolcontext.nit | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/toolcontext.nit b/src/toolcontext.nit index 4583868..de15aed 100644 --- a/src/toolcontext.nit +++ b/src/toolcontext.nit @@ -374,6 +374,9 @@ class ToolContext # Option --nit-dir var opt_nit_dir = new OptionString("Base directory of the Nit installation", "--nit-dir") + # Option --share-dir + var opt_share_dir = new OptionString("Directory containing tools assets", "--share-dir") + # Option --help var opt_help = new OptionBool("Show Help (This screen)", "-h", "-?", "--help") @@ -542,6 +545,20 @@ The Nit language documentation and the source code of its tools and libraries ma # The identified root directory of the Nit package var nit_dir: String is noinit + # Shared files directory. + # + # Most often `nit/share/`. + var share_dir: String is lazy do + var sharedir = opt_share_dir.value + if sharedir == null then + sharedir = nit_dir / "share" + if not sharedir.file_exists then + fatal_error(null, "Fatal Error: cannot locate shared files directory in {sharedir}. Uses --share-dir to define it's location.") + end + end + return sharedir + end + private fun compute_nit_dir: String do # the option has precedence -- 1.7.9.5