Commit 089b2af4 authored by Josh Smith's avatar Josh Smith

Refactored project such that top level hdlmake directory is now a package. Added…

Refactored project such that top level hdlmake directory is now a package. Added setup.py for easy packaging of project with setuptools. Note that installation instructions (and how to run hdlmake) has changed!

Related changes:
- hdlmake/_version.py file now exists as a single location to manage the version of hdlmake. This is used by Sphinx docs, setup.py, and hdlmake itself.
- Cleaned up some circular dependencies in hdlmake.fetch package. This changed the design of backend_factory such that it no longer depends on importing git/svn fetchers.
- Added tests/run_tests.py. Right now it has one test which iterates through all of the top level sim and syn Manifest files and attempts to run hdlmake against them. This acts as a crude regression test.
- Added ez_setup.py. This installs setuptools if it is not available in the python environment. This guarantees that setup.py will work.
- Added Manifest.in. This lists non-hdlmake application data that should be included in a source distribution (documentation, test files, etc)
- Updated Sphinx docs to agree with the new package/module structure (with hdlmake as a top level package). Note that the installation instructions have changed.

Stealth changes:
- hdlmake now will return a non-zero exit code when an exception is caught at the top level. Previously the exception was caught and hdlmake exited with 0 exit code. This was confusing because it actually was a failure.
- Fixed a small bug in synthesis_project.py where version_key may not exist in env dictionary, causing an exception, instead of printing the helpful error message.

