Skip to content

Commit

Permalink
fixed compile for iOS/Mac
Browse files Browse the repository at this point in the history
  • Loading branch information
jehoochen committed Apr 26, 2017
1 parent ef23ec3 commit d4dca60
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1,152 deletions.
23 changes: 23 additions & 0 deletions mars/libraries/build_apple.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,27 @@ def get_child_project(project_path):
file.close()
return (folders, projects)

def link_openssl(output_lib_path, cpu_folder):
#split .a by cpu arch
openssl_lib_folder = os.path.join(LIBRARIES_PATH, "../openssl/openssl_lib_iOS")
os.system("mkdir %s/%s"%(openssl_lib_folder, cpu_folder))
os.system("lipo %s/libcrypto.a -thin %s -output %s/%s/libcrypto.a"% (openssl_lib_folder, cpu_folder, openssl_lib_folder, cpu_folder))
os.system("lipo %s/libssl.a -thin %s -output %s/%s/libssl.a"% (openssl_lib_folder, cpu_folder, openssl_lib_folder, cpu_folder))
#split .a to .o
old_path = os.getcwd()
cur_path = "%s/%s" % (openssl_lib_folder, cpu_folder)
os.chdir(cur_path)
os.system("ar -x %s/%s/libcrypto.a" % (openssl_lib_folder, cpu_folder))
os.system("ar -x %s/%s/libssl.a" % (openssl_lib_folder, cpu_folder))
os.chdir(old_path)

if not os.path.isfile(output_lib_path):
os.system("ar -cur %s %s/%s/*.o 2>/dev/null" %(output_lib_path, openssl_lib_folder, cpu_folder))
else:
os.system("ar -q %s %s/%s/*.o 2>/dev/null" %(output_lib_path, openssl_lib_folder, cpu_folder))

os.system("rm -rf %s/%s" % (openssl_lib_folder, cpu_folder))

def build_apple(project, save_path):
gen_revision_file(save_path, save_path)

Expand Down Expand Up @@ -131,6 +152,8 @@ def build_apple(project, save_path):
os.system("ar -cur %s %s/%s/*.o 2>/dev/null" %(cpu_lib_path, obj_folders, cpu_folder))
else:
os.system("ar -q %s %s/%s/*.o 2>/dev/null" %(cpu_lib_path, obj_folders, cpu_folder))
if cf=="openssl":
link_openssl(cpu_lib_path, cpu_folder)


framework_path = save_path + "/" + project.framework_name
Expand Down
Loading

0 comments on commit d4dca60

Please sign in to comment.