Flutter Engine
The Flutter Engine
Functions | Variables
update Namespace Reference

Functions

def convertOne (infile, options)
 
def Flags ()
 
def getAllHtmlFiles ()
 
def main ()
 
def UpdateClangFormatOnWindows ()
 
def CreateSymlink (symlink, link_name)
 
def LinksForGitCLFormat ()
 
def main (argv)
 

Variables

 APP_PATH = os.getcwd()
 
 CLIENT_TOOLS_PATH = dirname(abspath(__file__))
 
 CLIENT_PATH = dirname(CLIENT_TOOLS_PATH)
 
 THIS_DIR = os.path.abspath(os.path.dirname(__file__))
 
 DART_ROOT = os.path.abspath(os.path.join(THIS_DIR, '..', '..'))
 
 BUILDTOOLS = os.path.join(DART_ROOT, 'buildtools')
 
 TOOLS_BUILDTOOLS = os.path.join(DART_ROOT, 'tools', 'buildtools')
 
 DEPOT_PATH = find_depot_tools.add_depot_tools_to_path()
 

Function Documentation

◆ convertOne()

def update.convertOne (   infile,
  options 
)

Definition at line 24 of file update.py.

24def convertOne(infile, options):
25 outDirBase = 'outcode'
26 outfile = join(outDirBase, infile)
27 print('converting %s to %s' % (infile, outfile))
28
29 if 'dart' in options.target:
30 htmlconverter.convertForDartium(infile, outDirBase,
31 outfile.replace('.html', '-dart.html'),
32 options.verbose)
33 if 'js' in options.target:
34 htmlconverter.convertForChromium(infile, options.dartc_extra_flags,
35 outfile.replace('.html', '-js.html'),
36 options.verbose)
37
38
def print(*args, **kwargs)
Definition: run_tests.py:49
def convertOne(infile, options)
Definition: update.py:24
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741

◆ CreateSymlink()

def update.CreateSymlink (   symlink,
  link_name 
)

Definition at line 37 of file update.py.

37def CreateSymlink(symlink, link_name):
38 try:
39 os.symlink(symlink, link_name)
40 except OSError as e:
41 if e.errno == errno.EEXIST:
42 os.remove(link_name)
43 os.symlink(symlink, link_name)
44 else:
45 raise e
46
47
48# On Mac and Linux we symlink clang-format and gn to the place where
49# 'git cl format' expects them to be.
def CreateSymlink(symlink, link_name)
Definition: update.py:37

◆ Flags()

def update.Flags ( )
 Constructs a parser for extracting flags from the command line. 

Definition at line 39 of file update.py.

39def Flags():
40 """ Constructs a parser for extracting flags from the command line. """
41 result = optparse.OptionParser()
42 result.add_option("-t",
43 "--target",
44 help="The target html to generate",
45 metavar="[js,dart]",
46 default='js,dart')
47 result.add_option("--verbose",
48 help="Print verbose output",
49 default=False,
50 action="store_true")
51 result.add_option("--dartc_extra_flags",
52 help="Additional flag text to pass to dartc",
53 default="",
54 action="store")
55 #result.set_usage("update.py input.html -o OUTDIR -t chromium,dartium")
56 return result
57
58
def Flags()
Definition: update.py:39

◆ getAllHtmlFiles()

def update.getAllHtmlFiles ( )

Definition at line 59 of file update.py.

59def getAllHtmlFiles():
60 htmlFiles = []
61 for filename in os.listdir(APP_PATH):
62 fName, fExt = os.path.splitext(filename)
63 if fExt.lower() == '.html':
64 htmlFiles.append(filename)
65
66 return htmlFiles
67
68
def getAllHtmlFiles()
Definition: update.py:59

◆ LinksForGitCLFormat()

def update.LinksForGitCLFormat ( )

Definition at line 50 of file update.py.