Rationale:
- Packages are the means of sharing Python code. The whole application should be bundled in a package.
- Easier distribution of project via setuptools
- Installation via setup.py / setuptools automatically creates executable hdlmake script
- Utilizing setuptools allows for possibility of distributing releases via PyPI.
- Possible to import from any module in hdlmake for purposes of unit testing without sys.path hacking.
parent 8cd9c99c
......@@ -8,4 +8,10 @@ hdlmake.log
*.swap
*.odt
*.orig
.svn
\ No newline at end of file
*.pyc
*.egg-info/
.svn
/pyenv/
/cyg_pyenv/
docs/_build
dist/
include COPYING
include ez_setup.py
recursive-include docs *
recursive-include scripts *
recursive-include tests *
prune docs/_build
......@@ -52,10 +52,18 @@ copyright = u'2013-2015, CERN'
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '2.1'
# Hook the common version file to get our version information
exec(open(os.path.abspath(os.path.join('..','hdlmake','_version.py'))).read())
try:
__version__
except Exception:
__version__ = '0.0' # default if for some reason the exec did not work
version = __version__
# The full version, including alpha/beta/rc tags.
release = '2.1'
release = __version__
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......@@ -265,5 +273,5 @@ texinfo_documents = [
#texinfo_no_detailmenu = False
# Path to sources
sys.path.insert(0, os.path.abspath('../hdlmake'))
sys.path.insert(0, os.path.abspath('../'))
dep_file module
===============
.. automodule:: dep_file
:members:
:undoc-members:
:show-inheritance:
dep_solver module
=================
.. automodule:: dep_solver
:members:
:undoc-members:
:show-inheritance:
dependable_file module
======================
.. automodule:: dependable_file
:members:
:undoc-members:
:show-inheritance:
env module
==========
.. automodule:: env
:members:
:undoc-members:
:show-inheritance:
global_mod module
=================
.. automodule:: global_mod
:members:
:undoc-members:
:show-inheritance:
hdlmake.action package
======================
Submodules
----------
hdlmake.action.action module
----------------------------
.. automodule:: hdlmake.action.action
:members:
:undoc-members:
:show-inheritance:
hdlmake.action.check_condition module
-------------------------------------
.. automodule:: hdlmake.action.check_condition
:members:
:undoc-members:
:show-inheritance:
hdlmake.action.check_manifest module
------------------------------------
.. automodule:: hdlmake.action.check_manifest
:members:
:undoc-members:
:show-inheritance:
hdlmake.action.clean module
---------------------------
.. automodule:: hdlmake.action.clean
:members:
:undoc-members:
:show-inheritance:
hdlmake.action.fetch module
---------------------------
.. automodule:: hdlmake.action.fetch
:members:
:undoc-members:
:show-inheritance:
hdlmake.action.fetch_makefile module
------------------------------------
.. automodule:: hdlmake.action.fetch_makefile
:members:
:undoc-members:
:show-inheritance:
hdlmake.action.list_files module
--------------------------------
.. automodule:: hdlmake.action.list_files
:members:
:undoc-members:
:show-inheritance:
hdlmake.action.list_modules module
----------------------------------
.. automodule:: hdlmake.action.list_modules
:members:
:undoc-members:
:show-inheritance:
hdlmake.action.merge_cores module
---------------------------------
.. automodule:: hdlmake.action.merge_cores
:members:
:undoc-members:
:show-inheritance:
hdlmake.action.remote_synthesis module
--------------------------------------
.. automodule:: hdlmake.action.remote_synthesis
:members:
:undoc-members:
:show-inheritance:
hdlmake.action.simulation module
--------------------------------
.. automodule:: hdlmake.action.simulation
:members:
:undoc-members:
:show-inheritance:
hdlmake.action.synthesis module
-------------------------------
.. automodule:: hdlmake.action.synthesis
:members:
:undoc-members:
:show-inheritance:
hdlmake.action.synthesis_project module
---------------------------------------
.. automodule:: hdlmake.action.synthesis_project
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: hdlmake.action
:members:
:undoc-members:
:show-inheritance:
fetch package
=============
hdlmake.fetch package
=====================
Submodules
----------
fetch.backend_factory module
----------------------------
hdlmake.fetch.backend_factory module
------------------------------------
.. automodule:: fetch.backend_factory
.. automodule:: hdlmake.fetch.backend_factory
:members:
:undoc-members:
:show-inheritance:
fetch.fetcher module
--------------------
hdlmake.fetch.constants module
------------------------------
.. automodule:: hdlmake.fetch.constants
:members:
:undoc-members:
:show-inheritance:
hdlmake.fetch.fetcher module
----------------------------
.. automodule:: fetch.fetcher
.. automodule:: hdlmake.fetch.fetcher
:members:
:undoc-members:
:show-inheritance:
fetch.git module
----------------
hdlmake.fetch.git module
------------------------
.. automodule:: fetch.git
.. automodule:: hdlmake.fetch.git
:members:
:undoc-members:
:show-inheritance:
fetch.svn module
----------------
hdlmake.fetch.svn module
------------------------
.. automodule:: fetch.svn
.. automodule:: hdlmake.fetch.svn
:members:
:undoc-members:
:show-inheritance:
......@@ -40,7 +48,7 @@ fetch.svn module
Module contents
---------------
.. automodule:: fetch
.. automodule:: hdlmake.fetch
:members:
:undoc-members:
:show-inheritance:
action package
==============
hdlmake package
===============
Subpackages
-----------
.. toctree::
hdlmake.action
hdlmake.fetch
hdlmake.tools
hdlmake.util
Submodules
----------
action.action module
--------------------
hdlmake.dep_file module
-----------------------
.. automodule:: action.action
.. automodule:: hdlmake.dep_file
:members:
:undoc-members:
:show-inheritance:
action.check_condition module
-----------------------------
hdlmake.dep_solver module
-------------------------
.. automodule:: action.check_condition
.. automodule:: hdlmake.dep_solver
:members:
:undoc-members:
:show-inheritance:
action.check_manifest module
----------------------------
hdlmake.dependable_file module
------------------------------
.. automodule:: action.check_manifest
.. automodule:: hdlmake.dependable_file
:members:
:undoc-members:
:show-inheritance:
action.clean module
-------------------
hdlmake.env module
------------------
.. automodule:: action.clean
.. automodule:: hdlmake.env
:members:
:undoc-members:
:show-inheritance:
action.fetch module
-------------------
hdlmake.global_mod module
-------------------------
.. automodule:: action.fetch
.. automodule:: hdlmake.global_mod
:members:
:undoc-members:
:show-inheritance:
action.fetch_makefile module
----------------------------
hdlmake.makefile_writer module
------------------------------
.. automodule:: action.fetch_makefile
.. automodule:: hdlmake.makefile_writer
:members:
:undoc-members:
:show-inheritance:
action.list_files module
------------------------
hdlmake.manifest_parser module
------------------------------
.. automodule:: action.list_files
.. automodule:: hdlmake.manifest_parser
:members:
:undoc-members:
:show-inheritance:
action.list_modules module
--------------------------
hdlmake.module module
---------------------
.. automodule:: action.list_modules
.. automodule:: hdlmake.module
:members:
:undoc-members:
:show-inheritance:
action.merge_cores module
-------------------------
hdlmake.module_pool module
--------------------------
.. automodule:: action.merge_cores
.. automodule:: hdlmake.module_pool
:members:
:undoc-members:
:show-inheritance:
action.remote_synthesis module
------------------------------
hdlmake.new_dep_solver module
-----------------------------
.. automodule:: action.remote_synthesis
.. automodule:: hdlmake.new_dep_solver
:members:
:undoc-members:
:show-inheritance:
action.simulation module
------------------------
hdlmake.srcfile module
----------------------
.. automodule:: action.simulation
.. automodule:: hdlmake.srcfile
:members:
:undoc-members:
:show-inheritance:
action.synthesis module
-----------------------
hdlmake.vhdl_parser module
--------------------------
.. automodule:: action.synthesis
.. automodule:: hdlmake.vhdl_parser
:members:
:undoc-members:
:show-inheritance:
action.synthesis_project module
-------------------------------
hdlmake.vlog_parser module
--------------------------
.. automodule:: action.synthesis_project
.. automodule:: hdlmake.vlog_parser
:members:
:undoc-members:
:show-inheritance:
......@@ -112,7 +122,7 @@ action.synthesis_project module
Module contents
---------------
.. automodule:: action
.. automodule:: hdlmake
:members:
:undoc-members:
:show-inheritance:
tools.planahead package
=======================
hdlmake.tools.aldec package
===========================
Submodules
----------
tools.planahead.planahead module
hdlmake.tools.aldec.aldec module
--------------------------------
.. automodule:: tools.planahead.planahead
.. automodule:: hdlmake.tools.aldec.aldec
:members:
:undoc-members:
:show-inheritance:
......@@ -16,7 +16,7 @@ tools.planahead.planahead module
Module contents
---------------
.. automodule:: tools.planahead
.. automodule:: hdlmake.tools.aldec
:members:
:undoc-members:
:show-inheritance:
hdlmake.tools.common package
============================
Submodules
----------
hdlmake.tools.common.sim_makefile_support module
------------------------------------------------
.. automodule:: hdlmake.tools.common.sim_makefile_support
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: hdlmake.tools.common
:members:
:undoc-members:
:show-inheritance:
tools.diamond package
=====================
hdlmake.tools.diamond package
=============================
Submodules
----------
tools.diamond.diamond module
----------------------------
hdlmake.tools.diamond.diamond module
------------------------------------
.. automodule:: tools.diamond.diamond
.. automodule:: hdlmake.tools.diamond.diamond
:members:
:undoc-members:
:show-inheritance:
......@@ -16,7 +16,7 @@ tools.diamond.diamond module
Module contents
---------------
.. automodule:: tools.diamond
.. automodule:: hdlmake.tools.diamond
:members:
:undoc-members:
:show-inheritance:
tools.iverilog package
======================
hdlmake.tools.ghdl package
==========================
Submodules
----------
tools.iverilog.iverilog module
hdlmake.tools.ghdl.ghdl module
------------------------------
.. automodule:: tools.iverilog.iverilog
.. automodule:: hdlmake.tools.ghdl.ghdl
:members:
:undoc-members:
:show-inheritance:
......@@ -16,7 +16,7 @@ tools.iverilog.iverilog module
Module contents
---------------
.. automodule:: tools.iverilog
.. automodule:: hdlmake.tools.ghdl
:members:
:undoc-members:
:show-inheritance:
tools.quartus package
=====================
hdlmake.tools.ise package
=========================
Submodules
----------
tools.quartus.quartus module
hdlmake.tools.ise.ise module
----------------------------
.. automodule:: tools.quartus.quartus
.. automodule:: hdlmake.tools.ise.ise
:members:
:undoc-members:
:show-inheritance:
......@@ -16,7 +16,7 @@ tools.quartus.quartus module
Module contents
---------------
.. automodule:: tools.quartus
.. automodule:: hdlmake.tools.ise
:members:
:undoc-members:
:show-inheritance:
tools.modelsim package
======================
hdlmake.tools.isim package
==========================
Submodules
----------
tools.modelsim.modelsim module
hdlmake.tools.isim.isim module
------------------------------
.. automodule:: tools.modelsim.modelsim
.. automodule:: hdlmake.tools.isim.isim
:members:
:undoc-members:
:show-inheritance:
......@@ -16,7 +16,7 @@ tools.modelsim.modelsim module
Module contents
---------------
.. automodule:: tools.modelsim
.. automodule:: hdlmake.tools.isim
:members:
:undoc-members:
:show-inheritance:
hdlmake.tools.iverilog package
==============================
Submodules
----------
hdlmake.tools.iverilog.iverilog module
--------------------------------------
.. automodule:: hdlmake.tools.iverilog.iverilog
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: hdlmake.tools.iverilog
:members:
:undoc-members:
:show-inheritance:
tools.ise package
=================
hdlmake.tools.libero package
============================
Submodules
----------
tools.ise.ise module
--------------------
hdlmake.tools.libero.libero module
----------------------------------
.. automodule:: tools.ise.ise
.. automodule:: hdlmake.tools.libero.libero
:members:
:undoc-members:
:show-inheritance:
......@@ -16,7 +16,7 @@ tools.ise.ise module
Module contents
---------------
.. automodule:: tools.ise
.. automodule:: hdlmake.tools.libero
:members:
:undoc-members:
:show-inheritance:
hdlmake.tools.modelsim package
==============================
Submodules
----------
hdlmake.tools.modelsim.modelsim module
--------------------------------------
.. automodule:: hdlmake.tools.modelsim.modelsim
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: hdlmake.tools.modelsim
:members:
:undoc-members:
:show-inheritance:
hdlmake.tools.planahead package
===============================
Submodules
----------
hdlmake.tools.planahead.planahead module
----------------------------------------
.. automodule:: hdlmake.tools.planahead.planahead
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: hdlmake.tools.planahead
:members:
:undoc-members:
:show-inheritance:
tools.ghdl package
==================
hdlmake.tools.quartus package
=============================
Submodules
----------
tools.ghdl.ghdl module
----------------------
hdlmake.tools.quartus.quartus module
------------------------------------
.. automodule:: tools.ghdl.ghdl
.. automodule:: hdlmake.tools.quartus.quartus
:members:
:undoc-members:
:show-inheritance:
......@@ -16,7 +16,7 @@ tools.ghdl.ghdl module
Module contents
---------------
.. automodule:: tools.ghdl
.. automodule:: hdlmake.tools.quartus
:members:
:undoc-members:
:show-inheritance:
hdlmake.tools.riviera package
=============================
Submodules
----------
hdlmake.tools.riviera.riviera module
------------------------------------
.. automodule:: hdlmake.tools.riviera.riviera
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: hdlmake.tools.riviera
:members:
:undoc-members:
:show-inheritance:
hdlmake.tools package
=====================
Subpackages
-----------
.. toctree::
hdlmake.tools.aldec
hdlmake.tools.common
hdlmake.tools.diamond
hdlmake.tools.ghdl
hdlmake.tools.ise
hdlmake.tools.isim
hdlmake.tools.iverilog
hdlmake.tools.libero
hdlmake.tools.modelsim
hdlmake.tools.planahead
hdlmake.tools.quartus
hdlmake.tools.riviera
hdlmake.tools.vivado
Module contents
---------------
.. automodule:: hdlmake.tools
:members:
:undoc-members:
:show-inheritance:
tools.aldec package
===================
hdlmake.tools.vivado package
============================
Submodules
----------
tools.aldec.aldec module
------------------------
hdlmake.tools.vivado.vivado module
----------------------------------
.. automodule:: tools.aldec.aldec
.. automodule:: hdlmake.tools.vivado.vivado
:members:
:undoc-members:
:show-inheritance:
......@@ -16,7 +16,7 @@ tools.aldec.aldec module
Module contents
---------------
.. automodule:: tools.aldec
.. automodule:: hdlmake.tools.vivado
:members:
:undoc-members:
:show-inheritance:
util package
============
hdlmake.util package
====================
Submodules
----------
util.configparser module
------------------------
hdlmake.util.configparser module
--------------------------------
.. automodule:: util.configparser
.. automodule:: hdlmake.util.configparser
:members:
:undoc-members:
:show-inheritance:
util.path module
----------------
hdlmake.util.path module
------------------------
.. automodule:: util.path
.. automodule:: hdlmake.util.path
:members:
:undoc-members:
:show-inheritance:
util.termcolor module
---------------------
hdlmake.util.termcolor module
-----------------------------
.. automodule:: util.termcolor
.. automodule:: hdlmake.util.termcolor
:members:
:undoc-members:
:show-inheritance:
......@@ -32,7 +32,7 @@ util.termcolor module
Module contents
---------------
.. automodule:: util
.. automodule:: hdlmake.util
:members:
:undoc-members:
:show-inheritance:
......@@ -152,29 +152,72 @@ As a prerequisite, you must have the following programs installed in your host m
- ``git``: you need git for both fetching the ``hdlmake`` code and accessing to remote HDL repositories.
- ``svn``: svn will only be used when accessing to remote SVN HDL repositories.
Now, you need to fetch the code from the official ``hdlmake`` git repository, that can be found at the next link:
There are two methods to obtain and install ``hdlmake``: via git repository or PyPI. PyPI is the preferred method if you are only interested in releases. Git may be preferred if you are a developer, or would like to stay in sync with active development.
PyPI and ``pip``
~~~~~~~~~~~~~~~~
Installing ``hdlmake`` via PyPI is straightforward assuming that you have ``pip`` already installed in your local Python environment.
.. note:: For directions on installing ``pip`` see the `pip documentation <https://pip.pypa.io/en/latest/installing.html>`_.
To install directly from `PyPI <https://pypi.python.org/pypi>`_ simply run:
.. code-block:: bash
pip install hdlmake
Alternatively, if you have already downloaded a source distribution, you can install it as follows:
.. code-block:: bash
pip install hdlmake-X.X.tar.gz
At this point, ``hdlmake`` is now installed into your active Python environment and can be run simply by executing ``hdlmake`` in your shell.
Git
~~~
Fetch the code from the official ``hdlmake`` git repository, that can be found at the next link:
http://www.ohwr.org/projects/hdl-make/repository
Once you have a valid ``hdlmake`` source tree, you need to create a launch script in /usr/bin or any other available location at shell $PATH. You can name the script as you prefer so, by doing this, multiple ``hdlmake`` versions can easily be used in the same machine. In any case, in this documentation we will consider that the name for this launch script is just ``hdlmake``.
Once you have a valid ``hdlmake`` source tree, you can install ``hdlmake`` into your Python site-packages directly via *setup.py install*:
.. code-block:: bash
cd /path_to_hdlmake_sources/hdl-make
python2.7 setup.py install
``hdlmake`` is now installed into your active Python environment and can be run simply by executing ``hdlmake`` in your shell.
#!/usr/bin/env bash
python2.7 /path_to_hdlmake_sources/hdl-make/hdlmake/__main__.py $@
As a developer, you may wish to avoid installing ``hdlmake`` directly into your site-packages, but can instead link directly to the sources instead:
here:
.. code-block:: bash
cd /path_to_hdlmake_sources/hdl-make
python2.7 setup.py develop
Alternatively, you may choose to forgo installing anything in your Python environment and simply directly run from the source by creating a launch script.
Create a launch script in /usr/bin or any other available location at shell $PATH. You can name the script as you prefer so, by doing this, multiple ``hdlmake`` versions can easily be used in the same machine. In any case, in this documentation we will consider that the name for this launch script is just ``hdlmake``.
- ``python2.7`` is the executable of the Python deployment we want to use with ``hdlmake``.
- ``path_to_hdlmake_sources`` is the absolute path in which the ``hdlmake`` source code has been fetched.
- ``hdl-make`` is the name of the folder created when you checked out the repo.
- ``hdlmake`` is the subfolder of hdl-make (this is not binary or a file, this is folder name).
.. code-block:: bash
#!/usr/bin/env bash
PYTHONPATH=/path_to_hdlmake_sources/hdl-make python2.7 /path_to_hdlmake_sources/hdl-make -m hdlmake $@
Once the launch script has been created, the appropriated execution rights must be set:
Once the launch script has been created, the appropriate execution rights must be set:
.. code-block:: bash
chmod +x /usr/bin/hdlmake
In the above examples the following nomenclature is used:
- ``python2.7`` is the executable of the Python deployment we want to use with ``hdlmake``.
- ``path_to_hdlmake_sources`` is the absolute path in which the ``hdlmake`` source code has been fetched.
- ``hdl-make`` is the name of the folder created when you checked out the repo.
- ``hdlmake`` is the actual hdlmake package (this is not binary or a file, this is folder name).
Windows specific guidelines
---------------------------
......@@ -192,11 +235,11 @@ First, install a valid Cygwin environment for your Windows machine. I order to a
Once you have installed your Cygwin environment, you can just get into the Cygwin console and operate as if you were inside a Linux machine for both installing and working with ``hdlmake``.
Environment
----------_
-----------
When working in Linux or Windows inside Cygwin, in order to work with ``hdlmake`` we must assure that the tools executables that are going to be used are accessibles in the shell $PATH. This is a requirement for both simulation and synthesis
..warning:: there is another way to define the specific tools as an environmental variable, but this is buggy and fails when executing some of the actions. The $PATH way is the most easy and stable way to go!
.. warning:: there is another way to define the specific tools as an environmental variable, but this is buggy and fails when executing some of the actions. The $PATH way is the most easy and stable way to go!
Learn by example
......@@ -806,8 +849,8 @@ a secure TCP/IP connection by using SSL. For this purpose, the following tools n
+-----------+--------------------------------------------+
.. note:: You'll need a local ISE deployment if you want to regenerate the synthesis Makefile or the ISE project (.xise),
files that are mandatory to perform both local and remote synthesis. But, if you have a valid Makefile and ISE project, you can
launch the remote synthesis from a local machine in which the ISE toolchain is not installed.
files that are mandatory to perform both local and remote synthesis. But, if you have a valid Makefile and ISE project, you can
launch the remote synthesis from a local machine in which the ISE toolchain is not installed.
Before running the remote synthesis Makefile targets, there are different parameters that need to defined for proper operation.
These can be defined as shell environmental variables or, alternatively, inside the Makefile itself:
......
makefile_writer module
======================
.. automodule:: makefile_writer
:members:
:undoc-members:
:show-inheritance:
manifest_parser module
======================
.. automodule:: manifest_parser
:members:
:undoc-members:
:show-inheritance:
module module
=============
.. automodule:: module
:members:
:undoc-members:
:show-inheritance:
module_pool module
==================
.. automodule:: module_pool
:members:
:undoc-members:
:show-inheritance:
hdlmake
=======
.. toctree::
:maxdepth: 4
action
dep_file
dep_solver
dependable_file
env
fetch
global_mod
makefile_writer
manifest_parser
module
module_pool
new_dep_solver
srcfile
tools
util
vhdl_parser
vlog_parser
new_dep_solver module
=====================
.. automodule:: new_dep_solver
:members:
:undoc-members:
:show-inheritance:
srcfile module
==============
.. automodule:: srcfile
:members:
:undoc-members:
:show-inheritance:
tools.isim package
==================
Submodules
----------
tools.isim.isim module
----------------------
.. automodule:: tools.isim.isim
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: tools.isim
:members:
:undoc-members:
:show-inheritance:
tools.libero package
====================
Submodules
----------
tools.libero.libero module
--------------------------
.. automodule:: tools.libero.libero
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: tools.libero
:members:
:undoc-members:
:show-inheritance:
tools package
=============
Subpackages
-----------
.. toctree::
tools.aldec
tools.diamond
tools.ghdl
tools.ise
tools.isim
tools.iverilog
tools.libero
tools.modelsim
tools.planahead
tools.quartus
Module contents
---------------
.. automodule:: tools
:members:
:undoc-members:
:show-inheritance:
vhdl_parser module
==================
.. automodule:: vhdl_parser
:members:
:undoc-members:
:show-inheritance:
vlog_parser module
==================
.. automodule:: vlog_parser
:members:
:undoc-members:
:show-inheritance:
#!/usr/bin/env python
"""
Setuptools bootstrapping installer.
Run this script to install or upgrade setuptools.
"""
import os
import shutil
import sys
import tempfile
import zipfile
import optparse
import subprocess
import platform
import textwrap
import contextlib
import warnings
from distutils import log
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
try:
from site import USER_SITE
except ImportError:
USER_SITE = None
DEFAULT_VERSION = "16.0"
DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/"
DEFAULT_SAVE_DIR = os.curdir
def _python_cmd(*args):
"""
Execute a command.
Return True if the command succeeded.
"""
args = (sys.executable,) + args
return subprocess.call(args) == 0
def _install(archive_filename, install_args=()):
"""Install Setuptools."""
with archive_context(archive_filename):
# installing
log.warn('Installing Setuptools')
if not _python_cmd('setup.py', 'install', *install_args):
log.warn('Something went wrong during the installation.')
log.warn('See the error message above.')
# exitcode will be 2
return 2
def _build_egg(egg, archive_filename, to_dir):
"""Build Setuptools egg."""
with archive_context(archive_filename):
# building an egg
log.warn('Building a Setuptools egg in %s', to_dir)
_python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir)
# returning the result
log.warn(egg)
if not os.path.exists(egg):
raise IOError('Could not build the egg.')
class ContextualZipFile(zipfile.ZipFile):
"""Supplement ZipFile class to support context manager for Python 2.6."""
def __enter__(self):
return self
def __exit__(self, type, value, traceback):
self.close()
def __new__(cls, *args, **kwargs):
"""Construct a ZipFile or ContextualZipFile as appropriate."""
if hasattr(zipfile.ZipFile, '__exit__'):
return zipfile.ZipFile(*args, **kwargs)
return super(ContextualZipFile, cls).__new__(cls)
@contextlib.contextmanager
def archive_context(filename):
"""
Unzip filename to a temporary directory, set to the cwd.
The unzipped target is cleaned up after.
"""
tmpdir = tempfile.mkdtemp()
log.warn('Extracting in %s', tmpdir)
old_wd = os.getcwd()
try:
os.chdir(tmpdir)
with ContextualZipFile(filename) as archive:
archive.extractall()
# going in the directory
subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
os.chdir(subdir)
log.warn('Now working in %s', subdir)
yield
finally:
os.chdir(old_wd)
shutil.rmtree(tmpdir)
def _do_download(version, download_base, to_dir, download_delay):
"""Download Setuptools."""
egg = os.path.join(to_dir, 'setuptools-%s-py%d.%d.egg'
% (version, sys.version_info[0], sys.version_info[1]))
if not os.path.exists(egg):
archive = download_setuptools(version, download_base,
to_dir, download_delay)
_build_egg(egg, archive, to_dir)
sys.path.insert(0, egg)
# Remove previously-imported pkg_resources if present (see
# https://bitbucket.org/pypa/setuptools/pull-request/7/ for details).
if 'pkg_resources' in sys.modules:
del sys.modules['pkg_resources']
import setuptools
setuptools.bootstrap_install_from = egg
def use_setuptools(
version=DEFAULT_VERSION, download_base=DEFAULT_URL,
to_dir=DEFAULT_SAVE_DIR, download_delay=15):
"""
Ensure that a setuptools version is installed.
Return None. Raise SystemExit if the requested version
or later cannot be installed.
"""
to_dir = os.path.abspath(to_dir)
# prior to importing, capture the module state for
# representative modules.
rep_modules = 'pkg_resources', 'setuptools'
imported = set(sys.modules).intersection(rep_modules)
try:
import pkg_resources
pkg_resources.require("setuptools>=" + version)
# a suitable version is already installed
return
except ImportError:
# pkg_resources not available; setuptools is not installed; download
pass
except pkg_resources.DistributionNotFound:
# no version of setuptools was found; allow download
pass
except pkg_resources.VersionConflict as VC_err:
if imported:
_conflict_bail(VC_err, version)
# otherwise, unload pkg_resources to allow the downloaded version to
# take precedence.
del pkg_resources
_unload_pkg_resources()
return _do_download(version, download_base, to_dir, download_delay)
def _conflict_bail(VC_err, version):
"""
Setuptools was imported prior to invocation, so it is
unsafe to unload it. Bail out.
"""
conflict_tmpl = textwrap.dedent("""
The required version of setuptools (>={version}) is not available,
and can't be installed while this script is running. Please
install a more recent version first, using
'easy_install -U setuptools'.
(Currently using {VC_err.args[0]!r})
""")
msg = conflict_tmpl.format(**locals())
sys.stderr.write(msg)
sys.exit(2)
def _unload_pkg_resources():
del_modules = [
name for name in sys.modules
if name.startswith('pkg_resources')
]
for mod_name in del_modules:
del sys.modules[mod_name]
def _clean_check(cmd, target):
"""
Run the command to download target.
If the command fails, clean up before re-raising the error.
"""
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError:
if os.access(target, os.F_OK):
os.unlink(target)
raise
def download_file_powershell(url, target):
"""
Download the file at url to target using Powershell.
Powershell will validate trust.
Raise an exception if the command cannot complete.
"""
target = os.path.abspath(target)
ps_cmd = (
"[System.Net.WebRequest]::DefaultWebProxy.Credentials = "
"[System.Net.CredentialCache]::DefaultCredentials; "
"(new-object System.Net.WebClient).DownloadFile(%(url)r, %(target)r)"
% vars()
)
cmd = [
'powershell',
'-Command',
ps_cmd,
]
_clean_check(cmd, target)
def has_powershell():
"""Determine if Powershell is available."""
if platform.system() != 'Windows':
return False
cmd = ['powershell', '-Command', 'echo test']
with open(os.path.devnull, 'wb') as devnull:
try:
subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
except Exception:
return False
return True
download_file_powershell.viable = has_powershell
def download_file_curl(url, target):
cmd = ['curl', url, '--silent', '--output', target]
_clean_check(cmd, target)
def has_curl():
cmd = ['curl', '--version']
with open(os.path.devnull, 'wb') as devnull:
try:
subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
except Exception:
return False
return True
download_file_curl.viable = has_curl
def download_file_wget(url, target):
cmd = ['wget', url, '--quiet', '--output-document', target]
_clean_check(cmd, target)
def has_wget():
cmd = ['wget', '--version']
with open(os.path.devnull, 'wb') as devnull:
try:
subprocess.check_call(cmd, stdout=devnull, stderr=devnull)
except Exception:
return False
return True
download_file_wget.viable = has_wget
def download_file_insecure(url, target):
"""Use Python to download the file, without connection authentication."""
src = urlopen(url)
try:
# Read all the data in one block.
data = src.read()
finally:
src.close()
# Write all the data in one block to avoid creating a partial file.
with open(target, "wb") as dst:
dst.write(data)
download_file_insecure.viable = lambda: True
def get_best_downloader():
downloaders = (
download_file_powershell,
download_file_curl,
download_file_wget,
download_file_insecure,
)
viable_downloaders = (dl for dl in downloaders if dl.viable())
return next(viable_downloaders, None)
def download_setuptools(
version=DEFAULT_VERSION, download_base=DEFAULT_URL,
to_dir=DEFAULT_SAVE_DIR, delay=15,
downloader_factory=get_best_downloader):
"""
Download setuptools from a specified location and return its filename.
`version` should be a valid setuptools version number that is available
as an sdist for download under the `download_base` URL (which should end
with a '/'). `to_dir` is the directory where the egg will be downloaded.
`delay` is the number of seconds to pause before an actual download
attempt.
``downloader_factory`` should be a function taking no arguments and
returning a function for downloading a URL to a target.
"""
# making sure we use the absolute path
to_dir = os.path.abspath(to_dir)
zip_name = "setuptools-%s.zip" % version
url = download_base + zip_name
saveto = os.path.join(to_dir, zip_name)
if not os.path.exists(saveto): # Avoid repeated downloads
log.warn("Downloading %s", url)
downloader = downloader_factory()
downloader(url, saveto)
return os.path.realpath(saveto)
def _build_install_args(options):
"""
Build the arguments to 'python setup.py install' on the setuptools package.
Returns list of command line arguments.
"""
return ['--user'] if options.user_install else []
def _parse_args():
"""Parse the command line for options."""
parser = optparse.OptionParser()
parser.add_option(
'--user', dest='user_install', action='store_true', default=False,
help='install in user site package (requires Python 2.6 or later)')
parser.add_option(
'--download-base', dest='download_base', metavar="URL",
default=DEFAULT_URL,
help='alternative URL from where to download the setuptools package')
parser.add_option(
'--insecure', dest='downloader_factory', action='store_const',
const=lambda: download_file_insecure, default=get_best_downloader,
help='Use internal, non-validating downloader'
)
parser.add_option(
'--version', help="Specify which version to download",
default=DEFAULT_VERSION,
)
parser.add_option(
'--to-dir',
help="Directory to save (and re-use) package",
default=DEFAULT_SAVE_DIR,
)
options, args = parser.parse_args()
# positional arguments are ignored
return options
def _download_args(options):
"""Return args for download_setuptools function from cmdline args."""
return dict(
version=options.version,
download_base=options.download_base,
downloader_factory=options.downloader_factory,
to_dir=options.to_dir,
)
def main():
"""Install or upgrade setuptools and EasyInstall."""
options = _parse_args()
archive = download_setuptools(**_download_args(options))
return _install(archive, _build_install_args(options))
if __name__ == '__main__':
sys.exit(main())
......@@ -24,18 +24,20 @@
from __future__ import print_function
import os
import importlib
import global_mod
import argparse
import logging
import sys
from util.termcolor import colored
from manifest_parser import ManifestParser
from module_pool import ModulePool
from env import Env
import fetch as fetch_mod
from action import (CheckCondition, CleanModules, FetchModules, GenerateFetchMakefile, ListFiles,
from . import global_mod
from .util.termcolor import colored
from .manifest_parser import ManifestParser
from .module_pool import ModulePool
from .env import Env
from . import fetch as fetch_mod
from .action import (CheckCondition, CleanModules, FetchModules, GenerateFetchMakefile, ListFiles,
ListModules, MergeCores, GenerateSimulationMakefile,
GenerateSynthesisMakefile, GenerateRemoteSynthesisMakefile, GenerateSynthesisProject)
from ._version import __version__
#from argument_parser import get_argument_parser
......@@ -121,7 +123,7 @@ def main():
tool_name = top_mod.sim_tool
logging.info('import tool module: ' + tool_name)
try:
tool_module = importlib.import_module("tools.%s.%s" % (tool_name, tool_name))
tool_module = importlib.import_module("hdlmake.tools.%s.%s" % (tool_name, tool_name))
except Exception as e:
logging.error(e)
quit()
......@@ -213,6 +215,7 @@ def main():
logging.error(e)
print("Trace:")
traceback.print_exc()
sys.exit("Exiting in failure because exception occurred")
def _get_parser():
......@@ -221,11 +224,11 @@ def _get_parser():
"""
usage = """hdlmake [command] [options]"""
description = """Version 2.1\n
description = """Version %s\n
To see optional arguments for particular command type:
hdlmake <command> --help
\0
"""
""" % (__version__,)
parser = argparse.ArgumentParser("hdlmake",
usage=usage,
......@@ -264,6 +267,7 @@ def _get_parser():
condition_check.add_argument("--condition", dest="condition", required=True)
auto = subparsers.add_parser("auto", help="default action for hdlmake. Run when no args are given")
auto.add_argument('-v', '--version', action='version', version=parser.prog + " " + __version__)
auto.add_argument("--force", help="force hdlmake to generate the makefile, even if the specified tool is missing", default=False, action="store_true")
auto.add_argument("--noprune", help="prevent hdlmake from pruning unneeded files", default=False, action="store_true")
auto.add_argument("--generate-project-vhd", help="generate project.vhd file with a meta package describing the project",
......
__version__ = "2.1-jsmith_setuppy"
......@@ -20,16 +20,16 @@
# You should have received a copy of the GNU General Public License
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
from check_condition import CheckCondition
from check_manifest import CheckManifest
from clean import CleanModules
from fetch import FetchModules
from fetch_makefile import GenerateFetchMakefile
from list_files import ListFiles
from list_modules import ListModules
from merge_cores import MergeCores
from .check_condition import CheckCondition
from .check_manifest import CheckManifest
from .clean import CleanModules
from .fetch import FetchModules
from .fetch_makefile import GenerateFetchMakefile
from .list_files import ListFiles
from .list_modules import ListModules
from .merge_cores import MergeCores
from synthesis_project import GenerateSynthesisProject
from synthesis import GenerateSynthesisMakefile
from remote_synthesis import GenerateRemoteSynthesisMakefile
from simulation import GenerateSimulationMakefile
from .synthesis_project import GenerateSynthesisProject
from .synthesis import GenerateSynthesisMakefile
from .remote_synthesis import GenerateRemoteSynthesisMakefile
from .simulation import GenerateSimulationMakefile
......@@ -21,7 +21,6 @@
import sys
import logging
from makefile_writer import MakefileWriter
class Action(object):
......
......@@ -22,9 +22,10 @@
from __future__ import print_function
import logging
import sys
from action import Action
import re
from .action import Action
class CheckCondition(Action):
def _compare(self, local, reference, cond):
......
......@@ -19,10 +19,9 @@
# You should have received a copy of the GNU General Public License
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
from action import Action
import logging
import global_mod
from manifest_parser import ManifestParser
from .action import Action
class CheckManifest(Action):
......
......@@ -19,9 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
from action import Action
import logging
from .action import Action
class CleanModules(Action):
def run(self):
......
......@@ -21,7 +21,8 @@
import logging
import sys
from action import Action
from .action import Action
class FetchModules(Action):
......
......@@ -19,10 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
from action import Action
import global_mod
import logging
from hdlmake import global_mod
from .action import Action
class GenerateFetchMakefile(Action):
def run(self):
......
......@@ -19,7 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
from action import Action
from .action import Action
class ListFiles(Action):
......
......@@ -20,11 +20,13 @@
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
from __future__ import absolute_import
from action.action import Action
from util import path
import fetch
from hdlmake.util import path
import hdlmake.fetch as fetch
from .action import Action
def _convert_to_source_name(source_code):
if source_code == fetch.GIT:
return "git"
......
......@@ -21,14 +21,16 @@
from __future__ import print_function
import logging
from action import Action
from srcfile import VerilogFile, VHDLFile, NGCFile
from vlog_parser import VerilogPreprocessor
import os
import os.path
import time
import sys
from hdlmake.srcfile import VerilogFile, VHDLFile, NGCFile
from hdlmake.vlog_parser import VerilogPreprocessor
from .action import Action
class MergeCores(Action):
def _check_manifest(self):
......
......@@ -20,14 +20,14 @@
# You should have received a copy of the GNU General Public License
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
from action import Action
import logging
import os
import sys
import global_mod
from srcfile import SourceFileFactory
import importlib
from hdlmake import global_mod
from hdlmake.srcfile import SourceFileFactory
from .action import Action
class GenerateRemoteSynthesisMakefile(Action):
......
......@@ -21,15 +21,14 @@
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from action import Action
from dep_file import DepFile
import new_dep_solver as dep_solver
import logging
import sys
import global_mod
import importlib
from hdlmake.dep_file import DepFile
import hdlmake.new_dep_solver as dep_solver
from hdlmake import global_mod
from .action import Action
class GenerateSimulationMakefile(Action):
......
......@@ -21,15 +21,12 @@
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from dep_file import DepFile
import new_dep_solver as dep_solver
import logging
import sys
import global_mod
from action import Action
import importlib
from hdlmake import global_mod
from .action import Action
class GenerateSynthesisMakefile(Action):
......
......@@ -22,18 +22,15 @@
from __future__ import print_function
import logging
from action import Action
import sys
import os
import new_dep_solver as dep_solver
from srcfile import SourceFileFactory
from dependable_file import DependableFile
import global_mod
from util import path
import importlib
from hdlmake.srcfile import SourceFileFactory
from hdlmake.dependable_file import DependableFile
from hdlmake import global_mod
from hdlmake.util import path
from .action import Action
class GenerateSynthesisProject(Action):
......@@ -150,7 +147,7 @@ end sdb_meta_pkg;""")
if self.env[path_key] is None:
logging.error("Can't generate the " + name + " project. " + name + " not found.")
quit()
if not env[version_key]:
if version_key not in env or not env[version_key]:
logging.error(name + " version cannot be deduced. Cannot generate " + name + " "
"project file properly. Please use syn_" + id_value + "_version in the manifest "
"or set")
......
......@@ -19,9 +19,10 @@
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
#
import global_mod
import os
from util import path as path_mod
from . import global_mod
from .util import path as path_mod
class DepRelation(object):
......@@ -141,7 +142,7 @@ class File(object):
class DepFile(File):
def __init__(self, file_path, module, include_paths=None):
from module import Module
from .module import Module
assert isinstance(file_path, basestring)
assert isinstance(module, Module)
......@@ -159,7 +160,7 @@ class DepFile(File):
self.include_paths = include_paths
def _parse_if_needed(self):
from new_dep_solver import ParserFactory
from .new_dep_solver import ParserFactory
if not self.is_parsed:
parser = ParserFactory().create(self)
parser.parse(self)
......
......@@ -23,10 +23,11 @@
import re
import os
import logging
import global_mod
from srcfile import SourceFileFactory, SourceFileSet, SourceFile
from srcfile import VHDLFile, VerilogFile, SVFile
from dependable_file import DependableFile
from . import global_mod
from .srcfile import SourceFileFactory, SourceFileSet, SourceFile
from .srcfile import VHDLFile, VerilogFile, SVFile
from .dependable_file import DependableFile
class DependencySolver(object):
......@@ -225,7 +226,7 @@ def solve(fileset):
vhdl_solver = VHDLDependencySolver()
vhdl_solver.solve(vhdl_files)
import srcfile as sf
from . import srcfile as sf
verilog_files = [file for file in fset if isinstance(file, VerilogFile)]
verilog_solver = VerilogDependencySolver()
......
......@@ -25,14 +25,12 @@ from __future__ import print_function
import os
import sys
from subprocess import Popen, PIPE
import re
import logging
import os.path
from util import path
from util.termcolor import colored
import global_mod
import importlib
from .util import path
from .util.termcolor import colored
from . import global_mod
_plain_print = print
......
......@@ -19,12 +19,6 @@
# You should have received a copy of the GNU General Public License
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
from backend_factory import BackendFactory
from svn import Svn
from git import Git
GIT = 1
SVN = 2
LOCAL = 3
GITSUBMODULE = 4
from .constants import (GIT, GITSUBMODULE, SVN, LOCAL, fetch_type_lookup)
from .git import Git
from .svn import Svn
......@@ -19,34 +19,29 @@
# You should have received a copy of the GNU General Public License
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
from git import (Git, GitSubmodule)
from svn import Svn
import logging
import fetch
from fetcher import Fetcher
class Local(Fetcher):
def __init__(self):
pass
def fetch(self, module):
pass
from .constants import (LOCAL)
class BackendFactory(object):
def __init__(self):
pass
self.backend_table = {}
def register_backend(self, backend_id, backend):
"""Add a mapping: backend_id -> backend"""
self.backend_table[backend_id] = backend
def get_backend(self, module):
if module.source == fetch.LOCAL:
return Local()
else:
try:
if module.source != LOCAL:
logging.info("Investigating module: " + str(module) +
"[parent: " + str(module.parent) + "]")
if module.source == fetch.SVN:
return Svn()
if module.source == fetch.GIT:
return Git()
if module.source == fetch.GITSUBMODULE:
return GitSubmodule()
backend = self.backend_table[module.source]
except KeyError:
error_string = "No registered backend found for module: " +\
str(module) + "\n" +\
"Registered backends are:\n"
for backend_id in self.backend_table.iterkeys():
error_string += "\t%d" % (backend_id)
logging.error(error_string)
raise # this is serious enough we should let the exception keep going
return backend
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2015 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
#
# 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/>.
# Note that the order here is important. The constants must be
# defined first! If they are not, there will likely be an obscure error
# when doing the imports within the imports that come afterwards.
GIT = 1
SVN = 2
LOCAL = 3
GITSUBMODULE = 4
from .svn import Svn
from .git import (Git, GitSubmodule)
from .local import Local
from .backend_factory import BackendFactory
# Initialize an instance of BackendFactory which will be made publicly available
fetch_type_lookup = BackendFactory()
fetch_type_lookup.register_backend(GIT, Git)
fetch_type_lookup.register_backend(SVN, Svn)
fetch_type_lookup.register_backend(LOCAL, Local)
fetch_type_lookup.register_backend(GITSUBMODULE, GitSubmodule)
......@@ -20,17 +20,17 @@
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
import os
from util import path
from hdlmake.util import path
import logging
from tempfile import TemporaryFile
from subprocess import Popen, PIPE
import fetch
from fetcher import Fetcher
from .constants import (GIT, GITSUBMODULE)
from .fetcher import Fetcher
class GitSubmodule(Fetcher):
def fetch(self, module):
if module.source != fetch.GITSUBMODULE:
if module.source != GITSUBMODULE:
raise ValueError("This backend should get git modules only.")
cur_dir = os.getcwd()
os.chdir(module.fetchto)
......@@ -112,7 +112,7 @@ submodule.ip_cores/wr-cores.url=git://ohwr.org/hdl-core-lib/wr-cores.git
return config_submodules
def fetch(self, module):
if module.source != fetch.GIT:
if module.source != GIT:
raise ValueError("This backend should get git modules only.")
if not os.path.exists(module.fetchto):
os.mkdir(module.fetchto)
......
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
#
# 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/>.
from .fetcher import Fetcher
class Local(Fetcher):
def __init__(self):
pass
def fetch(self, module):
pass
\ No newline at end of file
......@@ -22,9 +22,11 @@
import os
import logging
from tempfile import TemporaryFile
from util import path
from subprocess import Popen, PIPE
from fetcher import Fetcher
from hdlmake.util import path
from .fetcher import Fetcher
class Svn(Fetcher):
......
......@@ -29,4 +29,4 @@ mod_pool = None
sim_tool = None
env = None
tool_module = None
makefile_writer = None
......@@ -22,12 +22,9 @@
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
import os
import sys
import logging
import string
import fetch
import global_mod
from string import Template
from . import fetch
class _StaticClassVariable():
pass
......
......@@ -20,9 +20,10 @@
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
#
from util import path as path_mod
import os
from util.configparser import ConfigParser
from .util import path as path_mod
from .util.configparser import ConfigParser
class Manifest:
......
......@@ -21,13 +21,14 @@
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from manifest_parser import Manifest, ManifestParser
from util import path as path_mod
import os
import global_mod
import logging
import fetch
import sys
import logging
from .manifest_parser import Manifest, ManifestParser
from .util import path as path_mod
from . import global_mod
from . import fetch
class Module(object):
......@@ -47,7 +48,7 @@ class Module(object):
@property
def basename(self):
from util import path
from .util import path
if self.source == fetch.SVN:
return path.svn_basename(self.url)
else:
......@@ -231,7 +232,7 @@ class Module(object):
self.manifest_dict = opt_map
def process_manifest(self):
from srcfile import TCLFile, VerilogFile, VHDLFile, SourceFileSet
from .srcfile import TCLFile, VerilogFile, VHDLFile, SourceFileSet
if self.isprocessed is True:
return
if self.manifest_dict is None:
......@@ -508,7 +509,7 @@ class Module(object):
return modules
def _create_file_list_from_paths(self, paths):
from srcfile import SourceFileFactory, SourceFileSet
from .srcfile import SourceFileFactory, SourceFileSet
sff = SourceFileFactory()
srcs = SourceFileSet()
for p in paths:
......
......@@ -23,12 +23,13 @@
from __future__ import print_function
import os
import logging
import global_mod
import sys
import new_dep_solver as dep_solver
from util import path as path_mod
import fetch
from subprocess import PIPE, Popen
import sys
from . import global_mod
from . import new_dep_solver as dep_solver
from .util import path as path_mod
from . import fetch
class ModulePool(list):
......@@ -65,7 +66,7 @@ class ModulePool(list):
This is the only way to add new modules to the pool. Thanks to it the pool can easily
control its content
"""
from module import Module
from .module import Module
self._deps_solved = False
if source != fetch.LOCAL:
clean_url, branch, revision = path_mod.url_parse(url)
......@@ -134,7 +135,7 @@ class ModulePool(list):
os.chdir(cwd)
def _add(self, new_module):
from module import Module
from .module import Module
if not isinstance(new_module, Module):
raise RuntimeError("Expecting a Module instance")
if self.__contains(new_module):
......@@ -149,8 +150,7 @@ class ModulePool(list):
new_modules = []
logging.debug("Fetching module: " + str(module))
bf = fetch.BackendFactory()
fetcher = bf.get_backend(module)
fetcher = fetch.fetch_type_lookup.get_backend(module)
result = fetcher.fetch(module)
if result is False:
logging.error("Unable to fetch module %s" % module.url)
......@@ -197,7 +197,7 @@ class ModulePool(list):
def build_file_set(self):
"""Build set of all files listed in the manifests"""
from srcfile import SourceFileSet
from .srcfile import SourceFileSet
all_manifested_files = SourceFileSet()
for module in self:
all_manifested_files.add(module.files)
......@@ -206,7 +206,7 @@ class ModulePool(list):
def build_global_file_set(self):
"""Build set of all files from manifests plus all include files from sources"""
from srcfile import SourceFileSet
from .srcfile import SourceFileSet
files = self.build_file_set()
assert isinstance(files, SourceFileSet)
self.solve_dependencies()
......
......@@ -23,11 +23,10 @@
from __future__ import print_function
import logging
from dep_file import DepFile
from srcfile import VHDLFile, VerilogFile, SVFile
import global_mod
from .dep_file import DepFile
from .srcfile import VHDLFile, VerilogFile, SVFile
from . import global_mod
class DepParser(object):
......@@ -41,8 +40,8 @@ class DepParser(object):
class ParserFactory(object):
def create(self, dep_file):
import re
from vlog_parser import VerilogParser
from vhdl_parser import VHDLParser
from .vlog_parser import VerilogParser
from .vhdl_parser import VHDLParser
if isinstance(dep_file, VHDLFile) :
return VHDLParser(dep_file)
......@@ -74,8 +73,8 @@ class ParserFactory(object):
def solve(fileset):
from srcfile import SourceFileSet
from dep_file import DepRelation
from .srcfile import SourceFileSet
from .dep_file import DepRelation
assert isinstance(fileset, SourceFileSet)
fset = fileset.filter(DepFile)
......
......@@ -23,18 +23,18 @@
from __future__ import print_function
#from dependable_file import DependableFile
import os
import global_mod
import logging
from module import Module
from util import path as path_mod
from dep_file import DepFile, File
from .module import Module
from .util import path as path_mod
from .dep_file import DepFile, File
class SourceFile(DepFile):
cur_index = 0
def __init__(self, path, module, library=None):
from dep_file import DepFile
from .dep_file import DepFile
assert isinstance(path, basestring)
assert isinstance(module, Module)
self.library = library
......
......@@ -21,12 +21,9 @@
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
#
import string
from string import Template
import fetch
from makefile_writer import MakefileWriter
import logging
from hdlmake.makefile_writer import MakefileWriter
class ToolControls(MakefileWriter):
......@@ -49,7 +46,7 @@ class ToolControls(MakefileWriter):
def generate_simulation_makefile(self, fileset, top_module):
# TODO: ??
from srcfile import VHDLFile, VerilogFile, SVFile
from hdlmake.srcfile import VHDLFile, VerilogFile, SVFile
makefile_tmplt_1 = string.Template("""TOP_MODULE := ${top_module}
ALDEC_CRAP := \
run.command \
......
......@@ -21,10 +21,10 @@
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
#
from makefile_writer import MakefileWriter
import os
import string
from string import Template
from hdlmake.makefile_writer import MakefileWriter
class VsimMakefileWriter(MakefileWriter):
......@@ -63,12 +63,12 @@ class VsimMakefileWriter(MakefileWriter):
The Makefile format is shared, but flags, dependencies, clean rules,
etc are defined by the specific tool.
"""
from srcfile import VerilogFile, VHDLFile, SVFile
from hdlmake.srcfile import VerilogFile, VHDLFile, SVFile
self.vlog_flags.append(self.__get_rid_of_vsim_incdirs(top_module.vlog_opt))
self.vcom_flags.append(top_module.vcom_opt)
self.vmap_flags.append(top_module.vmap_opt)
self.vsim_flags.append(top_module.vsim_opt)
self.vlog_flags.append(self.__get_rid_of_vsim_incdirs(top_module.vlog_opt))
self.vcom_flags.append(top_module.vcom_opt)
self.vmap_flags.append(top_module.vmap_opt)
self.vsim_flags.append(top_module.vsim_opt)
tmp = """## variables #############################
PWD := $(shell pwd)
......@@ -194,7 +194,7 @@ sim_post_cmd:
# self.write(incdir)
# self.writeln(vl.vlog_opt+" $<")
####
compile_template = Template("\t\tvlog -work ${library} $$(VLOG_FLAGS) ${sv_option} +incdir+${include_dirs} ${vlog_opt} $$<")
compile_template = string.Template("\t\tvlog -work ${library} $$(VLOG_FLAGS) ${sv_option} +incdir+${include_dirs} ${vlog_opt} $$<")
compile_line = compile_template.substitute(library=vl.library,
sv_option="-sv" if isinstance(vl, SVFile) else "",
include_dirs='+'.join(vl.include_dirs),
......
......@@ -24,14 +24,10 @@
import subprocess
import sys
import os
import logging
import string
from string import Template
import fetch
from makefile_writer import MakefileWriter
from hdlmake.makefile_writer import MakefileWriter
DIAMOND_STANDARD_LIBS = ['ieee', 'std']
......@@ -197,7 +193,7 @@ mrproper:
def __emit_files(self, update=False):
tmp = 'prj_src {0} \"{1}\"'
ret = []
from srcfile import VHDLFile, VerilogFile, SVFile, EDFFile, LPFFile
from hdlmake.srcfile import VHDLFile, VerilogFile, SVFile, EDFFile, LPFFile
for f in self.files:
line = ''
if isinstance(f, VHDLFile) or isinstance(f, VerilogFile) or isinstance(f, SVFile) or isinstance(f, EDFFile):
......
......@@ -21,13 +21,8 @@
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
#
import string
from string import Template
import fetch
from makefile_writer import MakefileWriter
import logging
from hdlmake.makefile_writer import MakefileWriter
class ToolControls(MakefileWriter):
......@@ -53,7 +48,7 @@ class ToolControls(MakefileWriter):
def generate_simulation_makefile(self, fileset, top_module):
# TODO: vhdl87 vs vhdl97 options
from srcfile import VHDLFile
from hdlmake.srcfile import VHDLFile
makefile_tmplt_1 = string.Template("""TOP_MODULE := ${top_module}
GHDL_CRAP := \
......
......@@ -26,18 +26,13 @@ import xml.dom.minidom
import xml.parsers.expat
import logging
import re
import global_mod
import os
import sys
from subprocess import Popen, PIPE
import new_dep_solver as dep_solver
import string
from string import Template
import fetch
from subprocess import Popen, PIPE
from makefile_writer import MakefileWriter
from hdlmake import global_mod
import hdlmake.new_dep_solver as dep_solver
from hdlmake.makefile_writer import MakefileWriter
XmlImpl = xml.dom.minidom.getDOMImplementation()
......@@ -105,7 +100,6 @@ class ToolControls(MakefileWriter):
def generate_remote_synthesis_makefile(self, files, name, cwd, user, server):
from subprocess import PIPE, Popen
if name is None:
import random
name = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(8))
......@@ -452,7 +446,7 @@ mrproper:
return new
def _output_files(self, node):
from srcfile import UCFFile, VHDLFile, VerilogFile, CDCFile, NGCFile
from hdlmake.srcfile import UCFFile, VHDLFile, VerilogFile, CDCFile, NGCFile
for f in self.files:
fp = self.xml_doc.createElement("file")
......@@ -486,7 +480,7 @@ mrproper:
node.appendChild(fp)
def _output_bindings(self, node):
from srcfile import CDCFile
from hdlmake.srcfile import CDCFile
for b in [f for f in self.files if isinstance(f, CDCFile)]:
bp = self.xml_doc.createElement("binding")
bp.setAttribute("xil_pn:location", self.top_mod.syn_top)
......
......@@ -23,18 +23,15 @@
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
#
import os
import os.path
from subprocess import Popen, PIPE
import os
import logging
import sys
import string
from string import Template
import fetch
import global_mod
from makefile_writer import MakefileWriter
from hdlmake import global_mod
from hdlmake.makefile_writer import MakefileWriter
ISIM_STANDARD_LIBS = ['std', 'ieee', 'ieee_proposed', 'vl', 'synopsys',
......@@ -65,15 +62,15 @@ class ToolControls(MakefileWriter):
stdout=PIPE)
print os.path.join(path, "vlogcomp")
try:
isim_version = isim.stdout.readlines()[0].strip()
isim_version = isim.stdout.readlines()[0].strip()
except:
return None
return None
return isim_version
def generate_simulation_makefile(self, fileset, top_module):
from srcfile import VerilogFile, VHDLFile
#from tools.ise import XilinxsiminiReader
from hdlmake.srcfile import VerilogFile, VHDLFile
#from ..ise import XilinxsiminiReader
make_preambule_p1 = """## variables #############################
PWD := $(shell pwd)
TOP_MODULE := """ + top_module.top_module + """
......
......@@ -22,12 +22,12 @@
#
from subprocess import Popen, PIPE
import string
from string import Template
import fetch
import os
import logging
from makefile_writer import MakefileWriter
from hdlmake import global_mod
from hdlmake.makefile_writer import MakefileWriter
IVERILOG_STANDARD_LIBS = ['std', 'ieee', 'ieee_proposed', 'vl', 'synopsys',
......@@ -66,7 +66,7 @@ class ToolControls(MakefileWriter):
# TODO: include dir
from srcfile import VerilogFile, VHDLFile, SVFile
from hdlmake.srcfile import VerilogFile, VHDLFile, SVFile
makefile_tmplt_1 = string.Template("""TOP_MODULE := ${top_module}
IVERILOG_CRAP := \
......@@ -137,7 +137,7 @@ mrproper: clean
def generate_iverilog_makefile(self, fileset, top_module, modules_pool):
print('javi checkpoint 0')
from srcfile import VerilogFile
from hdlmake.srcfile import VerilogFile
for f in global_mod.top_module.incl_makefiles:
self.writeln("include " + f)
......
......@@ -24,12 +24,10 @@
import subprocess
import sys
import os
import string
from string import Template
import fetch
import logging
from makefile_writer import MakefileWriter
from hdlmake.makefile_writer import MakefileWriter
LIBERO_STANDARD_LIBS = ['ieee', 'std']
......@@ -190,7 +188,7 @@ mrproper:
synthesis_constraints = []
compilation_constraints = []
ret = []
from srcfile import VHDLFile, VerilogFile, SDCFile, PDCFile
from hdlmake.srcfile import VHDLFile, VerilogFile, SDCFile, PDCFile
# First stage: linking files
for f in self.files:
if isinstance(f, VHDLFile) or isinstance(f, VerilogFile):
......
......@@ -23,17 +23,10 @@
from __future__ import print_function
import xml.dom.minidom
import xml.parsers.expat
import re
import os
import global_mod
import string
from string import Template
import fetch
from .. common.sim_makefile_support import VsimMakefileWriter
from hdlmake import global_mod
from ..common.sim_makefile_support import VsimMakefileWriter
XmlImpl = xml.dom.minidom.getDOMImplementation()
......
......@@ -24,13 +24,11 @@
import subprocess
import sys
import os
import string
from string import Template
import fetch
import logging
from makefile_writer import MakefileWriter
from hdlmake.makefile_writer import MakefileWriter
PLANAHEAD_STANDARD_LIBS = ['ieee', 'std']
......@@ -229,7 +227,7 @@ mrproper:
def __emit_files(self):
tmp = "add_files -norecurse {0}"
ret = []
from srcfile import VHDLFile, VerilogFile, SVFile, UCFFile, NGCFile, XMPFile, XCOFile
from hdlmake.srcfile import VHDLFile, VerilogFile, SVFile, UCFFile, NGCFile, XMPFile, XCOFile
for f in self.files:
if isinstance(f, VHDLFile) or isinstance(f, VerilogFile) or isinstance(f, SVFile) or isinstance(f, UCFFile) or isinstance(f, NGCFile) or isinstance(f, XMPFile) or isinstance(f, XCOFile):
line = tmp.format(f.rel_path())
......
......@@ -22,13 +22,9 @@
#
import os
import sys
import string
from string import Template
import fetch
from makefile_writer import MakefileWriter
from hdlmake.makefile_writer import MakefileWriter
QUARTUS_STANDARD_LIBS = ['altera', 'altera_mf', 'lpm', 'ieee', 'std']
......@@ -182,7 +178,7 @@ mrproper:
return pre+'\n'+mod+'\n'+post+'\n'
def __emit_files(self):
from srcfile import VHDLFile, VerilogFile, SignalTapFile, SDCFile, QIPFile, DPFFile
from hdlmake.srcfile import VHDLFile, VerilogFile, SignalTapFile, SDCFile, QIPFile, DPFFile
tmp = "set_global_assignment -name {0} {1}"
ret = []
for f in self.files:
......
......@@ -23,7 +23,7 @@
#
from __future__ import print_function
from .. common.sim_makefile_support import VsimMakefileWriter
from ..common.sim_makefile_support import VsimMakefileWriter
# as of 2014.06, these are the standard libraries
# included in an installation
......
......@@ -24,13 +24,10 @@
import subprocess
import sys
import os
import string
from string import Template
import fetch
import logging
from makefile_writer import MakefileWriter
from hdlmake.makefile_writer import MakefileWriter
VIVADO_STANDARD_LIBS = ['ieee', 'std']
......@@ -230,7 +227,7 @@ mrproper:
tmp = "add_files -norecurse {0}"
tcl = "source {0}"
ret = []
from srcfile import VHDLFile, VerilogFile, SVFile, UCFFile, NGCFile, XMPFile, XCOFile, BDFile, TCLFile
from hdlmake.srcfile import VHDLFile, VerilogFile, SVFile, UCFFile, NGCFile, XMPFile, XCOFile, BDFile, TCLFile
for f in self.files:
if isinstance(f, VHDLFile) or isinstance(f, VerilogFile) or isinstance(f, SVFile) or isinstance(f, UCFFile) or isinstance(f, NGCFile) or isinstance(f, XMPFile) or isinstance(f, XCOFile) or isinstance(f, BDFile):
line = tmp.format(f.rel_path())
......
......@@ -21,11 +21,11 @@
# You should have received a copy of the GNU General Public License
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
from new_dep_solver import DepParser
import logging
import re
from .new_dep_solver import DepParser
class VHDLPreprocessor(object):
......@@ -55,7 +55,7 @@ class VHDLParser(DepParser):
def parse(self, dep_file):
from dep_file import DepRelation
from .dep_file import DepRelation
if dep_file.is_parsed:
return
logging.info("Parsing %s" % dep_file.path)
......
......@@ -28,9 +28,10 @@ import os
import re
import sys
import logging
from new_dep_solver import DepParser
from dep_file import DepRelation
from srcfile import SourceFileFactory
from .new_dep_solver import DepParser
from .dep_file import DepRelation
from .srcfile import SourceFileFactory
class VerilogPreprocessor(object):
......
import ez_setup
ez_setup.use_setuptools()
from setuptools import (setup, find_packages)
exec(open('hdlmake/_version.py').read())
try:
__version__
except Exception:
__version__ = "0.0" # default if for some reason the exec did not work
setup(
name="hdlmake",
version=__version__,
description="Hdlmake generates multi-purpose makefiles for HDL projects management.",
author="Javier D. Garcia-Lasheras",
author_email="hdl-make@ohwr.org",
license="GPLv3",
url="http://www.ohwr.org/projects/hdl-make",
packages=find_packages(),
entry_points={
'console_scripts': [
'hdlmake = hdlmake.__main__:main',
],
},
include_package_data=True, # use MANIFEST.in during install
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Topic :: Utilities",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Topic :: Software Development :: Build Tools",
],
)
# -*- coding: utf-8 -*-
#
# Copyright (c) 2015 CERN
# Author: Joshua Smith (joshrsmith@gmail.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/>.
#
import os
import subprocess
def test_makefile_generation():
"""This simple function finds top level (action) manifest files based on an
assumed directory structure and attempts to run hdlmake on them. If hdlmake
exits with a successful exit code, it assumes hdlmake was successful.
This is more of an exercise of the code than a check for Makefile correctness.
Assumes python is on the $PATH
"""
this_mod_dir = os.path.dirname(__file__)
failures = []
# Get the absolute path to the hdlmake base project directory, and put it on
# a copied environment's PYTHONPATH. This will later allow us to execute the
# package as a script using "-m" option to python
hdlmakedir = os.path.abspath(os.path.join(this_mod_dir,'..'))
subprocess_env = os.environ.copy()
if "PYTHONPATH" in subprocess_env:
subprocess_env["PYTHONPATH"] = hdlmakedir + ":" + subprocess_env["PYTHONPATH"]
else:
subprocess_env["PYTHONPATH"] = hdlmakedir
manifests_locations = []
for action in ('sim','syn'): # currently only works on sim. The force option does not appear to work on syn targets
for (dirname, subdir_items, filelist) in os.walk(os.path.join(this_mod_dir,'counter',action)):
for filename in filelist:
if "Manifest.py" in filename:
print "Found: " + os.path.join(dirname,filename)
manifests_locations.append(os.path.abspath(dirname))
print "Running hdlmake on found manifests..."
for manifestdir in manifests_locations:
os.chdir(manifestdir)
args = ["python",
"-m",
"hdlmake",
"auto",
"--force"]
try:
subprocess.check_call(args)
except subprocess.CalledProcessError:
print "Error processing manifest in: " + manifestdir
failures.append(manifestdir)
if len(failures) > 0:
print "Problems processing the following Manifest files:"
for failure in failures:
print failure
else:
print "Successfully processed all Manifest files."
def main():
test_makefile_generation()
if __name__ == "__main__":
main()
\ No newline at end of file
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