OLD | NEW |
1 # Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import os, sys | 5 import os, sys |
6 | 6 |
7 class BuildObject(object): | 7 class BuildObject(object): |
8 """ | 8 """ |
9 Common base class that defines key paths in the source tree. | 9 Common base class that defines key paths in the source tree. |
10 """ | 10 """ |
11 def __init__(self, root_dir, static_dir): | 11 def __init__(self, root_dir, static_dir): |
12 self.app_id = '87efface-864d-49a5-9bb3-4b050a7c227a' | 12 self.app_id = '87efface-864d-49a5-9bb3-4b050a7c227a' |
13 self.root_dir = root_dir | 13 self.root_dir = root_dir |
14 self.scripts_dir = '%s/src/scripts' % os.environ['CROS_WORKON_SRCROOT'] | |
15 self.devserver_dir = os.path.dirname(os.path.abspath(sys.argv[0])) | 14 self.devserver_dir = os.path.dirname(os.path.abspath(sys.argv[0])) |
16 self.static_dir = static_dir | 15 self.static_dir = static_dir |
17 self.x86_pkg_dir = '%s/build/x86/local_packages' % self.root_dir | 16 self.x86_pkg_dir = '%s/build/x86/local_packages' % self.root_dir |
| 17 try: |
| 18 self.scripts_dir = '%s/src/scripts' % os.environ['CROS_WORKON_SRCROOT'] |
| 19 except KeyError: |
| 20 # Outside of chroot: This is a corner case. Since we live either in |
| 21 # platform/dev or /usr/bin/, scripts have to live in ../../../src/scripts |
| 22 self.scripts_dir = os.path.abspath(os.path.join( |
| 23 self.devserver_dir, '../../../src/scripts')) |
18 | 24 |
19 def AssertSystemCallSuccess(self, err, cmd='unknown'): | 25 def AssertSystemCallSuccess(self, err, cmd='unknown'): |
20 """ | 26 """ |
21 TODO(rtc): This code should probably live somewhere else. | 27 TODO(rtc): This code should probably live somewhere else. |
22 """ | 28 """ |
23 if err != 0: | 29 if err != 0: |
24 raise Exception('%s failed to execute' % cmd) | 30 raise Exception('%s failed to execute' % cmd) |
OLD | NEW |