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
0a6230de
Commit
0a6230de
authored
Sep 07, 2016
by
Piotr Miedzik
Committed by
Javier D. Garcia-Lasheras
Sep 07, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
which: use pure python code to find executable
parent
a02f00dc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
5 deletions
+16
-5
makefile.py
hdlmake/tools/makefile.py
+6
-5
path.py
hdlmake/util/path.py
+10
-0
No files found.
hdlmake/tools/makefile.py
View file @
0a6230de
...
...
@@ -65,11 +65,12 @@ class ToolMakefile(object):
"""Check if the binary is available in the O.S. environment"""
def
_get_path
(
name
):
"""Get the directory in which the tool binary is at Host"""
location
=
os
.
popen
(
path_mod
.
which_cmd
()
+
"
%
s"
%
name
)
.
read
()
.
split
(
'
\n
'
,
1
)[
0
]
.
strip
()
logging
.
debug
(
"location for
%
s:
%
s"
,
name
,
location
)
return
os
.
path
.
dirname
(
location
)
locations
=
path_mod
.
which
(
name
)
if
len
(
locations
)
==
0
:
return
logging
.
debug
(
"location for
%
s:
%
s"
,
name
,
locations
[
0
])
return
os
.
path
.
dirname
(
locations
[
0
])
def
_is_in_path
(
name
,
path
=
None
):
"""Check if the directory is in the system path"""
...
...
hdlmake/util/path.py
View file @
0a6230de
...
...
@@ -199,6 +199,16 @@ def mkdir_command():
return
"mkdir -p"
def
which
(
filename
):
"""docstring for which"""
locations
=
os
.
environ
.
get
(
"PATH"
)
.
split
(
os
.
pathsep
)
candidates
=
[]
for
location
in
locations
:
candidate
=
os
.
path
.
join
(
location
,
filename
)
if
os
.
path
.
isfile
(
candidate
):
candidates
.
append
(
candidate
)
return
candidates
def
which_cmd
():
"""Get a string with the O.S. specific which command"""
if
check_windows
():
...
...
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