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
c898a4ca
Commit
c898a4ca
authored
Oct 21, 2013
by
Pawel Szostek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
correct git submodules treatment
parent
5d5145a1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
24 deletions
+65
-24
simulation.py
hdlmake/action/simulation.py
+1
-1
git.py
hdlmake/fetch/git.py
+50
-16
module.py
hdlmake/module.py
+14
-7
No files found.
hdlmake/action/simulation.py
View file @
c898a4ca
...
@@ -49,7 +49,7 @@ class GenerateSimulationMakefile(Action):
...
@@ -49,7 +49,7 @@ class GenerateSimulationMakefile(Action):
self
.
_generate_vsim_makefile
()
self
.
_generate_vsim_makefile
()
logging
.
info
(
"Generating simulation makefile for vsim"
)
logging
.
info
(
"Generating simulation makefile for vsim"
)
else
:
else
:
logging
.
error
(
"Unrecognized or not specified simulation tool:
%
s"
%
str
(
tm
.
sim_tool
))
logging
.
error
(
"Unrecognized or not specified simulation tool:
%
s
\n
Please set sim_tool in the top manifest.
"
%
str
(
tm
.
sim_tool
))
sys
.
exit
(
"Exiting"
)
sys
.
exit
(
"Exiting"
)
logging
.
info
(
"Simulation makefile generated."
)
logging
.
info
(
"Simulation makefile generated."
)
...
...
hdlmake/fetch/git.py
View file @
c898a4ca
...
@@ -43,6 +43,22 @@ class Git(Fetcher):
...
@@ -43,6 +43,22 @@ class Git(Fetcher):
def
__init__
(
self
):
def
__init__
(
self
):
pass
pass
@
staticmethod
def
get_git_toplevel
(
module
):
cur_dir
=
os
.
getcwd
()
try
:
os
.
chdir
(
path
.
rel2abs
(
module
.
path
))
if
not
os
.
path
.
exists
(
".gitmodules"
):
return
None
tree_root_cmd
=
Popen
(
"git rev-parse --show-toplevel"
,
stdout
=
PIPE
,
stdin
=
PIPE
,
shell
=
True
)
tree_root_line
=
tree_root_cmd
.
stdout
.
readlines
()[
0
]
.
strip
()
return
tree_root_line
finally
:
os
.
chdir
(
cur_dir
)
@
staticmethod
@
staticmethod
def
get_git_submodules
(
module
):
def
get_git_submodules
(
module
):
submodule_dir
=
path
.
rel2abs
(
module
.
path
)
submodule_dir
=
path
.
rel2abs
(
module
.
path
)
...
@@ -51,31 +67,49 @@ class Git(Fetcher):
...
@@ -51,31 +67,49 @@ class Git(Fetcher):
try
:
try
:
os
.
chdir
(
submodule_dir
)
os
.
chdir
(
submodule_dir
)
if
not
os
.
path
.
exists
(
".gitmodules"
):
return
{}
#"git config --list" | grep submodule | sed 's/.*=//')" % submodule_dir
#"git config --list" | grep submodule | sed 's/.*=//')" % submodule_dir
config_content
=
Popen
(
"git config --list"
,
config_submodules
=
{}
config_content
=
Popen
(
"git config -f .gitmodules --list"
,
stdout
=
PIPE
,
stdout
=
PIPE
,
stdin
=
PIPE
,
stdin
=
PIPE
,
shell
=
True
)
shell
=
True
)
config_lines
=
[
line
.
strip
()
for
line
in
config_content
.
stdout
.
readlines
()]
config_lines
=
[
line
.
strip
()
for
line
in
config_content
.
stdout
.
readlines
()]
config_submodule_lines
=
[
line
for
line
in
config_lines
if
"submodule"
in
line
]
"""try to parse sth like this:
config_submodules
=
[
line
.
split
(
"="
)[
-
1
]
for
line
in
config_submodule_lines
]
paszoste@oplarra1:~/beco/hdlmake-tests/wr-switch-hdl$ git config -f .gitmodules --list
submodule.ip_cores/general-cores.path=ip_cores/general-cores
submodule.ip_cores/general-cores.url=git://ohwr.org/hdl-core-lib/general-cores.git
submodule.ip_cores/wr-cores.path=ip_cores/wr-cores
submodule.ip_cores/wr-cores.url=git://ohwr.org/hdl-core-lib/wr-cores.git
"""
config_submodule_lines
=
[
line
for
line
in
config_lines
if
line
.
startswith
(
"submodule"
)]
for
line
in
config_submodule_lines
:
line_split
=
line
.
split
(
"="
)
lhs
=
line_split
[
0
]
rhs
=
line_split
[
1
]
lhs_split
=
lhs
.
split
(
"."
)
module_name
=
'.'
.
join
(
lhs_split
[
1
:
-
1
])
if
module_name
not
in
config_submodules
:
config_submodules
[
module_name
]
=
{}
config_submodules
[
module_name
][
lhs_split
[
-
1
]]
=
rhs
#"(cd %s && cat ./.gitmodules 2>/dev/null | grep url | sed 's/url = //')" % submodule_dir
#"(cd %s && cat ./.gitmodules 2>/dev/null | grep url | sed 's/url = //')" % submodule_dir
try
:
#try:
dotgitmodules_file
=
open
(
".gitmodules"
,
'r'
)
## dotgitmodules_file = open(".gitmodules", 'r')
dotgitmodules_lines
=
dotgitmodules_file
.
readlines
()
# dotgitmodules_lines = dotgitmodules_file.readlines()
url_lines
=
[
line
for
line
in
dotgitmodules_lines
if
'url'
in
line
]
# url_lines = [line for line in dotgitmodules_lines if 'url' in line]
dotgitmodules_submodules
=
[
line
.
split
(
" = "
)[
-
1
]
.
strip
()
for
line
in
url_lines
]
# dotgitmodules_submodules = [line.split(" = ")[-1].strip() for line in url_lines]
set
(
config_submodules
)
.
update
(
set
(
dotgitmodules_submodules
))
# set(config_submodules).update(set(dotgitmodules_submodules))
except
IOError
:
#except IOError:
pass
# no .gitmodules file
# pass # no .gitmodules file
submodules
=
list
(
config_submodules
)
if
len
(
list
(
config_submodules
))
>
0
:
if
len
(
submodules
)
>
0
:
logging
.
info
(
"Found git submodules in
%
s:
%
s"
%
(
module
.
path
,
str
(
config_submodules
)))
logging
.
info
(
"Found git submodules in
%
s"
%
module
.
path
)
finally
:
finally
:
os
.
chdir
(
cur_dir
)
os
.
chdir
(
cur_dir
)
return
submodules
return
config_
submodules
def
fetch
(
self
,
module
):
def
fetch
(
self
,
module
):
if
module
.
source
!=
fetch
.
GIT
:
if
module
.
source
!=
fetch
.
GIT
:
...
...
hdlmake/module.py
View file @
c898a4ca
...
@@ -112,9 +112,11 @@ class Module(object):
...
@@ -112,9 +112,11 @@ class Module(object):
if
os
.
path
.
exists
(
os
.
path
.
abspath
(
os
.
path
.
join
(
fetchto
,
self
.
basename
))):
if
os
.
path
.
exists
(
os
.
path
.
abspath
(
os
.
path
.
join
(
fetchto
,
self
.
basename
))):
self
.
path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
fetchto
,
self
.
basename
))
self
.
path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
fetchto
,
self
.
basename
))
self
.
isfetched
=
True
self
.
isfetched
=
True
logging
.
debug
(
"Module
%
s (parent:
%
s) is fetched."
%
(
url
,
parent
.
path
))
else
:
else
:
self
.
path
=
None
self
.
path
=
None
self
.
isfetched
=
False
self
.
isfetched
=
False
logging
.
debug
(
"Module
%
s (parent:
%
s) is NOT fetched."
%
(
url
,
parent
.
path
))
self
.
manifest
=
None
self
.
manifest
=
None
...
@@ -226,9 +228,9 @@ class Module(object):
...
@@ -226,9 +228,9 @@ class Module(object):
if
self
.
isprocessed
is
True
:
if
self
.
isprocessed
is
True
:
return
return
if
self
.
manifest_dict
is
None
:
if
self
.
manifest_dict
is
None
:
logging
.
debug
(
"
there is no manifest to be processed"
)
logging
.
debug
(
"
There is no manifest to be processed in:
%
s"
%
self
.
url
)
return
return
logging
.
debug
(
self
.
path
)
logging
.
debug
(
"Process manifest in:
%
s"
%
self
.
path
)
if
self
.
manifest_dict
[
"syn_ise_version"
]
is
not
None
:
if
self
.
manifest_dict
[
"syn_ise_version"
]
is
not
None
:
version
=
self
.
manifest_dict
[
"syn_ise_version"
]
version
=
self
.
manifest_dict
[
"syn_ise_version"
]
self
.
syn_ise_version
=
str
(
version
)
self
.
syn_ise_version
=
str
(
version
)
...
@@ -316,7 +318,7 @@ class Module(object):
...
@@ -316,7 +318,7 @@ class Module(object):
pass
pass
else
:
else
:
self
.
manifest_dict
[
"files"
]
=
self
.
_flatten_list
(
self
.
manifest_dict
[
"files"
])
self
.
manifest_dict
[
"files"
]
=
self
.
_flatten_list
(
self
.
manifest_dict
[
"files"
])
logging
.
debug
(
self
.
path
+
str
(
self
.
manifest_dict
[
"files"
]
))
logging
.
debug
(
"Files in
%
s:
%
s"
%
(
self
.
path
,
str
(
self
.
manifest_dict
[
"files"
])
))
paths
=
self
.
_make_list_of_paths
(
self
.
manifest_dict
[
"files"
])
paths
=
self
.
_make_list_of_paths
(
self
.
manifest_dict
[
"files"
])
self
.
files
=
self
.
_create_file_list_from_paths
(
paths
=
paths
)
self
.
files
=
self
.
_create_file_list_from_paths
(
paths
=
paths
)
for
f
in
self
.
files
:
for
f
in
self
.
files
:
...
@@ -366,11 +368,16 @@ class Module(object):
...
@@ -366,11 +368,16 @@ class Module(object):
else
:
else
:
self
.
git
=
[]
self
.
git
=
[]
git_submodule_urls
=
fetch
.
Git
.
get_git_submodules
(
self
)
git_submodule_dict
=
fetch
.
Git
.
get_git_submodules
(
self
)
for
submodule_url
in
git_submodule_urls
:
git_toplevel
=
fetch
.
Git
.
get_git_toplevel
(
self
)
for
submodule_key
in
git_submodule_dict
.
keys
():
url
=
git_submodule_dict
[
submodule_key
][
"url"
]
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_submodules
.
append
(
self
.
pool
.
new_module
(
parent
=
self
,
self
.
git_submodules
.
append
(
self
.
pool
.
new_module
(
parent
=
self
,
url
=
submodule_
url
,
url
=
url
,
fetchto
=
self
.
path
,
fetchto
=
fetchto
,
source
=
fetch
.
GITSUBMODULE
))
source
=
fetch
.
GITSUBMODULE
))
self
.
target
=
self
.
manifest_dict
[
"target"
]
.
lower
()
self
.
target
=
self
.
manifest_dict
[
"target"
]
.
lower
()
self
.
action
=
self
.
manifest_dict
[
"action"
]
.
lower
()
self
.
action
=
self
.
manifest_dict
[
"action"
]
.
lower
()
...
...
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