Flutter Engine
The Flutter Engine
Classes | Functions | Variables
create_pkg_manifest Namespace Reference

Classes

class  VarImpl
 

Functions

def ParseDepsFile (deps_file)
 
def WriteManifest (deps, manifest_file)
 
def ParseArgs (args)
 
def Main (argv)
 

Variables

 SCRIPT_DIR = os.path.dirname(sys.argv[0])
 
 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
 

Function Documentation

◆ Main()

def create_pkg_manifest.Main (   argv)

Definition at line 114 of file create_pkg_manifest.py.

114def Main(argv):
115 args = ParseArgs(argv)
116 deps = ParseDepsFile(args.deps)
117 WriteManifest(deps, args.output)
118 return 0
119
120
def WriteManifest(deps, manifest_file)
def ParseDepsFile(deps_file)

◆ ParseArgs()

def create_pkg_manifest.ParseArgs (   args)

Definition at line 93 of file create_pkg_manifest.py.

93def ParseArgs(args):
94 args = args[1:]
95 parser = argparse.ArgumentParser(
96 description='A script to generate a jiri manifest for third_party/pkg.')
97
98 parser.add_argument(
99 '--deps',
100 '-d',
101 type=str,
102 help='Input DEPS file.',
103 default=os.path.join(DART_ROOT, 'DEPS'))
104 parser.add_argument(
105 '--output',
106 '-o',
107 type=str,
108 help='Output jiri manifest.',
109 default=os.path.join(DART_ROOT, 'dart_third_party_pkg.manifest'))
110
111 return parser.parse_args(args)
112
113

◆ ParseDepsFile()

def create_pkg_manifest.ParseDepsFile (   deps_file)

Definition at line 43 of file create_pkg_manifest.py.

43def ParseDepsFile(deps_file):
44 local_scope = {}
45 var = VarImpl(local_scope)
46 global_scope = {
47 'Var': var.Lookup,
48 'deps_os': {},
49 }
50 # Read the content.
51 with open(deps_file, 'r') as fp:
52 deps_content = fp.read()
53
54 # Eval the content.
55 exec (deps_content, global_scope, local_scope)
56
57 # Extract the deps and filter.
58 deps = local_scope.get('deps', {})
59 filtered_deps = {}
60 for k, v in deps.items():
61 if 'sdk/third_party/pkg' in k:
62 new_key = k.replace('sdk', 'third_party/dart', 1)
63 filtered_deps[new_key] = v
64
65 return filtered_deps
66
67

◆ WriteManifest()

def create_pkg_manifest.WriteManifest (   deps,
  manifest_file 
)

Definition at line 68 of file create_pkg_manifest.py.

68def WriteManifest(deps, manifest_file):
69 project_template = """
70 <project name="%s"
71 path="%s"
72 remote="%s"
73 revision="%s"/>
74"""
75 warning = (
76 '<!-- This file is generated by '
77 '//third_party/dart/tools/create_pkg_manifest.py. DO NOT EDIT -->\n')
78 with open(manifest_file, 'w') as manifest:
79 manifest.write('<?xml version="1.0" encoding="UTF-8"?>\n')
80 manifest.write(warning)
81 manifest.write('<manifest>\n')
82 manifest.write(' <projects>\n')
83 for path, remote in sorted(deps.items()):
84 remote_components = remote.split('@')
85 remote_url = remote_components[0]
86 remote_version = remote_components[1]
87 manifest.write(
88 project_template % (path, path, remote_url, remote_version))
89 manifest.write(' </projects>\n')
90 manifest.write('</manifest>\n')
91
92

Variable Documentation

◆ DART_ROOT

create_pkg_manifest.DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))

Definition at line 20 of file create_pkg_manifest.py.

◆ SCRIPT_DIR

create_pkg_manifest.SCRIPT_DIR = os.path.dirname(sys.argv[0])

Definition at line 19 of file create_pkg_manifest.py.