Permalink
Browse files

added sort_ios_headers.py script

  • Loading branch information...
1 parent 224a98a commit e88ddf3e95d645bc79a24f66a3b53e2b73842f1d @nst committed Sep 26, 2012
Showing with 52 additions and 0 deletions.
  1. +2 −0 iPhone/RuntimeBrowser.xcodeproj/project.pbxproj
  2. +50 −0 tools/sort_ios_headers.py
@@ -556,11 +556,13 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
+ CODE_SIGN_IDENTITY = "iPhone Distribution";
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = RuntimeBrowser_Prefix.pch;
INFOPLIST_FILE = Info.plist;
PRODUCT_NAME = OCRuntime;
+ PROVISIONING_PROFILE = "";
};
name = Release;
};
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+
+# $ cd headers
+# $ python sort_ios_headers.py
+
+import os
+import shutil
+
+def ios_path_in_header(header_path):
+ count = 0
+ for line in open(header_path):
+ count += 1
+ if count == 2:
+ # line expected to be like " Image: /System/Library/Frameworks/Accounts.framework/Accounts"
+ comps = line.split(" ")
+ if len(comps) == 5:
+ return comps[4][:-1]
+ break
+ return None
+
+def dst_dir_for_ios_path(ios_path):
+ ios_path_comps_full = ios_path.split(os.path.sep)
+
+ if len(ios_path_comps_full) >= 6:
+ ios_path_comps = ios_path_comps_full[3:5]
+ else:
+ ios_path_comps = ["lib", ios_path_comps_full[-1]]
+
+ return os.path.sep.join(ios_path_comps)
+
+for root, dirs, files in os.walk('.'):
+
+ headers = (f for f in files if f.endswith(".h"))
+
+ for f in headers:
+ filename = os.path.splitext(f)[0]
+
+ path = os.path.join(root, f)
+
+ ios_path = ios_path_in_header(path)
+
+ dst_dir = dst_dir_for_ios_path(ios_path)
+
+ if not os.path.exists(dst_dir):
+ os.makedirs(dst_dir)
+
+ dst = os.path.join(dst_dir, f)
+
+ print dst
+ shutil.move(path, dst)

0 comments on commit e88ddf3

Please sign in to comment.