Skip to content

Commit 7554b2d

Browse files
committed
Archive Source and keep separate
1 parent 358b3dd commit 7554b2d

1 file changed

Lines changed: 40 additions & 4 deletions

File tree

build-ffmpeg-descript.py

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import shutil
2020
import subprocess
2121
import sys
22+
from zipfile import ZipFile
2223

2324
#
2425
# Constants
@@ -47,7 +48,13 @@ def buildFFmpeg(script_dir, log_file):
4748

4849
# call main build script
4950
build_ffmpeg_path = os.path.join(script_dir, 'build-ffmpeg')
50-
subprocess.call([build_ffmpeg_path, '-b', '--full-shared'], env=env, stdout=log_file)
51+
args = [
52+
build_ffmpeg_path,
53+
'-b', # build
54+
'--full-shared', # custom Descript shim to build shared libraries instead of static
55+
'--enable-gpl-and-free'] # custom Descript shim to build GPL but not non-free (libpostproc is needed by Beamcoder and requires GPL)
56+
log_file.write(' '.join(args) + '\n\n')
57+
subprocess.call(args, env=env, stdout=log_file)
5158

5259
#
5360
# Copies symbol file to the workspace destination
@@ -214,6 +221,11 @@ def readVersion() -> str:
214221
result = line[15:].strip()
215222
return result
216223

224+
#
225+
# Returns a string like darwin-x86_64.1.31rc2
226+
#
227+
def getPlatformMachineVersion() -> str:
228+
return sys.platform + '-' + platform.machine() + '.' + readVersion()
217229

218230
#
219231
#
@@ -225,9 +237,13 @@ def main():
225237
os.makedirs(output_dir)
226238

227239
# create a log file for the build-ffmpeg command for build archival purposes
228-
build_ffmpeg_log_file_path = os.path.join(output_dir, 'build-ffmpeg.log.txt')
240+
log_file_name = 'build-ffmpeg-' + getPlatformMachineVersion() + '.log.txt'
241+
build_ffmpeg_log_file_path = os.path.join(os.path.dirname(output_dir), log_file_name)
229242
build_ffmpeg_log_file = open(build_ffmpeg_log_file_path, 'w')
230243

244+
build_ffmpeg_log_file.write('Begin build-ffmpeg-descript.py\n')
245+
build_ffmpeg_log_file.write('=======================\n')
246+
231247
# Run the script
232248
buildFFmpeg(cwd, build_ffmpeg_log_file)
233249

@@ -271,11 +287,31 @@ def main():
271287
for lib in sorted(copied_libs):
272288
build_ffmpeg_log_file.write('Copied ' + lib + '\n')
273289

274-
build_ffmpeg_log_file.close()
290+
build_ffmpeg_log_file.write('\nArchiving third-party source\n')
291+
build_ffmpeg_log_file.write('=======================\n')
292+
293+
# bundle up the third-party source
294+
# grab each .tar.* from the packages folder
295+
packages_zip_name = '-'.join(executables) + '-packages-' + getPlatformMachineVersion() + '.zip'
296+
with ZipFile(os.path.join(os.path.dirname(output_dir), packages_zip_name), 'w') as myzip:
297+
archives = pathlib.Path(packages_dir + '/').glob('*.tar.*')
298+
for archive in sorted(archives, key=lambda s: str(s).lower()):
299+
build_ffmpeg_log_file.write(os.path.join('packages', archive.name) + '\n')
300+
myzip.write(str(archive.absolute()), archive.name)
301+
302+
build_ffmpeg_log_file.write('\nArchiving libraries\n')
303+
build_ffmpeg_log_file.write('=======================\n')
275304

276305
# bundle up the build artifacts
277306
os.chdir(output_dir)
278-
subprocess.check_output(['/usr/bin/zip', '--symlinks', '-r', '../ffmpeg-ffprobe-shared-' + sys.platform + '-' + platform.machine() + '.' + readVersion() + '.zip', '.'])
307+
shared_zip_name = '-'.join(executables) + '-shared-' + getPlatformMachineVersion() + '.zip'
308+
args = ['/usr/bin/zip', '--symlinks', '-r', os.path.join('..', shared_zip_name), '.']
309+
build_ffmpeg_log_file.write(' '.join(args))
310+
subprocess.check_output(args)
311+
312+
build_ffmpeg_log_file.write('\nEnd of build-ffmpeg-descript.py\n')
313+
build_ffmpeg_log_file.write('=======================\n')
314+
build_ffmpeg_log_file.close()
279315

280316
#
281317
# entry

0 commit comments

Comments
 (0)