Skip to content
Snippets Groups Projects
Commit 6800f5b3 authored by Pawel Szostek's avatar Pawel Szostek
Browse files

no "fetching" for local modules - everything stays at its place

parent b88ba03a
Branches
Tags
No related merge requests found
......@@ -68,13 +68,12 @@ def generate_deps_for_modules(modules_paths):
opt_map_dict[module] = parse_manifest(module_manifest_dict[module])
module_files_dict = {}
from hdlmake import make_list_of_files
from path import make_list_of_files
for module in modules_paths:
if module in opt_map_dict:
module_files_dict[module] = make_list_of_files(module, opt_map_dict[module].files, os.path.dirname(module_manifest_dict[module]))
else:
module_files_dict[module] = make_list_of_files(module)
all_files = []
file_lib_dict = {}
......@@ -85,10 +84,10 @@ def generate_deps_for_modules(modules_paths):
else:
file_lib_dict[os.path.abspath(x)] = "work"
all_files.append(os.path.abspath(x))
all_files = list(set(all_files))
#all_files = [(opt_map_dict[k].library, os.path.abspath(x)) for k in module_files_dict for x in module_files_dict[k]]
all_vhdl_files = [x for x in all_files if os.path.splitext(x)[1] == '.vhd']
p.vpprint(all_vhdl_files)
file_use_clause_dict = {}
for file in all_vhdl_files:
......@@ -135,6 +134,15 @@ def generate_deps_for_modules(modules_paths):
return file_file_dict, file_lib_dict
def generate_makefile(file_deps_dict, file_lib_dict):
from time import gmtime, strftime
import path
date = strftime("%a, %d %b %Y %H:%M:%S", gmtime())
notices = """#######################################################################
# This makefile has been automatically generated by hdl-make
# for testbench """ + path.url_basename(global_mod.cwd) + """ on """ + date + """
#######################################################################
"""
make_preambule_p1 = """## variables #############################
PWD := $(shell pwd)
WORK_NAME := work
......@@ -166,6 +174,7 @@ clean:
pwd = os.getcwd()
#open the file and write the above preambule (part 1)
f = open("makefile", "w")
f.write(notices)
f.write(make_preambule_p1)
libs = set(v for k,v in file_lib_dict.iteritems())
......
......@@ -23,15 +23,16 @@ def fetch_from_local(url):
quit()
basename = path.url_basename(url)
make_hdlm_dir()
if os.path.exists(global_mod.hdlm_path + "/" + basename):
p.echo("Folder " + global_mod.hdlm_path + "/" + basename + " exists. Maybe it is already fetched?")
return
os.symlink(url, global_mod.hdlm_path + "/" + basename)
def fetch_from_git(url, revision = None):
cwd = os.getcwd()
basename = url_basename(url)
make_hdlm_dir()
basename = url_basename(url)
if basename.endswith(".git"):
basename = basename[:-4] #remove trailing .git
os.chdir(global_mod.hdlm_path)
......@@ -42,4 +43,8 @@ def fetch_from_git(url, revision = None):
os.chdir(basename)
os.system("git checkout " + revision)
os.chdir(cwd)
\ No newline at end of file
os.chdir(global_mod.cwd)
def make_hdlm_dir():
if not os.path.exists(global_mod.hdlm_path):
os.mkdir(global_mod.hdlm_path)
\ No newline at end of file
......@@ -54,6 +54,15 @@ def check_module_and_append(list, module):
return 0
def parse_manifest(manifest_file):
def make_list(sth):
if sth != None:
if not isinstance(sth, (list,tuple)):
sth = [sth]
else:
sth = []
return sth
manifest_path = os.path.dirname(manifest_file)
manifest_parser = cfgparse.ConfigParser(allow_py = True)
......@@ -70,39 +79,30 @@ def parse_manifest(manifest_file):
manifest_parser.add_file(manifest_file)
#Take configuration parser from the global namespace
global_mod.opt_map = manifest_parser.parse()
opt_map = manifest_parser.parse()
if global_mod.opt_map.root == None:
global_mod.opt_map.root = "."
if opt_map.root == None:
opt_map.root = "."
if global_mod.opt_map.rtl == None:
global_mod.opt_map.rtl = ["."]
elif not isinstance (global_mod.opt_map.rtl, list):
global_mod.opt_map.rtl = [global_mod.opt_map.rtl]
if opt_map.rtl == None:
opt_map.rtl = ["."]
elif not isinstance (opt_map.rtl, list):
opt_map.rtl = [opt_map.rtl]
if global_mod.opt_map.ise == None:
global_mod.opt_map.ise = "13.1"
if opt_map.ise == None:
opt_map.ise = "13.1"
if global_mod.opt_map.files != None:
if not isinstance(global_mod.opt_map.files, list):
global_mod.opt_map.files = [global_mod.opt_map.files]
if global_mod.opt_map.local != None:
if not isinstance(global_mod.opt_map.local, (list, tuple)):
global_mod.opt_map.local = [global_mod.opt_map.local]
for i in global_mod.opt_map.local:
if path.is_abs_path(i):
p.echo(sys.argv[0] + " accepts relative paths only: " + i)
quit()
#global_mod.opt_map.local[:] = [x for x in global_mod.opt_map.local if not path.is_abs_path(
opt_map.local = make_list(opt_map.local)
for i in opt_map.local:
if path.is_abs_path(i):
p.echo(sys.argv[0] + " accepts relative paths only: " + i)
quit()
opt_map.local = [path.rel2abs(x, manifest_path) for x in opt_map.local]
if global_mod.opt_map.svn != None and not isinstance(global_mod.opt_map.svn, (list, tuple)):
global_mod.opt_map.svn = [global_mod.opt_map.svn]
if global_mod.opt_map.git != None and not isinstance(global_mod.opt_map.git, (list, tuple)):
global_mod.opt_map.git = [global_mod.opt_map.git]
if global_mod.opt_map.files != None and not isinstance(global_mod.opt_map.files, (list, tuple)):
global_mod.opt_map.files = [global_mod.opt_map.files]
return global_mod.opt_map
opt_map.svn = make_list(opt_map.svn)
opt_map.git = make_list(opt_map.git)
opt_map.files = make_list(opt_map.files)
return opt_map
def convert_xise(xise):
......@@ -228,92 +228,72 @@ def main():
tcl_pat = re.compile("^.*\.tcl$")
for file in os.listdir("."): #try to find it in the current dir
if re.match(tcl_pat, file):
p.vprint("Found .tcl file in the current directory: " + file)
p.vprint("Found .tcf l file in the current directory: " + file)
global_mod.opt_map.tcl = file
break
else:
global_mod.opt_map.tcl = options.tcl
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
if global_mod.options.fetch == True:
if not os.path.exists(global_mod.hdlm_path):
os.mkdir(global_mod.hdlm_path)
cur_manifest = global_mod.top_manifest
involved_modules = []
new_manifests = []
while True:
if global_mod.opt_map.local != None:
for i in global_mod.opt_map.local:
if not os.path.exists(global_mod.cwd + '/' + i):
p.echo("Error in parsing " + cur_manifest +". There is not such catalogue as "+
global_mod.cwd + '/' + i)
for i in global_mod.opt_map.local:
if not os.path.exists(i):
p.echo("Error in parsing " + cur_manifest +". There is not such catalogue as "+
global_mod.cwd + '/' + i)
p.vprint("Modules waiting in fetch queue:"+
str(global_mod.opt_map.git) + " " + str(global_mod.opt_map.svn) + " " + str(global_mod.opt_map.local))
if global_mod.opt_map.svn != None:
for i in global_mod.opt_map.svn:
p.vprint("Checking SVN url: " + i)
try:
url, revision = parse_repo_url(i)
fetch_from_svn(url, revision)
except ValueError:
url = parse_repo_url(i)
fetch_from_svn(url)
except RuntimeError:
continue
ret = check_module_and_append(involved_modules, os.path.abspath(global_mod.hdlm_path + "/" + path.url_basename(url)))
if ret == 0:
manifest = search_for_manifest(global_mod.hdlm_path + "/" + path.url_basename(url))
if manifest != None:
new_manifests.append(manifest)
global_mod.opt_map.svn = None
for i in global_mod.opt_map.svn:
p.vprint("Checking SVN url: " + i)
try:
url, revision = parse_repo_url(i)
fetch_from_svn(url, revision)
except ValueError:
url = parse_repo_url(i)
fetch_from_svn(url)
except RuntimeError:
continue
ret = check_module_and_append(involved_modules, os.path.abspath(global_mod.hdlm_path + "/" + path.url_basename(url)))
if ret == 0:
manifest = search_for_manifest(global_mod.hdlm_path + "/" + path.url_basename(url))
if manifest != None:
new_manifests.append(manifest)
global_mod.opt_map.svn = None
if global_mod.opt_map.git != None:
for i in global_mod.opt_map.git:
p.vprint("Checking git url: " + i)
try:
url, revision = parse_repo_url(i)
fetch_from_git(url, revision)
except ValueError:
url = parse_repo_url(i)
fetch_from_git(url)
except RuntimeError:
continue
if url.endswith(".git"):
url = url[:-4]
ret = check_module_and_append(involved_modules, os.path.abspath(global_mod.hdlm_path + "/" + path.url_basename(url)))
if ret == 0:
manifest = search_for_manifest(global_mod.hdlm_path + "/" + path.url_basename(url))
if manifest != None:
new_manifests.append(manifest)
global_mod.opt_map.git = None
for i in global_mod.opt_map.git:
p.vprint("Checking git url: " + i)
try:
url, revision = parse_repo_url(i)
fetch_from_git(url, revision)
except ValueError:
url = parse_repo_url(i)
fetch_from_git(url)
except RuntimeError:
continue
if url.endswith(".git"):
url = url[:-4]
ret = check_module_and_append(involved_modules, os.path.abspath(global_mod.hdlm_path + "/" + path.url_basename(url)))
if ret == 0:
manifest = search_for_manifest(global_mod.hdlm_path + "/" + path.url_basename(url))
if manifest != None:
new_manifests.append(manifest)
global_mod.opt_map.git = None
if global_mod.opt_map.local != None:
for i in global_mod.opt_map.local:
i = os.path.abspath(path.rel2abs(os.path.expanduser(i), os.path.dirname(cur_manifest)))
p.vprint("Checking local url: " + i)
try:
url, revision = i
print "Revision number not allowed in local URLs"
continue
except ValueError:
url = i
if not os.path.exists(url):
print "Specified module (" + url + ") does not exist"
print "Ommitting"
continue
fetch_from_local(url)
ret = check_module_and_append(involved_modules, os.path.abspath(global_mod.hdlm_path + "/" + path.url_basename(url)))
if ret == 0:
manifest = search_for_manifest(url)
if manifest != None:
new_manifests.append(manifest)
global_mod.opt_map.local = None
for i in global_mod.opt_map.local:
manifest = search_for_manifest(i)
if manifest != None:
new_manifests.append(manifest)
involved_modules.extend(global_mod.opt_map.local)
if len(new_manifests) == 0:
p.vprint("All found manifests have been scanned")
break
......@@ -400,15 +380,30 @@ def main():
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
if global_mod.options.make == True:
import depend
if not os.path.exists(global_mod.hdlm_path):
p.echo("There is no "+global_mod.hdlm_path+" catalog. Probably modules are not fetched?")
quit()
cur_manifest = global_mod.top_manifest
involved_modules = []
new_manifests = []
opt_map = global_mod.opt_map
while True:
if opt_map.local != None:
involved_modules.extend(opt_map.local)
for i in opt_map.local:
manifest = search_for_manifest(i)
if manifest != None:
new_manifests.append(manifest)
if len(new_manifests) == 0:
break;
cur_manifest = new_manifests.pop()
opt_map = parse_manifest(cur_manifest)
modules = os.listdir(global_mod.hdlm_path)
modules = involved_modules
if os.path.exists(global_mod.hdlm_path):
modules += [global_mod.hdlm_path+"/"+x for x in os.listdir(global_mod.hdlm_path)]
if len(modules) == 0:
p.vprint("No modules were found in " + global_mod.hdlm_path)
modules = [global_mod.hdlm_path+"/"+x for x in modules]
#modules += global_mod.opt_map.rtl
p.vprint("Modules that will be taken into account in the makefile: " + str(modules))
deps, libs = depend.generate_deps_for_modules(modules)
......@@ -426,7 +421,6 @@ def main():
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
if __name__ == "__main__":
#global options' map for use in the entire script
t0 = None
......
......@@ -82,7 +82,7 @@ def make_list_of_files(modules, take_files = None, base_folder = None):
for module in modules:
files.extend(getfiles(module))
if take_files != None:
if take_files != None and take_files != []:
ret_files = []
for file in files:
for take_file in take_files:
......
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