Clone of official tools

Revision:
24:25bff2709c20
Parent:
15:cd36228f7d73
Child:
32:fef1f96d5e06
Child:
33:c8effba9595f
--- a/build_profiles.py	Sat Jul 16 22:51:17 2016 +0100
+++ b/build_profiles.py	Mon Aug 01 09:10:17 2016 +0100
@@ -20,7 +20,7 @@
 import colorama
 
 from copy import copy
-from os.path import join
+from os.path import join, abspath, exists
 from os import walk
 import fnmatch
 
@@ -69,6 +69,29 @@
     return builds
 
 
+def find_targets_json(path, depth=1):
+    f = 'targets.json'
+    if exists(join(path, f)):
+        return os.path.abspath(join(path, f))
+
+    if depth > 2:
+        return None
+
+    for root, dirs, files in walk(path):
+        for d in copy(dirs):
+            if d.startswith('.'):
+                dirs.remove(d)
+
+            if exists(join(root, d, f)):
+                return abspath(join(root, d, f))
+            else:
+                found = find_targets_json(join(root, d), depth+1)
+                if found:
+                    return found
+
+    return None
+
+
 # Toolchain profiles for backward compatibility with old mbed SDK library releases
 TOOLCHAIN_PROFILES = {
     'ARM_STD' : {