mbed-scli test program

Dependencies:   Scheduler

Revision:
4:85e9057db7a6
Parent:
3:60330a83318b
Child:
5:c3524dc89507
diff -r 60330a83318b -r 85e9057db7a6 makelib.py
--- a/makelib.py	Sun Feb 26 20:46:49 2017 +0900
+++ b/makelib.py	Mon Feb 27 22:51:57 2017 +0900
@@ -1,8 +1,7 @@
 ####  lib.py for mbed ####
-# v0.5
+# v0.6
 # 2017/02 made by dinau
 #
-
 # Notice: Unsupported libraries.
 #         These libraries must be specified in Makefile.
 #   mbed-os
@@ -37,8 +36,9 @@
 def gitCheckout(param):
     cmd = CMD_GIT_CHECKOUT + param
     return os.system( cmd )
-
 def getDvcs(url):
+    p = urlparse( url )
+    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:
@@ -62,6 +62,9 @@
         #print liblist
         for libfile in liblist:
             subdir, ext = os.path.splitext(libfile)
+            if os.path.isdir( subdir ):
+                print "%s :: already exists !" % (subdir)
+                continue
             print subdir
             url = open(libfile).read()
             print url
@@ -91,30 +94,21 @@
 ###################
 # main prog
 ###################
-if len(sys.argv) >= 2:
-    url = sys.argv[1]
-    dvcs = getDvcs( url )
-    if dvcs == HG:
-        p = urlparse( url )
-        path = p.path
-        if path[-1:] == '/':
-            path = path[:-1]
-        libdir = os.path.basename(path)
-        hgClone( url )
-        getLibs(libdir)
-    elif dvcs == GIT:
-        params = url.split('#')
-        if len(params) == 1:
-            gitClone( params[0] )
-        elif len(params) == 2:
-            gitClone( params[0] )
-            os.chdir(subdir)
-            print 'cd %s' % (subdir)
-            sys.stdout.flush()
-            gitCheckout( params[1] )
-else:
+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 ---'