Bug 1783690 - part 3: Point files to android-components folder
[gecko.git] / mobile / android / taskcluster / ac_taskgraph / build_config.py
blobf7aeb0560b1511965e17b50740fc34a46e42f52e
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 import os
7 import yaml
9 from taskgraph.util.memoize import memoize
12 EXTENSIONS = {
13 'aar': ('.aar', '.pom', '-sources.jar'),
14 'jar': ('.jar', '.pom', '-sources.jar')
16 CHECKSUMS_EXTENSIONS = ('.sha1', '.md5')
17 CURRENT_DIR = os.path.dirname(os.path.realpath(__file__))
18 PROJECT_DIR = os.path.realpath(os.path.join(CURRENT_DIR, '..', '..'))
19 ANDROID_COMPONENTS_DIR = os.path.join(PROJECT_DIR, "android-components")
22 def get_components():
23 build_config = _read_build_config()
24 return [{
25 'name': name,
26 'path': project['path'],
27 'shouldPublish': project['publish']
28 } for (name, project) in build_config['projects'].items()]
31 def get_version():
32 with open(os.path.join(PROJECT_DIR, "version.txt")) as fh:
33 return fh.read().strip()
36 def get_path(component):
37 return _read_build_config()["projects"][component]["path"]
40 def get_extensions(component):
41 artifact_type = _read_build_config()["projects"][component].get("artifact-type", "aar")
42 if artifact_type not in EXTENSIONS:
43 raise ValueError(
44 "For '{}', 'artifact-type' must be one of {}".format(
45 component, repr(EXTENSIONS.keys())
49 return [
50 extension + checksum_extension
51 for extension in EXTENSIONS[artifact_type]
52 for checksum_extension in ('',) + CHECKSUMS_EXTENSIONS
56 @memoize
57 def _read_build_config():
58 with open(os.path.join(ANDROID_COMPONENTS_DIR, '.buildconfig.yml'), 'rb') as f:
59 return yaml.safe_load(f)