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
2
Merge Requests
2
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
921fc7b5
Commit
921fc7b5
authored
Oct 04, 2019
by
Tristan Gingold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
module: refactoring.
parent
0d2c5746
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
61 deletions
+31
-61
content.py
hdlmake/module/content.py
+24
-3
core.py
hdlmake/module/core.py
+4
-56
module.py
hdlmake/module/module.py
+3
-2
No files found.
hdlmake/module/content.py
View file @
921fc7b5
...
...
@@ -5,12 +5,12 @@ from __future__ import absolute_import
import
logging
from
hdlmake.fetch.git
import
Git
from
hdlmake.util
import
path
as
path_mod
from
.core
import
ModuleCo
re
from
.core
import
ModuleCo
nfig
import
six
import
os
class
ModuleContent
(
ModuleCo
re
):
class
ModuleContent
(
ModuleCo
nfig
):
"""Class providing the HDLMake module content"""
...
...
@@ -20,15 +20,32 @@ class ModuleContent(ModuleCore):
# Manifest Modules Properties
self
.
modules
=
{
'local'
:
[],
'git'
:
[],
'gitsm'
:
[],
'svn'
:
[]}
self
.
incl_makefiles
=
[]
self
.
library
=
"work"
self
.
action
=
None
self
.
pool
=
None
self
.
top_manifest
=
None
self
.
manifest_dict
=
{}
super
(
ModuleContent
,
self
)
.
__init__
()
def
process_manifest
(
self
):
"""Process the content section of the manifest_dic"""
s
uper
(
ModuleContent
,
self
)
.
process_manifest
()
s
elf
.
_process_manifest_universal
()
self
.
_process_manifest_files
()
self
.
_process_manifest_modules
()
self
.
_process_manifest_makefiles
()
def
_process_manifest_universal
(
self
):
"""Method processing the universal manifest directives;
set library (inherited if not set) and action"""
# Libraries
if
"library"
in
self
.
manifest_dict
:
self
.
library
=
self
.
manifest_dict
[
"library"
]
elif
self
.
parent
:
self
.
library
=
self
.
parent
.
library
if
"action"
in
self
.
manifest_dict
:
self
.
action
=
self
.
manifest_dict
[
"action"
]
.
lower
()
def
_process_manifest_files
(
self
):
"""Process the files instantiated by the HDLMake module"""
from
hdlmake.srcfile
import
SourceFileSet
...
...
@@ -46,6 +63,10 @@ class ModuleContent(ModuleCore):
paths
=
self
.
_make_list_of_paths
(
self
.
manifest_dict
[
"files"
])
self
.
files
=
self
.
_create_file_list_from_paths
(
paths
=
paths
)
def
fetchto
(
self
):
"""Get the fetchto folder for the module"""
return
os
.
path
.
dirname
(
self
.
path
)
def
_get_fetchto
(
self
):
"""Calculate the fetchto folder"""
if
(
"fetchto"
in
self
.
manifest_dict
and
...
...
hdlmake/module/core.py
View file @
921fc7b5
...
...
@@ -40,21 +40,6 @@ class ModuleConfig(object):
self
.
path
=
None
self
.
isfetched
=
False
def
process_manifest
(
self
):
"""process_manifest does nothing for ModuleConfig"""
pass
def
basename
(
self
):
"""Get the basename for the module"""
if
self
.
source
==
'svn'
:
return
path_mod
.
svn_basename
(
self
.
url
)
else
:
return
path_mod
.
url_basename
(
self
.
url
)
def
fetchto
(
self
):
"""Get the fetchto folder for the module"""
return
os
.
path
.
dirname
(
self
.
path
)
def
init_config
(
self
,
module_args
):
"""This initializes the module configuration.
The function is executed by Module constructor"""
...
...
@@ -78,20 +63,19 @@ class ModuleConfig(object):
else
:
if
self
.
source
==
'svn'
:
self
.
url
,
self
.
revision
=
path_mod
.
svn_parse
(
url
)
basename
=
path_mod
.
svn_basename
(
self
.
url
)
else
:
self
.
url
,
self
.
branch
,
self
.
revision
=
path_mod
.
url_parse
(
url
)
basename
=
self
.
basename
(
)
path
=
path_mod
.
relpath
(
os
.
path
.
abspath
(
basename
=
path_mod
.
url_basename
(
self
.
url
)
self
.
path
=
path_mod
.
relpath
(
os
.
path
.
abspath
(
os
.
path
.
join
(
fetchto
,
basename
)))
# Check if the module dir exists and is not empty
if
os
.
path
.
exists
(
path
)
and
os
.
listdir
(
path
):
self
.
path
=
path
if
os
.
path
.
exists
(
self
.
path
)
and
os
.
listdir
(
self
.
path
):
self
.
isfetched
=
True
logging
.
debug
(
"Module
%
s (parent:
%
s) is fetched."
,
url
,
self
.
parent
.
path
)
else
:
self
.
path
=
path
self
.
isfetched
=
False
logging
.
debug
(
"Module
%
s (parent:
%
s) is NOT fetched."
,
url
,
self
.
parent
.
path
)
...
...
@@ -124,39 +108,3 @@ class ModuleConfig(object):
if
self
.
_check_filepath
(
filepath
):
paths
.
append
(
path_mod
.
rel2abs
(
filepath
,
self
.
path
))
return
paths
class
ModuleCore
(
ModuleConfig
):
"""This is the class providing the module core functionality"""
def
__init__
(
self
):
# Universal Manifest Properties
self
.
library
=
"work"
self
.
action
=
None
self
.
pool
=
None
self
.
top_manifest
=
None
self
.
manifest_dict
=
{}
super
(
ModuleCore
,
self
)
.
__init__
()
def
set_pool
(
self
,
pool
):
"""Set the associated pool for the module instance"""
self
.
pool
=
pool
self
.
top_manifest
=
pool
.
get_top_manifest
()
def
process_manifest
(
self
):
"""Method that process the core manifest section"""
self
.
_process_manifest_universal
()
super
(
ModuleCore
,
self
)
.
process_manifest
()
def
_process_manifest_universal
(
self
):
"""Method processing the universal manifest directives;
set library (inherited if not set) and action"""
# Libraries
if
"library"
in
self
.
manifest_dict
:
self
.
library
=
self
.
manifest_dict
[
"library"
]
elif
self
.
parent
:
self
.
library
=
self
.
parent
.
library
if
"action"
in
self
.
manifest_dict
:
self
.
action
=
self
.
manifest_dict
[
"action"
]
.
lower
()
hdlmake/module/module.py
View file @
921fc7b5
...
...
@@ -51,10 +51,11 @@ class Module(ModuleContent):
"""Calculate and initialize the origin attributes: path, source..."""
assert
module_args
.
url
is
not
None
assert
module_args
.
source
is
not
None
self
.
manifest_dict
=
{}
super
(
Module
,
self
)
.
__init__
()
self
.
init_config
(
module_args
)
self
.
set_pool
(
pool
)
self
.
module_args
=
ModuleArgs
()
self
.
pool
=
pool
self
.
top_manifest
=
pool
.
get_top_manifest
()
self
.
module_args
=
module_args
def
__str__
(
self
):
...
...
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