mbed-scli test program

Dependencies:   Scheduler

Revision:
6:7915b5819364
Parent:
5:c3524dc89507
--- a/makelib.py	Tue Feb 28 22:12:26 2017 +0900
+++ b/makelib.py	Sat Mar 04 14:46:27 2017 +0900
@@ -1,6 +1,5 @@
 ####  lib.py for mbed ####
-# v0.7
-# 2017/02 made by dinau
+# v0.8 # 2017/03 made by dinau
 #
 # Notice: Unsupported libraries.
 #         These libraries must be specified in Makefile.
@@ -23,7 +22,7 @@
 MBEDOS          = 3
 CMD_HG_CLONE    = 'hg clone -q '
 CMD_GIT_CLONE   = 'git clone -q '
-CMD_GIT_CHECKOUT= 'git checkout -q '
+CMD_GIT_CHECKOUT= 'git checkout '
 
 def hgClone(param):
     cmd = CMD_HG_CLONE + param
@@ -33,12 +32,16 @@
     cmd = CMD_GIT_CLONE + param
     return os.system( cmd )
 
-def gitCheckout(param):
+def gitCheckout(param,disp=False):
     cmd = CMD_GIT_CHECKOUT + param
+    if disp:
+        print cmd
+        sys.stdout.flush()
     return os.system( cmd )
+
 def getDvcs(url):
     p = urlparse( url )
-    print p
+    #print p
     if ('developer.mbed.org' in url) or ('mbed.org' in url) or ('bitbucke.org' in url):
         return HG;
     elif 'mbed-os' in url:
@@ -92,23 +95,34 @@
     os.chdir(savedir)
 
 ###################
-# main prog
+# main program
 ###################
 if len(sys.argv) == 1:
     print '--- Getting libraries ----'
     getLibs('.')
     print '--- end ---'
 else:
-    url = sys.argv[1]
-    p = urlparse( url )
-    path = p.path
-    if path[-1:] == '/':
-        path = path[:-1]
-    libdir  = os.path.basename(path)
-    libname = libdir + '.lib'
-    if not os.path.isdir( libdir ):
-        with open( libname,'w') as fp:
-            fp.write( url )
-        print '--- Getting libraries ----'
-        getLibs('.')
-        print '--- end ---'
+    url = param1 = sys.argv[1]
+    try:
+        revNum = int(param1)
+    except:
+        p = urlparse( url )
+        path = p.path
+        if path[-1:] == '/':
+            path = path[:-1]
+        libdir  = os.path.basename(path)
+        libname = libdir + '.lib'
+        if not os.path.isdir( libdir ):
+            with open( libname,'w') as fp:
+                fp.write( url )
+            print '--- Getting libraries ----'
+            getLibs('.')
+            print '--- end ---'
+    else:
+        mbed_root_file ='mbed-root.txt'
+        mbedRoot = open(mbed_root_file).read()
+        os.chdir( mbedRoot.strip() )
+        gitCheckout( 'mbed_lib_rev' + str( revNum ), True )
+
+
+