Update ffmpeg-mt submodule
[mplayer2-build.git] / script / update
blob6a55a4045e1c0516b9d1ef1e40d5fe1a0e19a97c
1 #!/usr/bin/env python
3 import os
4 from os import path
5 from subprocess import check_call
7 from helpers import GitWrapper, run_command
9 def main():
10 git = GitWrapper()
12 # Currently only ffmpeg-mt is supported. When upgrading from
13 # previous versions force it enabled.
14 switch_to_mt = not path.exists('ffmpeg-mt-enabled')
15 if switch_to_mt:
16 open('ffmpeg-mt-enabled', 'w').close()
17 if path.exists('ffmpeg-mt-disabled'):
18 os.remove('ffmpeg-mt-disabled')
19 # Allow setups where both ffmpeg and ffmpeg-mt are checked out
20 # simultaneously, and leave the directories alone in that case.
21 if path.exists('ffmpeg/.git') and not path.exists('ffmpeg-mt/.git'):
22 # fmpeg-mt should be an empty directory if things are right
23 os.rmdir('ffmpeg-mt')
24 os.rename('ffmpeg', 'ffmpeg-mt')
25 os.mkdir('ffmpeg')
26 # libswscale has changed from a submodule to a normal subdirectory
27 if path.exists('ffmpeg-mt/libswscale/.git'):
28 os.system('cd ffmpeg-mt && rm -rf libswscale')
30 config = git.get_config()
31 submodules = git.get_submodules()
32 # Update existing submodules, but don't check out new ones
33 for p in submodules:
34 if not 'submodule.%s.url' % p in config:
35 continue
36 if not path.exists(path.join(p, '.git')):
37 continue
38 check_call('git submodule update'.split() + [p])
39 def cmd():
40 check_call('git submodule update --init'.split())
41 git.foreach_submodule(cmd)
43 if switch_to_mt:
44 print
45 print "Currently only ffmpeg-mt version is maintained."
46 print "This repository has been automatically switched from ffmpeg to ffmpeg-mt."
47 print "This should work OK on single-core machines too."
48 print "You should run ./clean before recompiling due to the switch."
50 main()