Some improvements for the fetch mechanism

parent eb4c2abe
......@@ -33,7 +33,7 @@ from .manifest_parser import ManifestParser
from .module_pool import ModulePool
from .env import Env
from . import fetch as fetch_mod
from .action import (CheckCondition, CleanModules, FetchModules, GenerateFetchMakefile, ListFiles,
from .action import (CheckCondition, CleanModules, FetchModules, ListFiles,
ListModules, MergeCores, Tree, GenerateSimulationMakefile,
GenerateSynthesisMakefile, GenerateRemoteSynthesisMakefile, GenerateSynthesisProject,
QsysHwTclUpdate,)
......@@ -81,9 +81,8 @@ def main():
# 2- There is not a top_module yet in modules_pool, so only this time...:
# - this becomes the top_module
# - the manifest is parsed & processed
current_path = os.getcwd()
modules_pool.new_module(parent=None,
url=current_path,
url=os.getcwd(),
source=fetch_mod.LOCAL,
fetchto=".")
......@@ -124,7 +123,6 @@ def main():
quit()
action = [
GenerateSimulationMakefile,
#GenerateFetchMakefile
]
elif top_mod.action == "synthesis":
if not top_mod.syn_tool:
......@@ -133,7 +131,6 @@ def main():
quit()
action = [
GenerateSynthesisProject,
#GenerateFetchMakefile,
GenerateSynthesisMakefile,
GenerateRemoteSynthesisMakefile
]
......@@ -149,8 +146,6 @@ def main():
action = [ GenerateSimulationMakefile ]
elif options.command == "make-synthesis":
action = [ GenerateSynthesisMakefile ]
elif options.command == "make-fetch":
action = [ GenerateFetchMakefile ]
elif options.command == "make-remote":
action = [ GenerateRemoteSynthesisMakefile ]
elif options.command == "fetch":
......@@ -211,7 +206,6 @@ def _get_parser():
check_manifest.add_argument("--top", help="indicate path to the top manifest", default=None)
manifest_help = subparsers.add_parser("manifest-help", help="print manifest file variables description")
make_simulation = subparsers.add_parser("make-simulation", help="generate simulation makefile")
make_fetch = subparsers.add_parser("make-fetch", help="generate fetch makefile")
make_synthesis = subparsers.add_parser("make-synthesis", help="generate synthesis makefile")
make_remote = subparsers.add_parser("make-remote", help="generate remote synthesis makefile")
......
......@@ -24,7 +24,6 @@ from .check_condition import CheckCondition
from .check_manifest import CheckManifest
from .clean import CleanModules
from .fetch import FetchModules
from .fetch_makefile import GenerateFetchMakefile
from .list_files import ListFiles
from .list_modules import ListModules
from .merge_cores import MergeCores
......@@ -34,4 +33,4 @@ from .synthesis_project import GenerateSynthesisProject
from .synthesis import GenerateSynthesisMakefile
from .remote_synthesis import GenerateRemoteSynthesisMakefile
from .simulation import GenerateSimulationMakefile
from .qsys_hw_tcl_update import QsysHwTclUpdate
\ No newline at end of file
from .qsys_hw_tcl_update import QsysHwTclUpdate
......@@ -32,7 +32,7 @@ class GitSubmodule(Fetcher):
def fetch(self, module):
if module.source != GITSUBMODULE:
raise ValueError("This backend should get git modules only.")
cur_dir = module.pool.top_module.url
cur_dir = module.pool.top_module.path
os.chdir(module.fetchto)
os.system("git submodule init")
os.system("git submodule update")
......@@ -45,7 +45,7 @@ class Git(Fetcher):
@staticmethod
def get_git_toplevel(module):
cur_dir = module.pool.top_module.url
cur_dir = module.pool.top_module.path
try:
os.chdir(path.rel2abs(module.path))
if not os.path.exists(".gitmodules"):
......@@ -63,7 +63,7 @@ class Git(Fetcher):
def get_git_submodules(module):
submodule_dir = path.rel2abs(module.path)
logging.debug("Checking git submodules in %s" % submodule_dir)
cur_dir = module.pool.top_module.url
cur_dir = module.pool.top_module.path
try:
os.chdir(submodule_dir)
......@@ -117,7 +117,7 @@ submodule.ip_cores/wr-cores.url=git://ohwr.org/hdl-core-lib/wr-cores.git
if not os.path.exists(module.fetchto):
os.mkdir(module.fetchto)
cur_dir = module.pool.top_module.url
cur_dir = module.pool.top_module.path
if module.branch is None:
module.branch = "master"
......
......@@ -35,7 +35,7 @@ class Svn(Fetcher):
if not os.path.exists(module.fetchto):
os.mkdir(module.fetchto)
cur_dir = module.pool.top_module.url
cur_dir = module.pool.top_module.path
os.chdir(module.fetchto)
basename = path.url_basename(module.url)
......
......@@ -79,46 +79,3 @@ class MakefileWriter(object):
self.write(text+"\n")
def generate_fetch_makefile(self, modules_pool):
rp = os.path.relpath
top_module = modules_pool.get_top_module()
self.write("#target for fetching all modules stored in repositories\n")
self.write("fetch: __fetch_pre_cmd __run_fetch __fetch_post_cmd\n\n")
self.write("__run_fetch:\\\n")
self.write(' \\\n'.join(["__"+m.basename+"_fetch" for m in modules_pool if m.source in (fetch.SVN, fetch.GIT)]))
self.write("\n\n")
self.write("__fetch_pre_cmd:\n")
self.write("\t\t%s\n\n" % top_module.fetch_pre_cmd)
self.write("__fetch_post_cmd:\n")
self.write("\t\t%s\n\n" % top_module.fetch_post_cmd)
for module in modules_pool:
basename = module.basename
if module.source == fetch.SVN:
self.write("__"+basename+"_fetch:\n")
self.write("\t\tmkdir -p %s\n" % rp(module.fetchto))
self.write("\t\tPWD=$(shell pwd) ")
self.write("cd " + rp(module.fetchto) + ' && ')
c = "svn checkout {0}{1}"
if module.revision:
c = c.format(module.url, "@"+module.revision)
else:
c = c.format(module.url, "")
self.write(c)
self.write("; cd $(PWD) \n\n")
elif module.source == fetch.GIT:
self.write("__"+basename+"_fetch:\n")
self.write("\t\tmkdir -p %s\n" % rp(module.fetchto))
self.write("\t\t")
self.write("PWD=$(shell pwd) ")
self.write("cd " + rp(module.fetchto) + ' && ')
self.write("if [ -d " + basename + " ]; then cd " + basename + ' && ')
self.write("git pull ")
if module.revision:
self.write(" && git checkout " + module.revision + '; ')
self.write("else git clone " + module.url + ' && ')
if module.revision:
self.write("cd " + basename + " && git checkout " + module.revision + '; fi; ')
self.write("cd $(PWD) \n\n")
......@@ -112,7 +112,7 @@ class ModulePool(list):
def _guess_origin(self, path):
"""Guess origin (git, svn, local) of a module at given path"""
cwd = self.top_module.url
cwd = self.top_module.path
try:
os.chdir(path)
git_out = Popen("git config --get remote.origin.url", stdout=PIPE, shell=True, close_fds=True)
......
Markdown is supported
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