4040missing_libs = set ()
4141
4242#
43- # builds FFmpeg and logs output to build-ffmpeg.log.txt
43+ #
4444#
4545def buildFFmpeg (script_dir , log_file ):
46+ """
47+ builds FFmpeg and logs output to `log_file`
48+ """
4649 # set environment variables
4750 env = os .environ
4851 env ['SKIPINSTALL' ] = 'yes' # append 'SKIPINSTALL=yes' to skip prompt for installing FFmpeg to /usr/local/bin/etc
@@ -60,11 +63,14 @@ def buildFFmpeg(script_dir, log_file):
6063 subprocess .call (args , env = env , stdout = log_file )
6164
6265#
63- # Copies symbol file to the workspace destination
64- # skips symlinks to avoid duplication
65- # Copies entire dSYM packages for dylib files already within .dSYM packages
66+ #
6667#
6768def copyOrGenerateSymbolFile (file , dest , log_file ):
69+ """
70+ Copies a single symbol file to the workspace destination
71+ skips symlinks to avoid duplication
72+ Copies entire `dSYM` packages for `dylib` files already within `.dSYM` packages
73+ """
6874 fileref = pathlib .Path (file )
6975 if not fileref .is_symlink ():
7076 symbolFileName = fileref .name + '.dSYM'
@@ -92,17 +98,27 @@ def copyOrGenerateSymbolFile(file, dest, log_file):
9298 subprocess .call (args , stdout = log_file )
9399
94100#
95- # Copies symbol files to the workspace destination
96- # skips symlinks to avoid duplication
97- # Copies entire dSYM packages for dylib files already within .dSYM packages
101+ #
98102#
99103def copyOrGenerateSymbolFiles (source , dest , log_file ):
104+ """
105+ Recursively copies symbol files to the workspace destination
106+ skips symlinks to avoid duplication
107+ Copies entire `dSYM` packages for `dylib` files already within `.dSYM` packages
108+ """
100109 for fileref in pathlib .Path (source + '/' ).glob ('**/*.dylib' ):
101110 copyOrGenerateSymbolFile (str (fileref ), dest , log_file )
102111 for fileref in pathlib .Path (source + '/' ).glob ('**/*.so*' ):
103112 copyOrGenerateSymbolFile (str (fileref ), dest , log_file )
104113
114+ #
115+ #
116+ #
105117def readDeploymentTarget (src_file ) -> str :
118+ """
119+ Reads the deployment target of a binary
120+ :return: something like `'10.11'` or an empty string
121+ """
106122 args = ['/usr/bin/otool' , '-l' , src_file ]
107123 otool_proc = subprocess .Popen (args , stdout = subprocess .PIPE )
108124 inLoaderCommand = False
@@ -120,10 +136,13 @@ def readDeploymentTarget(src_file) -> str:
120136
121137
122138#
123- # Copies a library and its corresponding .dSYM bundle
124- # (if present)
139+ #
125140#
126141def copyLibraryAndSymbolPackage (src_file , dest_folder , overwrite ):
142+ """
143+ Copies a library and its corresponding `.dSYM` bundle
144+ (if present)
145+ """
127146 this_deployment_target = readDeploymentTarget (src_file )
128147 assert this_deployment_target == deployment_target , '{0} wrong deployment target {1}' .format (src_file , this_deployment_target )
129148
@@ -144,21 +163,26 @@ def copyLibraryAndSymbolPackage(src_file, dest_folder, overwrite):
144163 shutil .copytree (src_symbol_package , dest_symbol_package )
145164
146165#
147- # Helper function to get a base name of a library
148- # without version numbers
166+ #
149167#
150168def getFilenameWithoutVersion (file_name ) -> str :
151- result = file_name .split ('.' )[0 ]
152- # libSDL2 weirdly has hypthen after then name (i.e., libSDL2-2.0.0.dylib)
153- if 'libSDL2' in result :
154- result = 'libSDL2'
155- return result
169+ """
170+ :return: `'libSDL2'` for something like `'libSDL2-2.0.0.dylib'`
171+ """
172+ result = file_name .split ('.' )[0 ]
173+ # libSDL2 weirdly has hypthen after then name (i.e., libSDL2-2.0.0.dylib)
174+ if 'libSDL2' in result :
175+ result = 'libSDL2'
176+ return result
156177
157178#
158- # Recursive function to copy a library and its (non-system) dependencies
159- # also fixes loader paths for each library
179+ #
160180#
161181def copyLibraryAndDependencies (src_file , dest_folder , log_file ):
182+ """
183+ Recursive function to copy a library and its (non-system) dependencies
184+ also fixes loader paths for each library to be `@loader_path`
185+ """
162186
163187 dest_file = os .path .join (dest_folder , os .path .basename (src_file ))
164188
@@ -233,9 +257,13 @@ def copyLibraryAndDependencies(src_file, dest_folder, log_file):
233257 subprocess .check_output (args )
234258
235259#
236- # Read the version string from ./build-ffmpeg
260+ #
237261#
238262def readVersion () -> str :
263+ """
264+ Reads the version string from ../build-ffmpeg
265+ :return: something like `'1.31rc1'`
266+ """
239267 result = ''
240268 with open (os .path .join (base_dir , 'build-ffmpeg' )) as f :
241269 lines = f .readlines ()
@@ -245,9 +273,12 @@ def readVersion() -> str:
245273 return result
246274
247275#
248- # Returns a string like darwin-x86_64.1.31rc2
276+ #
249277#
250278def getPlatformMachineVersion () -> str :
279+ """
280+ :return: a string like `'darwin-x86_64.1.31rc2'`
281+ """
251282 return sys .platform + '-' + platform .machine () + '.' + readVersion ()
252283
253284
@@ -257,8 +288,8 @@ def getPlatformMachineVersion() -> str:
257288def generateChecksum (output_folder ):
258289 """
259290 Calculates checksums for every file in `output_folder`
291+ and puts it in a `SHAMSUM256.txt` file
260292 """
261-
262293 checksums = set ()
263294
264295 # calculate checksums for all files
0 commit comments