blob: 84af58eae169754e1689a604065c1834327a77cf [file] [log] [blame]
Chris Sosa7c931362010-10-11 19:49:01 -07001# Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved.
rtc@google.comded22402009-10-26 22:36:21 +00002# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
Zdenek Behan59d8aa72011-02-24 01:09:02 +01005import os, sys
6
Sean O'Connor14b6a0a2010-03-20 23:23:48 -07007class BuildObject(object):
rtc@google.comded22402009-10-26 22:36:21 +00008 """
rtc@google.com64244662009-11-12 00:52:08 +00009 Common base class that defines key paths in the source tree.
rtc@google.comded22402009-10-26 22:36:21 +000010 """
rtc@google.com64244662009-11-12 00:52:08 +000011 def __init__(self, root_dir, static_dir):
Zdenek Behan59d8aa72011-02-24 01:09:02 +010012 self.app_id = '87efface-864d-49a5-9bb3-4b050a7c227a'
rtc@google.com64244662009-11-12 00:52:08 +000013 self.root_dir = root_dir
Zdenek Behan59d8aa72011-02-24 01:09:02 +010014 self.devserver_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
rtc@google.com64244662009-11-12 00:52:08 +000015 self.static_dir = static_dir
Zdenek Behan59d8aa72011-02-24 01:09:02 +010016 self.x86_pkg_dir = '%s/build/x86/local_packages' % self.root_dir
Zdenek Behan92cece82011-03-02 22:35:04 +010017 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'))
rtc@google.com64244662009-11-12 00:52:08 +000024
Zdenek Behan59d8aa72011-02-24 01:09:02 +010025 def AssertSystemCallSuccess(self, err, cmd='unknown'):
rtc@google.com64244662009-11-12 00:52:08 +000026 """
27 TODO(rtc): This code should probably live somewhere else.
28 """
29 if err != 0:
Zdenek Behan59d8aa72011-02-24 01:09:02 +010030 raise Exception('%s failed to execute' % cmd)