Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
makelib.py
00001 #### lib.py for mbed #### 00002 # v0.5 00003 # 2017/02 made by dinau 00004 # 00005 # Notice: Unsupported libraries. 00006 # These libraries must be specified in Makefile. 00007 # mbed-os 00008 # mbed-dev 00009 00010 00011 # Usage: 00012 # $ make lib 00013 # or 00014 # $ python makelib.py 00015 # 00016 import os,sys 00017 import commands 00018 from urlparse import urlparse 00019 HG = 1 00020 GIT = 2 00021 MBEDOS = 3 00022 CMD_HG_CLONE = 'hg clone -q ' 00023 CMD_GIT_CLONE = 'git clone -q ' 00024 CMD_GIT_CHECKOUT= 'git checkout -q ' 00025 00026 def hgClone(param): 00027 cmd = CMD_HG_CLONE + param 00028 return os.system( cmd ) 00029 00030 def gitClone(param): 00031 cmd = CMD_GIT_CLONE + param 00032 return os.system( cmd ) 00033 00034 def gitCheckout(param): 00035 cmd = CMD_GIT_CHECKOUT + param 00036 return os.system( cmd ) 00037 00038 def getDvcs(url): 00039 if ('developer.mbed.org' in url) or ('mbed.org' in url) or ('bitbucke.org' in url): 00040 return HG; 00041 elif 'mbed-os' in url: 00042 return MBEDOS 00043 elif 'github.com' in url: 00044 return GIT 00045 else: 00046 return 0 00047 00048 def getLibs(target_dir): 00049 savedir = os.getcwd() 00050 os.chdir(target_dir) 00051 liblist=[] 00052 for fname in os.listdir('.'): 00053 if os.path.isfile(fname): 00054 name, ext = os.path.splitext(fname) 00055 if ext == '.lib': 00056 if name != 'mbed-os': 00057 liblist.append(fname) 00058 if len( liblist ) > 0: 00059 #print liblist 00060 for libfile in liblist: 00061 subdir, ext = os.path.splitext(libfile) 00062 print subdir 00063 url = open(libfile).read() 00064 print url 00065 sys.stdout.flush() 00066 dvcs = getDvcs(url) 00067 if dvcs == HG: 00068 hgClone( url ) 00069 getLibs(subdir) 00070 elif dvcs == MBEDOS: 00071 # Nothing is downloaded if mbed-os lib be. 00072 print 'mbed-os' 00073 sys.stdout.flush() 00074 elif dvcs == GIT: 00075 params = url.split('#') 00076 if len(params) == 1: 00077 gitClone( params[0] ) 00078 getLibs(subdir) 00079 elif len(params) == 2: 00080 gitClone( params[0] ) 00081 os.chdir(subdir) 00082 print 'cd %s' % (subdir) 00083 sys.stdout.flush() 00084 gitCheckout( params[1] ) 00085 getLibs(subdir) 00086 os.chdir(savedir) 00087 ################### 00088 # main prog 00089 ################### 00090 if len(sys.argv) >= 2: 00091 url = sys.argv[1] 00092 dvcs = getDvcs( url ) 00093 if dvcs == HG: 00094 p = urlparse( url ) 00095 path = p.path 00096 if path[-1:] == '/': 00097 path = path[:-1] 00098 libdir = os.path.basename(path) 00099 hgClone( url ) 00100 getLibs(libdir) 00101 elif dvcs == GIT: 00102 params = url.split('#') 00103 if len(params) == 1: 00104 gitClone( params[0] ) 00105 elif len(params) == 2: 00106 gitClone( params[0] ) 00107 os.chdir(subdir) 00108 print 'cd %s' % (subdir) 00109 sys.stdout.flush() 00110 gitCheckout( params[1] ) 00111 else: 00112 print '--- Getting libraries ----' 00113 getLibs('.') 00114 print '--- end ---'
Generated on Fri Jul 22 2022 00:46:00 by
1.7.2