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
f307a1db
Commit
f307a1db
authored
Jun 08, 2016
by
Javier D. Garcia-Lasheras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The flag close_fds=True does not work on Windows: check before spawning a subprocess
parent
662b4763
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
35 additions
and
19 deletions
+35
-19
env.py
hdlmake/env.py
+6
-2
git.py
hdlmake/fetch/git.py
+4
-1
svn.py
hdlmake/fetch/svn.py
+4
-1
module_pool.py
hdlmake/module_pool.py
+5
-2
ise.py
hdlmake/tools/ise/ise.py
+8
-11
isim.py
hdlmake/tools/isim/isim.py
+4
-1
iverilog.py
hdlmake/tools/iverilog/iverilog.py
+4
-1
No files found.
hdlmake/env.py
View file @
f307a1db
...
...
@@ -24,6 +24,7 @@
from
__future__
import
print_function
import
os
import
sys
import
platform
from
subprocess
import
Popen
,
PIPE
import
os.path
...
...
@@ -148,6 +149,9 @@ class Env(dict):
def
check_remote_tool
(
self
,
info_class
):
if
platform
.
system
()
==
'Windows'
:
is_windows
=
True
else
:
is_windows
=
False
tool_info
=
info_class
.
get_keys
()
remote_path_key
=
'rsynth_'
+
tool_info
[
'id'
]
+
'_path'
remote_version_key
=
'rsynth_'
+
tool_info
[
'id'
]
+
'_version'
...
...
@@ -160,7 +164,7 @@ class Env(dict):
if
self
[
"rsynth_user"
]
is
not
None
and
self
[
"rsynth_server"
]
is
not
None
:
ssh_cmd
=
'ssh -o BatchMode=yes -o ConnectTimeout=5
%
s@
%
s echo ok 2>&1'
ssh_cmd
=
ssh_cmd
%
(
self
[
"rsynth_user"
],
self
[
"rsynth_server"
])
ssh_out
=
Popen
(
ssh_cmd
,
shell
=
True
,
stdin
=
PIPE
,
stdout
=
PIPE
,
close_fds
=
True
)
ssh_out
=
Popen
(
ssh_cmd
,
shell
=
True
,
stdin
=
PIPE
,
stdout
=
PIPE
,
close_fds
=
not
is_windows
)
ssh_response
=
ssh_out
.
stdout
.
readlines
()[
0
]
.
strip
()
if
ssh_response
==
"ok"
:
print
(
"Can connect to the remote machine:
%
s@
%
s."
%
(
self
[
"rsynth_user"
],
self
[
"rsynth_server"
]))
...
...
@@ -173,7 +177,7 @@ class Env(dict):
if
can_connect
and
self
[
remote_path_key
]
is
not
None
:
ssh_cmd
=
'ssh -o BatchMode=yes -o ConnectTimeout=5
%
s@
%
s test -e
%
s 2>&1'
ssh_cmd
=
ssh_cmd
%
(
self
[
"rsynth_user"
],
self
[
"rsynth_server"
],
self
[
remote_path_key
])
ssh_out
=
Popen
(
ssh_cmd
,
shell
=
True
,
stdin
=
PIPE
,
stdout
=
PIPE
,
close_fds
=
True
)
ssh_out
=
Popen
(
ssh_cmd
,
shell
=
True
,
stdin
=
PIPE
,
stdout
=
PIPE
,
close_fds
=
not
is_windows
)
ssh_response
=
ssh_out
.
returncode
if
ssh_response
==
0
:
print
(
"
%
s found on remote machine under
%
s."
%
(
name
,
self
[
remote_path_key
]))
...
...
hdlmake/fetch/git.py
View file @
f307a1db
...
...
@@ -22,6 +22,7 @@
import
os
from
hdlmake.util
import
path
import
logging
import
platform
from
tempfile
import
TemporaryFile
from
subprocess
import
Popen
,
PIPE
from
.constants
import
(
GIT
,
GITSUBMODULE
)
...
...
@@ -168,6 +169,8 @@ submodule.ip_cores/wr-cores.url=git://ohwr.org/hdl-core-lib/wr-cores.git
commit
=
None
stderr
=
TemporaryFile
()
try
:
if
platform
.
system
()
==
'Windows'
:
is_windows
=
True
else
:
is_windows
=
False
os
.
chdir
(
path
)
git_cmd
=
'git log -1 --format="
%
H" | cut -c1-32'
git_out
=
Popen
(
git_cmd
,
...
...
@@ -175,7 +178,7 @@ submodule.ip_cores/wr-cores.url=git://ohwr.org/hdl-core-lib/wr-cores.git
stdin
=
PIPE
,
stdout
=
PIPE
,
stderr
=
stderr
,
close_fds
=
True
)
close_fds
=
not
is_windows
)
errmsg
=
stderr
.
readlines
()
if
errmsg
:
logging
.
debug
(
"git error message (in
%
s):
%
s"
%
(
path
,
'
\n
'
.
join
(
errmsg
)))
...
...
hdlmake/fetch/svn.py
View file @
f307a1db
...
...
@@ -21,6 +21,7 @@
import
os
import
logging
import
platform
from
tempfile
import
TemporaryFile
from
subprocess
import
Popen
,
PIPE
from
hdlmake.util
import
path
...
...
@@ -66,9 +67,11 @@ class Svn(Fetcher):
stderr
=
TemporaryFile
()
try
:
if
platform
.
system
()
==
'Windows'
:
is_windows
=
True
else
:
is_windows
=
False
os
.
chdir
(
path
)
svn_cmd
=
"svn info 2>/dev/null | awk '{if(NR == 5) {print $2}}'"
svn_out
=
Popen
(
svn_cmd
,
shell
=
True
,
stdin
=
PIPE
,
stdout
=
PIPE
,
stderr
=
stderr
,
close_fds
=
True
)
svn_out
=
Popen
(
svn_cmd
,
shell
=
True
,
stdin
=
PIPE
,
stdout
=
PIPE
,
stderr
=
stderr
,
close_fds
=
not
is_windows
)
errmsg
=
stderr
.
readlines
()
if
errmsg
:
logging
.
debug
(
"svn error message (in
%
s):
%
s"
%
(
path
,
'
\n
'
.
join
(
errmsg
)))
...
...
hdlmake/module_pool.py
View file @
f307a1db
...
...
@@ -23,6 +23,7 @@
from
__future__
import
print_function
import
os
import
logging
import
platform
from
subprocess
import
PIPE
,
Popen
import
sys
...
...
@@ -114,14 +115,16 @@ class ModulePool(list):
"""Guess origin (git, svn, local) of a module at given path"""
cwd
=
self
.
top_module
.
path
try
:
if
platform
.
system
()
==
'Windows'
:
is_windows
=
True
else
:
is_windows
=
False
os
.
chdir
(
path
)
git_out
=
Popen
(
"git config --get remote.origin.url"
,
stdout
=
PIPE
,
shell
=
True
,
close_fds
=
True
)
git_out
=
Popen
(
"git config --get remote.origin.url"
,
stdout
=
PIPE
,
shell
=
True
,
close_fds
=
not
is_windows
)
lines
=
git_out
.
stdout
.
readlines
()
if
len
(
lines
)
==
0
:
return
None
url
=
lines
[
0
]
.
strip
()
if
not
url
:
# try svn
svn_out
=
Popen
(
"svn info | grep 'Repository Root' | awk '{print $NF}'"
,
stdout
=
PIPE
,
shell
=
True
,
close_fds
=
True
)
svn_out
=
Popen
(
"svn info | grep 'Repository Root' | awk '{print $NF}'"
,
stdout
=
PIPE
,
shell
=
True
,
close_fds
=
not
is_windows
)
url
=
svn_out
.
stdout
.
readlines
()[
0
]
.
strip
()
if
url
:
return
url
...
...
hdlmake/tools/ise/ise.py
View file @
f307a1db
...
...
@@ -27,6 +27,7 @@ import xml.parsers.expat
import
logging
import
re
import
os
import
platform
import
string
from
subprocess
import
Popen
,
PIPE
...
...
@@ -66,15 +67,9 @@ class ToolControls(MakefileWriter):
return
ISE_STANDARD_LIBS
def
detect_version
(
self
,
path
):
#xst = Popen('which xst', shell=True, stdin=PIPE,
# stdout=PIPE, close_fds=True)
#lines = xst.stdout.readlines()
#if not lines:
# return None
#xst = str(lines[0].strip())
if
platform
.
system
()
==
'Windows'
:
is_windows
=
True
else
:
is_windows
=
False
version_pattern
=
re
.
compile
(
'.*?(?P<major>
\
d|
\
d
\
d)[^
\
d](?P<minor>
\
d|
\
d
\
d).*'
)
# First check if we have version in path
...
...
@@ -83,7 +78,7 @@ class ToolControls(MakefileWriter):
ise_version
=
"
%
s.
%
s"
%
(
match
.
group
(
'major'
),
match
.
group
(
'minor'
))
else
:
# If it is not the case call the "xst -h" to get version
xst_output
=
Popen
(
'xst -h'
,
shell
=
True
,
stdin
=
PIPE
,
stdout
=
PIPE
,
close_fds
=
True
)
stdout
=
PIPE
,
close_fds
=
not
is_windows
)
xst_output
=
xst_output
.
stdout
.
readlines
()[
0
]
xst_output
=
xst_output
.
strip
()
version_pattern
=
re
.
compile
(
'Release
\
s(?P<major>
\
d|
\
d
\
d)[^
\
d](?P<minor>
\
d|
\
d
\
d)
\
s.*'
)
...
...
@@ -99,10 +94,12 @@ class ToolControls(MakefileWriter):
def
generate_remote_synthesis_makefile
(
self
,
files
,
name
,
cwd
,
user
,
server
):
if
platform
.
system
()
==
'Windows'
:
is_windows
=
True
else
:
is_windows
=
False
if
name
is
None
:
import
random
name
=
''
.
join
(
random
.
choice
(
string
.
ascii_letters
+
string
.
digits
)
for
_
in
range
(
8
))
whoami
=
Popen
(
'whoami'
,
shell
=
True
,
stdin
=
PIPE
,
stdout
=
PIPE
,
close_fds
=
True
)
whoami
=
Popen
(
'whoami'
,
shell
=
True
,
stdin
=
PIPE
,
stdout
=
PIPE
,
close_fds
=
not
is_windows
)
name
=
whoami
.
stdout
.
readlines
()[
0
]
.
strip
()
+
'/'
+
name
user_tmpl
=
"USER:={0}"
server_tmpl
=
"SERVER:={0}"
...
...
hdlmake/tools/isim/isim.py
View file @
f307a1db
...
...
@@ -29,6 +29,7 @@ from subprocess import Popen, PIPE
import
logging
import
sys
import
string
import
platform
from
hdlmake.makefile_writer
import
MakefileWriter
...
...
@@ -54,9 +55,11 @@ class ToolControls(MakefileWriter):
return
ISIM_STANDARD_LIBS
def
detect_version
(
self
,
path
):
if
platform
.
system
()
==
'Windows'
:
is_windows
=
True
else
:
is_windows
=
False
isim
=
Popen
(
"
%
s --version | awk '{print $2}'"
%
os
.
path
.
join
(
path
,
"vlogcomp"
),
shell
=
True
,
close_fds
=
True
,
close_fds
=
not
is_windows
,
stdin
=
PIPE
,
stdout
=
PIPE
)
print
os
.
path
.
join
(
path
,
"vlogcomp"
)
...
...
hdlmake/tools/iverilog/iverilog.py
View file @
f307a1db
...
...
@@ -24,6 +24,7 @@
from
subprocess
import
Popen
,
PIPE
import
string
import
os
import
platform
import
logging
from
hdlmake.makefile_writer
import
MakefileWriter
...
...
@@ -51,11 +52,13 @@ class ToolControls(MakefileWriter):
return
IVERILOG_STANDARD_LIBS
def
detect_version
(
self
,
path
):
if
platform
.
system
()
==
'Windows'
:
is_windows
=
True
else
:
is_windows
=
False
iverilog
=
Popen
(
"iverilog -v 2>/dev/null| awk '{if(NR==1) print $4}'"
,
shell
=
True
,
stdin
=
PIPE
,
stdout
=
PIPE
,
close_fds
=
True
)
close_fds
=
not
is_windows
)
version
=
iverilog
.
stdout
.
readlines
()[
0
]
.
strip
()
return
version
...
...
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