Commit dcbcfc1d authored by Paweł Szostek's avatar Paweł Szostek

Merge branch 'master' of ohwr.org:misc/hdl-make

Conflicts:
	src/env_checker.py
parents 25dcc05b 3109af65
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program 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 this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
# Modified to allow ISim simulation by Lucas Russo (lucas.russo@lnls.br)
......
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program 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 this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
#
import msg as p
......
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program 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 this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
#
import os
......
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program 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 this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
# Modified to allow ISim simulation by Lucas Russo (lucas.russo@lnls.br)
import msg as p
......
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
import os
import sys
import msg as p
from subprocess import Popen, PIPE
import re
class _IsePath(object):
......@@ -27,9 +33,9 @@ class _IsePath(object):
@staticmethod
def get_path(arch, major, minor):
if arch == 32:
dct = IsePath._ise_path_32
dct = _IsePath._ise_path_32
else:
dct = IsePath._ise_path_64
dct = _IsePath._ise_path_64
try:
minor_dct = dct[major]
......@@ -60,84 +66,108 @@ class EnvChecker(dict):
def check(self):
platform = sys.platform
print("Plartform: %s" % platform)
print("Platform: %s" % platform)
xilinx = os.environ("XILINX")
if val:
#1: determine path for ise
xilinx = os.environ.get("XILINX")
if xilinx:
print("Environmental variable %s is set: %s." % ("XILINX", xilinx))
self["xilinx"] = xilinx
else:
print("Environmental variable XILINX is not set.")
ise_version = self._guess_ise_version()
top_module = self.report_and_set_var("TOP_MODULE")
self.report_in_path("isim")
self.report_and_set_var("ise_path")
if "ise_path" in self and "xilinx" in self:
print("HDLMAKE_ISE_PATH and XILINX can't be set at a time\n"
"Ignoring HDLMAKE_ISE_PATH")
self["ise_path"] = self["xilinx"]
XLINX?
self.report_and_set_var("ISE_PATH")
if self["ise_path"]:
print("HDLMAKE_ISE_PATH set to %s" % self["ise_path"])
if "ise_path" in self:
if self.check_in_path("ise", self["ise_path"]):
print("ise found in HDLMAKE_ISE_PATH: %s." % self["ise_path"])
print("ISE found in HDLMAKE_ISE_PATH: %s." % self["ise_path"])
else:
print("ise not found in HDLMAKE_ISE_PATH: %s." % self("ise_path"))
print("ISE not found in HDLMAKE_ISE_PATH: %s." % self("ise_path"))
else:
if self.check_in_path("ise"):
print("ise found in PATH: %s." % self.get_path("ise"))
print("ISE found in PATH: %s." % self.get_path("ise"))
else:
print("ISE not found in PATH")
#2: determine ISE version
try:
ise_version = tuple(self.manifest["force_ise"].split('.'))
print("ise_version set in the manifest: %d.%d" % (ise_version[0], ise_version[1]))
self["ise_version"] = ise_version
except KeyError:
ise_version = None
if "ise_version" not in self:
ise_version = self._guess_ise_version(xilinx, '')
if ise_version:
print("force_ise not set in the manifest,"
" guessed ISE version: %d.%d" % (ise_version[0], ise_version[1]))
self["ise_version"] = ise_version
#######
self.report_and_set_var("top_module")
self.report_in_path("isim")
#3: determine modelsim path
self.report_and_set_var("modelsim_path")
if "modelsim_path" in self:
if not self.check_in_path("vsim", self["modelsim_path"]):
if self.report_in_path("vsim"):
self["modelsim_path"] = self.get_path("modelsim_path")
if self.report_and_set_var("MODELSIM_PATH"):
self.check_in_path(vsim, self["modelsim_path"])
self.report_in_path("vsim")
#4: determine iverilog path
self.report_in_path("iverilog")
if "iverilog" in self:
if not self.check_in_path("iverilog", self["iverilog_path"]):
if self.report_in_path("iverilog"):
self["iverilog_path"] = self.get_path("iverilog")
self.report_and_set_var("RSYNTH_USER")
self.report_and_set_var("RSYNTH_ISE_PATH")
self.report_and_set_var("RSYNTH_USE_SCREEN")
self.report_and_set_var("coredir")
def check_modelsim_ini(self):
pass
self.report_and_set_var("rsynth_user")
self.report_and_set_var("rsynth_ise_path")
self.report_and_set_var("rsynth_use_screen")
def check_xilinxsim_init(self):
pass
def _check_ise_version(self, xilinx, ise_path):
import subprocess
import re
xst = subprocess.Popen('which xst', shell=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)
def _guess_ise_version(self, xilinx, ise_path):
xst = Popen('which xst', shell=True, stdin=PIPE,
stdout=PIPE, close_fds=True)
lines = xst.stdout.readlines()
if not lines:
p.error("Xilinx binaries are not in the PATH variable\n"
"Can't determine ISE version")
quit()
return None
xst = str(lines[0].strip())
version_pattern = re.compile(".*?(\d\d\.\d).*") #First check if we have version in path
version_pattern = re.compile('.*?(?P<major>\d|\d\d)[^\d](?P<minor>\d|\d\d).*')
# First check if we have version in path
match = re.match(version_pattern, xst)
if match:
ise_version = match.group(1)
else: #If it is not the case call the "xst -h" to get version
xst_output = subprocess.Popen('xst -h', shell=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)
ise_version = (int(match.group('major')), int(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)
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.*')
version_pattern = re.compile('Release\s(?P<major>\d|\d\d)[^\d](?P<minor>\d|\d\d)\s.*')
match = re.match(version_pattern, xst_output)
if match:
ise_version = ''.join((match.group('major'), '.', match.group('minor')))
ise_version = (int(match.group('major')), int(match.group('minor')))
else:
p.error("xst output is not in expected format: "+ xst_output +"\n"
p.error("xst output is not in expected format: %s\n" % xst_output +
"Can't determine ISE version")
return None
p.vprint("ISE version: " + ise_version)
return ise_version
def __figure_out_ise_path(self):
if self.options.force_ise is not None:
if self.options.force_ise == 0:
ise = self.__check_ise_version()
......@@ -147,7 +177,8 @@ class EnvChecker(dict):
ise = 0
try:
ise_path = path.ise_path_32[str(ise)]+'/'
#TODO: change hardcoded 32
ise_path = _IsePath.get_path(arch=32, major=ise[0], minor=ise[1]) + '/'
except KeyError:
if ise != 0:
ise_path = "/opt/Xilinx/"+str(ise)+"/ISE_DS/ISE/bin/lin/"
......@@ -159,19 +190,19 @@ class EnvChecker(dict):
assert not name.startswith("HDLMAKE_")
assert isinstance(name, basestring)
return os.environ("HDLMAKE_%s" % name)
return os.environ.get("HDLMAKE_%s" % name)
def get_path(self, name):
return os.popen("which %s" % name).read().strip()
def check_in_path(self, name, path):
return os.path.exists(os.path.join(path, name))
def check_in_path(self, name):
assert isinstance(name, basestring)
def check_in_path(self, name, path=None):
if path is not None:
return os.path.exists(os.path.join(path, name))
else:
assert isinstance(name, basestring)
path = self.get_path(name)
return len(path) > 0
path = self.get_path(name)
return len(path) > 0
def report_in_path(self, name):
path = self.get_path(name)
......@@ -179,15 +210,20 @@ class EnvChecker(dict):
print("%s is in PATH: %s." % (name, path))
return True
else:
print("%s is not in PATH." % path)
print("%s is not in PATH." % name)
return False
def report_and_set_var(self, name):
val = os.environ("HDLMAKE_%s" % name)
name = name.upper()
val = os.environ.get("HDLMAKE_%s" % name)
if val:
print("Environmental variable %s is set: %s." % (name, val))
print("Environmental variable HDLMAKE_%s is set: %s." % (name, val))
self[name.lower()] = val
return True
else:
print("Environmental variable %s is not set." % name)
print("Environmental variable HDLMAKE_%s is not set." % name)
return False
if __name__ == "__main__":
ec = EnvChecker({}, {})
ec.check()
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program 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 this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
import os
import msg as p
......
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program 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 this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
# Modified to allow ISim simulation by Lucas Russo (lucas.russo@lnls.br)
# Modified to allow ISim simulation by Adrian Byszuk (adrian.byszuk@lnls.br)
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program 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 this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
class _QuartusProjectProperty:
......
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program 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 this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
# Modified to allow ISim simulation by Lucas Russo (lucas.russo@lnls.br)
options = None
......
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program 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 this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
# Modified to allow ISim simulation by Lucas Russo (lucas.russo@lnls.br)
import os
......
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program 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 this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
# Modified to allow ISim simulation by Lucas Russo (lucas.russo@lnls.br)
import os
......
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program 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 this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
import path as path_mod
import os
......
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either 2 of the License, or (at your option)
# any later version.
#
# This program 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 this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
import path as path_mod
import msg as p
......
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program 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 this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
import global_mod
......
#!/usr/bin/python
#
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
class DepRelation:
PROVIDE = 1
......
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program 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 this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
from dep_solver import IDependable
import os
......
#!/usr/bin/python
# Copyright (c) 2013 CERN
# Author: Vamsi Vytla
# A Verilog preprocessor. Still lots of stuff to be done, but it's already quite useful
# for calculating dependencies.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment