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
28f89a9e
Commit
28f89a9e
authored
Jul 26, 2016
by
Javier D. Garcia-Lasheras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Just a working refactoring checkpoint
parent
d175223c
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
95 additions
and
103 deletions
+95
-103
__main__.py
hdlmake/__main__.py
+4
-4
__init__.py
hdlmake/module/__init__.py
+1
-0
altera.py
hdlmake/module/altera.py
+2
-3
content.py
hdlmake/module/content.py
+6
-7
core.py
hdlmake/module/core.py
+3
-3
module.py
hdlmake/module/module.py
+14
-59
origin.py
hdlmake/module/origin.py
+47
-0
plugin.py
hdlmake/module/plugin.py
+0
-20
simulation.py
hdlmake/module/simulation.py
+4
-4
synthesis.py
hdlmake/module/synthesis.py
+2
-3
path.py
hdlmake/util/path.py
+12
-0
No files found.
hdlmake/__main__.py
View file @
28f89a9e
...
...
@@ -87,10 +87,10 @@ def main():
# Check if our top_module has been successfully assigned and
# contains a Manifest.py (ModulePool class)
if
not
modules_pool
.
get_top_module
()
.
isparsed
:
logging
.
info
(
"No manifest found. At least an empty one is needed"
)
logging
.
info
(
"To see some help, type hdlmake --help"
)
sys
.
exit
(
"Exiting"
)
#if not modules_pool.get_top_module().manifest_dict
:
#
logging.info("No manifest found. At least an empty one is needed")
#
logging.info("To see some help, type hdlmake --help")
#
sys.exit("Exiting")
_action_runner
(
modules_pool
)
...
...
hdlmake/module/__init__.py
View file @
28f89a9e
from
.origin
import
ModuleOrigin
from
.core
import
ModuleCore
from
.synthesis
import
ModuleSynthesis
from
.simulation
import
ModuleSimulation
...
...
hdlmake/module/altera.py
View file @
28f89a9e
import
os
from
.plugin
import
ModulePlugin
from
hdlmake.util
import
path
as
path_mod
class
ModuleAltera
(
ModulePlugin
):
class
ModuleAltera
(
object
):
def
__init__
(
self
):
# Manifest Altera Properties
self
.
quartus_preflow
=
None
...
...
@@ -13,7 +12,7 @@ class ModuleAltera(ModulePlugin):
def
process_manifest
(
self
):
self
.
_process_manifest_altera
()
super
(
ModuleAltera
,
self
)
.
process_manifest
()
#
super(ModuleAltera, self).process_manifest()
def
_process_manifest_altera
(
self
):
from
hdlmake.srcfile
import
TCLFile
...
...
hdlmake/module/content.py
View file @
28f89a9e
import
logging
from
hdlmake
import
fetch
from
.plugin
import
ModulePlugin
from
hdlmake.util
import
path
as
path_mod
class
ModuleContent
(
ModulePlugin
):
class
ModuleContent
(
object
):
def
__init__
(
self
):
# Manifest Files Properties
self
.
files
=
None
...
...
@@ -18,7 +17,7 @@ class ModuleContent(ModulePlugin):
self
.
_process_manifest_fetch
()
self
.
_process_manifest_files
()
self
.
_process_manifest_modules
()
super
(
ModuleContent
,
self
)
.
process_manifest
()
#
super(ModuleContent, self).process_manifest()
def
_process_manifest_files
(
self
):
from
hdlmake.srcfile
import
(
TCLFile
,
VerilogFile
,
VHDLFile
,
...
...
@@ -32,7 +31,7 @@ class ModuleContent(ModulePlugin):
except
AttributeError
:
pass
else
:
self
.
manifest_dict
[
"files"
]
=
ModulePlugin
.
flatten_list
(
self
.
manifest_dict
[
"files"
]
=
path_mod
.
flatten_list
(
self
.
manifest_dict
[
"files"
])
logging
.
debug
(
"Files in
%
s:
%
s"
,
self
.
path
,
str
(
self
.
manifest_dict
[
"files"
]))
...
...
@@ -60,7 +59,7 @@ class ModuleContent(ModulePlugin):
fetchto
=
self
.
fetchto
# Process required modules
if
"local"
in
self
.
manifest_dict
[
"modules"
]:
local_paths
=
ModulePlugin
.
flatten_list
(
local_paths
=
path_mod
.
flatten_list
(
self
.
manifest_dict
[
"modules"
][
"local"
])
local_mods
=
[]
for
path
in
local_paths
:
...
...
@@ -78,7 +77,7 @@ class ModuleContent(ModulePlugin):
self
.
local
=
[]
if
"svn"
in
self
.
manifest_dict
[
"modules"
]:
self
.
manifest_dict
[
"modules"
][
"svn"
]
=
ModulePlugin
.
flatten_list
(
self
.
manifest_dict
[
"modules"
][
"svn"
]
=
path_mod
.
flatten_list
(
self
.
manifest_dict
[
"modules"
][
"svn"
])
svn_mods
=
[]
for
url
in
self
.
manifest_dict
[
"modules"
][
"svn"
]:
...
...
@@ -91,7 +90,7 @@ class ModuleContent(ModulePlugin):
self
.
svn
=
[]
if
"git"
in
self
.
manifest_dict
[
"modules"
]:
self
.
manifest_dict
[
"modules"
][
"git"
]
=
ModulePlugin
.
flatten_list
(
self
.
manifest_dict
[
"modules"
][
"git"
]
=
path_mod
.
flatten_list
(
self
.
manifest_dict
[
"modules"
][
"git"
])
git_mods
=
[]
for
url
in
self
.
manifest_dict
[
"modules"
][
"git"
]:
...
...
hdlmake/module/core.py
View file @
28f89a9e
...
...
@@ -3,16 +3,16 @@
import
os
import
logging
from
.plugin
import
ModulePlugin
from
hdlmake
import
fetch
class
ModuleCore
(
ModulePlugin
):
class
ModuleCore
(
object
):
"""This is the class providing the module core functionality"""
def
__init__
(
self
):
# Universal Manifest Properties
self
.
library
=
"work"
self
.
target
=
None
self
.
action
=
None
self
.
top_entity
=
None
super
(
ModuleCore
,
self
)
.
__init__
()
# Manifest Force tool Property
...
...
@@ -23,7 +23,7 @@ class ModuleCore(ModulePlugin):
"""Method that process the core manifest section"""
self
.
_process_manifest_force_tool
()
self
.
_process_manifest_universal
()
super
(
ModuleCore
,
self
)
.
process_manifest
()
#
super(ModuleCore, self).process_manifest()
def
_process_manifest_force_tool
(
self
):
...
...
hdlmake/module/module.py
View file @
28f89a9e
...
...
@@ -32,14 +32,14 @@ import os
import
sys
import
logging
from
hdlmake.manifest_parser
import
Manifest
,
Manifest
Parser
from
hdlmake.manifest_parser
import
ManifestParser
from
hdlmake.util
import
path
as
path_mod
from
hdlmake
import
fetch
from
hdlmake.module
import
(
ModuleCore
,
ModuleSynthesis
,
from
hdlmake.module
import
(
ModuleCore
,
ModuleSynthesis
,
ModuleOrigin
,
ModuleSimulation
,
ModuleContent
,
ModuleAltera
)
class
Module
(
ModuleCore
,
ModuleSynthesis
,
class
Module
(
ModuleCore
,
ModuleSynthesis
,
ModuleOrigin
,
ModuleSimulation
,
ModuleContent
,
ModuleAltera
):
"""
This is the class providing the HDLMake module, the basic element
...
...
@@ -53,54 +53,17 @@ class Module(ModuleCore, ModuleSynthesis,
def
__init__
(
self
,
parent
,
url
,
source
,
fetchto
):
"""Calculate and initialize the origin attributes: path, source..."""
assert
url
is
not
None
assert
source
is
not
None
super
(
Module
,
self
)
.
__init__
()
self
.
pool
=
None
self
.
top_module
=
None
self
.
isparsed
=
False
self
.
top_entity
=
None
"""Calculate and initialize the origin attributes: path, source..."""
self
.
source
=
source
self
.
parent
=
parent
self
.
fetchto
=
fetchto
self
.
raw_url
=
url
if
source
!=
fetch
.
LOCAL
:
self
.
url
,
self
.
branch
,
self
.
revision
=
path_mod
.
url_parse
(
url
)
if
(
os
.
path
.
exists
(
os
.
path
.
abspath
(
os
.
path
.
join
(
fetchto
,
self
.
basename
)
)
)
and
os
.
listdir
(
os
.
path
.
abspath
(
os
.
path
.
join
(
fetchto
,
self
.
basename
))
)
):
self
.
path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
fetchto
,
self
.
basename
))
self
.
isfetched
=
True
logging
.
debug
(
"Module
%
s (parent:
%
s) is fetched."
,
url
,
parent
.
path
)
else
:
self
.
path
=
None
self
.
isfetched
=
False
logging
.
debug
(
"Module
%
s (parent:
%
s) is NOT fetched."
,
url
,
parent
.
path
)
else
:
self
.
url
,
self
.
branch
,
self
.
revision
=
url
,
None
,
None
self
.
manifest_dict
=
None
self
.
set_origin
(
parent
,
url
,
source
,
fetchto
)
super
(
Module
,
self
)
.
__init__
()
if
not
os
.
path
.
exists
(
url
):
logging
.
error
(
"Path to the local module doesn't exist:
\n
"
+
url
+
"
\n
This module was instantiated in: "
+
str
(
parent
))
quit
()
self
.
path
=
url
self
.
isfetched
=
True
def
__str__
(
self
):
...
...
@@ -155,7 +118,11 @@ class Module(ModuleCore, ModuleSynthesis,
contained in the action specific inherited Python modules.
"""
logging
.
debug
(
"Process manifest at: "
+
os
.
path
.
dirname
(
self
.
path
))
super
(
Module
,
self
)
.
process_manifest
()
#super(Module, self).process_manifest()
module_list
=
[
ModuleCore
,
ModuleSynthesis
,
ModuleSimulation
,
ModuleContent
,
ModuleAltera
]
for
module_plugin
in
module_list
:
module_plugin
.
process_manifest
(
self
)
def
parse_manifest
(
self
):
...
...
@@ -176,12 +143,8 @@ class Module(ModuleCore, ModuleSynthesis,
- ...but deleting some key fields that needs to be respected.
"""
if
self
.
manifest_dict
:
if
self
.
manifest_dict
or
self
.
isfetched
is
False
:
return
if
self
.
isparsed
is
True
or
self
.
isfetched
is
False
:
return
#if self.manifest is None:
# self.manifest = manifest_parser.search_for_manifest()
if
self
.
path
is
None
:
raise
RuntimeError
()
...
...
@@ -191,11 +154,6 @@ class Module(ModuleCore, ModuleSynthesis,
#manifest_parser.add_arbitrary_code(
# self.pool.top_module.options.arbitrary_code)
#if self.manifest is Non:
# logging.debug("No manifest found in module "+str(self))
#else:
# logging.debug("Parse manifest in: %s", self.path)
manifest_parser
.
add_manifest
(
self
.
path
)
if
self
.
parent
is
None
:
...
...
@@ -211,16 +169,13 @@ class Module(ModuleCore, ModuleSynthesis,
except
NameError
as
name_error
:
logging
.
error
(
"Error while parsing {0}:
\n
{1}: {2}."
.
format
(
self
.
manifest
,
type
(
name_error
),
name_error
))
self
.
path
,
type
(
name_error
),
name_error
))
quit
()
self
.
manifest_dict
=
opt_map
# Process the parsed manifest_dict to assign the module properties
self
.
process_manifest
()
# Tag the module as parsed
self
.
isparsed
=
True
# Parse every detected submodule
for
module_aux
in
self
.
submodules
():
module_aux
.
parse_manifest
()
...
...
hdlmake/module/origin.py
0 → 100644
View file @
28f89a9e
import
os
import
logging
from
hdlmake
import
fetch
from
hdlmake.util
import
path
as
path_mod
class
ModuleOrigin
(
object
):
def
set_origin
(
self
,
parent
,
url
,
source
,
fetchto
):
# Manifest Module Origin Properties
self
.
fetchto
=
fetchto
self
.
raw_url
=
url
if
source
!=
fetch
.
LOCAL
:
self
.
url
,
self
.
branch
,
self
.
revision
=
path_mod
.
url_parse
(
url
)
if
(
os
.
path
.
exists
(
os
.
path
.
abspath
(
os
.
path
.
join
(
fetchto
,
self
.
basename
)
)
)
and
os
.
listdir
(
os
.
path
.
abspath
(
os
.
path
.
join
(
fetchto
,
self
.
basename
))
)
):
self
.
path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
fetchto
,
self
.
basename
))
self
.
isfetched
=
True
logging
.
debug
(
"Module
%
s (parent:
%
s) is fetched."
,
url
,
parent
.
path
)
else
:
self
.
path
=
None
self
.
isfetched
=
False
logging
.
debug
(
"Module
%
s (parent:
%
s) is NOT fetched."
,
url
,
parent
.
path
)
else
:
self
.
url
,
self
.
branch
,
self
.
revision
=
url
,
None
,
None
if
not
os
.
path
.
exists
(
url
):
logging
.
error
(
"Path to the local module doesn't exist:
\n
"
+
url
+
"
\n
This module was instantiated in: "
+
str
(
parent
))
quit
()
self
.
path
=
url
self
.
isfetched
=
True
#super(ModuleOrigin, self).__init__(parent, url, source, fetchto)
hdlmake/module/plugin.py
deleted
100644 → 0
View file @
d175223c
class
ModulePlugin
(
object
):
def
__init__
(
self
):
self
.
manifest
=
None
self
.
manifest_dict
=
None
def
process_manifest
(
self
):
pass
@
staticmethod
def
flatten_list
(
sth
):
"""Convert the argument in a list, being an empty list if none"""
if
sth
is
not
None
:
if
not
isinstance
(
sth
,
(
list
,
tuple
)):
sth
=
[
sth
]
else
:
sth
=
[]
return
sth
hdlmake/module/simulation.py
View file @
28f89a9e
from
.plugin
import
ModulePlugin
from
hdlmake.util
import
path
as
path_mod
class
ModuleSimulation
(
ModulePlugin
):
class
ModuleSimulation
(
object
):
def
__init__
(
self
):
# Manifest Simulation Properties
...
...
@@ -21,7 +21,7 @@ class ModuleSimulation(ModulePlugin):
def
process_manifest
(
self
):
self
.
_process_manifest_simulation
()
self
.
_process_manifest_includes
()
super
(
ModuleSimulation
,
self
)
.
process_manifest
()
#
super(ModuleSimulation, self).process_manifest()
def
_process_manifest_simulation
(
self
):
from
hdlmake.srcfile
import
SourceFileSet
...
...
@@ -40,7 +40,7 @@ class ModuleSimulation(ModulePlugin):
if
len
(
self
.
manifest_dict
[
"sim_only_files"
])
==
0
:
self
.
sim_only_files
=
SourceFileSet
()
else
:
self
.
manifest_dict
[
"sim_only_files"
]
=
ModulePlugin
.
flatten_list
(
self
.
manifest_dict
[
"sim_only_files"
])
self
.
manifest_dict
[
"sim_only_files"
]
=
path_mod
.
flatten_list
(
self
.
manifest_dict
[
"sim_only_files"
])
paths
=
self
.
_make_list_of_paths
(
self
.
manifest_dict
[
"sim_only_files"
])
self
.
sim_only_files
=
self
.
_create_file_list_from_paths
(
paths
=
paths
)
...
...
hdlmake/module/synthesis.py
View file @
28f89a9e
from
.plugin
import
ModulePlugin
class
ModuleSynthesis
(
ModulePlugin
):
class
ModuleSynthesis
(
object
):
def
__init__
(
self
):
# Manifest Synthesis Properties
self
.
syn_device
=
None
...
...
@@ -20,7 +19,7 @@ class ModuleSynthesis(ModulePlugin):
def
process_manifest
(
self
):
self
.
_process_manifest_synthesis
()
self
.
_process_manifest_included_makefiles
()
super
(
ModuleSynthesis
,
self
)
.
process_manifest
()
#
super(ModuleSynthesis, self).process_manifest()
def
_process_manifest_synthesis
(
self
):
# Synthesis properties
...
...
hdlmake/util/path.py
View file @
28f89a9e
...
...
@@ -140,3 +140,15 @@ def search_for_manifest(search_path):
return
os
.
path
.
abspath
(
os
.
path
.
join
(
search_path
,
filename
))
# no manifest file found
return
None
def
flatten_list
(
sth
):
"""Convert the argument in a list, being an empty list if none"""
if
sth
is
not
None
:
if
not
isinstance
(
sth
,
(
list
,
tuple
)):
sth
=
[
sth
]
else
:
sth
=
[]
return
sth
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