Revision: 1672
Author: sebastien.lelong
Date: Thu Feb 18 07:14:48 2010
Log: new action command: 'list' will list all JAL libraries found in one or
more JALLIB_REPOS, resolved as compiler does
http://code.google.com/p/jallib/source/detail?r=1672
Modified:
/trunk/tools/jallib.py
=======================================
--- /trunk/tools/jallib.py Sat Feb 13 11:19:49 2010
+++ /trunk/tools/jallib.py Thu Feb 18 07:14:48 2010
@@ -99,6 +99,17 @@
return re.findall("^\s*include\s+(\w+)\s*",content,re.MULTILINE)
+def split_repos(repos):
+ # honor way to define to different paths whether it's on *nix
+ # (using ":") or windows (using ";" like jalv2 compiler)
+ if sys.platform.lower().startswith("win"):
+ gdirs = repos.split(";")
+ else:
+ gdirs = repos.split(":")
+
+ return gdirs
+
+
################
# MAIN TARGETS #
################
@@ -190,12 +201,7 @@
# No root specified ? Try env var, else defaut to cwd
if not dirs:
try:
- # honor way to define to different paths whether it's on *nix
- # (using ":") or windows (using ";" like jalv2 compiler)
- if sys.platform.lower().startswith("win"):
- gdirs = os.environ['JALLIB_REPOS'].split(";")
- else:
- gdirs = os.environ['JALLIB_REPOS'].split(":")
+ gdirs = split_repos(os.environ['JALLIB_REPOS'])
except KeyError:
# no such env var, takes param from commandline, and honor
# jalv2 compiler separator
@@ -761,9 +767,9 @@
reindent_file(filename,withchar,howmany)
-#-------------#
-# JALAPI FUNC #
-#-------------#
+#---------------#
+# UNITTEST FUNC #
+#---------------#
def unittest(filename,verbose=False):
oracle = {'success' : None, 'failure' : None, 'notrun' : None}
@@ -1102,6 +1108,27 @@
return tmpl.main()
+#-----------#
+# LIST FUNC #
+#-----------#
+
+def do_list(_trash):
+ gdirs = split_repos(os.environ['JALLIB_REPOS'])
+ # first directories have precedence, so we start by the end
+ # and will override as needed
+ gdirs.reverse()
+ jalfiles = {}
+ for gdir in gdirs:
+ found = get_jal_filenames(gdir)
+ # rebuild complete path
+ for fname,path in found.items():
+ jalfiles[fname] = os.path.join(gdir,path)
+
+ # sort on filename (not using path)
+ for jalfile in sorted(jalfiles.items(),cmp=lambda a,b: cmp(a[0],b[0])):
+ print jalfile[1]
+
+
#############
# HELP FUNC #
@@ -1117,6 +1144,7 @@
- sample : generate samples from board and test files
- reindent : re-indent jal code
- jalapi : generate HTML documentation from jal files
+ - list : list all JAL libraries found in JALLIB_REPOS, as resolved
by compiler
- license : display license
Use 'help' with each action for more (eg. "jallib help compile")
@@ -1282,6 +1310,20 @@
-o: specify the output sample filename, or the output directory
when used in combination with -a option
+"""
+
+def list_help():
+ print """
+ jallib list
+
+List JAL libraries found according to JALLIB_REPOS variable.
+JALLIB_REPOS represents the root(s) from which *.jal files are
+search, recursively. If multiple repositories are specified, first
+have precedence. So listing libraries also take into account this
+precedence rule.
+
+Output contains one line per library.
+
"""
def do_help(action_args=[]):
@@ -1298,6 +1340,7 @@
ACTIONS = {
'compile' : {'callback' :
do_compile, 'options' : 'R:E:', 'help' : compile_help},
'validate' : {'callback' :
do_validate, 'options' : '', 'help' : validate_help},
+ 'list' : {'callback' :
do_list, 'options' : '', 'help' : list_help},
'jalapi' : {'callback' :
do_jalapi, 'options' : 'slt:d:g:o:', 'help' : jalapi_help},
'sample' : {'callback' :
do_sample, 'options' : 'a:b:t:o:', 'help' : sample_help},
'reindent' : {'callback' :
do_reindent, 'options' : 'c:', 'help' : reindent_help},
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en.