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
e773bd4b
Commit
e773bd4b
authored
May 23, 2017
by
Javier D. Garcia-Lasheras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create a separated util package with the shell dependent stuff
parent
7a62dd99
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
182 additions
and
152 deletions
+182
-152
action.py
hdlmake/action/action.py
+4
-4
fetcher.py
hdlmake/fetch/fetcher.py
+2
-2
git.py
hdlmake/fetch/git.py
+3
-2
module.py
hdlmake/module/module.py
+3
-2
ise.py
hdlmake/tools/ise.py
+3
-3
isim.py
hdlmake/tools/isim.py
+19
-19
make_sim.py
hdlmake/tools/make_sim.py
+3
-3
make_syn.py
hdlmake/tools/make_syn.py
+8
-8
makefile.py
hdlmake/tools/makefile.py
+8
-8
quartus.py
hdlmake/tools/quartus.py
+4
-3
sim_makefile_support.py
hdlmake/tools/sim_makefile_support.py
+10
-10
path.py
hdlmake/util/path.py
+0
-88
shell.py
hdlmake/util/shell.py
+115
-0
No files found.
hdlmake/action/action.py
View file @
e773bd4b
...
...
@@ -29,7 +29,7 @@ import logging
from
subprocess
import
PIPE
,
Popen
import
sys
from
hdlmake.util
import
path
as
path_mod
from
hdlmake.util
import
shell
from
hdlmake.util.termcolor
import
colored
from
hdlmake
import
new_dep_solver
as
dep_solver
...
...
@@ -40,7 +40,7 @@ def set_logging_level(options):
if
not
isinstance
(
numeric_level
,
int
):
sys
.
exit
(
'Invalid log level:
%
s'
%
options
.
log
)
if
not
path_mod
.
check_windows
():
if
not
shell
.
check_windows
():
logging
.
basicConfig
(
format
=
colored
(
"
%(levelname)
s"
,
...
...
@@ -161,7 +161,7 @@ class Action(list):
for
mod
in
self
:
manifest_dict_tmp
=
mod
.
manifest_dict
if
'fetchto'
in
manifest_dict_tmp
:
manifest_dict_tmp
[
'fetchto'
]
=
path_mod
.
relpath
(
os
.
path
.
join
(
manifest_dict_tmp
[
'fetchto'
]
=
os
.
path
.
relpath
(
os
.
path
.
join
(
mod
.
path
,
mod
.
manifest_dict
[
'fetchto'
]))
manifest_dict_tmp
.
update
(
config_dict
)
...
...
@@ -192,7 +192,7 @@ class Action(list):
"""Guess origin (git, svn, local) of a module at given path"""
cwd
=
self
.
top_module
.
path
try
:
is_windows
=
path_mod
.
check_windows
()
is_windows
=
shell
.
check_windows
()
os
.
chdir
(
path
)
git_out
=
Popen
(
"git config --get remote.origin.url"
,
stdout
=
PIPE
,
shell
=
True
,
close_fds
=
not
is_windows
)
...
...
hdlmake/fetch/fetcher.py
View file @
e773bd4b
...
...
@@ -23,7 +23,7 @@
from
__future__
import
absolute_import
import
os
from
hdlmake.util
import
path
as
path_utils
from
hdlmake.util
import
shell
import
logging
from
tempfile
import
TemporaryFile
from
subprocess
import
Popen
,
PIPE
...
...
@@ -45,7 +45,7 @@ class Fetcher(object):
identifier
=
None
stderr
=
TemporaryFile
()
try
:
is_windows
=
path_utils
.
check_windows
()
is_windows
=
shell
.
check_windows
()
os
.
chdir
(
path
)
command_out
=
Popen
(
command
,
...
...
hdlmake/fetch/git.py
View file @
e773bd4b
...
...
@@ -24,6 +24,7 @@
from
__future__
import
absolute_import
import
os
from
hdlmake.util
import
path
as
path_utils
from
hdlmake.util
import
shell
import
logging
from
subprocess
import
Popen
,
PIPE
,
CalledProcessError
from
.constants
import
GIT
...
...
@@ -45,7 +46,7 @@ class Git(Fetcher):
tree_root_cmd
=
Popen
(
"git rev-parse --show-toplevel"
,
stdout
=
PIPE
,
stdin
=
PIPE
,
close_fds
=
not
path_utils
.
check_windows
(),
close_fds
=
not
shell
.
check_windows
(),
shell
=
True
)
tree_root_line
=
tree_root_cmd
.
stdout
.
readlines
()[
0
]
.
strip
()
return
tree_root_line
...
...
@@ -63,7 +64,7 @@ class Git(Fetcher):
stdout
=
PIPE
,
stdin
=
PIPE
,
stderr
=
PIPE
,
close_fds
=
not
path_utils
.
check_windows
(),
close_fds
=
not
shell
.
check_windows
(),
shell
=
True
)
status_output
=
status_cmd
.
stdout
.
readlines
()
if
len
(
status_output
)
==
1
:
...
...
hdlmake/module/module.py
View file @
e773bd4b
...
...
@@ -34,6 +34,7 @@ import logging
from
subprocess
import
Popen
,
PIPE
,
CalledProcessError
from
hdlmake.util
import
path
as
path_mod
from
hdlmake.util
import
shell
from
hdlmake.manifest_parser
import
ManifestParser
from
.content
import
ModuleContent
import
six
...
...
@@ -103,12 +104,12 @@ class Module(ModuleContent):
return
logging
.
debug
(
"Removing "
+
self
.
path
)
try
:
command_tmp
=
path_mod
.
rmdir_command
()
+
" "
+
self
.
path
command_tmp
=
shell
.
rmdir_command
()
+
" "
+
self
.
path
Popen
(
command_tmp
,
stdout
=
PIPE
,
stdin
=
PIPE
,
stderr
=
PIPE
,
close_fds
=
not
path_mod
.
check_windows
(),
close_fds
=
not
shell
.
check_windows
(),
shell
=
True
)
except
CalledProcessError
as
process_error
:
logging
.
error
(
"Cannot clean the module:
%
s"
,
...
...
hdlmake/tools/ise.py
View file @
e773bd4b
...
...
@@ -29,7 +29,7 @@ import logging
from
.make_syn
import
ToolSyn
from
hdlmake.util
import
path
as
path_mod
from
hdlmake.util
import
shell
from
hdlmake.srcfile
import
(
VHDLFile
,
VerilogFile
,
SVFile
,
UCFFile
,
CDCFile
,
NGCFile
)
...
...
@@ -115,7 +115,7 @@ $(TCL_CLOSE)'''
'translate'
:
_ISE_RUN
.
format
(
"Translate"
),
'map'
:
_ISE_RUN
.
format
(
"Map"
),
'par'
:
_ISE_RUN
.
format
(
"Place "
+
(
"^&"
if
path_mod
.
check_windows
()
else
"'&'"
)
+
(
"^&"
if
shell
.
check_windows
()
else
"'&'"
)
+
" Route"
),
'bitstream'
:
_ISE_RUN
.
format
(
"Generate Programming File"
),
'install_source'
:
"*.bit *.bin"
}
...
...
@@ -149,7 +149,7 @@ $(TCL_CLOSE)'''
syn_properties
=
self
.
manifest_dict
.
get
(
"syn_properties"
)
project_new
=
[]
project_tcl
=
self
.
_tcl_controls
[
"project"
]
if
path_mod
.
check_windows
():
if
shell
.
check_windows
():
tmp
=
'project set "{0}" "{1}"'
else
:
tmp
=
'project set
\\
"{0}
\\
"
\\
"{1}
\\
"'
...
...
hdlmake/tools/isim.py
View file @
e773bd4b
...
...
@@ -31,7 +31,7 @@ import os.path
import
logging
from
.make_sim
import
ToolSim
from
hdlmake.util
import
path
as
path_mod
from
hdlmake.util
import
shell
from
hdlmake.srcfile
import
VerilogFile
,
VHDLFile
...
...
@@ -78,11 +78,11 @@ class ToolISim(ToolSim):
logging
.
error
(
"Cannot calculate xilinx tools base directory"
)
quit
()
hdl_language
=
'vhdl'
# 'verilog'
if
path_mod
.
check_windows
():
if
shell
.
check_windows
():
os_prefix
=
'nt'
else
:
os_prefix
=
'lin'
if
path_mod
.
architecture
()
==
32
:
if
shell
.
architecture
()
==
32
:
arch_sufix
=
''
else
:
arch_sufix
=
'64'
...
...
@@ -136,7 +136,7 @@ VLOGCOMP_FLAGS := -intstyle default -incremental -initfile xilinxsim.ini """ +
self
.
write
(
'
\n
'
)
# tell how to make libraries
self
.
write
(
'LIB_IND := '
)
self
.
write
(
' '
.
join
([
lib
+
path_mod
.
slash_char
()
+
self
.
write
(
' '
.
join
([
lib
+
shell
.
slash_char
()
+
"."
+
lib
for
lib
in
libs
]))
self
.
write
(
'
\n
'
)
self
.
writeln
(
"""
\
...
...
@@ -146,8 +146,8 @@ $(VHDL_OBJ): $(LIB_IND) xilinxsim.ini
"""
)
self
.
writeln
(
"xilinxsim.ini: $(XILINX_INI_PATH)"
+
path_mod
.
slash_char
()
+
"xilinxsim.ini"
)
self
.
writeln
(
"
\t\t
"
+
path_mod
.
copy_command
()
+
" $< ."
)
shell
.
slash_char
()
+
"xilinxsim.ini"
)
self
.
writeln
(
"
\t\t
"
+
shell
.
copy_command
()
+
" $< ."
)
self
.
writeln
(
"""
\
fuse:
\t\t
fuse work.$(TOP_MODULE) -intstyle ise -incremental -o $(FUSE_OUTPUT)
...
...
@@ -156,11 +156,11 @@ fuse:
# ISim does not have a vmap command to insert additional libraries in
#.ini file.
for
lib
in
libs
:
self
.
write
(
lib
+
path_mod
.
slash_char
()
+
"."
+
lib
+
":
\n
"
)
self
.
write
(
lib
+
shell
.
slash_char
()
+
"."
+
lib
+
":
\n
"
)
self
.
write
(
' '
.
join
([
"
\t
("
+
path_mod
.
mkdir_command
(),
lib
,
"&&"
,
path_mod
.
touch_command
(),
lib
+
path_mod
.
slash_char
()
+
"."
+
lib
+
" "
]))
' '
.
join
([
"
\t
("
+
shell
.
mkdir_command
(),
lib
,
"&&"
,
shell
.
touch_command
(),
lib
+
shell
.
slash_char
()
+
"."
+
lib
+
" "
]))
# self.write(' '.join(["&&", "echo", "\""+lib+"="+lib+"/."+lib+"\"
# ", ">>", "xilinxsim.ini) "]))
self
.
write
(
...
...
@@ -169,7 +169,7 @@ fuse:
lib
+
"="
+
lib
,
" >>"
,
"xilinxsim.ini) "
]))
self
.
write
(
' '
.
join
([
"||"
,
path_mod
.
del_command
(),
lib
,
"
\n
"
]))
self
.
write
(
' '
.
join
([
"||"
,
shell
.
del_command
(),
lib
,
"
\n
"
]))
self
.
write
(
'
\n
'
)
# Modify xilinxsim.ini file by including the extra local libraries
# self.write(' '.join(["\t(echo """, lib+"="+lib+"/."+lib, ">>",
...
...
@@ -197,7 +197,7 @@ fuse:
self
.
writeln
(
' '
.
join
([
fname
.
rel_path
()
for
fname
in
vl_file
.
depends_on
]))
self
.
write
(
"
\t\t
vlogcomp -work "
+
vl_file
.
library
+
"=."
+
path_mod
.
slash_char
()
+
vl_file
.
library
)
+
"=."
+
shell
.
slash_char
()
+
vl_file
.
library
)
self
.
write
(
" $(VLOGCOMP_FLAGS) "
)
# if isinstance(vl_file, SVFile):
# self.write(" -sv ")
...
...
@@ -208,8 +208,8 @@ fuse:
self
.
write
(
' -i '
)
self
.
write
(
' '
.
join
(
vl_file
.
include_dirs
)
+
' '
)
self
.
writeln
(
vl_file
.
vlog_opt
+
" $<"
)
self
.
write
(
"
\t\t
@"
+
path_mod
.
mkdir_command
()
+
" $(dir $@)"
)
self
.
writeln
(
" && "
+
path_mod
.
touch_command
()
+
" $@
\n\n
"
)
self
.
write
(
"
\t\t
@"
+
shell
.
mkdir_command
()
+
" $(dir $@)"
)
self
.
writeln
(
" && "
+
shell
.
touch_command
()
+
" $@
\n\n
"
)
self
.
write
(
"
\n
"
)
# list rules for all _primary.dat files for vhdl
for
vhdl_file
in
fileset
.
filter
(
VHDLFile
):
...
...
@@ -236,10 +236,10 @@ fuse:
' '
.
join
([
"
\t\t
vhpcomp $(VHPCOMP_FLAGS)"
,
vhdl_file
.
vcom_opt
,
"-work"
,
lib
+
"=."
+
path_mod
.
slash_char
()
+
lib
,
lib
+
"=."
+
shell
.
slash_char
()
+
lib
,
"$< "
]))
self
.
writeln
(
"
\t\t
@"
+
path_mod
.
mkdir_command
()
+
" $(dir $@) && "
+
path_mod
.
touch_command
()
+
" $@
\n
"
)
self
.
writeln
(
"
\t\t
@"
+
shell
.
mkdir_command
()
+
" $(dir $@) && "
+
shell
.
touch_command
()
+
" $@
\n
"
)
self
.
writeln
()
# dependency meta-target.
# This rule just list the dependencies of the above file
...
...
@@ -260,5 +260,5 @@ fuse:
else
:
self
.
write
(
"
\\\n
"
+
os
.
path
.
join
(
dep_file
.
rel_path
()))
self
.
write
(
'
\n
'
)
self
.
writeln
(
"
\t\t
@"
+
path_mod
.
mkdir_command
()
+
" $(dir $@) && "
+
path_mod
.
touch_command
()
+
" $@
\n
"
)
self
.
writeln
(
"
\t\t
@"
+
shell
.
mkdir_command
()
+
" $(dir $@) && "
+
shell
.
touch_command
()
+
" $@
\n
"
)
hdlmake/tools/make_sim.py
View file @
e773bd4b
...
...
@@ -7,7 +7,7 @@ import string
import
logging
from
.makefile
import
ToolMakefile
from
hdlmake.util
import
path
as
path_mod
from
hdlmake.util
import
shell
from
hdlmake.srcfile
import
VerilogFile
,
VHDLFile
,
SVFile
from
hdlmake.dep_file
import
DepFile
...
...
@@ -149,8 +149,8 @@ PWD := $$(shell pwd)
isinstance
(
file_aux
,
SVFile
)):
command_key
=
'vlog'
self
.
writeln
(
"
\t\t
"
+
self
.
_simulator_controls
[
command_key
])
self
.
write
(
"
\t\t
@"
+
path_mod
.
mkdir_command
()
+
" $(dir $@)"
)
self
.
writeln
(
" && "
+
path_mod
.
touch_command
()
+
" $@
\n
"
)
self
.
write
(
"
\t\t
@"
+
shell
.
mkdir_command
()
+
" $(dir $@)"
)
self
.
writeln
(
" && "
+
shell
.
touch_command
()
+
" $@
\n
"
)
self
.
writeln
()
def
makefile_sim_command
(
self
):
...
...
hdlmake/tools/make_syn.py
View file @
e773bd4b
...
...
@@ -6,7 +6,7 @@ import logging
import
string
from
.makefile
import
ToolMakefile
from
hdlmake.util
import
path
as
path_mod
from
hdlmake.util
import
shell
def
_check_synthesis_manifest
(
manifest_dict
):
...
...
@@ -73,7 +73,7 @@ class ToolSyn(ToolMakefile):
def
makefile_syn_top
(
self
):
"""Create the top part of the synthesis Makefile"""
if
path_mod
.
check_windows
():
if
shell
.
check_windows
():
tcl_interpreter
=
self
.
_tool_info
[
"windows_bin"
]
else
:
tcl_interpreter
=
self
.
_tool_info
[
"linux_bin"
]
...
...
@@ -129,7 +129,7 @@ endif""")
file_list
=
[]
for
file_aux
in
self
.
fileset
:
if
isinstance
(
file_aux
,
filetype
):
file_list
.
append
(
path_mod
.
tclpath
(
file_aux
.
rel_path
()))
file_list
.
append
(
shell
.
tclpath
(
file_aux
.
rel_path
()))
if
not
file_list
==
[]:
ret
.
append
(
'SOURCES_{0} :=
\\\n
'
...
...
@@ -145,14 +145,14 @@ endif""")
for
command
in
self
.
_tcl_controls
[
"files"
]
.
split
(
'
\n
'
):
tcl_command
.
append
(
echo_command
.
format
(
command
))
command_string
=
"
\n
"
.
join
(
tcl_command
)
if
path_mod
.
check_windows
():
if
shell
.
check_windows
():
command_string
=
command_string
.
replace
(
"'"
,
""
)
self
.
writeln
(
command_string
)
for
filetype
in
sources_list
:
filetype_string
=
(
'
\t\t
@$(foreach sourcefile,'
' $(SOURCES_{0}), echo "{1}" >> $@ &)'
.
format
(
filetype
.
__name__
,
fileset_dict
[
filetype
]))
if
path_mod
.
check_windows
():
if
shell
.
check_windows
():
filetype_string
=
filetype_string
.
replace
(
'"'
,
''
)
self
.
writeln
(
filetype_string
)
...
...
@@ -175,7 +175,7 @@ endif""")
for
command
in
self
.
_tcl_controls
[
stage
]
.
split
(
'
\n
'
):
tcl_command
.
append
(
echo_command
.
format
(
command
))
command_string
=
"
\n
"
.
join
(
tcl_command
)
if
path_mod
.
check_windows
():
if
shell
.
check_windows
():
command_string
=
command_string
.
replace
(
"'"
,
""
)
self
.
writeln
(
"""
\
...
...
@@ -188,7 +188,7 @@ endif""")
\t\t
$(SYN_POST_{2}_CMD)
\t\t
{4} $@
"""
.
format
(
stage
,
stage_previous
,
stage
.
upper
(),
command_string
,
path_mod
.
touch_command
()))
command_string
,
shell
.
touch_command
()))
stage_previous
=
stage
def
makefile_syn_command
(
self
):
...
...
@@ -207,7 +207,7 @@ SYN_POST_{0}_CMD := {2}
def
makefile_syn_clean
(
self
):
"""Print the Makefile clean target for synthesis"""
self
.
makefile_clean
()
self
.
writeln
(
"
\t\t
"
+
path_mod
.
del_command
()
+
self
.
writeln
(
"
\t\t
"
+
shell
.
del_command
()
+
" project synthesize translate map par bitstream"
)
self
.
writeln
()
self
.
makefile_mrproper
()
...
...
hdlmake/tools/makefile.py
View file @
e773bd4b
...
...
@@ -28,7 +28,7 @@ import os
import
logging
import
six
from
hdlmake.util
import
path
as
path_mod
from
hdlmake.util
import
shell
class
ToolMakefile
(
object
):
...
...
@@ -62,7 +62,7 @@ class ToolMakefile(object):
def
_get_name_bin
(
self
):
"""Get the name and binary values"""
if
path_mod
.
check_windows
():
if
shell
.
check_windows
():
bin_name
=
self
.
_tool_info
[
'windows_bin'
]
else
:
bin_name
=
self
.
_tool_info
[
'linux_bin'
]
...
...
@@ -71,7 +71,7 @@ class ToolMakefile(object):
def
_get_path
(
self
):
"""Get the directory in which the tool binary is at Host"""
bin_name
=
self
.
_get_name_bin
()
locations
=
path_mod
.
which
(
bin_name
)
locations
=
shell
.
which
(
bin_name
)
if
len
(
locations
)
==
0
:
return
logging
.
debug
(
"location for
%
s:
%
s"
,
bin_name
,
locations
[
0
])
...
...
@@ -131,17 +131,17 @@ class ToolMakefile(object):
self
.
writeln
(
"CLEAN_TARGETS := $(LIBS) "
+
' '
.
join
(
self
.
_clean_targets
[
"clean"
])
+
"
\n
"
)
self
.
writeln
(
"clean:"
)
tmp
=
"
\t\t
"
+
path_mod
.
del_command
()
+
" $(CLEAN_TARGETS)"
tmp
=
"
\t\t
"
+
shell
.
del_command
()
+
" $(CLEAN_TARGETS)"
self
.
writeln
(
tmp
)
if
path_mod
.
check_windows
():
tmp
=
"
\t\t
@-"
+
path_mod
.
rmdir_command
()
+
\
if
shell
.
check_windows
():
tmp
=
"
\t\t
@-"
+
shell
.
rmdir_command
()
+
\
" $(CLEAN_TARGETS) >nul 2>&1"
self
.
writeln
(
tmp
)
def
makefile_mrproper
(
self
):
"""Print the Makefile target for cleaning final files"""
self
.
writeln
(
"mrproper: clean"
)
tmp
=
"
\t\t
"
+
path_mod
.
del_command
()
+
\
tmp
=
"
\t\t
"
+
shell
.
del_command
()
+
\
" "
+
' '
.
join
(
self
.
_clean_targets
[
"mrproper"
])
+
"
\n
"
self
.
writeln
(
tmp
)
...
...
@@ -168,7 +168,7 @@ class ToolMakefile(object):
"""Write a string in the manifest, no new line"""
if
not
self
.
_initialized
:
self
.
initialize
()
if
path_mod
.
check_windows
():
if
shell
.
check_windows
():
self
.
_file
.
write
(
line
.
replace
(
'
\\
"'
,
'"'
))
else
:
self
.
_file
.
write
(
line
)
...
...
hdlmake/tools/quartus.py
View file @
e773bd4b
...
...
@@ -30,6 +30,7 @@ import logging
from
.make_syn
import
ToolSyn
from
hdlmake.util
import
path
as
path_mod
from
hdlmake.util
import
shell
from
hdlmake.srcfile
import
(
VHDLFile
,
VerilogFile
,
SVFile
,
DPFFile
,
SignalTapFile
,
SDCFile
,
QIPFile
,
QSYSFile
,
QSFFile
,
BSFFile
,
BDFFile
,
TDFFile
,
GDFFile
)
...
...
@@ -202,7 +203,7 @@ class ToolQuartus(ToolSyn):
# Insert the Quartus standard control TCL files
command_list
=
[]
if
"quartus_preflow"
in
self
.
manifest_dict
:
path
=
path_mod
.
tclpath
(
path_mod
.
compose
(
path
=
shell
.
tclpath
(
path_mod
.
compose
(
self
.
manifest_dict
[
"quartus_preflow"
],
os
.
getcwd
()))
if
not
os
.
path
.
exists
(
path
):
logging
.
error
(
"quartus_preflow file listed in "
...
...
@@ -214,7 +215,7 @@ class ToolQuartus(ToolSyn):
{
'name_type'
:
'PRE_FLOW_SCRIPT_FILE'
,
'name'
:
preflow
}))
if
"quartus_postmodule"
in
self
.
manifest_dict
:
path
=
path_mod
.
tclpath
(
path_mod
.
compose
(
path
=
shell
.
tclpath
(
path_mod
.
compose
(
self
.
manifest_dict
[
"quartus_postmodule"
],
os
.
getcwd
()))
if
not
os
.
path
.
exists
(
path
):
...
...
@@ -227,7 +228,7 @@ class ToolQuartus(ToolSyn):
{
'name_type'
:
'POST_MODULE_SCRIPT_FILE'
,
'name'
:
postmodule
}))
if
"quartus_postflow"
in
self
.
manifest_dict
:
path
=
path_mod
.
tclpath
(
path_mod
.
compose
(
path
=
shell
.
tclpath
(
path_mod
.
compose
(
self
.
manifest_dict
[
"quartus_postflow"
],
os
.
getcwd
()))
if
not
os
.
path
.
exists
(
path
):
logging
.
error
(
"quartus_postflow file listed in "
...
...
hdlmake/tools/sim_makefile_support.py
View file @
e773bd4b
...
...
@@ -28,7 +28,7 @@ import os
import
string
from
.make_sim
import
ToolSim
from
hdlmake.util
import
path
as
path_mod
from
hdlmake.util
import
shell
from
hdlmake.srcfile
import
VerilogFile
,
VHDLFile
,
SVFile
import
six
...
...
@@ -96,7 +96,7 @@ class VsimMakefileWriter(ToolSim):
copying it to the local directory."""
rule
=
"""
%
s:
%
s
\t\t
%
s $< . 2>&1
"""
%
(
name
,
src
,
path_mod
.
copy_command
())
"""
%
(
name
,
src
,
shell
.
copy_command
())
return
rule
fileset
=
self
.
fileset
# self.writeln("INCLUDE_DIRS := +incdir+%s" %
...
...
@@ -107,7 +107,7 @@ class VsimMakefileWriter(ToolSim):
self
.
write
(
'
\n
'
)
# tell how to make libraries
self
.
write
(
'LIB_IND := '
)
self
.
write
(
' '
.
join
([
lib
+
path_mod
.
slash_char
()
+
self
.
write
(
' '
.
join
([
lib
+
shell
.
slash_char
()
+
"."
+
lib
for
lib
in
libs
]))
self
.
write
(
'
\n
'
)
self
.
writeln
()
...
...
@@ -123,12 +123,12 @@ class VsimMakefileWriter(ToolSim):
for
filename
,
filesource
in
six
.
iteritems
(
self
.
copy_rules
):
self
.
write
(
__create_copy_rule
(
filename
,
filesource
))
for
lib
in
libs
:
self
.
write
(
lib
+
path_mod
.
slash_char
()
+
"."
+
lib
+
":
\n
"
)
self
.
write
(
lib
+
shell
.
slash_char
()
+
"."
+
lib
+
":
\n
"
)
vmap_command
=
"vmap $(VMAP_FLAGS)"
self
.
write
(
' '
.
join
([
"
\t
(vlib"
,
lib
,
"&&"
,
vmap_command
,
lib
,
"&&"
,
path_mod
.
touch_command
(),
lib
+
path_mod
.
slash_char
()
+
shell
.
touch_command
(),
lib
+
shell
.
slash_char
()
+
"."
+
lib
,
")"
]))
self
.
write
(
' '
.
join
([
"||"
,
path_mod
.
del_command
(),
lib
,
"
\n
"
]))
self
.
write
(
' '
.
join
([
"||"
,
shell
.
del_command
(),
lib
,
"
\n
"
]))
self
.
write
(
'
\n\n
'
)
# rules for all _primary.dat files for sv
for
vlog
in
fileset
.
filter
(
VerilogFile
):
...
...
@@ -163,8 +163,8 @@ class VsimMakefileWriter(ToolSim):
library
=
vlog
.
library
,
sv_option
=
"-sv"
if
isinstance
(
vlog
,
SVFile
)
else
""
)
self
.
writeln
(
compile_line
)
self
.
write
(
"
\t\t
@"
+
path_mod
.
mkdir_command
()
+
" $(dir $@)"
)
self
.
writeln
(
" && "
+
path_mod
.
touch_command
()
+
" $@
\n\n
"
)
self
.
write
(
"
\t\t
@"
+
shell
.
mkdir_command
()
+
" $(dir $@)"
)
self
.
writeln
(
" && "
+
shell
.
touch_command
()
+
" $@
\n\n
"
)
self
.
writeln
()
# list rules for all _primary.dat files for vhdl
for
vhdl
in
fileset
.
filter
(
VHDLFile
):
...
...
@@ -187,5 +187,5 @@ class VsimMakefileWriter(ToolSim):
self
.
writeln
()
self
.
writeln
(
' '
.
join
([
"
\t\t
vcom $(VCOM_FLAGS)"
,
vhdl
.
vcom_opt
,
"-work"
,
lib
,
"$< "
]))
self
.
writeln
(
"
\t\t
@"
+
path_mod
.
mkdir_command
()
+
" $(dir $@) && "
+
path_mod
.
touch_command
()
+
" $@
\n\n
"
)
self
.
writeln
(
"
\t\t
@"
+
shell
.
mkdir_command
()
+
" $(dir $@) && "
+
shell
.
touch_command
()
+
" $@
\n\n
"
)
hdlmake/util/path.py
View file @
e773bd4b
...
...
@@ -25,8 +25,6 @@
from
__future__
import
print_function
from
__future__
import
absolute_import
import
os
import
sys
import
platform
def
url_parse
(
url
):
...
...
@@ -110,11 +108,6 @@ def is_abs_path(path):
return
os
.
path
.
isabs
(
path
)
def
tclpath
(
path
):
"""Convert a O.S. specific path into a TCL friendly one"""
return
path
.
replace
(
slash_char
(),
"/"
)
def
relpath
(
path1
,
path2
=
None
):
"""Return the relative path of one path with respect to the other"""
if
path2
is
None
:
...
...
@@ -158,84 +151,3 @@ def flatten_list(sth):
else
:
sth
=
[]
return
sth
def
check_windows
():
"""Check if we are operating on a Windows filesystem"""
if
platform
.
system
()
==
'Windows'
or
sys
.
platform
==
'cygwin'
:
return
True
else
:
return
False
def
del_command
():
"""Get a string with the O.S. specific delete command"""
if
check_windows
():
return
"del /s /q /f"
else
:
return
"rm -rf"
def
rmdir_command
():
"""Get a string with the O.S. specific remove directory command"""
if
check_windows
():
return
"rmdir /s /q"
else
:
return
"rm -rf"
def
copy_command
():
"""Get a string with the O.S. specific copy command"""
if
check_windows
():
return
"copy"
else
:
return
"cp"
def
mkdir_command
():
"""Get a string with the O.S. specific mkdir command"""
if
check_windows
():
return
"mkdir"
else
:
return
"mkdir -p"
def
touch_command
():
"""Get a string with the O.S. specific mkdir command"""
if
check_windows
():
return
"type nul >>"
else
:
return
"touch"
def
which
(
filename
):
"""Implement the which function and return the paths as a string list"""
locations
=
os
.
environ
.
get
(
"PATH"
)
.
split
(
os
.
pathsep
)
candidates
=
[]
for
location
in
locations
:
candidate
=
os
.
path
.
join
(
location
,
filename
)
if
os
.
path
.
isfile
(
candidate
.
split
()[
0
]):
candidates
.
append
(
candidate
)
return
candidates
def
which_cmd
():
"""Get a string with the O.S. specific which command"""
if
check_windows
():
return
"where"
else
:
return
"which"
def
slash_char
():
"""Get a string with the O.S. specific path separator"""
if
check_windows
():
return
"
\\
"
else
:
return
"/"
def
architecture
():
"""Get a string with the O.S. bus width"""
import
struct
return
64
if
struct
.
calcsize
(
'P'
)
*
8
==
64
else
32
hdlmake/util/shell.py
0 → 100644
View file @
e773bd4b
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017 CERN
# Author: Javier Garcia (jgarcia@gl-research.com)
#
# This file is part of Hdlmake.
#
# Hdlmake is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Hdlmake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
#
"""This module provides stuff for cross shell and O.S. support"""
from
__future__
import
print_function
from
__future__
import
absolute_import
import
os
import
sys
import
platform
def
tclpath
(
path
):
"""Convert a O.S. specific path into a TCL friendly one"""
return
path
.
replace
(
slash_char
(),
"/"
)
def
check_windows
():
"""Check if we are operating on a Windows filesystem"""
if
platform
.
system
()
==
'Windows'
or
sys
.
platform
==
'cygwin'
:
return
True
else
:
return
False
def
del_command
():
"""Get a string with the O.S. specific delete command"""
if
check_windows
():
return
"del /s /q /f"
else
:
return
"rm -rf"
def
rmdir_command
():
"""Get a string with the O.S. specific remove directory command"""
if
check_windows
():
return
"rmdir /s /q"
else
:
return
"rm -rf"
def
copy_command
():
"""Get a string with the O.S. specific copy command"""
if
check_windows
():
return
"copy"
else
:
return
"cp"
def
mkdir_command
():
"""Get a string with the O.S. specific mkdir command"""
if
check_windows
():
return
"mkdir"
else
:
return
"mkdir -p"
def
touch_command
():
"""Get a string with the O.S. specific mkdir command"""
if
check_windows
():
return
"type nul >>"
else
:
return
"touch"
def
which
(
filename
):
"""Implement the which function and return the paths as a string list"""
locations
=
os
.
environ
.
get
(
"PATH"
)
.
split
(
os
.
pathsep
)
candidates
=
[]
for
location
in
locations
:
candidate
=
os
.
path
.
join
(
location
,
filename
)
if
os
.
path
.
isfile
(
candidate
.
split
()[
0
]):
candidates
.
append
(
candidate
)
return
candidates
def
which_cmd
():
"""Get a string with the O.S. specific which command"""
if
check_windows
():
return
"where"
else
:
return
"which"
def
slash_char
():
"""Get a string with the O.S. specific path separator"""
if
check_windows
():
return
"
\\
"
else
:
return
"/"
def
architecture
():
"""Get a string with the O.S. bus width"""
import
struct
return
64
if
struct
.
calcsize
(
'P'
)
*
8
==
64
else
32
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