1- #! /usr/bin/python
1+ #! /usr/bin/env python3
22
33########################################################################
44#
@@ -39,22 +39,22 @@ def GetSdkRevision():
3939 lines = os .popen (cmd ).readlines ()
4040 branch = ''
4141 if not lines [0 ].startswith ('## master' ):
42- print 'WARNING: not on master branch'
42+ print ( 'WARNING: not on master branch' )
4343 branch = '+' + lines [0 ][3 :].strip ()
4444 if len (lines ) > 1 :
45- print 'ERROR: git status not empty'
46- print '' .join (lines )
45+ print ( 'ERROR: git status not empty' )
46+ print ( '' .join (lines ) )
4747 return None
4848
4949 cmd = 'git tag --contains HEAD'
5050 tags = os .popen (cmd ).readlines ()
5151 if len (tags ) != 1 :
52- print 'ERROR: expected exactly one tag for HEAD, found' , len (tags ), ':' , tags
52+ print ( 'ERROR: expected exactly one tag for HEAD, found' , len (tags ), ':' , tags )
5353 return None
5454 version = tags [0 ].strip ()
5555 sep = version .find ('-' )
5656 if sep < 0 :
57- print 'ERROR: unrecognized version string format:' , version
57+ print ( 'ERROR: unrecognized version string format:' , version )
5858 return version [sep + 1 :] + branch
5959
6060#############################################################
@@ -70,11 +70,11 @@ def CopyFiles(file_patterns, configs=[''], rename_map={}):
7070 if not os .path .exists (dest_dir ):
7171 os .makedirs (dest_dir )
7272 filename = os .path .basename (file )
73- if rename_map . has_key ( filename ) :
73+ if filename in rename_map :
7474 dest_name = dest_dir + '/' + rename_map [filename ]
7575 else :
7676 dest_name = dest_dir
77- print 'COPY: ' + file + ' -> ' + dest_name
77+ print ( 'COPY: ' + file + ' -> ' + dest_name )
7878 shutil .copy2 (file , dest_name )
7979
8080#############################################################
@@ -95,7 +95,7 @@ def ZipDir(top, archive, dir) :
9595def ZipIt (basename , dir ) :
9696 path = basename + '/' + dir
9797 zip_filename = path + '.zip'
98- print 'ZIP: ' + path + ' -> ' + zip_filename
98+ print ( 'ZIP: ' + path + ' -> ' + zip_filename )
9999
100100 if os .path .exists (zip_filename ):
101101 os .remove (zip_filename )
@@ -117,17 +117,25 @@ def ZipIt(basename, dir) :
117117 SDK_TARGET = None
118118
119119if len (sys .argv ) > 2 :
120- BENTO4_HOME = sys .argv [1 ]
120+ BENTO4_HOME = sys .argv [2 ]
121121else :
122122 script_dir = os .path .abspath (os .path .dirname (__file__ ))
123123 BENTO4_HOME = os .path .join (script_dir ,'..' )
124124
125+ CMAKE_BUILD = False
126+ if len (sys .argv ) > 3 :
127+ if sys .argv [3 ] == 'cmake' :
128+ CMAKE_BUILD = True
129+ else :
130+ print ('ERROR: unknown build type' )
131+ sys .exit (1 )
132+
125133# ensure that BENTO4_HOME has been set and exists
126134if not os .path .exists (BENTO4_HOME ) :
127- print 'ERROR: BENTO4_HOME (' + BENTO4_HOME + ') does not exist'
135+ print ( 'ERROR: BENTO4_HOME (' + BENTO4_HOME + ') does not exist' )
128136 sys .exit (1 )
129137else :
130- print 'BENTO4_HOME = ' + BENTO4_HOME
138+ print ( 'BENTO4_HOME = ' + BENTO4_HOME )
131139
132140# compute the target if it is not specified
133141if SDK_TARGET is None :
@@ -154,13 +162,13 @@ def ZipIt(basename, dir) :
154162 'darwin' : 'universal-apple-macosx'
155163 }
156164
157- if platform_to_target_map . has_key ( platform_id ) :
165+ if platform_id in platform_to_target_map :
158166 SDK_TARGET = platform_to_target_map [platform_id ]
159167 else :
160- print 'ERROR: SDK_TARGET is not set and cannot be detected'
168+ print ( 'ERROR: SDK_TARGET is not set and cannot be detected' )
161169 sys .exit (1 )
162170
163- print "TARGET = " + SDK_TARGET
171+ print ( "TARGET = " + SDK_TARGET )
164172
165173BENTO4_VERSION = GetVersion ()
166174
@@ -174,11 +182,16 @@ def ZipIt(basename, dir) :
174182SDK_TARGET_DIR = 'Build/Targets/' + SDK_TARGET
175183SDK_TARGET_ROOT = BENTO4_HOME + '/' + SDK_TARGET_DIR
176184
177- # special case for Xcode builds
178- if SDK_TARGET == 'universal-apple-macosx' :
179- SDK_TARGET_DIR = 'Build/Targets/universal-apple-macosx/build'
185+ if CMAKE_BUILD :
186+ SDK_BUILD_OUTPUT_DIR = 'cmakebuild'
187+ else :
188+ # special case for Xcode builds
189+ if SDK_TARGET == 'universal-apple-macosx' :
190+ SDK_BUILD_OUTPUT_DIR = 'Build/Targets/universal-apple-macosx/Build/Products/Release'
191+ else :
192+ SDK_BUILD_OUTPUT_DIR = SDK_TARGET_DIR + '/Release'
180193
181- print SDK_NAME
194+ print ( SDK_NAME )
182195
183196# remove any previous SDK directory
184197if os .path .exists (SDK_ROOT ):
@@ -213,7 +226,7 @@ def ZipIt(basename, dir) :
213226 script_bin_dir = None
214227
215228# binaries
216- bin_in = SDK_TARGET_DIR + '/Release'
229+ bin_in = SDK_BUILD_OUTPUT_DIR
217230bin_files = [
218231 (bin_in ,'mp4*.exe' ,'bin' ),
219232 (bin_in ,'aac2mp4.exe' ,'bin' ),
0 commit comments