From 7b4247f40fb3e1a41629c3a92f043920ed46f44d Mon Sep 17 00:00:00 2001 From: Alexis Christoforides Date: Wed, 19 Aug 2015 03:44:06 -0400 Subject: Fixed import resolution issues with subclassing mono_master --- bockbuild/profile.py | 46 ++++++++++++++----------- bockbuild/util/util.py | 4 ++- profiles/mono-mac-release/MonoReleaseProfile.py | 13 ++----- 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/bockbuild/profile.py b/bockbuild/profile.py index 004508e..efddb49 100644 --- a/bockbuild/profile.py +++ b/bockbuild/profile.py @@ -3,7 +3,7 @@ from optparse import OptionParser from util.util import * from util.csproj import * from environment import Environment -from package import * +from bockbuild.package import * import collections import hashlib @@ -197,24 +197,6 @@ class Profile: self.process_release (self.package_root) self.package () - def load_package (self, path): - if not os.path.isabs (path): - fullpath = os.path.join (self.resource_root, path + '.py') - else: - fullpath = path - - if not os.path.exists (fullpath): - error ("Resource '%s' not found" % path) - - Package.last_instance = None - exec compile (open (fullpath).read (), fullpath, 'exec') - if Package.last_instance == None: - error ('%s does not provide a valid package.' % path) - - new_package = Package.last_instance - new_package._path = fullpath - return new_package - def track_env (self): tracked_env = [] @@ -241,8 +223,8 @@ class Profile: self.toolchain_packages = collections.OrderedDict() self.release_packages = collections.OrderedDict() - for path in self.packages_to_build: - package = self.load_package (path) + for source in self.packages_to_build: + package = self.load_package (source) Profile.setup_package (self, package) Profile.fetch_package (self, package) @@ -252,6 +234,28 @@ class Profile: else: self.release_packages[package.name] = package + def load_package (self, source): + if isinstance (source, Package): # package can already be loaded in the source list + return source + + if not os.path.isabs (source): + fullpath = os.path.join (self.resource_root, source + '.py') + else: + fullpath = source + + if not os.path.exists (fullpath): + error ("Resource '%s' not found" % source) + + Package.last_instance = None + execfile (fullpath) + + if Package.last_instance == None: + error ('%s does not provide a valid package.' % path) + + new_package = Package.last_instance + new_package._path = fullpath + return new_package + def fetch_package (self, package): clean_func = None def fetch (): diff --git a/bockbuild/util/util.py b/bockbuild/util/util.py index 0830db9..5db13ae 100644 --- a/bockbuild/util/util.py +++ b/bockbuild/util/util.py @@ -131,11 +131,12 @@ def retry (func, tries = 3, delay = 5): result = None exc = None cwd = None + result = None for x in range(tries): try: cwd = os.getcwd () result = func () - return result + break except CommandException as e: if x == tries - 1: raise @@ -146,6 +147,7 @@ def retry (func, tries = 3, delay = 5): if cwd != os.getcwd (): warn ('%s returned on different directory: Was %s, is %s' % (func.__name__, cwd, os.getcwd ())) os.chdir (cwd) + return result def ensure_dir (d, purge = False): diff --git a/profiles/mono-mac-release/MonoReleaseProfile.py b/profiles/mono-mac-release/MonoReleaseProfile.py index b0a1fbc..c16dc5b 100755 --- a/profiles/mono-mac-release/MonoReleaseProfile.py +++ b/profiles/mono-mac-release/MonoReleaseProfile.py @@ -8,7 +8,8 @@ import tempfile import subprocess import stat -sys.path.append('../..') +if __name__ == "__main__": + sys.path.append('../..') from bockbuild.darwinprofile import DarwinProfile from bockbuild.util.util import * @@ -394,13 +395,3 @@ class MonoReleaseProfile(DarwinProfile): os.chmod (path, os.stat(path).st_mode | stat.S_IEXEC) subprocess.call(['bash', '-c', path] ) - -def main(): - try: - MonoReleaseProfile().build() - except Exception as e: - error (str(e)) - raise - -if __name__ == "__main__": - main() -- cgit v1.2.3