Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
Hdlmake
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
15
Issues
15
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Hdlmake
Commits
c8692b97
Commit
c8692b97
authored
Jul 27, 2016
by
Javier D. Garcia-Lasheras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring Module, focus on ModuleContent
parent
58884d63
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
75 deletions
+81
-75
content.py
hdlmake/module/content.py
+12
-10
core.py
hdlmake/module/core.py
+56
-0
module.py
hdlmake/module/module.py
+13
-65
No files found.
hdlmake/module/content.py
View file @
c8692b97
import
os
"""This provides the stuff related with the HDLMake module,
from files to required submodules"""
import
logging
from
.core
import
ModuleCore
from
hdlmake
import
fetch
from
hdlmake.util
import
path
as
path_mod
class
ModuleContent
(
ModuleCore
):
"""Class providing the HDLMake module content"""
def
__init__
(
self
):
self
.
top_entity
=
None
# Manifest Files Properties
...
...
@@ -13,22 +16,25 @@ class ModuleContent(ModuleCore):
self
.
local
=
[]
self
.
git
=
[]
self
.
svn
=
[]
self
.
fetch_pre_cmd
=
None
self
.
fetch_post_cmd
=
None
super
(
ModuleContent
,
self
)
.
__init__
()
def
process_manifest
(
self
):
"""Process the content section of the manifest_dic"""
self
.
_process_manifest_files
()
self
.
_process_manifest_modules
()
super
(
ModuleContent
,
self
)
.
process_manifest
()
def
_process_manifest_files
(
self
):
from
hdlmake.srcfile
import
(
TCLFile
,
VerilogFile
,
VHDLFile
,
SourceFileSet
)
"""Process the files instantiated by the HDLMake module"""
from
hdlmake.srcfile
import
SourceFileSet
# HDL files provided by the module
if
self
.
manifest_dict
[
"files"
]
==
[]:
self
.
files
=
SourceFileSet
()
try
:
logging
.
debug
(
"No files in the manifest
%
s"
,
self
.
manifest
.
path
)
logging
.
debug
(
"No files in the manifest
at
%
s"
,
self
.
path
)
except
AttributeError
:
pass
else
:
...
...
@@ -38,14 +44,10 @@ class ModuleContent(ModuleCore):
self
.
path
,
str
(
self
.
manifest_dict
[
"files"
]))
paths
=
self
.
_make_list_of_paths
(
self
.
manifest_dict
[
"files"
])
self
.
files
=
self
.
_create_file_list_from_paths
(
paths
=
paths
)
for
f
in
self
.
files
:
if
isinstance
(
f
,
VerilogFile
):
f
.
vsim_opt
=
self
.
vsim_opt
elif
isinstance
(
f
,
VHDLFile
):
f
.
vcom_opt
=
self
.
vcom_opt
def
_process_manifest_modules
(
self
):
"""Process the submodules required by the HDLMake module"""
if
self
.
manifest_dict
[
"fetchto"
]
is
not
None
:
fetchto
=
path_mod
.
rel2abs
(
self
.
manifest_dict
[
"fetchto"
],
self
.
path
)
...
...
hdlmake/module/core.py
View file @
c8692b97
"""Provides the core functionality for the HDLMake module"""
import
os
import
sys
import
logging
from
hdlmake
import
fetch
...
...
@@ -68,6 +69,38 @@ class ModuleConfig(object):
self
.
isfetched
=
True
def
_check_filepath
(
self
,
filepath
):
"""Check the provided filepath against several conditions"""
if
filepath
:
if
path_mod
.
is_abs_path
(
filepath
):
logging
.
warning
(
"Specified path seems to be an absolute path: "
+
filepath
+
"
\n
Omitting."
)
return
False
filepath
=
os
.
path
.
join
(
self
.
path
,
filepath
)
if
not
os
.
path
.
exists
(
filepath
):
logging
.
error
(
"Path specified in manifest in
%
s doesn't exist:
%
s"
,
self
.
path
,
filepath
)
sys
.
exit
(
"Exiting"
)
filepath
=
path_mod
.
rel2abs
(
filepath
,
self
.
path
)
if
os
.
path
.
isdir
(
filepath
):
logging
.
warning
(
"Path specified in manifest
%
s is a directory:
%
s"
,
self
.
path
,
filepath
)
return
True
def
_make_list_of_paths
(
self
,
list_of_paths
):
"""Get a list with only the valid absolute paths from the provided"""
paths
=
[]
for
filepath
in
list_of_paths
:
if
self
.
_check_filepath
(
filepath
):
paths
.
append
(
path_mod
.
rel2abs
(
filepath
,
self
.
path
))
return
paths
class
ModuleCore
(
ModuleConfig
):
"""This is the class providing the module core functionality"""
...
...
@@ -116,3 +149,26 @@ class ModuleCore(ModuleConfig):
self
.
action
=
self
.
manifest_dict
[
"action"
]
.
lower
()
def
_create_file_list_from_paths
(
self
,
paths
):
"""
Build a Source File Set containing the files indicated by the
provided list of paths
"""
from
hdlmake.srcfile
import
SourceFileFactory
,
SourceFileSet
sff
=
SourceFileFactory
()
srcs
=
SourceFileSet
()
for
path_aux
in
paths
:
if
os
.
path
.
isdir
(
path_aux
):
dir_
=
os
.
listdir
(
path_aux
)
for
f_dir
in
dir_
:
f_dir
=
os
.
path
.
join
(
self
.
path
,
path_aux
,
f_dir
)
if
not
os
.
path
.
isdir
(
f_dir
):
srcs
.
add
(
sff
.
new
(
path
=
f_dir
,
module
=
self
,
library
=
self
.
library
))
else
:
srcs
.
add
(
sff
.
new
(
path
=
path_aux
,
module
=
self
,
library
=
self
.
library
))
return
srcs
hdlmake/module/module.py
View file @
c8692b97
...
...
@@ -29,11 +29,9 @@ specific parent modules providing specific methods and attributes.
from
__future__
import
print_function
import
os
import
sys
import
logging
from
hdlmake.manifest_parser
import
ManifestParser
from
hdlmake.util
import
path
as
path_mod
from
hdlmake.module
import
(
ModuleSynthesis
,
ModuleSimulation
,
ModuleContent
,
ModuleAltera
)
...
...
@@ -98,6 +96,19 @@ class Module(ModuleSynthesis,
"""
logging
.
debug
(
"Process manifest at: "
+
os
.
path
.
dirname
(
self
.
path
))
super
(
Module
,
self
)
.
process_manifest
()
self
.
_set_simulation_options
()
def
_set_simulation_options
(
self
):
"""This set the simulation option for all the files in the Module"""
from
hdlmake.srcfile
import
VerilogFile
,
VHDLFile
for
file_aux
in
self
.
files
:
if
isinstance
(
file_aux
,
VerilogFile
):
file_aux
.
vsim_opt
=
self
.
vsim_opt
file_aux
.
include_dirs
=
self
.
include_dirs
elif
isinstance
(
file_aux
,
VHDLFile
):
file_aux
.
vcom_opt
=
self
.
vcom_opt
file_aux
.
include_dirs
=
self
.
include_dirs
def
parse_manifest
(
self
):
...
...
@@ -156,66 +167,3 @@ class Module(ModuleSynthesis,
module_aux
.
parse_manifest
()
def
_make_list_of_paths
(
self
,
list_of_paths
):
"""Get a list with only the valid absolute paths from the provided"""
paths
=
[]
for
filepath
in
list_of_paths
:
if
self
.
_check_filepath
(
filepath
):
paths
.
append
(
path_mod
.
rel2abs
(
filepath
,
self
.
path
))
return
paths
def
_check_filepath
(
self
,
filepath
):
"""Check the provided filepath against several conditions"""
if
filepath
:
if
path_mod
.
is_abs_path
(
filepath
):
logging
.
warning
(
"Specified path seems to be an absolute path: "
+
filepath
+
"
\n
Omitting."
)
return
False
filepath
=
os
.
path
.
join
(
self
.
path
,
filepath
)
if
not
os
.
path
.
exists
(
filepath
):
logging
.
error
(
"Path specified in manifest in
%
s doesn't exist:
%
s"
,
self
.
path
,
filepath
)
sys
.
exit
(
"Exiting"
)
filepath
=
path_mod
.
rel2abs
(
filepath
,
self
.
path
)
if
os
.
path
.
isdir
(
filepath
):
logging
.
warning
(
"Path specified in manifest
%
s is a directory:
%
s"
,
self
.
path
,
filepath
)
return
True
def
_create_file_list_from_paths
(
self
,
paths
):
"""
Build a Source File Set containing the files indicated by the
provided list of paths
"""
from
hdlmake.srcfile
import
SourceFileFactory
,
SourceFileSet
sff
=
SourceFileFactory
()
srcs
=
SourceFileSet
()
for
path_aux
in
paths
:
if
os
.
path
.
isdir
(
path_aux
):
dir_
=
os
.
listdir
(
path_aux
)
for
f_dir
in
dir_
:
f_dir
=
os
.
path
.
join
(
self
.
path
,
path_aux
,
f_dir
)
if
not
os
.
path
.
isdir
(
f_dir
):
srcs
.
add
(
sff
.
new
(
path
=
f_dir
,
module
=
self
,
library
=
self
.
library
,
vcom_opt
=
self
.
vcom_opt
,
vlog_opt
=
self
.
vlog_opt
,
include_dirs
=
self
.
include_dirs
))
else
:
srcs
.
add
(
sff
.
new
(
path
=
path_aux
,
module
=
self
,
library
=
self
.
library
,
vcom_opt
=
self
.
vcom_opt
,
vlog_opt
=
self
.
vlog_opt
,
include_dirs
=
self
.
include_dirs
))
return
srcs
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment