Roll src/third_party/skia 2440fcd:4de8c3a
[chromium-blink-merge.git] / mojo / tools / mopy / paths.py
blob6ed6a906631e7e26f7c50eb16a7ac583f0e9379e
1 # Copyright 2014 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.
5 import os
7 from .config import Config
10 SRC_ROOT = os.path.abspath(os.path.join(__file__, '..', '..', '..', '..'))
12 class Paths(object):
13 '''Provides commonly used paths'''
15 def __init__(self, config):
16 '''Generate paths to binary artifacts from a Config object.'''
17 self.src_root = SRC_ROOT
18 self.mojo_dir = os.path.join(self.src_root, 'mojo')
20 self.build_dir = config.build_dir
21 if self.build_dir is None:
22 subdir = ''
23 if config.target_os == Config.OS_ANDROID:
24 subdir += 'android_'
25 if config.target_cpu != Config.ARCH_ARM:
26 subdir += config.target_cpu + '_'
27 elif config.target_os == Config.OS_CHROMEOS:
28 subdir += 'chromeos_'
29 subdir += 'Debug' if config.is_debug else 'Release'
30 if config.is_asan:
31 subdir += '_asan'
32 if not(config.is_debug) and config.dcheck_always_on:
33 subdir += '_dcheck'
34 self.build_dir = os.path.join(self.src_root, 'out', subdir)
36 self.mojo_runner = [os.path.join(self.build_dir, 'mojo_runner')]
37 if config.target_os == Config.OS_WINDOWS:
38 self.mojo_runner[0] += '.exe'
39 if config.target_os == Config.OS_ANDROID:
40 self.apk_path = os.path.join(self.build_dir, 'apks', config.apk_name)
41 self.mojo_runner = [os.path.join(self.src_root, 'mojo', 'tools',
42 'android_mojo_shell.py'),
43 '--apk', self.apk_path]
45 def RelPath(self, path):
46 '''Returns the given path, relative to the current directory.'''
47 return os.path.relpath(path)
49 def SrcRelPath(self, path):
50 '''Returns the given path, relative to self.src_root.'''
51 return os.path.relpath(path, self.src_root)