Created
February 20, 2013 12:00
-
-
Save Superbil/4995026 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os, os.path | |
import glob | |
import shutil | |
def build(target, output_dir): | |
"builds tracker for device or simulator" | |
t = target.lower() | |
os.system("xcodebuild -parallelizeTargets \ | |
-jobs 8 \ | |
-sdk %s \ | |
-configuration Release\ | |
CONFIGURATION_BUILD_DIR='%s/Release-%s'" | |
% (t, output_dir, t)) | |
def put_library_together(src_root, library_path): | |
"Make static framework for iOS" | |
clear_and_make_folder(library_path) | |
# find the list of targets (["iPhoneOS", "iPhoneSimulator"]) | |
targets = glob.glob(os.path.join(src_root, "Release*")) | |
targetlist = [os.path.basename(t) for t in targets] | |
# make universal static lib | |
wlist = " ".join(["%s/libTracker.a" % (os.path.join(src_root, t)) for t in targetlist]) | |
if len(wlist) < 2: | |
raise NameError("input library list has error") | |
os.system("lipo -create %s -o %s" % (wlist, library_path)) | |
def clear_and_make_folder(file_dir): | |
"clear basename of dir and make new one" | |
base_dir = os.path.dirname(file_dir) | |
if os.path.isdir(base_dir): | |
shutil.rmtree(base_dir) | |
os.makedirs(base_dir) | |
if __name__ == "__main__": | |
# Get all variable for XCode | |
curr_dir = os.environ['SOURCE_ROOT'] | |
output_file = os.environ['SCRIPT_OUTPUT_FILE_0'] | |
temp_dir = os.environ['TARGET_TEMP_DIR'] | |
# work on souce folder | |
os.chdir(curr_dir) | |
# build simulator and device version | |
[build(target,temp_dir) for target in ["iPhoneOS", "iPhoneSimulator"]] | |
put_library_together(temp_dir, output_file) | |
# clean temp files | |
t = os.path.join(curr_dir, 'build') | |
if os.path.isdir(t): | |
shutil.rmtree(t) | |
if os.path.isdir(temp_dir): | |
shutil.rmtree(temp_dir) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment