• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 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
6"""Build Skia for various platforms."""
7
8
9from recipe_engine import recipe_api
10
11from . import android
12from . import canvaskit
13from . import chromebook
14from . import cmake
15from . import default
16from . import docker
17from . import pathkit
18
19
20class BuildApi(recipe_api.RecipeApi):
21  def __init__(self, buildername, *args, **kwargs):
22    b = buildername
23    if 'Android' in b and not 'Flutter' in b:
24      self.compile_fn = android.compile_fn
25      self.copy_fn = android.copy_build_products
26    elif 'Chromebook' in b:
27      self.compile_fn = chromebook.compile_fn
28      self.copy_fn = chromebook.copy_build_products
29    elif 'EMCC' in b:
30      if 'PathKit' in b:
31        self.compile_fn = pathkit.compile_fn
32        self.copy_fn = pathkit.copy_build_products
33      else:
34        self.compile_fn = canvaskit.compile_fn
35        self.copy_fn = canvaskit.copy_build_products
36    elif 'CMake' in b:
37      self.compile_fn = cmake.compile_fn
38      self.copy_fn = cmake.copy_build_products
39    elif 'Docker' in b:
40      self.compile_fn = docker.compile_fn
41      self.copy_fn = docker.copy_build_products
42    else:
43      self.compile_fn = default.compile_fn
44      self.copy_fn = default.copy_build_products
45    super(BuildApi, self).__init__(*args, **kwargs)
46
47  def __call__(self, checkout_root, out_dir):
48    """Compile the code."""
49    self.compile_fn(self.m, checkout_root, out_dir)
50
51  def copy_build_products(self, out_dir, dst):
52    """Copy selected build products to dst."""
53    self.copy_fn(self.m, out_dir, dst)
54