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.
7 from .config
import Config
10 SRC_ROOT
= os
.path
.abspath(os
.path
.join(__file__
, '..', '..', '..', '..'))
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:
23 if config
.target_os
== Config
.OS_ANDROID
:
25 if config
.target_cpu
!= Config
.ARCH_ARM
:
26 subdir
+= config
.target_cpu
+ '_'
27 elif config
.target_os
== Config
.OS_CHROMEOS
:
29 subdir
+= 'Debug' if config
.is_debug
else 'Release'
32 if not(config
.is_debug
) and config
.dcheck_always_on
:
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
)