blob: 771c1b55ee873b0a10045c6e2522dd47ca4d94d6 [file] [log] [blame]
#!/usr/bin/env python
# Copyright 2018 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Generates a new manifest.json for Canary, Dev builds with postfixed name and
git hash included.
This script takes a manifest.json file as input and generates a new one with
postfixed name and git hash included.
import argparse
import json
import os
import subprocess
import sys
CWD = os.path.dirname(os.path.realpath(__file__))
SRC_MANIFEST = CWD + '/../src/manifest.json'
CANARY_MANIFEST = CWD + '/../build/camera-canary/manifest.json'
DEV_MANIFEST = CWD + '/../build/camera-dev/manifest.json'
def GetGitHash():
return subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=CWD).strip()
def main(argv):
parser = argparse.ArgumentParser()
group = parser.add_mutually_exclusive_group(required=True)
help='Generate Canary manifest')
help='Generate Dev manifest')
args = parser.parse_args(argv)
with open(SRC_MANIFEST, 'r') as f:
manifest = json.load(f)
if args.canary:
output_manifest = CANARY_MANIFEST
output_manifest = DEV_MANIFEST
manifest['version_name'] = (manifest['version'] +
' (' + GetGitHash()[:8] + ')')
with open(output_manifest, 'w') as f:
f.write(json.dumps(manifest, indent=2))
return 0
if __name__ == '__main__':