Flutter Engine
The Flutter Engine
Functions | Variables
pub_get_offline Namespace Reference

Functions

def fetch_package (pub, package)
 
def check_package (package)
 
def find_unlisted_packages ()
 
def main ()
 

Variables

 SRC_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
 ENGINE_DIR = os.path.join(SRC_ROOT, 'flutter')
 
list ALL_PACKAGES
 
list EXCLUDED_DIRS
 

Function Documentation

◆ check_package()

def pub_get_offline.check_package (   package)

Definition at line 67 of file pub_get_offline.py.

67def check_package(package):
68 package_config = os.path.join(package, '.dart_tool', 'package_config.json')
69 pub_count = 0
70 with open(package_config) as config_file:
71 data_dict = json.load(config_file)
72 packages_data = data_dict['packages']
73 for package_data in packages_data:
74 package_uri = package_data['rootUri']
75 package_name = package_data['name']
76 if '.pub-cache' in package_uri and ('pub.dartlang.org' in package_uri or
77 'pub.dev' in package_uri):
78 print('Error: package "%s" was fetched from pub' % package_name)
79 pub_count = pub_count + 1
80 if pub_count > 0:
81 print('Error: %d packages were fetched from pub for %s' % (pub_count, package))
82 print(
83 'Please fix the pubspec.yaml for %s '
84 'so that all dependencies are path dependencies' % package
85 )
86 return pub_count
87
88
def check_package(package)
def print(*args, **kwargs)
Definition: run_tests.py:49

◆ fetch_package()

def pub_get_offline.fetch_package (   pub,
  package 
)

Definition at line 55 of file pub_get_offline.py.

55def fetch_package(pub, package):
56 try:
57 subprocess.check_output(pub, cwd=package, stderr=subprocess.STDOUT)
58 except subprocess.CalledProcessError as err:
59 print(
60 '"%s" failed in "%s" with status %d:\n%s' %
61 (' '.join(pub), package, err.returncode, err.output)
62 )
63 return 1
64 return 0
65
66
def fetch_package(pub, package)
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741

◆ find_unlisted_packages()

def pub_get_offline.find_unlisted_packages ( )

Definition at line 104 of file pub_get_offline.py.

105 unlisted = []
106 for root, dirs, files in os.walk(ENGINE_DIR):
107 excluded = []
108 for dirname in dirs:
109 full_dirname = os.path.join(root, dirname)
110 if full_dirname in EXCLUDED_DIRS:
111 excluded.append(dirname)
112 for exclude in excluded:
113 dirs.remove(exclude)
114 for filename in files:
115 if filename == 'pubspec.yaml':
116 if root not in ALL_PACKAGES:
117 unlisted.append(root)
118 return unlisted
119
120
def find_unlisted_packages()

◆ main()

def pub_get_offline.main ( )

Definition at line 121 of file pub_get_offline.py.

121def main():
122 dart_sdk_bin = os.path.join(
123 SRC_ROOT, 'flutter', 'third_party', 'dart', 'tools', 'sdks', 'dart-sdk', 'bin'
124 )
125
126 # Ensure all relevant packages are listed in ALL_PACKAGES.
127 unlisted = find_unlisted_packages()
128 if len(unlisted) > 0:
129 for pkg in unlisted:
130 print('The Dart package "%s" must be checked in flutter/tools/pub_get_offline.py' % pkg)
131 return 1
132
133 dart = 'dart'
134 if os.name == 'nt':
135 dart = 'dart.exe'
136 pubcmd = [os.path.join(dart_sdk_bin, dart), 'pub', '--suppress-analytics', 'get', '--offline']
137
138 pub_count = 0
139 for package in ALL_PACKAGES:
140 if fetch_package(pubcmd, package) != 0:
141 return 1
142 pub_count = pub_count + check_package(package)
143
144 if pub_count > 0:
145 return 1
146
147 return 0
148
149

Variable Documentation

◆ ALL_PACKAGES

list pub_get_offline.ALL_PACKAGES

Definition at line 20 of file pub_get_offline.py.

◆ ENGINE_DIR

pub_get_offline.ENGINE_DIR = os.path.join(SRC_ROOT, 'flutter')

Definition at line 18 of file pub_get_offline.py.

◆ EXCLUDED_DIRS

list pub_get_offline.EXCLUDED_DIRS
Initial value:
1= [
2 os.path.join(ENGINE_DIR, 'lib'),
3 os.path.join(ENGINE_DIR, 'prebuilts'),
4 os.path.join(ENGINE_DIR, 'shell', 'platform', 'fuchsia'),
5 os.path.join(ENGINE_DIR, 'shell', 'vmservice'),
6 os.path.join(ENGINE_DIR, 'sky', 'packages'),
7 os.path.join(ENGINE_DIR, 'testing', 'pkg_test_demo'),
8 os.path.join(ENGINE_DIR, 'third_party'),
9 os.path.join(ENGINE_DIR, 'web_sdk'),
10]

Definition at line 89 of file pub_get_offline.py.

◆ SRC_ROOT

pub_get_offline.SRC_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

Definition at line 17 of file pub_get_offline.py.