Flutter Engine
The Flutter Engine
Functions | Variables
create_tarball Namespace Reference

Functions

def BuildOptions ()
 
def Filter (tar_info)
 
def GenerateCopyright (filename)
 
def GenerateChangeLog (filename, version)
 
def GenerateEmpty (filename)
 
def GenerateGitRevision (filename, git_revision)
 
def GenerateGitTimestamp (filename, git_timestamp)
 
def CreateTarball (tarfilename)
 
def Main ()
 

Variables

 HOST_OS = utils.GuessOS()
 
 DART_DIR = abspath(join(dirname(__file__), '..', '..'))
 
bool verbose = False
 
string versiondir = ''
 
list ignoredPaths
 
list ignoredDirs
 
list ignoredEndings = ['.mk', '.pyc', 'Makefile', '~']
 

Function Documentation

◆ BuildOptions()

def create_tarball.BuildOptions ( )

Definition at line 67 of file create_tarball.py.

67def BuildOptions():
68 result = optparse.OptionParser()
69 result.add_option("-v",
70 "--verbose",
71 help='Verbose output.',
72 default=False,
73 action="store_true")
74 result.add_option("--tar_filename", default=None, help="The output file.")
75
76 return result
77
78

◆ CreateTarball()

def create_tarball.CreateTarball (   tarfilename)

Definition at line 139 of file create_tarball.py.

139def CreateTarball(tarfilename):
140 global ignoredPaths # Used for adding the output directory.
141 # Generate the name of the tarfile
142 version = utils.GetVersion()
143 global versiondir
144 versiondir = 'dart-%s' % version
145 debian_dir = 'tools/linux_dist_support/debian'
146 # Don't include the build directory in the tarball (ignored paths
147 # are relative to DART_DIR).
148 builddir = utils.GetBuildDir(HOST_OS)
149 ignoredPaths.append(builddir)
150
151 print('Creating tarball: %s' % tarfilename)
152 with tarfile.open(tarfilename, mode='w:gz') as tar:
153 for f in listdir(DART_DIR):
154 tar.add(join(DART_DIR, f), filter=Filter)
155 for f in listdir(join(DART_DIR, debian_dir)):
156 tar.add(join(DART_DIR, debian_dir, f),
157 arcname='%s/debian/%s' % (versiondir, f))
158
159 with utils.TempDir() as temp_dir:
160 # Generate and add debian/copyright
161 copyright_file = join(temp_dir, 'copyright')
162 GenerateCopyright(copyright_file)
163 tar.add(copyright_file, arcname='%s/debian/copyright' % versiondir)
164
165 # Generate and add debian/changelog
166 change_log = join(temp_dir, 'changelog')
167 GenerateChangeLog(change_log, version)
168 tar.add(change_log, arcname='%s/debian/changelog' % versiondir)
169
170 # For generated version file build dependency, add fake git reflog.
171 empty = join(temp_dir, 'empty')
172 GenerateEmpty(empty)
173 tar.add(empty, arcname='%s/dart/.git/logs/HEAD' % versiondir)
174
175 # For main, add the GIT_REVISION file.
176 if utils.GetChannel() in ['main', 'be']:
177 git_revision = join(temp_dir, 'GIT_REVISION')
179 tar.add(git_revision,
180 arcname='%s/dart/tools/GIT_REVISION' % versiondir)
181
182 # Add GIT_TIMESTAMP file as git is not available in tarball.
183 git_timestamp = join(temp_dir, 'GIT_TIMESTAMP')
185 tar.add(git_timestamp,
186 arcname='%s/dart/tools/GIT_TIMESTAMP' % versiondir)
187
def GenerateCopyright(filename)
def GenerateGitRevision(filename, git_revision)
def CreateTarball(tarfilename)
def GenerateEmpty(filename)
def GenerateGitTimestamp(filename, git_timestamp)
def GenerateChangeLog(filename, version)
def print(*args, **kwargs)
Definition: run_tests.py:49
def GetBuildDir(host_os)
Definition: utils.py:99
def GetGitTimestamp(git_timestamp_file=None, repo_path=DART_DIR)
Definition: utils.py:458
def GetChannel(version_file=None)
Definition: utils.py:376
def GetVersion(no_git_hash=False, version_file=None, git_revision_file=None)
Definition: utils.py:357
def GetGitRevision(git_revision_file=None, repo_path=DART_DIR)
Definition: utils.py:415
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741

◆ Filter()

def create_tarball.Filter (   tar_info)

Definition at line 79 of file create_tarball.py.

