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
e50d46ae
Commit
e50d46ae
authored
Jun 11, 2019
by
Tristan Gingold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
action: use composition instead of inheritance.
parent
24b0d92c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
13 deletions
+14
-13
action.py
hdlmake/action/action.py
+7
-6
core.py
hdlmake/action/core.py
+7
-7
No files found.
hdlmake/action/action.py
View file @
e50d46ae
...
...
@@ -34,13 +34,14 @@ from hdlmake import new_dep_solver as dep_solver
from
hdlmake.srcfile
import
SourceFileSet
,
VHDLFile
,
VerilogFile
,
SVFile
from
hdlmake.module.module
import
Module
,
ModuleArgs
class
Action
(
lis
t
):
class
Action
(
objec
t
):
"""This is the base class providing the common Action methods"""
def
__init__
(
self
,
options
):
super
(
Action
,
self
)
.
__init__
()
self
.
top_manifest
=
None
self
.
manifests
=
[]
self
.
parseable_fileset
=
SourceFileSet
()
self
.
privative_fileset
=
SourceFileSet
()
self
.
_deps_solved
=
False
...
...
@@ -98,8 +99,8 @@ class Action(list):
"""Build file set with all the files listed in the complete pool"""
logging
.
debug
(
"Begin build complete file set"
)
all_manifested_files
=
SourceFileSet
()
for
m
odule
in
self
:
all_manifested_files
.
add
(
m
odule
.
files
)
for
m
anifest
in
self
.
manifests
:
all_manifested_files
.
add
(
m
anifest
.
files
)
logging
.
debug
(
"End build complete file set"
)
return
all_manifested_files
...
...
@@ -154,7 +155,7 @@ class Action(list):
def
_get_config_dict
(
self
):
"""Get the combined hierarchical Manifest dictionary from the pool"""
config_dict
=
{}
for
mod
in
self
:
for
mod
in
self
.
manifests
:
manifest_dict_tmp
=
mod
.
manifest_dict
if
not
manifest_dict_tmp
==
None
:
if
'fetchto'
in
manifest_dict_tmp
:
...
...
@@ -173,12 +174,12 @@ class Action(list):
if
new_module
.
isfetched
:
for
mod
in
new_module
.
submodules
():
self
.
_add
(
mod
)
self
.
append
(
new_module
)
self
.
manifests
.
append
(
new_module
)
return
True
def
__contains
(
self
,
module
):
"""Check if the pool contains the given module by checking the URL"""
for
mod
in
self
:
for
mod
in
self
.
manifests
:
if
mod
.
url
==
module
.
url
:
return
True
return
False
...
...
hdlmake/action/core.py
View file @
e50d46ae
...
...
@@ -51,7 +51,7 @@ class ActionCore(Action):
def
_check_all_fetched
(
self
):
"""Check if every module in the pool is fetched"""
if
not
len
([
m
for
m
in
self
if
not
m
.
isfetched
])
==
0
:
if
not
len
([
m
for
m
in
self
.
manifests
if
not
m
.
isfetched
])
==
0
:
raise
Exception
(
"Fetching should be done before continuing.
\n
"
"The following modules remains unfetched:
\n
"
...
...
@@ -91,7 +91,7 @@ class ActionCore(Action):
new_modules
.
extend
(
module
.
modules
[
m
])
return
new_modules
fetch_queue
=
[
m
for
m
in
self
]
fetch_queue
=
[
m
for
m
in
self
.
manifests
]
while
len
(
fetch_queue
)
>
0
:
cur_mod
=
fetch_queue
.
pop
()
...
...
@@ -113,12 +113,12 @@ class ActionCore(Action):
def
fetch
(
self
):
"""Fetch the missing required modules from their remote origin"""
logging
.
info
(
"Fetching needed modules."
)
for
mod
in
self
:
for
mod
in
self
.
manifests
:
if
mod
.
isfetched
and
not
mod
.
manifest_dict
==
None
:
if
'fetch_pre_cmd'
in
mod
.
manifest_dict
:
os
.
system
(
mod
.
manifest_dict
.
get
(
"fetch_pre_cmd"
,
''
))
self
.
_fetch_all
()
for
mod
in
self
:
for
mod
in
self
.
manifests
:
if
mod
.
isfetched
and
not
mod
.
manifest_dict
==
None
:
if
'fetch_post_cmd'
in
mod
.
manifest_dict
:
os
.
system
(
mod
.
manifest_dict
.
get
(
"fetch_post_cmd"
,
''
))
...
...
@@ -127,7 +127,7 @@ class ActionCore(Action):
def
clean
(
self
):
"""Delete the local copy of the fetched modules"""
logging
.
info
(
"Removing fetched modules.."
)
remove_list
=
[
mod_aux
for
mod_aux
in
self
remove_list
=
[
mod_aux
for
mod_aux
in
self
.
manifests
if
mod_aux
.
source
in
[
'git'
,
'gitsm'
,
'svn'
]
and
mod_aux
.
isfetched
]
remove_list
.
reverse
()
# we will remove modules in backward order
...
...
@@ -142,7 +142,7 @@ class ActionCore(Action):
def
list_files
(
self
):
"""List the files added to the design across the pool hierarchy"""
unfetched_modules
=
[
mod_aux
for
mod_aux
in
self
unfetched_modules
=
[
mod_aux
for
mod_aux
in
self
.
manifests
if
not
mod_aux
.
isfetched
]
for
mod_aux
in
unfetched_modules
:
logging
.
warning
(
...
...
@@ -179,7 +179,7 @@ class ActionCore(Action):
def
list_modules
(
self
):
"""List the modules that are contained by the pool"""
for
mod_aux
in
self
:
for
mod_aux
in
self
.
manifests
:
if
not
mod_aux
.
isfetched
:
logging
.
warning
(
"Module not fetched:
%
s"
,
mod_aux
.
url
)
self
.
_print_comment
(
"# MODULE UNFETCHED! ->
%
s"
%
mod_aux
.
url
)
...
...
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