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
3fd3c0a9
Commit
3fd3c0a9
authored
Jul 31, 2016
by
Javier D. Garcia-Lasheras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consolidate module handling actions into a single class
parent
0cf25370
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
110 additions
and
97 deletions
+110
-97
__init__.py
hdlmake/action/__init__.py
+1
-3
core.py
hdlmake/action/core.py
+105
-0
fetch.py
hdlmake/action/fetch.py
+0
-52
list_files.py
hdlmake/action/list_files.py
+0
-38
module_pool.py
hdlmake/module_pool.py
+4
-4
No files found.
hdlmake/action/__init__.py
View file @
3fd3c0a9
...
...
@@ -22,9 +22,7 @@
from
.check_condition
import
CheckCondition
from
.check_manifest
import
CheckManifest
from
.fetch
import
FetchModules
from
.list_files
import
ListFiles
from
.list_modules
import
ListModules
from
.core
import
ActionCore
from
.merge_cores
import
MergeCores
from
.tree
import
Tree
...
...
hdlmake/action/
list_modules
.py
→
hdlmake/action/
core
.py
View file @
3fd3c0a9
...
...
@@ -19,17 +19,57 @@
# You should have received a copy of the GNU General Public License
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
from
__future__
import
absolute_import
import
logging
import
sys
import
os
from
hdlmake.util
import
path
from
.action
import
Action
import
hdlmake.fetch
as
fetch
import
hdlmake.new_dep_solver
as
dep_solver
from
hdlmake.util
import
path
as
path_mod
from
.action
import
Action
class
ActionCore
(
Action
):
def
fetch
(
self
):
top_module
=
self
.
get_top_module
()
logging
.
info
(
"Fetching needed modules."
)
os
.
system
(
top_module
.
manifest_dict
[
"fetch_pre_cmd"
])
self
.
fetch_all
()
os
.
system
(
top_module
.
manifest_dict
[
"fetch_post_cmd"
])
logging
.
info
(
"All modules fetched."
)
def
clean
(
self
):
logging
.
info
(
"Removing fetched modules.."
)
remove_list
=
[
m
for
m
in
self
if
m
.
source
in
[
fetch
.
GIT
,
fetch
.
SVN
]
and
m
.
isfetched
]
remove_list
.
reverse
()
# we will remove modules in backward order
if
len
(
remove_list
):
for
m
in
remove_list
:
logging
.
info
(
"... clean: "
+
m
.
url
+
" [from: "
+
m
.
path
+
"]"
)
m
.
remove_dir_from_disk
()
else
:
logging
.
info
(
"There are no modules to be removed"
)
logging
.
info
(
"Modules cleaned."
)
def
_convert_to_source_name
(
source_code
):
def
list_files
(
self
):
unfetched_modules
=
[
m
for
m
in
self
if
not
m
.
isfetched
]
for
m
in
unfetched_modules
:
logging
.
warning
(
"List incomplete, module
%
s has not been fetched!"
,
m
)
file_set
=
self
.
build_file_set
()
file_list
=
dep_solver
.
make_dependency_sorted_list
(
file_set
)
files_str
=
[
f
.
path
for
f
in
file_list
]
if
self
.
env
.
options
.
delimiter
==
None
:
delimiter
=
"
\n
"
else
:
delimiter
=
self
.
env
.
options
.
delimiter
print
(
delimiter
.
join
(
files_str
))
def
list_modules
(
self
):
def
_convert_to_source_name
(
source_code
):
if
source_code
==
fetch
.
GIT
:
return
"git"
elif
source_code
==
fetch
.
SVN
:
...
...
@@ -39,9 +79,6 @@ def _convert_to_source_name(source_code):
elif
source_code
==
fetch
.
GITSUBMODULE
:
return
"git_submodule"
class
ListModules
(
Action
):
def
list_modules
(
self
):
terse
=
self
.
env
.
options
.
terse
for
m
in
self
:
if
not
m
.
isfetched
:
...
...
@@ -55,13 +92,14 @@ class ListModules(Action):
if
not
terse
:
print
(
"# * The parent for this module is:
%
s"
%
m
.
parent
.
url
)
else
:
if
not
terse
:
print
(
"# * This is the root module"
)
print
(
"
%
s
\t
%
s"
%
(
path
.
relpath
(
m
.
path
),
_convert_to_source_name
(
m
.
source
)))
print
(
"
%
s
\t
%
s"
%
(
path
_mod
.
relpath
(
m
.
path
),
_convert_to_source_name
(
m
.
source
)))
if
self
.
env
.
options
.
withfiles
:
if
not
len
(
m
.
files
):
if
not
terse
:
print
(
"# * This module has no files"
)
else
:
for
f
in
m
.
files
:
print
(
"
%
s
\t
%
s"
%
(
path
.
relpath
(
f
.
path
),
"file"
))
print
(
"
%
s
\t
%
s"
%
(
path
_mod
.
relpath
(
f
.
path
),
"file"
))
if
not
terse
:
print
(
"# MODULE END ->
%
s"
%
m
.
url
)
if
not
terse
:
print
(
""
)
hdlmake/action/fetch.py
deleted
100644 → 0
View file @
0cf25370
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
#
# This file is part of Hdlmake.
#
# Hdlmake is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Hdlmake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
import
logging
import
sys
import
os
from
.action
import
Action
import
hdlmake.fetch
as
fetch
class
FetchModules
(
Action
):
def
fetch
(
self
):
top_module
=
self
.
get_top_module
()
logging
.
info
(
"Fetching needed modules."
)
os
.
system
(
top_module
.
manifest_dict
[
"fetch_pre_cmd"
])
self
.
fetch_all
()
os
.
system
(
top_module
.
manifest_dict
[
"fetch_post_cmd"
])
logging
.
info
(
"All modules fetched."
)
def
clean
(
self
):
logging
.
info
(
"Removing fetched modules.."
)
remove_list
=
[
m
for
m
in
self
if
m
.
source
in
[
fetch
.
GIT
,
fetch
.
SVN
]
and
m
.
isfetched
]
remove_list
.
reverse
()
# we will remove modules in backward order
if
len
(
remove_list
):
for
m
in
remove_list
:
logging
.
info
(
"... clean: "
+
m
.
url
+
" [from: "
+
m
.
path
+
"]"
)
m
.
remove_dir_from_disk
()
else
:
logging
.
info
(
"There are no modules to be removed"
)
logging
.
info
(
"Modules cleaned."
)
hdlmake/action/list_files.py
deleted
100644 → 0
View file @
0cf25370
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
#
# This file is part of Hdlmake.
#
# Hdlmake is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Hdlmake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
from
.action
import
Action
import
logging
import
hdlmake.new_dep_solver
as
dep_solver
class
ListFiles
(
Action
):
def
list_files
(
self
):
unfetched_modules
=
[
m
for
m
in
self
if
not
m
.
isfetched
]
for
m
in
unfetched_modules
:
logging
.
warning
(
"List incomplete, module
%
s has not been fetched!"
,
m
)
file_set
=
self
.
build_file_set
()
file_list
=
dep_solver
.
make_dependency_sorted_list
(
file_set
)
files_str
=
[
f
.
path
for
f
in
file_list
]
if
self
.
env
.
options
.
delimiter
==
None
:
delimiter
=
"
\n
"
else
:
delimiter
=
self
.
env
.
options
.
delimiter
print
(
delimiter
.
join
(
files_str
))
hdlmake/module_pool.py
View file @
3fd3c0a9
...
...
@@ -34,14 +34,14 @@ from . import new_dep_solver as dep_solver
from
.util
import
path
as
path_mod
from
.
import
fetch
from
.env
import
Env
from
.action
import
(
CheckManifest
,
CheckCondition
,
FetchModules
,
ListFiles
,
ListModules
,
MergeCores
,
Tree
,
GenerateSimulationMakefile
,
from
.action
import
(
CheckManifest
,
CheckCondition
,
ActionCore
,
MergeCores
,
Tree
,
GenerateSimulationMakefile
,
ActionSynthesis
,
QsysHwTclUpdate
)
class
ModulePool
(
list
,
CheckManifest
,
CheckCondition
,
FetchModules
,
ListFiles
,
ListModules
,
MergeCores
,
Tree
,
GenerateSimulationMakefile
,
class
ModulePool
(
list
,
CheckManifest
,
CheckCondition
,
ActionCore
,
MergeCores
,
Tree
,
GenerateSimulationMakefile
,
ActionSynthesis
,
QsysHwTclUpdate
):
"""
...
...
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