79def Filter(tar_info):
80 # Get the name of the file relative to the dart directory. Note the
81 # name from the TarInfo does not include a leading slash.
82 assert tar_info.name.startswith(DART_DIR[1:])
83 original_name = tar_info.name[len(DART_DIR):]
84 _, tail = split(original_name)
85 if tail in ignoredDirs:
86 return None
87 for path in ignoredPaths:
88 if original_name.startswith(path):
89 return None
90 for ending in ignoredEndings:
91 if original_name.endswith(ending):
92 return None
93 # Add the dart directory name with version. Place the debian
94 # directory one level over the rest which are placed in the
95 # directory 'dart'. This enables building the Debian packages
96 # out-of-the-box.
97 tar_info.name = join(versiondir, 'dart', original_name)
98 if verbose:
99 print('Adding %s as %s' % (original_name, tar_info.name))
100 return tar_info
101
102
def Filter(tar_info)

◆ GenerateChangeLog()

def create_tarball.GenerateChangeLog (   filename,
  version 
)

Definition at line 116 of file create_tarball.py.

116def GenerateChangeLog(filename, version):
117 with open(filename, 'w') as f:
118 f.write('dart (%s-1) UNRELEASED; urgency=low\n' % version)
119 f.write('\n')
120 f.write(' * Generated file.\n')
121 f.write('\n')
122 f.write(' -- Dart Team <misc@dartlang.org> %s\n' %
123 datetime.datetime.utcnow().strftime('%a, %d %b %Y %X +0000'))
124
125

◆ GenerateCopyright()

def create_tarball.GenerateCopyright (   filename)

Definition at line 103 of file create_tarball.py.

103def GenerateCopyright(filename):
104 with open(join(DART_DIR, 'LICENSE')) as lf:
105 license_lines = lf.readlines()
106
107 with open(filename, 'w') as f:
108 f.write('Name: dart\n')
109 f.write('Maintainer: Dart Team <misc@dartlang.org>\n')
110 f.write('Source: https://dart.googlesource.com/sdk\n')
111 f.write('License:\n')
112 for line in license_lines:
113 f.write(' %s' % line) # Line already contains trailing \n.
114
115

◆ GenerateEmpty()

def create_tarball.GenerateEmpty (   filename)

Definition at line 126 of file create_tarball.py.

126def GenerateEmpty(filename):
127 f = open(filename, 'w')
128 f.close()
129
130

◆ GenerateGitRevision()

def create_tarball.GenerateGitRevision (   filename,
  git_revision 
)

Definition at line 131 of file create_tarball.py.

131def GenerateGitRevision(filename, git_revision):
132 with open(filename, 'w') as f:
133 f.write(str(git_revision))
134

◆ GenerateGitTimestamp()

def create_tarball.GenerateGitTimestamp (   filename,
  git_timestamp 
)

Definition at line 135 of file create_tarball.py.

135def GenerateGitTimestamp(filename, git_timestamp):
136 with open(filename, 'w') as f:
137 f.write(str(git_timestamp))
138

◆ Main()

def create_tarball.Main ( )

Definition at line 188 of file create_tarball.py.

188def Main():
189 if HOST_OS != 'linux':
190 print('Tarball can only be created on linux')
191 return -1
192
193 # Parse the options.
194 parser = BuildOptions()
195 (options, args) = parser.parse_args()
196 if options.verbose:
197 global verbose
198 verbose = True
199
200 tar_filename = options.tar_filename
201 if not tar_filename:
202 tar_filename = join(DART_DIR, utils.GetBuildDir(HOST_OS),
203 'dart-%s.tar.gz' % utils.GetVersion())
204
205 CreateTarball(tar_filename)
206
207

Variable Documentation

◆ DART_DIR

create_tarball.DART_DIR = abspath(join(dirname(__file__), '..', '..'))

Definition at line 34 of file create_tarball.py.

◆ HOST_OS

create_tarball.HOST_OS = utils.GuessOS()

Definition at line 33 of file create_tarball.py.

◆ ignoredDirs

list create_tarball.ignoredDirs
Initial value:
1= [
2 '.cipd',
3 '.git',
4 'benchmarks',
5 'docs',
6 'fuchsia',
7 'parser_testcases',
8 'testcases',
9 'tests',
10]

Definition at line 54 of file create_tarball.py.

◆ ignoredEndings

list create_tarball.ignoredEndings = ['.mk', '.pyc', 'Makefile', '~']

Definition at line 64 of file create_tarball.py.

◆ ignoredPaths

list create_tarball.ignoredPaths
Initial value:
1= [
2 'buildtools/linux-x64/go',
3 'buildtools/linux-x64/rust',
4 'third_party/7zip',
5 'third_party/android_tools',
6 'third_party/clang',
7 'third_party/d8',
8 'third_party/firefox_jsshell',
9 'third_party/gsutil',
10 'third_party/llvm-build',
11 'third_party/mdn',
12]

Definition at line 42 of file create_tarball.py.

◆ verbose

bool create_tarball.verbose = False

Definition at line 36 of file create_tarball.py.

◆ versiondir

string create_tarball.versiondir = ''

Definition at line 39 of file create_tarball.py.