diff options
author | Alexis Christoforides <alexis@thenull.net> | 2016-10-14 20:14:31 +0300 |
---|---|---|
committer | Alexis Christoforides <alexis@thenull.net> | 2016-10-14 20:14:31 +0300 |
commit | f5235ed79ba7d0a2be7fcc70e898f5b815f8c6ee (patch) | |
tree | 8b9114c71d1ba06bc6f8790d5933df794ad961d6 /bockbuild.py | |
parent | ed29dc1fd692c53eb5a0e434ed9034b3b003a29b (diff) |
Find profiles proactively at launch, use that to make program more usable.
Also import Python module paths. The commandline is now `bockbuild.py mac-sdk`, instead of the full profile path
Diffstat (limited to 'bockbuild.py')
-rwxr-xr-x | bockbuild.py | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/bockbuild.py b/bockbuild.py index 375056e..180074e 100755 --- a/bockbuild.py +++ b/bockbuild.py @@ -11,7 +11,18 @@ import collections import hashlib import itertools import traceback +from collections import namedtuple +ProfileDesc = namedtuple ('Profile', 'name description path modes') + +def find_profiles (base_path): + import glob + profiles = [] + for path in iterate_dir ('%s/bockbuild' % base_path, with_dirs=True): + if os.path.isdir (path) and os.path.isfile ('%s/profile.py' % path): + sys.path.append (os.path.realpath (path)) + profiles.append (ProfileDesc (name = os.path.basename (path), description = "", path = path, modes = "")) + return profiles class Bockbuild: @@ -48,11 +59,14 @@ class Bockbuild: find_git(self) self.bockbuild_rev = git_get_revision(self, self.root) + self.profiles = find_profiles (self.profile_root) loginit('bockbuild (%s)' % (git_shortid(self, self.root))) info('cmd: %s' % ' '.join(sys.argv)) if len (sys.argv) < 2: + info ('Products in %s' % self.git ('config --get remote.origin.url', self.profile_root)[0]) + info (self.profiles) error ('One argument needed at least (the profile name)') self.load_profile (sys.argv[1]) @@ -274,19 +288,21 @@ class Bockbuild: self.name = 'bockbuild' def load_profile(self, source): - if isinstance(source, Profile): # package can already be loaded in the source list - return source + path = None + for profile in self.profiles: + if profile.name == source: + path = profile.path - if not os.path.isabs(source): - source = os.path.join(self.execution_root, source) + if isinstance(source, Profile): # package can already be loaded in the source list + Profile.active = source - fullpath = os.path.join(source, 'profile.py') + fullpath = os.path.join(path, 'profile.py') if not os.path.exists(fullpath): error("Profile '%s' not found" % source) - sys.path.append (source) - self.resources.append (source) + sys.path.append (path) + self.resources.append (path) execfile(fullpath, globals()) Profile.active.attach (self) @@ -298,7 +314,9 @@ class Bockbuild: new_profile = Profile.active new_profile._path = fullpath - new_profile.git_root = git_rootdir (self, os.path.dirname (fullpath)) + new_profile.git_root = git_rootdir (self, os.path.dirname (path)) + config.protected_git_repos.append (new_profile.git_root) + self.profile_name = source return new_profile if __name__ == "__main__": |