4 Copies current subproject git repository to create a cache
14 PARSER = argparse.ArgumentParser()
15 PARSER.add_argument('subprojects_dir')
16 PARSER.add_argument('--build', action="store_true", default=False)
19 def create_cache_in_image(options):
20 os.makedirs(DEST, exist_ok=True)
21 print("Creating cache from %s" % options.subprojects_dir)
22 for project_name in os.listdir(options.subprojects_dir):
23 project_path = os.path.join(options.subprojects_dir, project_name)
25 if project_name != "packagecache" and not os.path.exists(os.path.join(project_path, '.git')):
28 if os.path.exists(os.path.join(DEST, project_name)):
31 print("Copying %s" % project_name)
32 shutil.copytree(project_path, os.path.join(DEST, project_name))
34 media_path = os.path.join(options.subprojects_dir, '..', '.git',
35 'modules', 'subprojects', 'gst-integration-testsuites', 'medias')
36 if os.path.exists(os.path.join(DEST, 'medias.git')):
39 if os.path.exists(media_path):
40 print("Creating media cache")
41 shutil.copytree(media_path, os.path.join(DEST, 'medias.git'))
43 print("Did not find medias in %s" % media_path)
46 def copy_cache(options):
47 # FIXME Remove when not needed anymore.
48 for path in [DEST, "/gst-build/subprojects", r"C:\gst-build\subprojects"]:
49 if not os.path.exists(path):
50 print("%s doesn't exist." % path)
53 for project_name in os.listdir(path):
54 project_path = os.path.join(options.subprojects_dir, project_name)
55 cache_dir = os.path.join(path, project_name)
57 if project_name == 'medias.git':
58 project_path = os.path.join(options.subprojects_dir, '..', '.git', 'modules',
59 'subprojects', 'gst-integration-testsuites')
60 os.makedirs(project_path, exist_ok=True)
61 project_path = os.path.join(project_path, 'medias')
63 if os.path.exists(project_path):
64 print("- Ignoring %s" % cache_dir)
67 if not os.path.isdir(cache_dir):
68 print("- Ignoring %s" % cache_dir)
71 print("Copying from %s -> %s" % (cache_dir, project_path))
72 shutil.copytree(cache_dir, project_path)
73 subprocess.check_call(['meson', 'subprojects', 'update', '--reset'])
77 # MESON_COMMIT variable can be set when creating a pipeline to test meson pre releases
78 meson_commit = os.environ.get('MESON_COMMIT')
80 url = f'git+https://github.com/mesonbuild/meson.git@{meson_commit}'
81 subprocess.check_call(['pip3', 'install', '--upgrade', url])
84 if __name__ == "__main__":
85 options = PARSER.parse_args()
88 create_cache_in_image(options)