Flutter Engine
The Flutter Engine
api.py
Go to the documentation of this file.
1# Copyright 2016 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5
6from recipe_engine import recipe_api
7
8
9INFRA_GO_PKG = 'go.skia.org/infra'
10UPDATE_GO_ATTEMPTS = 5
11UPLOAD_ATTEMPTS = 5
12
13
14class InfraApi(recipe_api.RecipeApi):
15 @property
16 def goroot(self):
17 go_root = self.m.vars.workdir.join('go', 'go')
18 # Starting with Go 1.18, the standard library includes "//go:embed"
19 # directives that point to other files in the standard library. For
20 # security reasons, the "embed" package does not support symbolic links
21 # (discussion at
22 # https://github.com/golang/go/issues/35950#issuecomment-561725322), and it
23 # produces "cannot embed irregular file" errors when it encounters one.
24 #
25 # To prevent the above error, we ensure our GOROOT environment variable
26 # points to a path without symbolic links.
27 #
28 # For some reason step.m.path.realpath returns the path unchanged, so we
29 # invoke realpath instead.
30 symlink_version_file = go_root.join('VERSION') # Arbitrary symlink.
31 step_result = self.m.step('realpath go/go/VERSION',
32 cmd=['realpath', str(symlink_version_file)],
33 stdout=self.m.raw_io.output_text())
34 step_result = self.m.step('dirname',
35 cmd=['dirname', step_result.stdout],
36 stdout=self.m.raw_io.output_text())
37 go_root_nosymlinks = step_result.stdout.strip()
38 if go_root_nosymlinks != "":
39 return go_root_nosymlinks # pragma: nocover
40 else:
41 # This branch exists solely to appease recipe tests, under which the
42 # workdir variable is unset. Returning an empty string causes tests to
43 # fail, so we return the original GOROOT instead.
44 return go_root
45
46 @property
47 def go_bin(self):
48 return self.m.path.join(self.goroot, 'bin')
49
50 @property
51 def go_env(self):
52 return {
53 'GOCACHE': self.m.vars.cache_dir.join('go_cache'),
54 'GOPATH': self.gopath,
55 'GOROOT': self.goroot,
56 'PATH': self.m.path.pathsep.join([
57 str(self.go_bin), str(self.gopath.join('bin')), '%(PATH)s']),
58 }
59
60 @property
61 def gopath(self):
62 return self.m.vars.cache_dir.join('gopath')
static int step(int x, SkScalar min, SkScalar max)
Definition: BlurTest.cpp:215
def go_env(self)
Definition: api.py:51
def goroot(self)
Definition: api.py:16
def go_bin(self)
Definition: api.py:47
def gopath(self)
Definition: api.py:61
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741