• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2022 The ChromiumOS Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5from recipe_engine.post_process import Filter
6
7DEPS = [
8    "crosvm",
9    "depot_tools/depot_tools",
10    "recipe_engine/buildbucket",
11    "recipe_engine/context",
12    "recipe_engine/properties",
13    "recipe_engine/step",
14]
15
16
17def RunSteps(api):
18    with api.crosvm.cros_container_build_context():
19        gitilies = api.buildbucket.build.input.gitiles_commit
20        upstream_url = "https://chromium.googlesource.com/crosvm/crosvm"
21        revision = gitilies.id or "upstream/main"
22
23        api.crosvm.step_in_container(
24            "Sync repo",
25            [
26                "repo",
27                "sync",
28                "-j8",
29            ],
30            cros=True,
31        )
32
33        api.crosvm.step_in_container(
34            "Add crosvm upstream remote",
35            ["git", "remote", "add", "upstream", upstream_url],
36            cros=True,
37        )
38
39        # Ignore errors from unshallow as repo sync sometimes resulted in full git history
40        api.crosvm.step_in_container(
41            "Unshallow crosvm as needed",
42            [
43                "for i in $(seq 1 5);do if [[ $(git rev-parse --is-shallow-repository) == 'true' ]]; then git fetch cros --unshallow; else break; fi; done"
44            ],
45            cros=True,
46        )
47
48        api.crosvm.step_in_container("Print current git log", ["git", "log"], cros=True)
49
50        api.crosvm.step_in_container(
51            "Fetch upstream crosvm", ["git", "fetch", "upstream"], cros=True
52        )
53
54        # Apply unmerged commit from upstream to crOS tree
55        api.crosvm.step_in_container(
56            "Cherry-pick from upstream revision", ["git", "cherry-pick", ".." + revision], cros=True
57        )
58
59        api.crosvm.step_in_container(
60            "cros-workon-hatch crosvm",
61            ["cros_sdk", "cros-workon-hatch", "start", "crosvm"],
62            cros=True,
63        )
64
65        api.crosvm.step_in_container(
66            "Build crosvm",
67            [
68                "cros_sdk",
69                "build_packages",
70                "--board=hatch",
71                "crosvm",
72            ],
73            cros=True,
74        )
75
76
77def GenTests(api):
78    filter_steps = Filter("Build crosvm")
79    yield (
80        api.test(
81            "build_chromeos_hatch",
82            api.buildbucket.ci_build(project="crosvm/crosvm"),
83        )
84        + api.post_process(filter_steps)
85    )
86