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
2db9c7bf
Commit
2db9c7bf
authored
Sep 19, 2019
by
Tristan Gingold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shell: Split check_windows.
THere is now check_windows_tools and check_windows_commands.
parent
e9b5dc57
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
34 additions
and
29 deletions
+34
-29
git.py
hdlmake/fetch/git.py
+1
-1
main.py
hdlmake/main.py
+1
-1
ise.py
hdlmake/tools/ise.py
+2
-2
isim.py
hdlmake/tools/isim.py
+1
-1
make_syn.py
hdlmake/tools/make_syn.py
+4
-4
makefile.py
hdlmake/tools/makefile.py
+3
-3
shell.py
hdlmake/util/shell.py
+15
-13
test_all.py
testsuite/test_all.py
+7
-4
No files found.
hdlmake/fetch/git.py
View file @
2db9c7bf
...
@@ -119,7 +119,7 @@ class Git(Fetcher):
...
@@ -119,7 +119,7 @@ class Git(Fetcher):
config_content
=
Popen
(
"git config -f .gitmodules --list"
,
config_content
=
Popen
(
"git config -f .gitmodules --list"
,
stdout
=
PIPE
,
stdout
=
PIPE
,
stdin
=
PIPE
,
stdin
=
PIPE
,
close_fds
=
not
shell
.
check_windows
(),
close_fds
=
not
shell
.
check_windows
_tools
(),
shell
=
True
)
shell
=
True
)
config_lines
=
[
line
.
strip
()
.
decode
(
'utf-8'
)
for
line
config_lines
=
[
line
.
strip
()
.
decode
(
'utf-8'
)
for
line
in
config_content
.
stdout
.
readlines
()]
in
config_content
.
stdout
.
readlines
()]
...
...
hdlmake/main.py
View file @
2db9c7bf
...
@@ -172,7 +172,7 @@ def set_logging_level(options):
...
@@ -172,7 +172,7 @@ def set_logging_level(options):
if
not
isinstance
(
numeric_level
,
int
):
if
not
isinstance
(
numeric_level
,
int
):
raise
Exception
(
'Invalid log level:
%
s'
%
options
.
log
)
raise
Exception
(
'Invalid log level:
%
s'
%
options
.
log
)
if
not
shell
.
check_windows
()
and
options
.
logfile
==
None
:
if
not
shell
.
check_windows
_tools
()
and
options
.
logfile
==
None
:
logging
.
basicConfig
(
logging
.
basicConfig
(
format
=
colored
(
format
=
colored
(
"
%(levelname)
s"
,
"
%(levelname)
s"
,
...
...
hdlmake/tools/ise.py
View file @
2db9c7bf
...
@@ -118,7 +118,7 @@ $(TCL_CLOSE)'''
...
@@ -118,7 +118,7 @@ $(TCL_CLOSE)'''
'translate'
:
_ISE_RUN
.
format
(
"Translate"
),
'translate'
:
_ISE_RUN
.
format
(
"Translate"
),
'map'
:
_ISE_RUN
.
format
(
"Map"
),
'map'
:
_ISE_RUN
.
format
(
"Map"
),
'par'
:
_ISE_RUN
.
format
(
"Place "
'par'
:
_ISE_RUN
.
format
(
"Place "
+
(
"^&"
if
shell
.
check_windows
()
else
"'&'"
)
+
(
"^&"
if
shell
.
check_windows
_tools
()
else
"'&'"
)
+
" Route"
),
+
" Route"
),
'bitstream'
:
_ISE_RUN
.
format
(
"Generate Programming File"
),
'bitstream'
:
_ISE_RUN
.
format
(
"Generate Programming File"
),
'install_source'
:
"*.bit *.bin"
}
'install_source'
:
"*.bit *.bin"
}
...
@@ -151,7 +151,7 @@ $(TCL_CLOSE)'''
...
@@ -151,7 +151,7 @@ $(TCL_CLOSE)'''
syn_properties
=
self
.
manifest_dict
.
get
(
"syn_properties"
)
syn_properties
=
self
.
manifest_dict
.
get
(
"syn_properties"
)
project_new
=
[]
project_new
=
[]
project_tcl
=
self
.
_tcl_controls
[
"project"
]
project_tcl
=
self
.
_tcl_controls
[
"project"
]
if
shell
.
check_windows
():
if
shell
.
check_windows
_commands
():
tmp
=
'project set "{0}" "{1}"'
tmp
=
'project set "{0}" "{1}"'
else
:
else
:
tmp
=
'project set
\\
"{0}
\\
"
\\
"{1}
\\
"'
tmp
=
'project set
\\
"{0}
\\
"
\\
"{1}
\\
"'
...
...
hdlmake/tools/isim.py
View file @
2db9c7bf
...
@@ -74,7 +74,7 @@ class ToolISim(MakeSim):
...
@@ -74,7 +74,7 @@ class ToolISim(MakeSim):
xilinx_dir
=
str
(
os
.
path
.
join
(
xilinx_dir
=
str
(
os
.
path
.
join
(
self
.
manifest_dict
[
"sim_path"
],
".."
,
".."
))
self
.
manifest_dict
[
"sim_path"
],
".."
,
".."
))
hdl_language
=
'vhdl'
# 'verilog'
hdl_language
=
'vhdl'
# 'verilog'
if
shell
.
check_windows
():
if
shell
.
check_windows
_tools
():
os_prefix
=
'nt'
os_prefix
=
'nt'
else
:
else
:
os_prefix
=
'lin'
os_prefix
=
'lin'
...
...
hdlmake/tools/make_syn.py
View file @
2db9c7bf
...
@@ -48,7 +48,7 @@ class MakeSyn(ToolMakefile):
...
@@ -48,7 +48,7 @@ class MakeSyn(ToolMakefile):
def
_makefile_syn_top
(
self
):
def
_makefile_syn_top
(
self
):
"""Create the top part of the synthesis Makefile"""
"""Create the top part of the synthesis Makefile"""
if
shell
.
check_windows
():
if
shell
.
check_windows
_tools
():
tcl_interpreter
=
self
.
_tool_info
[
"windows_bin"
]
tcl_interpreter
=
self
.
_tool_info
[
"windows_bin"
]
else
:
else
:
tcl_interpreter
=
self
.
_tool_info
[
"linux_bin"
]
tcl_interpreter
=
self
.
_tool_info
[
"linux_bin"
]
...
@@ -125,14 +125,14 @@ endif""")
...
@@ -125,14 +125,14 @@ endif""")
for
command
in
self
.
_tcl_controls
[
"files"
]
.
split
(
'
\n
'
):
for
command
in
self
.
_tcl_controls
[
"files"
]
.
split
(
'
\n
'
):
tcl_command
.
append
(
echo_command
.
format
(
command
))
tcl_command
.
append
(
echo_command
.
format
(
command
))
command_string
=
"
\n
"
.
join
(
tcl_command
)
command_string
=
"
\n
"
.
join
(
tcl_command
)
if
shell
.
check_windows
():
if
shell
.
check_windows
_commands
():
command_string
=
command_string
.
replace
(
"'"
,
""
)
command_string
=
command_string
.
replace
(
"'"
,
""
)
self
.
writeln
(
command_string
)
self
.
writeln
(
command_string
)
for
filetype
in
sources_list
:
for
filetype
in
sources_list
:
filetype_string
=
(
'
\t\t
@$(foreach sourcefile,'
filetype_string
=
(
'
\t\t
@$(foreach sourcefile,'
' $(SOURCES_{0}), echo "{1}" >> $@ &)'
.
format
(
' $(SOURCES_{0}), echo "{1}" >> $@ &)'
.
format
(
filetype
.
__name__
,
fileset_dict
[
filetype
]))
filetype
.
__name__
,
fileset_dict
[
filetype
]))
if
shell
.
check_windows
():
if
shell
.
check_windows
_commands
():
filetype_string
=
filetype_string
.
replace
(
filetype_string
=
filetype_string
.
replace
(
'"'
,
''
)
'"'
,
''
)
self
.
writeln
(
filetype_string
)
self
.
writeln
(
filetype_string
)
...
@@ -155,7 +155,7 @@ endif""")
...
@@ -155,7 +155,7 @@ endif""")
for
command
in
self
.
_tcl_controls
[
stage
]
.
split
(
'
\n
'
):
for
command
in
self
.
_tcl_controls
[
stage
]
.
split
(
'
\n
'
):
tcl_command
.
append
(
echo_command
.
format
(
command
))
tcl_command
.
append
(
echo_command
.
format
(
command
))
command_string
=
"
\n
"
.
join
(
tcl_command
)
command_string
=
"
\n
"
.
join
(
tcl_command
)
if
shell
.
check_windows
():
if
shell
.
check_windows
_commands
():
command_string
=
command_string
.
replace
(
command_string
=
command_string
.
replace
(
"'"
,
""
)
"'"
,
""
)
self
.
writeln
(
"""
\
self
.
writeln
(
"""
\
...
...
hdlmake/tools/makefile.py
View file @
2db9c7bf
...
@@ -74,7 +74,7 @@ class ToolMakefile(object):
...
@@ -74,7 +74,7 @@ class ToolMakefile(object):
def
_get_name_bin
(
self
):
def
_get_name_bin
(
self
):
"""Get the name and binary values"""
"""Get the name and binary values"""
if
shell
.
check_windows
():
if
shell
.
check_windows
_tools
():
bin_name
=
self
.
_tool_info
[
'windows_bin'
]
bin_name
=
self
.
_tool_info
[
'windows_bin'
]
else
:
else
:
bin_name
=
self
.
_tool_info
[
'linux_bin'
]
bin_name
=
self
.
_tool_info
[
'linux_bin'
]
...
@@ -137,7 +137,7 @@ class ToolMakefile(object):
...
@@ -137,7 +137,7 @@ class ToolMakefile(object):
self
.
writeln
(
"clean:"
)
self
.
writeln
(
"clean:"
)
tmp
=
"
\t\t
"
+
shell
.
del_command
()
+
" $(CLEAN_TARGETS)"
tmp
=
"
\t\t
"
+
shell
.
del_command
()
+
" $(CLEAN_TARGETS)"
self
.
writeln
(
tmp
)
self
.
writeln
(
tmp
)
if
shell
.
check_windows
():
if
shell
.
check_windows
_commands
():
tmp
=
"
\t\t
@-"
+
shell
.
rmdir_command
()
+
\
tmp
=
"
\t\t
@-"
+
shell
.
rmdir_command
()
+
\
" $(CLEAN_TARGETS) >nul 2>&1"
" $(CLEAN_TARGETS) >nul 2>&1"
self
.
writeln
(
tmp
)
self
.
writeln
(
tmp
)
...
@@ -170,7 +170,7 @@ class ToolMakefile(object):
...
@@ -170,7 +170,7 @@ class ToolMakefile(object):
if
not
self
.
_initialized
:
if
not
self
.
_initialized
:
self
.
_initialized
=
True
self
.
_initialized
=
True
self
.
initialize
()
self
.
initialize
()
if
shell
.
check_windows
():
if
shell
.
check_windows
_commands
():
self
.
_file
.
write
(
line
.
replace
(
'
\\
"'
,
'"'
))
self
.
_file
.
write
(
line
.
replace
(
'
\\
"'
,
'"'
))
else
:
else
:
self
.
_file
.
write
(
line
)
self
.
_file
.
write
(
line
)
...
...
hdlmake/util/shell.py
View file @
2db9c7bf
...
@@ -39,7 +39,7 @@ def run(command):
...
@@ -39,7 +39,7 @@ def run(command):
stdout
=
PIPE
,
stdout
=
PIPE
,
stdin
=
PIPE
,
stdin
=
PIPE
,
stderr
=
PIPE
,
stderr
=
PIPE
,
close_fds
=
not
check_windows
(),
close_fds
=
not
check_windows
_tools
(),
# FIXME: comment
shell
=
True
)
shell
=
True
)
lines
=
command_out
.
stdout
.
readlines
()
lines
=
command_out
.
stdout
.
readlines
()
if
len
(
lines
)
==
0
:
if
len
(
lines
)
==
0
:
...
@@ -56,17 +56,19 @@ def tclpath(path):
...
@@ -56,17 +56,19 @@ def tclpath(path):
return
path
.
replace
(
slash_char
(),
"/"
)
return
path
.
replace
(
slash_char
(),
"/"
)
def
check_windows
():
def
check_windows_tools
():
"""Check if we are operating on a Windows filesystem"""
"""Check if we are using windows version of synthesis/simulation tools"""
if
platform
.
system
()
==
'Windows'
or
sys
.
platform
==
'cygwin'
:
return
platform
.
system
()
==
'Windows'
or
sys
.
platform
==
'cygwin'
return
True
else
:
def
check_windows_commands
():
return
False
"""Check if we are using windows commands (del/type).
False on cygwin"""
return
platform
.
system
()
==
'Windows'
def
del_command
():
def
del_command
():
"""Get a string with the O.S. specific delete command"""
"""Get a string with the O.S. specific delete command"""
if
check_windows
():
if
check_windows
_commands
():
return
"del /s /q /f"
return
"del /s /q /f"
else
:
else
:
return
"rm -rf"
return
"rm -rf"
...
@@ -74,7 +76,7 @@ def del_command():
...
@@ -74,7 +76,7 @@ def del_command():
def
rmdir_command
():
def
rmdir_command
():
"""Get a string with the O.S. specific remove directory command"""
"""Get a string with the O.S. specific remove directory command"""
if
check_windows
():
if
check_windows
_commands
():
return
"rmdir /s /q"
return
"rmdir /s /q"
else
:
else
:
return
"rm -rf"
return
"rm -rf"
...
@@ -82,7 +84,7 @@ def rmdir_command():
...
@@ -82,7 +84,7 @@ def rmdir_command():
def
copy_command
():
def
copy_command
():
"""Get a string with the O.S. specific copy command"""
"""Get a string with the O.S. specific copy command"""
if
check_windows
():
if
check_windows
_commands
():
return
"copy"
return
"copy"
else
:
else
:
return
"cp"
return
"cp"
...
@@ -90,7 +92,7 @@ def copy_command():
...
@@ -90,7 +92,7 @@ def copy_command():
def
mkdir_command
():
def
mkdir_command
():
"""Get a string with the O.S. specific mkdir command"""
"""Get a string with the O.S. specific mkdir command"""
if
check_windows
():
if
check_windows
_commands
():
return
"mkdir"
return
"mkdir"
else
:
else
:
return
"mkdir -p"
return
"mkdir -p"
...
@@ -98,7 +100,7 @@ def mkdir_command():
...
@@ -98,7 +100,7 @@ def mkdir_command():
def
touch_command
():
def
touch_command
():
"""Get a string with the O.S. specific mkdir command"""
"""Get a string with the O.S. specific mkdir command"""
if
check_windows
():
if
check_windows
_commands
():
return
"type nul >>"
return
"type nul >>"
else
:
else
:
return
"touch"
return
"touch"
...
@@ -117,7 +119,7 @@ def which(filename):
...
@@ -117,7 +119,7 @@ def which(filename):
def
slash_char
():
def
slash_char
():
"""Get a string with the O.S. specific path separator"""
"""Get a string with the O.S. specific path separator"""
if
check_windows
():
if
check_windows
_tools
():
return
"
\\
"
return
"
\\
"
else
:
else
:
return
"/"
return
"/"
...
...
testsuite/test_all.py
View file @
2db9c7bf
...
@@ -12,7 +12,8 @@ class Config(object):
...
@@ -12,7 +12,8 @@ class Config(object):
def
__init__
(
self
,
path
=
None
,
check_windows
=
False
,
fakebin
=
"linux_fakebin"
):
def
__init__
(
self
,
path
=
None
,
check_windows
=
False
,
fakebin
=
"linux_fakebin"
):
self
.
path
=
path
self
.
path
=
path
self
.
prev_env_path
=
os
.
environ
[
'PATH'
]
self
.
prev_env_path
=
os
.
environ
[
'PATH'
]
self
.
prev_check_windows
=
hdlmake
.
util
.
shell
.
check_windows
self
.
prev_check_windows_commands
=
hdlmake
.
util
.
shell
.
check_windows_commands
self
.
prev_check_windows_tools
=
hdlmake
.
util
.
shell
.
check_windows_tools
self
.
check_windows
=
check_windows
self
.
check_windows
=
check_windows
self
.
fakebin
=
fakebin
self
.
fakebin
=
fakebin
...
@@ -22,13 +23,15 @@ class Config(object):
...
@@ -22,13 +23,15 @@ class Config(object):
+
self
.
prev_env_path
)
+
self
.
prev_env_path
)
if
self
.
path
is
not
None
:
if
self
.
path
is
not
None
:
os
.
chdir
(
self
.
path
)
os
.
chdir
(
self
.
path
)
hdlmake
.
util
.
shell
.
check_windows
=
(
lambda
:
self
.
check_windows
)
hdlmake
.
util
.
shell
.
check_windows_tools
=
(
lambda
:
self
.
check_windows
)
hdlmake
.
util
.
shell
.
check_windows_commands
=
(
lambda
:
self
.
check_windows
)
def
__exit__
(
self
,
*
_
):
def
__exit__
(
self
,
*
_
):
if
self
.
path
is
not
None
:
if
self
.
path
is
not
None
:
os
.
chdir
(
".."
)
os
.
chdir
(
".."
)
os
.
environ
[
'PATH'
]
=
self
.
prev_env_path
os
.
environ
[
'PATH'
]
=
self
.
prev_env_path
hdlmake
.
util
.
shell
.
check_windows
=
self
.
prev_check_windows
hdlmake
.
util
.
shell
.
check_windows_tools
=
self
.
prev_check_windows_tools
hdlmake
.
util
.
shell
.
check_windows_commands
=
self
.
prev_check_windows_commands
def
compare_makefile
():
def
compare_makefile
():
ref
=
open
(
'Makefile.ref'
,
'r'
)
.
read
()
ref
=
open
(
'Makefile.ref'
,
'r'
)
.
read
()
...
@@ -399,7 +402,7 @@ def test_dep_level():
...
@@ -399,7 +402,7 @@ def test_dep_level():
run
([
'list-files'
,
'--top'
,
'level2'
],
path
=
"053vlog_dep_level"
)
run
([
'list-files'
,
'--top'
,
'level2'
],
path
=
"053vlog_dep_level"
)
def
test_modelsim_windows
():
def
test_modelsim_windows
():
assert
hdlmake
.
util
.
shell
.
check_windows
()
is
False
assert
hdlmake
.
util
.
shell
.
check_windows
_tools
()
is
False
run_compare
(
path
=
"057msim_windows"
,
check_windows
=
True
)
run_compare
(
path
=
"057msim_windows"
,
check_windows
=
True
)
def
test_nosim_tool
():
def
test_nosim_tool
():
...
...
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