Skip to content
Snippets Groups Projects
Commit 37db2956 authored by Paweł Szostek's avatar Paweł Szostek
Browse files

Get rid of "fetchto" variable passing problem

If a module has "fetchto" variable defined, then all
it's modules are fetched to this destination. If the
variable is indefined, then it is taken the parent.
parent 31306973
No related merge requests found
No preview for this file type
...@@ -18,16 +18,14 @@ class ModulePool(list): ...@@ -18,16 +18,14 @@ class ModulePool(list):
if module.source == "svn": if module.source == "svn":
p.vprint("[svn] Fetching to " + module.fetchto) p.vprint("[svn] Fetching to " + module.fetchto)
self.__fetch_from_svn(module) self.__fetch_from_svn(module)
module.manifest = module.search_for_manifest()
if module.source == "git": if module.source == "git":
p.vprint("[git] Fetching to " + module.fetchto) p.vprint("[git] Fetching to " + module.fetchto)
self.__fetch_from_git(module) self.__fetch_from_git(module)
module.manifest = module.search_for_manifest()
module.parse_manifest() module.parse_manifest()
if module.root_module != None: if module.root_module != None:
p.vprint("Encountered root manifest: " + str(root_module)) p.vprint("Encountered root manifest: " + str(module.root_module))
new_modules.append(module.root_module) new_modules.append(module.root_module)
new_modules.extend(module.local) new_modules.extend(module.local)
......
...@@ -53,64 +53,67 @@ class Module(object): ...@@ -53,64 +53,67 @@ class Module(object):
self.revision = None self.revision = None
if files == None: if files == None:
self.options["files"] = [] self.files = []
elif not isinstance(files, list): elif not isinstance(files, list):
self.options["files"] = [files] self.files = [files]
else: else:
self.options["files"] = files self.files = files
if manifest != None and fetchto == None: if manifest != None and fetchto == None:
self.options["fetchto"] = os.path.dirname(manifest.path) self.fetchto = os.path.dirname(manifest.path)
if manifest != None and url == None and path == None: if manifest != None and url == None and path == None:
self.options["url"] = os.path.dirname(manifest.path) self.url = os.path.dirname(manifest.path)
self.options["path"] = os.path.dirname(manifest.path) self.path = os.path.dirname(manifest.path)
else: else:
if path != None and url == None: if path != None and url == None:
self.options["path"] = path self.path = path
self.options["url"] = path self.url = path
else: else:
self.options["path"] = path self.path = path
self.options["url"] = url self.url = url
if manifest == None: if manifest == None:
if path != None: if path != None:
self.options["manifest"] = self.__search_for_manifest() self.manifest = self.__search_for_manifest()
else: else:
self.options["manifest"] = None self.manifest = None
else: else:
self.options["manifest"] = manifest self.manifest = manifest
if source == "local": if source == "local":
self.path = self.url self.path = self.url
self.options["isfetched"] = True self.isfetched = True
else: else:
self.options["isfetched"] = isfetched self.isfetched = isfetched
if source != None: if source != None:
if source not in ["local", "svn", "git"]: if source not in ["local", "svn", "git"]:
raise ValueError("Inproper source: " + source) raise ValueError("Inproper source: " + source)
self.options["source"] = source self.source = source
else: else:
self.options["source"] = "local" self.source = "local"
if fetchto != None: if fetchto != None:
self.options["fetchto"] = fetchto self.fetchto = fetchto
else: else:
self.options["fetchto"] = parent.fetchto if parent == None:
self.fetchto = self.path
else:
self.fetchto = parent.fetchto
self.isparsed = False
basename = path_mod.url_basename(self.url)
self.options["isparsed"] = False
basename = path_mod.url_basename(self.options["url"])
if source == "local": if source == "local":
self.options["isfetched"] = True self.isfetched = True
elif self.options["path"] != None: elif self.path != None:
self.options["isfetched"] = True self.isfetched = True
elif os.path.exists(os.path.join(self.options["fetchto"], basename)): elif os.path.exists(os.path.join(self.fetchto, basename)):
self.options["isfetched"] = True self.isfetched = True
self.path = os.path.join(self.options["fetchto"], basename) self.path = os.path.join(self.fetchto, basename)
self.manifest = self.__search_for_manifest() self.manifest = self.__search_for_manifest()
self.options["library"] = "work" self.library = "work"
self.parse_manifest() self.parse_manifest()
def __getattr__(self, attr): def __getattr__(self, attr):
...@@ -120,8 +123,18 @@ class Module(object): ...@@ -120,8 +123,18 @@ class Module(object):
def __str__(self): def __str__(self):
return self.url return self.url
@property
def is_fetched_to(self):
return os.path.dirname(self.path)
def submodules(self): def submodules(self):
return self.local + self.git + self.svn def __nonull(x):
if not x:
return []
else:
return x
return __nonull(self.local) + __nonull(self.git) + __nonull(self.svn)
def basename(self): def basename(self):
import path import path
...@@ -184,20 +197,14 @@ class Module(object): ...@@ -184,20 +197,14 @@ class Module(object):
self.target = opt_map["target"] self.target = opt_map["target"]
if(opt_map["fetchto"] != None):
#derivate fetchto from the root_module print ">>>" + opt_map["fetchto"]
import sys fetchto = path_mod.rel2abs(opt_map["fetchto"], self.path)
if opt_map["root_module"] != None:
self.fetchto = self.root_module.fetchto
else: else:
if not path_mod.is_rel_path(opt_map["fetchto"]): if self.fetchto == None:
p.echo(' '.join([os.path.basename(sys.argv[0]), "accepts relative paths only:", opt_map["fetchto"]])) fetchto = self.is_fetched_to
quit()
if(opt_map["fetchto"] != None):
fetchto = path_mod.rel2abs(opt_map["fetchto"], self.path)
else: else:
fetchto = None fetchto = self.fetchto
if self.ise == None: if self.ise == None:
self.ise = "13.1" self.ise = "13.1"
...@@ -206,7 +213,7 @@ class Module(object): ...@@ -206,7 +213,7 @@ class Module(object):
local_mods = [] local_mods = []
for path in local_paths: for path in local_paths:
path = path_mod.rel2abs(path, self.path) path = path_mod.rel2abs(path, self.path)
local_mods.append(Module(path=path, source="local", parent=self)) local_mods.append(Module(path=path, source="local", parent=self, fetchto=fetchto))
self.local = local_mods self.local = local_mods
else: else:
self.local = [] self.local = []
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment