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
a2c8a6df
Commit
a2c8a6df
authored
Oct 28, 2019
by
Tristan Gingold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extract sourcefileset.py from srcfile.py
parent
16656b90
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
45 deletions
+69
-45
action.py
hdlmake/action/action.py
+2
-1
module.py
hdlmake/module/module.py
+3
-2
new_dep_solver.py
hdlmake/sourcefiles/new_dep_solver.py
+2
-2
sourcefileset.py
hdlmake/sourcefiles/sourcefileset.py
+62
-0
srcfile.py
hdlmake/sourcefiles/srcfile.py
+0
-40
No files found.
hdlmake/action/action.py
View file @
a2c8a6df
...
...
@@ -31,7 +31,8 @@ import sys
from
..tools.makefile_writer
import
load_syn_tool
,
load_sim_tool
from
..util
import
shell
from
..sourcefiles
import
new_dep_solver
as
dep_solver
from
..sourcefiles.srcfile
import
SourceFileSet
,
VHDLFile
,
VerilogFile
,
SVFile
from
..sourcefiles.srcfile
import
VHDLFile
,
VerilogFile
,
SVFile
from
..sourcefiles.sourcefileset
import
SourceFileSet
from
..module.module
import
Module
,
ModuleArgs
class
Action
(
object
):
...
...
hdlmake/module/module.py
View file @
a2c8a6df
...
...
@@ -181,7 +181,8 @@ class Module(object):
Build a Source File Set containing the files indicated by the
provided list of paths
"""
from
..sourcefiles.srcfile
import
create_source_file
,
SourceFileSet
from
..sourcefiles.srcfile
import
create_source_file
from
..sourcefiles.sourcefileset
import
SourceFileSet
srcs
=
SourceFileSet
()
# Check if this is the top module and grab the include_dirs
if
self
.
parent
is
None
:
...
...
@@ -209,7 +210,7 @@ class Module(object):
def
_process_manifest_files
(
self
):
"""Process the files instantiated by the HDLMake module"""
from
..sourcefiles.s
rcfile
import
SourceFileSet
from
..sourcefiles.s
ourcefileset
import
SourceFileSet
# HDL files provided by the module
if
"files"
not
in
self
.
manifest_dict
:
self
.
files
=
SourceFileSet
()
...
...
hdlmake/sourcefiles/new_dep_solver.py
View file @
a2c8a6df
...
...
@@ -45,7 +45,7 @@ class DepParser(object):
def
solve
(
fileset
,
standard_libs
=
None
):
"""Function that Parses and Solves the provided HDL fileset. Note
that it doesn't return a new fileset, but modifies the original one"""
from
.s
rcfile
import
SourceFileSet
from
.s
ourcefileset
import
SourceFileSet
from
.dep_file
import
DepRelation
assert
isinstance
(
fileset
,
SourceFileSet
)
fset
=
fileset
.
filter
(
DepFile
)
...
...
@@ -125,7 +125,7 @@ def make_dependency_sorted_list(fileset):
def
make_dependency_set
(
fileset
,
top_level_entity
,
extra_modules
=
None
):
"""Create the set of all files required to build the named
top_level_entity."""
from
..sourcefiles.s
rcfile
import
SourceFileSet
from
..sourcefiles.s
ourcefileset
import
SourceFileSet
from
..sourcefiles.dep_file
import
DepRelation
assert
isinstance
(
fileset
,
SourceFileSet
)
fset
=
fileset
.
filter
(
DepFile
)
...
...
hdlmake/sourcefiles/sourcefileset.py
0 → 100644
View file @
a2c8a6df
# -*- coding: utf-8 -*-
#
# Copyright (c) 2019 CERN
#
# 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
class
SourceFileSet
(
set
):
"""Class providing a extension of the 'set' object that includes
methods that allow for an easier management of a collection of HDL
source files"""
def
__init__
(
self
):
super
(
SourceFileSet
,
self
)
.
__init__
()
self
=
[]
def
__str__
(
self
):
return
str
([
str
(
f
)
for
f
in
self
])
def
add
(
self
,
files
):
"""Add a set of files to the source fileset instance"""
if
isinstance
(
files
,
str
):
raise
RuntimeError
(
"Expected object, not a string"
)
elif
files
is
None
:
logging
.
debug
(
"Got None as a file.
\n
Ommiting"
)
else
:
try
:
for
file_aux
in
files
:
super
(
SourceFileSet
,
self
)
.
add
(
file_aux
)
except
TypeError
:
# single file, not a list
super
(
SourceFileSet
,
self
)
.
add
(
files
)
def
filter
(
self
,
filetype
):
"""Method that filters and returns all of the HDL source files
contained in the instance SourceFileSet matching the provided type"""
out
=
SourceFileSet
()
for
file_aux
in
self
:
if
isinstance
(
file_aux
,
filetype
):
out
.
add
(
file_aux
)
return
out
def
sort
(
self
):
"""Return a sorted list of the fileset. This is useful to have always
the same output"""
return
sorted
(
self
,
key
=
(
lambda
x
:
x
.
file_path
))
hdlmake/sourcefiles/srcfile.py
View file @
a2c8a6df
...
...
@@ -322,46 +322,6 @@ ALTERA_FILE_DICT = {
'gdf'
:
GDFFile
}
class
SourceFileSet
(
set
):
"""Class providing a extension of the 'set' object that includes
methods that allow for an easier management of a collection of HDL
source files"""
def
__init__
(
self
):
super
(
SourceFileSet
,
self
)
.
__init__
()
self
=
[]
def
__str__
(
self
):
return
str
([
str
(
f
)
for
f
in
self
])
def
add
(
self
,
files
):
"""Add a set of files to the source fileset instance"""
if
isinstance
(
files
,
str
):
raise
RuntimeError
(
"Expected object, not a string"
)
elif
files
is
None
:
logging
.
debug
(
"Got None as a file.
\n
Ommiting"
)
else
:
try
:
for
file_aux
in
files
:
super
(
SourceFileSet
,
self
)
.
add
(
file_aux
)
except
TypeError
:
# single file, not a list
super
(
SourceFileSet
,
self
)
.
add
(
files
)
def
filter
(
self
,
filetype
):
"""Method that filters and returns all of the HDL source files
contained in the instance SourceFileSet matching the provided type"""
out
=
SourceFileSet
()
for
file_aux
in
self
:
if
isinstance
(
file_aux
,
filetype
):
out
.
add
(
file_aux
)
return
out
def
sort
(
self
):
"""Return a sorted list of the fileset. This is useful to have always
the same output"""
return
sorted
(
self
,
key
=
(
lambda
x
:
x
.
file_path
))
def
create_source_file
(
path
,
module
,
library
=
None
,
include_dirs
=
None
,
is_include
=
False
):
"""Function that analyzes the given arguments and returns a new HDL source
...
...
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