Flutter Engine
The Flutter Engine
make_build_info.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2#
3# Copyright 2013 The Flutter Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7''' Interpolates build environment information into a file.
8'''
9
10from argparse import ArgumentParser
11from datetime import datetime
12from os import path
13import subprocess
14import sys
15import json
16
17
18def GetDartPath(buildroot):
19 dart_path = path.join(buildroot, 'flutter', 'third_party', 'dart')
20 if not path.exists(dart_path):
21 dart_path = path.join(buildroot, 'third_party', 'dart')
22 return dart_path
23
24
25def GetDartSdkGitRevision(buildroot):
26 return subprocess.check_output(['git', '-C', GetDartPath(buildroot), 'rev-parse', 'HEAD']).strip()
27
28
30 project_root = path.join(buildroot, 'third_party', 'dart')
31 return subprocess.check_output(['git', '-C',
32 GetDartPath(buildroot), 'describe', '--abbrev=0']).strip()
33
34
36 project_root = path.join(buildroot, 'flutter')
37 return subprocess.check_output(['git', '-C', project_root, 'rev-parse', 'HEAD']).strip()
38
39
40def GetFuchsiaSdkVersion(buildroot):
41 with open(path.join(buildroot, 'fuchsia', 'sdk',
42 'linux' if sys.platform.startswith('linux') else 'mac', 'meta',
43 'manifest.json'), 'r') as fuchsia_sdk_manifest:
44 return json.load(fuchsia_sdk_manifest)['id']
45
46
47def main():
48 # Parse arguments.
49 parser = ArgumentParser()
50 parser.add_argument('--input', action='store', help='input file path', required=True)
51 parser.add_argument('--output', action='store', help='output file path', required=True)
52 parser.add_argument(
53 '--buildroot', action='store', help='path to the flutter engine buildroot', required=True
54 )
55 args = parser.parse_args()
56
57 # Read, interpolate, write.
58 with open(args.input, 'r') as i, open(args.output, 'w') as o:
59 o.write(
60 i.read().replace(
61 '{{DART_SDK_GIT_REVISION}}',
62 GetDartSdkGitRevision(args.buildroot).decode('utf-8')
63 ).replace(
64 '{{DART_SDK_SEMANTIC_VERSION}}',
65 GetDartSdkSemanticVersion(args.buildroot).decode('utf-8')
66 ).replace(
67 '{{FLUTTER_ENGINE_GIT_REVISION}}',
68 GetFlutterEngineGitRevision(args.buildroot).decode('utf-8')
69 ).replace('{{FUCHSIA_SDK_VERSION}}', GetFuchsiaSdkVersion(args.buildroot))
70 )
71
72
73if __name__ == '__main__':
74 main()
Definition: main.py:1
def GetFuchsiaSdkVersion(buildroot)
def GetFlutterEngineGitRevision(buildroot)
def GetDartSdkGitRevision(buildroot)
def GetDartSdkSemanticVersion(buildroot)
def GetDartPath(buildroot)
static DecodeResult decode(std::string path)
Definition: png_codec.cpp:124