-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_openh264.py
90 lines (71 loc) · 2.89 KB
/
build_openh264.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
###########################################################################
# Automatic build script for libopenh264
#
# Johan Lantz, June 2015
###########################################################################
import os
import subprocess
import argparse
import shutil
###########################################################################
# Helper functions #
###########################################################################
def checkGit():
try:
res = subprocess.Popen(['git', '--version'],
stderr=subprocess.STDOUT,
stdout=subprocess.PIPE).communicate()[0]
print res
except:
print ("git not found. Please install git in order to be able to checkout the openh264 project ")
quit()
def checkoutLibOpenH264():
if os.path.exists("openh264"):
shutil.rmtree("openh264")
print("Cloning libopenh264")
os.system("git clone https://github.com/cisco/openh264.git")
###########################################################################################
# Build functions #
# Completely fresh builds for each arch to avoid cleaning issues. #
###########################################################################################
def buildForiOS():
#If you get build errors for the i386 versions, update nasm to 2.11.06. Check version with nasm -v
archList = ["armv7", "armv7s", "arm64", "i386", "x86_64"]
if os.path.exists("libs"):
shutil.rmtree("libs")
os.makedirs("libs")
os.makedirs("libs/xcrun")
for arch in archList:
print("Starting " + arch + " build.")
targetDir = ""
checkoutLibOpenH264()
print("Entering openh26h folder.")
os.chdir("openh264")
commandLine = "make OS=ios ARCH=" + arch
os.system(commandLine)
print("Build for " + arch + " completed. Stepping out to working dir.")
os.chdir("..")
os.makedirs("libs/" + arch)
shutil.copy("openh264/libopenh264.a", "libs/" + arch)
print("Copied " + arch + " libraries to " + "libs/" + arch)
print("All combinations built. Create fat binaries.")
xcrunCommandLine = "xcrun -sdk iphoneos lipo"
for arch in archList:
xcrunCommandLine += " libs/" + arch + "/libopenh264.a"
xcrunCommandLine += " -create -output libs/xcrun/libopenh264.a"
os.system(xcrunCommandLine)
print("All done. The final binary can be found in libs/xcrun/")
###########################################################################
# Main script #
###########################################################################
checkGit()
parser = argparse.ArgumentParser()
parser.add_argument("-platform",
help="The OS to build for",
choices=['Win32', 'iOS', 'android', 'WP8', 'unix'],
required=True)
args = parser.parse_args()
if args.platform == "iOS":
buildForiOS()
else:
print("Unsupported platform " + args.platform)