Commit 272dd2a6 authored by Paweł Szostek's avatar Paweł Szostek

Add --version option, (logically) nicer printing infrastructure

parent aafedcc5
#!/bin/bash
commit_line=$(git log | head -1)
commit_string=$(echo $commit_line | awk '{print $2}')
date_line=$(git log | head -3 | tail -1)
date_string=$(echo $date_line | awk '{print $6 $3 $4}')
embed_string=$(echo "$date_string:${commit_string:0:6}")
if [ ! -f src/global_mod.py ]; then
echo "Can't find src/global_mod.py file to put the versionID inside"
exit 1
fi
global_mod_path="src/global_mod.py"
sed 's/^BUILD_ID =.*$/BUILD_ID = \"'$embed_string'"/' $global_mod_path > ${global_mod_path}_TMP
rm $global_mod_path
mv ${global_mod_path}_TMP $global_mod_path
if [ ! -f src/global_mod.py ]; then
echo "Shit! Something went wrong. Better check what happened to $global_mod_path"
exit 1
fi
\ No newline at end of file
# -*- 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
#
SRC := configparser.py connection.py dep_solver.py fetch.py\
flow.py flow_altera.py global_mod.py hdlmake_kernel.py help_printer.py helper_classes.py\
__main__.py makefile_writer.py module.py msg.py path.py \
srcfile.py
PREFIX := ./
ARCH := hdlmake
../$(ARCH): $(foreach src, $(SRC), $(PREFIX)$(src))
zip $(ARCH) $(SRC)
echo '#!/usr/bin/python' > ../$(ARCH)
cat $(ARCH).zip >> ../$(ARCH)
rm $(ARCH).zip
chmod +x ../$(ARCH)
clean:
rm -f $(PREFIX)*~ $(PREFIX)*pyc
......@@ -29,7 +29,10 @@ from module import Module
from fetch import ModulePool
def main():
parser = optparse.OptionParser()
usage = "usage: %prog [options]\n"
usage += "type %prog --help to get help message"
parser = optparse.OptionParser(usage=usage)
parser.add_option("--manifest-help", action="store_true",
dest="manifest_help", help="print manifest file variables description")
......@@ -83,12 +86,19 @@ use 0 for current version""", metavar="ISE")
parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
default="false", help="verbose mode")
parser.add_option("--version", dest="print_version", action="store_true",
default="false", help="print version id of this Hdlmake build")
(options, args) = parser.parse_args()
global_mod.options = options
#HANDLE PROJECT INDEPENDENT OPTIONS
if options.manifest_help == True:
from helper_classes import ManifestParser
ManifestParser().help()
ManifestParser().help() and quit()
if options.print_version == True:
p.print_version()
quit()
p.vprint("LoadTopManifest");
......@@ -97,7 +107,8 @@ use 0 for current version""", metavar="ISE")
pool.set_top_module(m)
if m.manifest == None:
p.echo("No manifest found. At least an empty one is needed")
p.rawprint("No manifest found. At least an empty one is needed")
p.rawprint("To see some help, type hdlmake --help")
quit()
global_mod.top_module = m
global_mod.top_module.parse_manifest()
......@@ -130,9 +141,12 @@ use 0 for current version""", metavar="ISE")
getattr(kernel, function)()
sth_chosen = True
except Exception,e :
p.print_version()
print e
if not sth_chosen:
p.rawprint("No option selected. Running automatic flow")
p.rawprint("To see some help, type hdlmake --help")
kernel.run()
if __name__ == "__main__":
......
......@@ -22,4 +22,7 @@
options = None
top_module = None
global_target = "''"
#######
#this var is modified by the build makefile - DON'T TOUCH IT!
BUILD_ID = "2012Jan24:c213be"
######
......@@ -22,7 +22,6 @@
import os
import msg as p
from help_printer import HelpPrinter as hp
from makefile_writer import MakefileWriter
from flow import ISEProject
from flow_altera import QuartusProject
......@@ -39,8 +38,6 @@ class HdlmakeKernel(object):
return self.modules_pool.get_top_module()
def run(self):
p.rawprint("Running automatic flow\n")
tm = self.top_module
if not self.modules_pool.is_everything_fetched():
......@@ -63,7 +60,7 @@ class HdlmakeKernel(object):
else:
raise RuntimeError("Unrecognized target: "+tm.target)
else:
hp.print_action_help() and quit()
p.print_action_help() and quit()
def list_modules(self):
import path
......
# -*- 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
#
import msg as p
class HelpPrinter():
@staticmethod
def print_action_help():
p.rawprint("`Action' variable was not specified")
p.rawprint("Allowed values are: \"simulation\" or \"synthesis\"")
p.rawprint()
p.rawprint("This variable in a manifest file is necessary for Hdlmake " \
"to be able to know what to do with the given modules' structure.")
HelpPrinter.__more()
@staticmethod
def __more():
p.rawprint("For more help type `hdlmake --help' " \
"or visit http://www.ohwr.org/projects/hdl-make")
if __name__ == "__main__":
hp = HelpPrinter
hp.print_action_help()
\ No newline at end of file
......@@ -31,9 +31,12 @@ t0 = time.time()
def rawprint(msg = ""):
print(msg)
def die(msg=""):
rawprint(msg)
quit()
def echo(msg):
global t0
print(("["+os.path.basename(sys.argv[0]) + " " + "%.5f" % (time.time()-t0) + "]: " + str(msg)))
rawprint(msg)
def vprint(msg):
if global_mod.options.verbose == True:
......@@ -46,4 +49,19 @@ def pprint(msg):
def vpprint(msg):
if global_mod.options.verbose == True:
pp = prettyprinter.PrettyPrinter(indent = 2)
pp.pprint(msg)
\ No newline at end of file
pp.pprint(msg)
def print_version():
rawprint("Hdlmake build "+global_mod.BUILD_ID)
def print_action_help():
p.rawprint("`Action' variable was not specified")
p.rawprint("Allowed values are: \"simulation\" or \"synthesis\"")
p.rawprint()
p.rawprint("This variable in a manifest file is necessary for Hdlmake " \
"to be able to know what to do with the given modules' structure.")
basic()
def basic():
p.rawprint("For more help type `hdlmake --help' " \
"or visit http://www.ohwr.org/projects/hdl-make")
\ 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