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():
...
@@ -87,10 +87,10 @@ def main():
# Check if our top_module has been successfully assigned and
# Check if our top_module has been successfully assigned and
# contains a Manifest.py (ModulePool class)
# contains a Manifest.py (ModulePool class)
if
not
modules_pool
.
get_top_module
()
.
isparsed
:
#if not modules_pool.get_top_module().manifest_dict
:
logging
.
info
(
"No manifest found. At least an empty one is needed"
)
#
logging.info("No manifest found. At least an empty one is needed")
logging
.
info
(
"To see some help, type hdlmake --help"
)
#
logging.info("To see some help, type hdlmake --help")
sys
.
exit
(
"Exiting"
)
#
sys.exit("Exiting")
_action_runner
(
modules_pool
)
_action_runner
(
modules_pool
)
...
...
hdlmake/module/__init__.py
View file @
28f89a9e
from
.origin
import
ModuleOrigin
from
.core
import
ModuleCore
from
.core
import
ModuleCore
from
.synthesis
import
ModuleSynthesis
from
.synthesis
import
ModuleSynthesis
from
.simulation
import
ModuleSimulation
from
.simulation
import
ModuleSimulation
...
...
hdlmake/module/altera.py
View file @
28f89a9e
import
os
import
os
from
.plugin
import
ModulePlugin
from
hdlmake.util
import
path
as
path_mod
from
hdlmake.util
import
path
as
path_mod
class
ModuleAltera
(
ModulePlugin
):
class
ModuleAltera
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
# Manifest Altera Properties
# Manifest Altera Properties
self
.
quartus_preflow
=
None
self
.
quartus_preflow
=
None
...
@@ -13,7 +12,7 @@ class ModuleAltera(ModulePlugin):
...
@@ -13,7 +12,7 @@ class ModuleAltera(ModulePlugin):
def
process_manifest
(
self
):
def
process_manifest
(
self
):
self
.
_process_manifest_altera
()
self
.
_process_manifest_altera
()
super
(
ModuleAltera
,
self
)
.
process_manifest
()
#
super(ModuleAltera, self).process_manifest()
def
_process_manifest_altera
(
self
):
def
_process_manifest_altera
(
self
):
from
hdlmake.srcfile
import
TCLFile
from
hdlmake.srcfile
import
TCLFile
...
...
hdlmake/module/content.py
View file @
28f89a9e
import
logging
import
logging
from
hdlmake
import
fetch
from
hdlmake
import
fetch
from
.plugin
import
ModulePlugin
from
hdlmake.util
import
path
as
path_mod
from
hdlmake.util
import
path
as
path_mod
class
ModuleContent
(
ModulePlugin
):
class
ModuleContent
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
# Manifest Files Properties
# Manifest Files Properties
self
.
files
=
None
self
.
files
=
None
...
@@ -18,7 +17,7 @@ class ModuleContent(ModulePlugin):
...
@@ -18,7 +17,7 @@ class ModuleContent(ModulePlugin):
self
.
_process_manifest_fetch
()
self
.
_process_manifest_fetch
()
self
.
_process_manifest_files
()
self
.
_process_manifest_files
()
self
.
_process_manifest_modules
()
self
.
_process_manifest_modules
()
super
(
ModuleContent
,
self
)
.
process_manifest
()
#
super(ModuleContent, self).process_manifest()
def
_process_manifest_files
(
self
):
def
_process_manifest_files
(
self
):
from
hdlmake.srcfile
import
(
TCLFile
,
VerilogFile
,
VHDLFile
,
from
hdlmake.srcfile
import
(
TCLFile
,
VerilogFile
,
VHDLFile
,
...
@@ -32,7 +31,7 @@ class ModuleContent(ModulePlugin):
...
@@ -32,7 +31,7 @@ class ModuleContent(ModulePlugin):
except
AttributeError
:
except
AttributeError
:
pass
pass
else
:
else
:
self
.
manifest_dict
[
"files"
]
=
ModulePlugin
.
flatten_list
(
self
.
manifest_dict
[
"files"
]
=
path_mod
.
flatten_list
(
self
.
manifest_dict
[
"files"
])
self
.
manifest_dict
[
"files"
])
logging
.
debug
(
"Files in
%
s:
%
s"
,
logging
.
debug
(
"Files in
%
s:
%
s"
,
self
.
path
,
str
(
self
.
manifest_dict
[
"files"
]))
self
.
path
,
str
(
self
.
manifest_dict
[
"files"
]))
...
@@ -60,7 +59,7 @@ class ModuleContent(ModulePlugin):
...
@@ -60,7 +59,7 @@ class ModuleContent(ModulePlugin):
fetchto
=
self
.
fetchto
fetchto
=
self
.
fetchto
# Process required modules
# Process required modules
if
"local"
in
self
.
manifest_dict
[
"modules"
]:
if
"local"
in
self
.
manifest_dict
[
"modules"
]:
local_paths
=
ModulePlugin
.
flatten_list
(
local_paths
=
path_mod
.
flatten_list
(
self
.
manifest_dict
[
"modules"
][
"local"
])
self
.
manifest_dict
[
"modules"
][
"local"
])
local_mods
=
[]
local_mods
=
[]
for
path
in
local_paths
:
for
path
in
local_paths
:
...
@@ -78,7 +77,7 @@ class ModuleContent(ModulePlugin):
...
@@ -78,7 +77,7 @@ class ModuleContent(ModulePlugin):
self
.
local
=
[]
self
.
local
=
[]
if
"svn"
in
self
.
manifest_dict
[
"modules"
]:
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"
])
self
.
manifest_dict
[
"modules"
][
"svn"
])
svn_mods
=
[]
svn_mods
=
[]
for
url
in
self
.
manifest_dict
[
"modules"
][
"svn"
]:
for
url
in
self
.
manifest_dict
[
"modules"
][
"svn"
]:
...
@@ -91,7 +90,7 @@ class ModuleContent(ModulePlugin):
...
@@ -91,7 +90,7 @@ class ModuleContent(ModulePlugin):
self
.
svn
=
[]
self
.
svn
=
[]
if
"git"
in
self
.
manifest_dict
[
"modules"
]:
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"
])
self
.
manifest_dict
[
"modules"
][
"git"
])
git_mods
=
[]
git_mods
=
[]
for
url
in
self
.
manifest_dict
[
"modules"
][
"git"
]:
for
url
in
self
.
manifest_dict
[
"modules"
][
"git"
]:
...
...
hdlmake/module/core.py
View file @
28f89a9e
...
@@ -3,16 +3,16 @@
...
@@ -3,16 +3,16 @@
import
os
import
os
import
logging
import
logging
from
.plugin
import
ModulePlugin
from
hdlmake
import
fetch
from
hdlmake
import
fetch
class
ModuleCore
(
ModulePlugin
):
class
ModuleCore
(
object
):
"""This is the class providing the module core functionality"""
"""This is the class providing the module core functionality"""
def
__init__
(
self
):
def
__init__
(
self
):
# Universal Manifest Properties
# Universal Manifest Properties
self
.
library
=
"work"
self
.
library
=
"work"
self
.
target
=
None
self
.
target
=
None
self
.
action
=
None
self
.
action
=
None
self
.
top_entity
=
None
super
(
ModuleCore
,
self
)
.
__init__
()
super
(
ModuleCore
,
self
)
.
__init__
()
# Manifest Force tool Property
# Manifest Force tool Property
...
@@ -23,7 +23,7 @@ class ModuleCore(ModulePlugin):
...
@@ -23,7 +23,7 @@ class ModuleCore(ModulePlugin):
"""Method that process the core manifest section"""
"""Method that process the core manifest section"""
self
.
_process_manifest_force_tool
()
self
.
_process_manifest_force_tool
()
self
.
_process_manifest_universal
()
self
.
_process_manifest_universal
()
super
(
ModuleCore
,
self
)
.
process_manifest
()
#
super(ModuleCore, self).process_manifest()
def
_process_manifest_force_tool
(
self
):
def
_process_manifest_force_tool
(
self
):
...
...
hdlmake/module/module.py
View file @
28f89a9e
...
@@ -32,14 +32,14 @@ import os
...
@@ -32,14 +32,14 @@ import os
import
sys
import
sys
import
logging
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.util
import
path
as
path_mod
from
hdlmake
import
fetch
from
hdlmake
import
fetch
from
hdlmake.module
import
(
ModuleCore
,
ModuleSynthesis
,
from
hdlmake.module
import
(
ModuleCore
,
ModuleSynthesis
,
ModuleOrigin
,
ModuleSimulation
,
ModuleContent
,
ModuleAltera
)
ModuleSimulation
,
ModuleContent
,
ModuleAltera
)
class
Module
(
ModuleCore
,
ModuleSynthesis
,
class
Module
(
ModuleCore
,
ModuleSynthesis
,
ModuleOrigin
,
ModuleSimulation
,
ModuleContent
,
ModuleAltera
):
ModuleSimulation
,
ModuleContent
,
ModuleAltera
):
"""
"""
This is the class providing the HDLMake module, the basic element
This is the class providing the HDLMake module, the basic element
...
@@ -53,54 +53,17 @@ class Module(ModuleCore, ModuleSynthesis,
...
@@ -53,54 +53,17 @@ class Module(ModuleCore, ModuleSynthesis,
def
__init__
(
self
,
parent
,
url
,
source
,
fetchto
):
def
__init__
(
self
,
parent
,
url
,
source
,
fetchto
):
"""Calculate and initialize the origin attributes: path, source..."""
assert
url
is
not
None
assert
url
is
not
None
assert
source
is
not
None
assert
source
is
not
None
super
(
Module
,
self
)
.
__init__
()
self
.
pool
=
None
self
.
pool
=
None
self
.
top_module
=
None
self
.
top_module
=
None
self
.
isparsed
=
False
self
.
top_entity
=
None
"""Calculate and initialize the origin attributes: path, source..."""
self
.
source
=
source
self
.
source
=
source
self
.
parent
=
parent
self
.
parent
=
parent
self
.
fetchto
=
fetchto
self
.
manifest_dict
=
None
self
.
raw_url
=
url
self
.
set_origin
(
parent
,
url
,
source
,
fetchto
)
if
source
!=
fetch
.
LOCAL
:
super
(
Module
,
self
)
.
__init__
()
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
def
__str__
(
self
):
def
__str__
(
self
):
...
@@ -155,7 +118,11 @@ class Module(ModuleCore, ModuleSynthesis,
...
@@ -155,7 +118,11 @@ class Module(ModuleCore, ModuleSynthesis,
contained in the action specific inherited Python modules.
contained in the action specific inherited Python modules.
"""
"""
logging
.
debug
(
"Process manifest at: "
+
os
.
path
.
dirname
(
self
.
path
))
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
):
def
parse_manifest
(
self
):
...
@@ -176,12 +143,8 @@ class Module(ModuleCore, ModuleSynthesis,
...
@@ -176,12 +143,8 @@ class Module(ModuleCore, ModuleSynthesis,
- ...but deleting some key fields that needs to be respected.
- ...but deleting some key fields that needs to be respected.
"""
"""
if
self
.
manifest_dict
:
if
self
.
manifest_dict
or
self
.
isfetched
is
False
:
return
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
:
if
self
.
path
is
None
:
raise
RuntimeError
()
raise
RuntimeError
()
...
@@ -191,11 +154,6 @@ class Module(ModuleCore, ModuleSynthesis,
...
@@ -191,11 +154,6 @@ class Module(ModuleCore, ModuleSynthesis,
#manifest_parser.add_arbitrary_code(
#manifest_parser.add_arbitrary_code(
# self.pool.top_module.options.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
)
manifest_parser
.
add_manifest
(
self
.
path
)
if
self
.
parent
is
None
:
if
self
.
parent
is
None
:
...
@@ -211,16 +169,13 @@ class Module(ModuleCore, ModuleSynthesis,
...
@@ -211,16 +169,13 @@ class Module(ModuleCore, ModuleSynthesis,
except
NameError
as
name_error
:
except
NameError
as
name_error
:
logging
.
error
(
logging
.
error
(
"Error while parsing {0}:
\n
{1}: {2}."
.
format
(
"Error while parsing {0}:
\n
{1}: {2}."
.
format
(
self
.
manifest
,
type
(
name_error
),
name_error
))
self
.
path
,
type
(
name_error
),
name_error
))
quit
()
quit
()
self
.
manifest_dict
=
opt_map
self
.
manifest_dict
=
opt_map
# Process the parsed manifest_dict to assign the module properties
# Process the parsed manifest_dict to assign the module properties
self
.
process_manifest
()
self
.
process_manifest
()
# Tag the module as parsed
self
.
isparsed
=
True
# Parse every detected submodule
# Parse every detected submodule
for
module_aux
in
self
.
submodules
():
for
module_aux
in
self
.
submodules
():
module_aux
.
parse_manifest
()
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
):
def
__init__
(
self
):
# Manifest Simulation Properties
# Manifest Simulation Properties
...
@@ -21,7 +21,7 @@ class ModuleSimulation(ModulePlugin):
...
@@ -21,7 +21,7 @@ class ModuleSimulation(ModulePlugin):
def
process_manifest
(
self
):
def
process_manifest
(
self
):
self
.
_process_manifest_simulation
()
self
.
_process_manifest_simulation
()
self
.
_process_manifest_includes
()
self
.
_process_manifest_includes
()
super
(
ModuleSimulation
,
self
)
.
process_manifest
()
#
super(ModuleSimulation, self).process_manifest()
def
_process_manifest_simulation
(
self
):
def
_process_manifest_simulation
(
self
):
from
hdlmake.srcfile
import
SourceFileSet
from
hdlmake.srcfile
import
SourceFileSet
...
@@ -40,7 +40,7 @@ class ModuleSimulation(ModulePlugin):
...
@@ -40,7 +40,7 @@ class ModuleSimulation(ModulePlugin):
if
len
(
self
.
manifest_dict
[
"sim_only_files"
])
==
0
:
if
len
(
self
.
manifest_dict
[
"sim_only_files"
])
==
0
:
self
.
sim_only_files
=
SourceFileSet
()
self
.
sim_only_files
=
SourceFileSet
()
else
:
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"
])
paths
=
self
.
_make_list_of_paths
(
self
.
manifest_dict
[
"sim_only_files"
])
self
.
sim_only_files
=
self
.
_create_file_list_from_paths
(
paths
=
paths
)
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
):
def
__init__
(
self
):
# Manifest Synthesis Properties
# Manifest Synthesis Properties
self
.
syn_device
=
None
self
.
syn_device
=
None
...
@@ -20,7 +19,7 @@ class ModuleSynthesis(ModulePlugin):
...
@@ -20,7 +19,7 @@ class ModuleSynthesis(ModulePlugin):
def
process_manifest
(
self
):
def
process_manifest
(
self
):
self
.
_process_manifest_synthesis
()
self
.
_process_manifest_synthesis
()
self
.
_process_manifest_included_makefiles
()
self
.
_process_manifest_included_makefiles
()
super
(
ModuleSynthesis
,
self
)
.
process_manifest
()
#
super(ModuleSynthesis, self).process_manifest()
def
_process_manifest_synthesis
(
self
):
def
_process_manifest_synthesis
(
self
):
# Synthesis properties
# Synthesis properties
...
...
hdlmake/util/path.py
View file @
28f89a9e
...
@@ -140,3 +140,15 @@ def search_for_manifest(search_path):
...
@@ -140,3 +140,15 @@ def search_for_manifest(search_path):
return
os
.
path
.
abspath
(
os
.
path
.
join
(
search_path
,
filename
))
return
os
.
path
.
abspath
(
os
.
path
.
join
(
search_path
,
filename
))
# no manifest file found
# no manifest file found
return
None
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