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
afc58c0b
Commit
afc58c0b
authored
Jun 11, 2019
by
Tristan Gingold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
module: refactor to reduce code size.
parent
09a1ab5b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
75 deletions
+24
-75
core.py
hdlmake/action/core.py
+2
-4
content.py
hdlmake/module/content.py
+20
-63
module.py
hdlmake/module/module.py
+2
-8
No files found.
hdlmake/action/core.py
View file @
afc58c0b
...
...
@@ -87,10 +87,8 @@ class ActionCore(Action):
if
result
is
False
:
raise
Exception
(
"Unable to fetch module
%
s"
,
str
(
module
.
url
))
module
.
parse_manifest
()
new_modules
.
extend
(
module
.
local
)
new_modules
.
extend
(
module
.
svn
)
new_modules
.
extend
(
module
.
git
)
new_modules
.
extend
(
module
.
gitsm
)
for
m
in
module
.
modules
:
new_modules
.
extend
(
module
.
modules
[
m
])
return
new_modules
fetch_queue
=
[
m
for
m
in
self
]
...
...
hdlmake/module/content.py
View file @
afc58c0b
...
...
@@ -36,10 +36,7 @@ class ModuleContent(ModuleCore):
# Manifest Files Properties
self
.
files
=
None
# Manifest Modules Properties
self
.
local
=
[]
self
.
git
=
[]
self
.
gitsm
=
[]
self
.
svn
=
[]
self
.
modules
=
{
'local'
:
[],
'git'
:
[],
'gitsm'
:
[],
'svn'
:
[]}
self
.
incl_makefiles
=
[]
super
(
ModuleContent
,
self
)
.
__init__
()
...
...
@@ -83,61 +80,21 @@ class ModuleContent(ModuleCore):
if
"modules"
not
in
self
.
manifest_dict
:
return
fetchto
=
self
.
_get_fetchto
()
if
"local"
in
self
.
manifest_dict
[
"modules"
]:
local_paths
=
path_mod
.
flatten_list
(
self
.
manifest_dict
[
"modules"
][
"local"
])
local_mods
=
[]
for
path
in
local_paths
:
if
path_mod
.
is_abs_path
(
path
):
raise
Exception
(
"Found an absolute path ("
+
path
+
") in a manifest("
+
self
.
path
+
")"
)
path
=
path_mod
.
rel2abs
(
path
,
self
.
path
)
local_mods
.
append
(
self
.
pool
.
new_module
(
parent
=
self
,
url
=
path
,
source
=
'local'
,
fetchto
=
fetchto
))
self
.
local
=
local_mods
else
:
self
.
local
=
[]
if
"svn"
in
self
.
manifest_dict
[
"modules"
]:
self
.
manifest_dict
[
"modules"
][
"svn"
]
=
path_mod
.
flatten_list
(
self
.
manifest_dict
[
"modules"
][
"svn"
])
svn_mods
=
[]
for
url
in
self
.
manifest_dict
[
"modules"
][
"svn"
]:
svn_mods
.
append
(
self
.
pool
.
new_module
(
parent
=
self
,
url
=
url
,
source
=
'svn'
,
fetchto
=
fetchto
))
self
.
svn
=
svn_mods
else
:
self
.
svn
=
[]
if
"git"
in
self
.
manifest_dict
[
"modules"
]:
self
.
manifest_dict
[
"modules"
][
"git"
]
=
path_mod
.
flatten_list
(
self
.
manifest_dict
[
"modules"
][
"git"
])
git_mods
=
[]
for
url
in
self
.
manifest_dict
[
"modules"
][
"git"
]:
git_mods
.
append
(
self
.
pool
.
new_module
(
parent
=
self
,
url
=
url
,
source
=
'git'
,
fetchto
=
fetchto
))
self
.
git
=
git_mods
else
:
self
.
git
=
[]
if
"gitsm"
in
self
.
manifest_dict
[
"modules"
]:
self
.
manifest_dict
[
"modules"
][
"gitsm"
]
=
path_mod
.
flatten_list
(
self
.
manifest_dict
[
"modules"
][
"gitsm"
])
gitsm_mods
=
[]
for
url
in
self
.
manifest_dict
[
"modules"
][
"gitsm"
]:
gitsm_mods
.
append
(
self
.
pool
.
new_module
(
parent
=
self
,
url
=
url
,
source
=
'gitsm'
,
fetchto
=
fetchto
))
self
.
gitsm
=
gitsm_mods
else
:
self
.
gitsm
=
[]
for
m
in
self
.
modules
:
if
m
not
in
self
.
manifest_dict
[
"modules"
]:
continue
paths
=
path_mod
.
flatten_list
(
self
.
manifest_dict
[
"modules"
][
m
])
self
.
manifest_dict
[
"modules"
][
m
]
=
paths
mods
=
[]
for
path
in
paths
:
if
m
==
'local'
:
if
path_mod
.
is_abs_path
(
path
):
raise
Exception
(
"Found an absolute path ("
+
path
+
") in a manifest("
+
self
.
path
+
")"
)
path
=
path_mod
.
rel2abs
(
path
,
self
.
path
)
mods
.
append
(
self
.
pool
.
new_module
(
parent
=
self
,
url
=
path
,
source
=
m
,
fetchto
=
fetchto
))
self
.
modules
[
m
]
=
mods
def
process_git_submodules
(
self
):
"""Get the submodules if found in the Manifest path"""
...
...
@@ -150,10 +107,10 @@ class ModuleContent(ModuleCore):
path
=
git_submodule_dict
[
submodule_key
][
"path"
]
path
=
os
.
path
.
join
(
git_toplevel
,
path
)
fetchto
=
os
.
path
.
sep
.
join
(
path
.
split
(
os
.
path
.
sep
)[:
-
1
])
self
.
git
.
append
(
self
.
pool
.
new_module
(
parent
=
self
,
url
=
url
,
fetchto
=
fetchto
,
source
=
'git'
))
self
.
modules
[
'git'
]
.
append
(
self
.
pool
.
new_module
(
parent
=
self
,
url
=
url
,
fetchto
=
fetchto
,
source
=
'git'
))
def
_process_manifest_makefiles
(
self
):
"""Get the extra makefiles defined in the HDLMake module"""
...
...
hdlmake/module/module.py
View file @
afc58c0b
...
...
@@ -61,14 +61,8 @@ class Module(ModuleContent):
def
submodules
(
self
):
"""Get a list with all the submodules this module instance requires"""
def
__nonull
(
submodule_list
):
"""Returns a list with the submodules, being empty if null"""
if
not
submodule_list
:
return
[]
else
:
return
submodule_list
return
__nonull
(
self
.
local
)
+
__nonull
(
self
.
git
)
\
+
__nonull
(
self
.
gitsm
)
+
__nonull
(
self
.
svn
)
return
self
.
modules
[
'local'
]
+
self
.
modules
[
'git'
]
\
+
self
.
modules
[
'gitsm'
]
+
self
.
modules
[
'svn'
]
def
remove_dir_from_disk
(
self
):
"""Delete the module dir if it is already fetched and available"""
...
...
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