51 if sys.platform == 'darwin':
52 platform = 'darwin'
53 tools = 'mac'
54 toolchain = 'mac-x64'
55 elif sys.platform.startswith('linux'):
56 platform = 'linux'
57 tools = 'linux64'
58 toolchain = 'linux-x64'
59 else:
60 print('Unknown platform: ' + sys.platform)
61 return 1
62
63 clang_format = os.path.join(BUILDTOOLS, toolchain, 'clang', 'bin',
64 'clang-format')
65 gn = os.path.join(BUILDTOOLS, 'gn')
66 dest_dir = os.path.join(BUILDTOOLS, tools)
67 if not os.path.exists(dest_dir):
68 os.makedirs(dest_dir)
69 clang_format_dest = os.path.join(dest_dir, 'clang-format')
70 gn_dest = os.path.join(dest_dir, 'gn')
71 CreateSymlink(clang_format, clang_format_dest)
72 CreateSymlink(gn, gn_dest)
73 return 0
74
75
def LinksForGitCLFormat()
Definition: update.py:50

◆ main() [1/2]

def update.main ( )

Definition at line 69 of file update.py.

69def main():
70 os.chdir(CLIENT_PATH) # TODO(jimhug): I don't like chdir's in scripts...
71
72 parser = Flags()
73 options, args = parser.parse_args()
74 #if len(args) < 1 or not options.out or not options.target:
75 # parser.print_help()
76 # return 1
77
78 REL_APP_PATH = relpath(APP_PATH)
79 for file in getAllHtmlFiles():
80 infile = join(REL_APP_PATH, file)
81 convertOne(infile, options)
82
83
def main(argv)
Definition: update.py:76

◆ main() [2/2]

def update.main (   argv)

Definition at line 76 of file update.py.

76def main(argv):
77 arch_id = platform.machine()
78 # Don't try to download binaries if we're on an arm machine unless it is a
79 # Mac arm machine because the x64 binaries work using rosetta translation.
80 if ((arch_id.startswith('arm') and sys.platform != 'darwin') or
81 arch_id.startswith('aarch64')):
82 print('Not downloading buildtools binaries for ' + arch_id)
83 return 0
84 if sys.platform.startswith('win'):
86 return LinksForGitCLFormat()
87
88
def UpdateClangFormatOnWindows()
Definition: update.py:24

◆ UpdateClangFormatOnWindows()

def update.UpdateClangFormatOnWindows ( )

Definition at line 24 of file update.py.

25 sha1_file = os.path.join(TOOLS_BUILDTOOLS, 'win', 'clang-format.exe.sha1')
26 output_dir = os.path.join(BUILDTOOLS, 'win', 'clang-format.exe')
27 downloader_script = os.path.join(DEPOT_PATH,
28 'download_from_google_storage.py')
29 download_cmd = [
30 sys.executable, downloader_script, '--no_auth', '--no_resume',
31 '--quiet', '--platform=win', '--bucket', 'chromium-clang-format', '-s',
32 sha1_file, '-o', output_dir
33 ]
34 return subprocess.call(download_cmd)
35
36

Variable Documentation

◆ APP_PATH

update.APP_PATH = os.getcwd()

Definition at line 15 of file update.py.

◆ BUILDTOOLS

update.BUILDTOOLS = os.path.join(DART_ROOT, 'buildtools')

Definition at line 15 of file update.py.

◆ CLIENT_PATH

update.CLIENT_PATH = dirname(CLIENT_TOOLS_PATH)

Definition at line 17 of file update.py.

◆ CLIENT_TOOLS_PATH

update.CLIENT_TOOLS_PATH = dirname(abspath(__file__))

Definition at line 16 of file update.py.

◆ DART_ROOT

update.DART_ROOT = os.path.abspath(os.path.join(THIS_DIR, '..', '..'))

Definition at line 14 of file update.py.

◆ DEPOT_PATH

Definition at line 21 of file update.py.

◆ THIS_DIR

update.THIS_DIR = os.path.abspath(os.path.dirname(__file__))

Definition at line 13 of file update.py.

◆ TOOLS_BUILDTOOLS

update.TOOLS_BUILDTOOLS = os.path.join(DART_ROOT, 'tools', 'buildtools')

Definition at line 16 of file update.py.